ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TAM/interface/TAMSelector.h
Revision: 1.5
Committed: Tue Oct 7 04:13:54 2008 UTC (16 years, 7 months ago) by loizides
Content type: text/plain
Branch: MAIN
Changes since 1.4: +6 -5 lines
Log Message:
Introduced flags to indicate read TBranchRef branches.

File Contents

# User Rev Content
1 loizides 1.1 //
2 loizides 1.5 // $Id: TAMSelector.h,v 1.4 2008/10/06 16:50:07 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     #ifndef ROOT_TSelector
13     #include "TSelector.h"
14     #endif
15     #ifndef ROOT_THashTable
16     #include "THashTable.h"
17     #endif
18     #ifndef ROOT_List
19     #include "TList.h"
20     #endif
21     #ifndef ROOT_TAMBranchInfo
22     #include "TAMBranchInfo.h"
23     #endif
24     #ifndef ROOT_TAMVirtualLoader
25     #include "TAMVirtualLoader.h"
26     #endif
27     #ifndef ROOT_Riostream
28     #include <Riostream.h>
29     #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     class TAMAutoLoadProxy : public TObject {
55     // Class that acts as a proxy between the TRefTable, TAM and TBranchRef.
56     // If SetDoProxy(kTRUE) is called TRef branch auto-loading will be done via
57     // TAM loaders.
58     protected:
59 loizides 1.5 TAMSelector *fSel; //ptr to TAMSelector (we are a friend)
60     TRefTable *fOrig; //ptr to original TRefTable filled by I/O (owner is TBranchRef)
61     TRefTable *fFake; //ptr to our fake TRefTable of which we are owner
62     Long64_t fCurEntry; //cache of current entry
63     Bool_t fBrRead[1024]; //flag which TBranchRef branch was read
64 loizides 1.4
65     public:
66     TAMAutoLoadProxy(TAMSelector *sel, Bool_t e=kFALSE);
67     virtual ~TAMAutoLoadProxy();
68     void Disable();
69     void Enable();
70     Bool_t Notify();
71     };
72    
73 loizides 1.1 TTree *fTree; //!the tree or chain
74 loizides 1.4 TAMAutoLoadProxy *fProxy; //!the proxy for autoload branch loading
75 loizides 1.1 THashTable fBranchTable; //!table of requested branches
76     THashTable fEventObjs; //!table of objects available to any module while the current event is processed
77     TAModule *fAModules; //!the top-most TAModule. nothing but a container for more modules
78     Long64_t fCurEvt; //!the current event
79     TList *fOwnInput; //!keep pointer to own input list in case it was created by us
80     Bool_t fAnalysisAborted; //!true if the analysis should be aborted
81     Bool_t fModAborted; //!true if one or more modules(s) have been aborted
82     Bool_t fEventAborted; //!true if the current event should be aborted
83     Bool_t fActNotify; //!true if notify is active (avoiding recursive calls of Notify())
84 loizides 1.4 UInt_t fObjCounter; //!keep object counter for resetting it in the process loop
85     UInt_t fObjCounterRun; //!keep object counter for resetting it in the process loop when end of run is reached
86 loizides 1.1 UInt_t fVerbosity; //true if one wants to print debug info
87 loizides 1.4 Bool_t fDoProxy; //true if TAMAutoLoadProxy should be enabled
88 loizides 1.1 TList fLoaders; //list of data loaders
89    
90     void AddNewOutputLists();
91     void ClearAllLoaders();
92     void CopyModsFromInput();
93     Bool_t FindLoader(TAMBranchInfo* brInfo);
94     void TakeModsFromInput();
95     void TakeLoadersFromInput();
96     void ZeroAllBranches();
97 loizides 1.4
98     friend class TAMAutoLoadProxy;
99 loizides 1.1
100     public:
101     TAMSelector();
102     virtual ~TAMSelector();
103    
104     void AbortAnalysis();
105     void AbortEvent();
106     void AbortModule(TAModule* mod);
107     virtual void AddInput(TAModule* mod);
108     void AddLoader(TAMVirtualLoader *loader) { fLoaders.AddLast(loader); }
109     virtual Bool_t AddObjThisEvt(TObject* obj);
110     virtual Bool_t AddObjThisEvt(TObject* obj, const char *name);
111     void Begin(TTree* tree);
112 loizides 1.2 virtual Bool_t BeginRun() { return kFALSE; }
113     virtual Bool_t EndRun() { return kFALSE; }
114 loizides 1.1 TAMOutput *FindModOutput(const TAModule* mod);
115     virtual TObject *FindObjThisEvt(const Char_t* name) const;
116     virtual TObject *FindPublicObj(const Char_t* name) const;
117     Long64_t GetCurEvt() const { return fCurEvt; }
118 loizides 1.3 const TFile *GetCurrentFile() const;
119     TFile *GetCurrentFile();
120 loizides 1.1 const TAMOutput *GetModOutput() const;
121     TAMOutput *GetModOutput();
122 loizides 1.3 const TAModule *GetTopModule() const { return fAModules; }
123 loizides 1.4 const TTree *GetTree() const { return fTree; }
124     TTree *GetTree() { return fTree; }
125 loizides 1.1 UInt_t GetVerbosity() const { return fVerbosity; }
126     void Init(TTree* tree);
127     Bool_t IsAModAborted() const { return fModAborted; }
128     Bool_t IsEventAborted() const { return fEventAborted; }
129     Bool_t IsAnalysisAborted() const { return fAnalysisAborted; }
130     void LoadBranch(const Char_t* bname);
131     Bool_t Notify();
132     Bool_t Process(Int_t entry) { return Process(static_cast<Long64_t>(entry)); }
133     Bool_t Process(Long64_t entry);
134     virtual Bool_t PublishObj(TObject* obj);
135     template <typename T>
136     void ReqBranch(const Char_t* bname, T*& address);
137     virtual TObject *RemoveObjThisEvt(const Char_t* name);
138     virtual TObject *RetractObj(const Char_t* name);
139 loizides 1.4 void SetDoProxy(Bool_t b) { fDoProxy = b; }
140 loizides 1.1 void SetVerbosity(UInt_t vb) { fVerbosity = vb; }
141     void SlaveBegin(TTree* tree);
142     void SlaveTerminate();
143     void Terminate();
144     Int_t Version() const { return 1; }
145    
146 loizides 1.4 ClassDef(TAMSelector,8)
147 loizides 1.1 };
148    
149    
150     //______________________________________________________________________________
151     template <typename T>
152     inline void TAMSelector::ReqBranch(const Char_t* bname, T*& address)
153     {
154     // Tells the selector that a branch with the given name may be
155     // used by an TAModule and that the the module will access the branch
156     // using the pointer 'address'.
157    
158 loizides 1.4 TAMBranchInfo* brInfo =
159     dynamic_cast<TAMBranchInfo*>( fBranchTable.FindObject(bname) );
160 loizides 1.1
161     if (brInfo==0) {
162     brInfo = new TAMBranchInfo(bname);
163     fBranchTable.Add(brInfo);
164     }
165    
166     if (!brInfo->AddPtr(address)) AbortAnalysis();
167     }
168    
169 loizides 1.4
170 loizides 1.1 #endif //ROOT_TAMSelector