ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/TAM/interface/TAModule.h
Revision: 1.8
Committed: Thu Jul 16 21:02:04 2009 UTC (15 years, 9 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, 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, HEAD
Branch point for: Mit_025c_branch
Changes since 1.7: +3 -3 lines
Log Message:
use same include paths as rest of code. Remember to always remove this when committing to the svn version.

File Contents

# Content
1 //
2 // $Id: TAModule.h,v 1.7 2009/07/13 19:18:38 loizides Exp $
3 //
4
5 #ifndef ROOT_TAModule
6 #define ROOT_TAModule
7
8 // keep this for compatibility
9 #define TAM_TAModule
10
11
12 // typeid include
13 #include <typeinfo>
14
15
16 #ifndef ROOT_TTask
17 #include "TTask.h"
18 #endif
19 #ifndef ROOT_Varargs
20 #include "Varargs.h"
21 #endif
22 #ifndef ROOT_TAMSelector
23 #include "MitAna/TAM/interface/TAMSelector.h"
24 #endif
25 #ifndef ROOT_TAMOutput
26 #include "MitAna/TAM/interface/TAMOutput.h"
27 #endif
28
29 class TFile;
30 class TStopwatch;
31
32
33 class TAModule : public TTask {
34 public:
35 enum EModResult {
36 kWarning, //a problem requiring no action, just printing of a warning
37 kAbortModule, //a problem requiring this mod (and its submods) to stop
38 kAbortEvent, //a problem requiring the processing of this event to stop
39 kStopModule, //a problem requiring this module (and its submodules)
40 // to stop for the rest of the analysis
41 kAbortAnalysis //a problem requiring the analysis to stop
42 };
43
44 private:
45 TAMSelector *fSelector; //!the selector processing the tree
46 TAMOutput *fOutput; //the list of output objects for this mod
47 Bool_t fDefActv; //!copy of fActive so that TAMSelector can
48 // temporarily change this mod's active-ness
49 // to abort the module or the event
50 UInt_t fVerbose; //verbosity level
51 Bool_t fStopped; //!indicate if module (and its submodules) are
52 // aborted for the rest of the analysis
53 Bool_t fUseName; //if true use this module's name when
54 // writing the output in the flattening mode
55
56 static const Char_t kExecBegin; //!key to mark Begin
57 static const Char_t kExecSlaveBegin; //!key to mark SlaveBegin
58 static const Char_t kExecProcess; //!key to mark Process
59 static const Char_t kExecBeginRun; //!key to mark BeginRun
60 static const Char_t kExecEndRun; //!key to mark EndRun
61 static const Char_t kExecSlaveTerminate; //!key to mark SlaveTerminate
62 static const Char_t kExecTerminate; //!key to mark Terminate
63
64 void AbortAnalysis();
65 void AbortModule();
66 void DeactivateAll();
67 void NewOutputList(TList* list);
68 Bool_t NotifyAll();
69 void ResetAllActiveFlags();
70 void SetAllModOutput(TAMOutput* o);
71 void SetModOutput(TAMOutput* o);
72 void StopModule();
73
74 protected:
75
76 // utility functions to be used by derived classes
77 void AbortEvent();
78 virtual Bool_t AddObjThisEvt(TObject* obj);
79 virtual Bool_t AddObjThisEvt(TObject* obj, const char *name);
80 template <class OC>
81 void AddOutput(OC* const & obj);
82 const TAMSelector *GetSelector() const { return fSelector; }
83 Bool_t IsEventAborted() const;
84 Bool_t IsAnalysisAborted() const;
85 void ls(Option_t *option) const;
86 void LoadBranch(const Char_t* bname);
87 virtual TObject *FindObjThisEvt(const Char_t* name) const;
88 virtual Bool_t Notify() { return kTRUE; }
89 virtual TObject *RemoveObjThisEvt(const Char_t* name);
90 void RemoveOutput(TObject* obj);
91 template <typename T>
92 void ReqBranch(const Char_t* bname, T*& address);
93 void SendError(const EModResult errLevel,
94 const Char_t* location,
95 const Char_t* formattedMsg, ...);
96 void SkipEvent();
97
98 // functions to be overloaded by specific TAModule
99 virtual void Begin() {}
100 virtual void SlaveBegin() {}
101 virtual void Process() {}
102 virtual void BeginRun() {}
103 virtual void EndRun() {}
104 virtual void SlaveTerminate() {}
105 virtual void Terminate() {}
106
107 public:
108
109 TAModule();
110 TAModule(const Char_t* name, const Char_t* title);
111 virtual ~TAModule();
112
113 void SetActive(Bool_t act = kTRUE) { SetDefActive(act); }
114 virtual void Browse(TBrowser* b);
115 // intentionally have no GetSelector as modules should never directly
116 // interact with the selector, the input list or the output list
117 Bool_t CheckSelectors(const TAMSelector* sel,
118 const Bool_t warn=kTRUE) const;
119 // TAMSelector is a friend to allow it to call Exec
120 // using the private variables such as kExecProcess
121 // and to prevent TAModules inheritting from this class
122 // from making such explicit calls.
123 friend class TAMSelector;
124 void Exec(Option_t* option);
125 TObject *FindPublicObj(const Char_t* name) const;
126 TFile *GetCurrentFile() const;
127 const TAMOutput *GetModOutput() const { return fOutput; }
128 TAMOutput *GetModOutput() { return fOutput; }
129 TList* GetSubModules() { return GetListOfTasks(); }
130 const TList *GetSubModules() const { return GetListOfTasks(); }
131 Bool_t GetUseName() const { return fUseName; }
132 UInt_t GetVerbosity() const { return fVerbose; }
133 virtual void Print(Option_t *option="") const;
134 Bool_t PublishObj(TObject* obj);
135 TObject *RetractObj(const Char_t* name);
136 void SetDefActive(Bool_t active);
137 void SetSelector(TAMSelector* sel);
138 void SetUseName(Bool_t b) { fUseName = b; }
139 void SetVerbosity(UInt_t vb) { fVerbose = vb; }
140
141 static const char *Version();
142
143 ClassDef(TAModule,4) // Base class for modular processing a tree
144 };
145
146
147 //______________________________________________________________________________
148 template <class OC>
149 inline void TAModule::AddOutput(OC* const & obj)
150 {
151 // Add the object to the list of output objects of this module.
152 // The Proof facility can then merge this object from each worker
153 // computer.
154 // This version of the function will also store the address of the
155 // pointer, and if the pointer is a member of the module, the member
156 // will be made to point to the object in the output list on the
157 // client computer before Terminate is called.
158
159 if (fOutput!=0) {
160 fOutput->AddOutput(obj);
161 } else {
162 SendError(kAbortAnalysis,
163 "AddOutput",
164 "fOutput is null in module [%s]",
165 GetName());
166 }
167 }
168
169
170 //______________________________________________________________________________
171 inline Bool_t TAModule::IsEventAborted() const
172 {
173 // Return kTRUE if event has been aborted.
174
175 return (fSelector==0) ? kFALSE : fSelector->IsEventAborted();
176 }
177
178
179 //______________________________________________________________________________
180 inline Bool_t TAModule::IsAnalysisAborted() const
181 {
182 // Return kTRUE if analysis has been aborted.
183
184 return (fSelector==0) ? kFALSE : fSelector->IsAnalysisAborted();
185 }
186
187 //______________________________________________________________________________
188 template <typename T>
189 inline void TAModule::ReqBranch(const Char_t* bname, T*& address)
190 {
191 // Requests that the branch with the specified name be made available
192 // during processing and that it be read in to the address specified.
193 // The TAMSelector will automatically change the value of the pointer
194 // pointed to ('*address') to the address of the branch entry when it
195 // is read in via LoadBranch.
196
197 if (fSelector!=0) {
198 fSelector->ReqBranch(bname, address);
199 } else {
200 SendError(kAbortAnalysis,
201 "ReqBranch",
202 "fSelector is null in module [%s]",
203 GetName());
204 }
205 }
206
207
208 //______________________________________________________________________________
209 inline void TAModule::SetDefActive(Bool_t active)
210 {
211 // Set the activity and make it the default behavior.
212
213 fDefActv = active;
214 TTask::SetActive(active);
215 }
216
217 #endif //ROOT_TAModule