ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TAM/interface/TAMSelector.h
Revision: 1.2
Committed: Mon Jun 23 19:39:14 2008 UTC (16 years, 10 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: MITHEP_2_0_x
Changes since 1.1: +5 -2 lines
Log Message:
Added Begin and EndRun to core TAM framework.

File Contents

# User Rev Content
1 loizides 1.1 //
2 loizides 1.2 // $Id: TAMSelector.h,v 1.1 2008/05/27 19:13:21 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    
38    
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     TObject* fObj; // the object
49     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    
54     TTree *fTree; //!the tree or chain
55     THashTable fBranchTable; //!table of requested branches
56     THashTable fEventObjs; //!table of objects available to any module while the current event is processed
57     TAModule *fAModules; //!the top-most TAModule. nothing but a container for more modules
58     Long64_t fCurEvt; //!the current event
59     TList *fOwnInput; //!keep pointer to own input list in case it was created by us
60     Bool_t fAnalysisAborted; //!true if the analysis should be aborted
61     Bool_t fModAborted; //!true if one or more modules(s) have been aborted
62     Bool_t fEventAborted; //!true if the current event should be aborted
63     Bool_t fActNotify; //!true if notify is active (avoiding recursive calls of Notify())
64     UInt_t fObjCounter; //keep object counter for resetting it in the process loop
65 loizides 1.2 UInt_t fObjCounterRun; //keep object counter for resetting it in the process loop when end of run is reached
66 loizides 1.1 UInt_t fVerbosity; //true if one wants to print debug info
67     TList fLoaders; //list of data loaders
68    
69     void AddNewOutputLists();
70     void ClearAllLoaders();
71     void CopyModsFromInput();
72     Bool_t FindLoader(TAMBranchInfo* brInfo);
73     void TakeModsFromInput();
74     void TakeLoadersFromInput();
75     void ZeroAllBranches();
76    
77     public:
78     TAMSelector();
79     virtual ~TAMSelector();
80    
81     void AbortAnalysis();
82     void AbortEvent();
83     void AbortModule(TAModule* mod);
84     virtual void AddInput(TAModule* mod);
85     void AddLoader(TAMVirtualLoader *loader) { fLoaders.AddLast(loader); }
86     virtual Bool_t AddObjThisEvt(TObject* obj);
87     virtual Bool_t AddObjThisEvt(TObject* obj, const char *name);
88     void Begin(TTree* tree);
89 loizides 1.2 virtual Bool_t BeginRun() { return kFALSE; }
90     virtual Bool_t EndRun() { return kFALSE; }
91 loizides 1.1 TAMOutput *FindModOutput(const TAModule* mod);
92     virtual TObject *FindObjThisEvt(const Char_t* name) const;
93     virtual TObject *FindPublicObj(const Char_t* name) const;
94     Long64_t GetCurEvt() const { return fCurEvt; }
95     TFile* GetCurrentFile() const;
96     const TAMOutput *GetModOutput() const;
97     TAMOutput *GetModOutput();
98     UInt_t GetVerbosity() const { return fVerbosity; }
99     void Init(TTree* tree);
100     Bool_t IsAModAborted() const { return fModAborted; }
101     Bool_t IsEventAborted() const { return fEventAborted; }
102     Bool_t IsAnalysisAborted() const { return fAnalysisAborted; }
103     void LoadBranch(const Char_t* bname);
104     Bool_t Notify();
105     Bool_t Process(Int_t entry) { return Process(static_cast<Long64_t>(entry)); }
106     Bool_t Process(Long64_t entry);
107     virtual Bool_t PublishObj(TObject* obj);
108     template <typename T>
109     void ReqBranch(const Char_t* bname, T*& address);
110     virtual TObject *RemoveObjThisEvt(const Char_t* name);
111     virtual TObject *RetractObj(const Char_t* name);
112     void SetVerbosity(UInt_t vb) { fVerbosity = vb; }
113     void SlaveBegin(TTree* tree);
114     void SlaveTerminate();
115     void Terminate();
116     Int_t Version() const { return 1; }
117    
118     ClassDef(TAMSelector,7)
119     };
120    
121    
122     //______________________________________________________________________________
123     template <typename T>
124     inline void TAMSelector::ReqBranch(const Char_t* bname, T*& address)
125     {
126     // Tells the selector that a branch with the given name may be
127     // used by an TAModule and that the the module will access the branch
128     // using the pointer 'address'.
129    
130     TAMBranchInfo* brInfo = dynamic_cast<TAMBranchInfo*>( fBranchTable.FindObject(bname) );
131    
132     if (brInfo==0) {
133     brInfo = new TAMBranchInfo(bname);
134     fBranchTable.Add(brInfo);
135     }
136    
137     if (!brInfo->AddPtr(address)) AbortAnalysis();
138     }
139    
140     #endif //ROOT_TAMSelector