ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TAM/interface/TAMSelector.h
Revision: 1.14
Committed: Fri Jul 17 19:18:04 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, Mit_010
Changes since 1.13: +6 -4 lines
Log Message:
Docu.

File Contents

# User Rev Content
1 loizides 1.1 //
2 loizides 1.14 // $Id: TAMSelector.h,v 1.13 2009/07/16 21:02:04 loizides Exp $
3 loizides 1.1 //
4    
5     #ifndef ROOT_TAMSelector
6     #define ROOT_TAMSelector
7    
8     // keep this for compatibility
9     #define TAM_TAMSelector
10    
11    
12 loizides 1.13 #ifndef ROOT_Riostream
13     #include <Riostream.h>
14     #endif
15 loizides 1.1 #ifndef ROOT_TSelector
16     #include "TSelector.h"
17     #endif
18     #ifndef ROOT_THashTable
19     #include "THashTable.h"
20     #endif
21     #ifndef ROOT_List
22     #include "TList.h"
23     #endif
24     #ifndef ROOT_TAMBranchInfo
25 loizides 1.13 #include "MitAna/TAM/interface/TAMBranchInfo.h"
26 loizides 1.1 #endif
27     #ifndef ROOT_TAMVirtualLoader
28 loizides 1.13 #include "MitAna/TAM/interface/TAMVirtualLoader.h"
29 loizides 1.1 #endif
30    
31    
32     class TBranch;
33     class TTree;
34     class TFile;
35     class TAModule;
36     class TAMOutput;
37 loizides 1.4 class TBranchRef;
38 loizides 1.1
39     class TAMSelector : public TSelector {
40 loizides 1.2 protected:
41 loizides 1.1
42     struct TAMEvtObj : TNamed {
43     // Class for storing event objects:
44     // It assumes ownership of the object.
45     // It is needed to force the THashTable to call Hash on a TNamed
46     // to allow lookup using the hash value given the object's name
47     // (as opposed to its pointer value, as is done for TObject's).
48 loizides 1.4 TObject* fObj; //the object
49 loizides 1.1 TAMEvtObj(TObject* obj) : TNamed(obj->GetName(),0), fObj(obj) {}
50     TAMEvtObj(TObject* obj, const char *name) : TNamed(name,0), fObj(obj) {}
51     virtual ~TAMEvtObj() { if (fObj!=0) delete fObj; }
52     };
53 loizides 1.4
54 loizides 1.11 class BranchProxy : public TObject {
55     // Class that acts as a proxy between the TRefTable, TAM and TBranchRef.
56 loizides 1.12 // If SetDoProxy(kTRUE) is called TRef branch auto-loading will be done
57     // via TAM loaders.
58 loizides 1.11 public:
59     BranchProxy(TAMSelector *sel, Bool_t e=kFALSE);
60 loizides 1.12 virtual ~BranchProxy();
61 loizides 1.11 void Disable();
62     void Enable();
63     TObject *GetObjectWithID(UInt_t uid, TProcessID *pid);
64     Bool_t Notify();
65    
66     protected:
67     Bool_t Load(UInt_t uid, TProcessID *pid, TBranchRef *br, TRefTable *table);
68    
69     TAMSelector *fSel; //ptr to TAMSelector (we are a friend)
70 loizides 1.14 TRefTable *fOrig; //ptr to original TRefTable filled by I/O
71     // (owner is TBranchRef)
72     TRefTable *fFake; //ptr to our fake TRefTable
73     // of which we are owner
74 loizides 1.11 Long64_t fCurEntry; //cache of current entry
75     Bool_t fBrRead[1024]; //flag which TBranchRef branch was read
76     };
77    
78 loizides 1.1 TTree *fTree; //!the tree or chain
79     THashTable fBranchTable; //!table of requested branches
80 loizides 1.12 THashTable fEventObjs; //!table of objects available to any mod
81     // while the current event is processed
82     TAModule *fAModules; //!the top-most TAModule. Nothing but a
83     // container for more modules
84 loizides 1.1 Long64_t fCurEvt; //!the current event
85 loizides 1.12 TList *fOwnInput; //!keep pointer to own input list
86     // in case it was created by us
87     Bool_t fAnalysisAborted; //!if the analysis should be aborted
88     Bool_t fModAborted; //!if >=1 modules(s) are aborted
89     Bool_t fEventAborted; //!if the current event should be aborted
90     Bool_t fActNotify; //!if notify is active
91     // (avoiding recursive calls of Notify())
92     UInt_t fObjCounter; //!keep object counter for resetting it
93     // in the process loop
94     UInt_t fObjCounterRun; //!keep object counter for resetting it
95     // in process when end of run is reached
96     UInt_t fVerbosity; //if one wants to print debug info
97     BranchProxy fProxy; //proxy for reference resolving branch
98     // loading via TAM
99     Bool_t fDoProxy; //if TAMSelector should be proxy for
100     // TRef branch autoloads
101     Bool_t fDoObjTabClean; //true if TAMSelector should clean the
102     // object tables of process id's
103     Bool_t fObjTabClean; //bool to track whether object tables of
104     // process id's are currently clean
105 loizides 1.1 TList fLoaders; //list of data loaders
106    
107     void AddNewOutputLists();
108 bendavid 1.9 void CleanObjTable(TProcessID *pid, UInt_t lastKeptUID) const;
109 loizides 1.1 void ClearAllLoaders();
110     void CopyModsFromInput();
111     Bool_t FindLoader(TAMBranchInfo* brInfo);
112 loizides 1.7 void LoadBranch(TAMBranchInfo* brInfo);
113 loizides 1.1 void TakeModsFromInput();
114     void TakeLoadersFromInput();
115     void ZeroAllBranches();
116    
117     public:
118     TAMSelector();
119     virtual ~TAMSelector();
120    
121     void AbortAnalysis();
122     void AbortEvent();
123     void AbortModule(TAModule* mod);
124     virtual void AddInput(TAModule* mod);
125 loizides 1.12 void AddLoader(TAMVirtualLoader *loader)
126     { fLoaders.AddLast(loader); }
127 loizides 1.1 virtual Bool_t AddObjThisEvt(TObject* obj);
128     virtual Bool_t AddObjThisEvt(TObject* obj, const char *name);
129     void Begin(TTree* tree);
130 loizides 1.12 virtual Bool_t BeginRun() { return kFALSE; }
131     virtual Bool_t EndRun() { return kFALSE; }
132 loizides 1.1 TAMOutput *FindModOutput(const TAModule* mod);
133     virtual TObject *FindObjThisEvt(const Char_t* name) const;
134     virtual TObject *FindPublicObj(const Char_t* name) const;
135     Long64_t GetCurEvt() const { return fCurEvt; }
136 loizides 1.3 const TFile *GetCurrentFile() const;
137     TFile *GetCurrentFile();
138 loizides 1.1 const TAMOutput *GetModOutput() const;
139     TAMOutput *GetModOutput();
140 bendavid 1.10 TObject *GetObjectWithID(UInt_t uid, TProcessID *pid);
141 loizides 1.11 const TAModule *GetTopModule() const { return fAModules; }
142     const TTree *GetTree() const { return fTree; }
143     Bool_t GetObjTabClean() const { return fObjTabClean; }
144     TTree *GetTree() { return fTree; }
145     UInt_t GetVerbosity() const { return fVerbosity; }
146 loizides 1.1 void Init(TTree* tree);
147 loizides 1.11 Bool_t IsAModAborted() const { return fModAborted; }
148     Bool_t IsEventAborted() const { return fEventAborted; }
149 loizides 1.1 Bool_t IsAnalysisAborted() const { return fAnalysisAborted; }
150     void LoadBranch(const Char_t* bname);
151     Bool_t Notify();
152 loizides 1.12 Bool_t Process(Int_t entry)
153     { return Process(static_cast<Long64_t>(entry)); }
154 loizides 1.1 Bool_t Process(Long64_t entry);
155     virtual Bool_t PublishObj(TObject* obj);
156     template <typename T>
157     void ReqBranch(const Char_t* bname, T*& address);
158     virtual TObject *RemoveObjThisEvt(const Char_t* name);
159     virtual TObject *RetractObj(const Char_t* name);
160 loizides 1.11 void SetDoProxy(Bool_t b) { fDoProxy = b; }
161     void SetDoObjTabClean(Bool_t b) { fDoObjTabClean = b; }
162     void SetVerbosity(UInt_t vb) { fVerbosity = vb; }
163 loizides 1.1 void SlaveBegin(TTree* tree);
164     void SlaveTerminate();
165     void Terminate();
166     Int_t Version() const { return 1; }
167    
168 loizides 1.14 ClassDef(TAMSelector,8) // Tree analysis module selector
169 loizides 1.1 };
170    
171    
172     //______________________________________________________________________________
173     template <typename T>
174     inline void TAMSelector::ReqBranch(const Char_t* bname, T*& address)
175     {
176     // Tells the selector that a branch with the given name may be
177     // used by an TAModule and that the the module will access the branch
178     // using the pointer 'address'.
179    
180 loizides 1.4 TAMBranchInfo* brInfo =
181     dynamic_cast<TAMBranchInfo*>( fBranchTable.FindObject(bname) );
182 loizides 1.1
183     if (brInfo==0) {
184     brInfo = new TAMBranchInfo(bname);
185     fBranchTable.Add(brInfo);
186     }
187    
188 loizides 1.8 if (!brInfo->AddPtr(address))
189     AbortAnalysis();
190 loizides 1.1 }
191     #endif //ROOT_TAMSelector