]>
Commit | Line | Data |
---|---|---|
c8b1a7db | 1 | // |
2 | // Base class for FMD ESD input - sub classes can use the services to | |
3 | // easily setup a task to process the FMD ESD data | |
4 | // | |
5 | #ifndef ALIFMDESDTASK_H | |
6 | #define ALIFMDESDTASK_H | |
7 | ||
8 | #include <AliAnalysisTaskSE.h> | |
9 | class AliFMDEventInspector; | |
10 | class AliCorrectionManagerBase; | |
11 | class AliAODHandler; | |
12 | class AliESDEvent; | |
13 | class TAxis; | |
14 | class TList; | |
15 | ||
16 | /** | |
17 | * Base class for tasks that analyse the FMD ESD. This wraps a | |
18 | * single-event analysis task, and provides a modified interface to | |
19 | * implement for the sub-classes: | |
20 | * | |
21 | * @code | |
22 | * class MyFMDESDTask : public AliBaseESDTask | |
23 | * { | |
24 | * public: | |
25 | * MyFMDESDTask() : AliBaseESDTask() {} | |
26 | * MyFMDESDTask(const char* name) : AliBaseESDTask(name) | |
27 | * { | |
28 | * } | |
29 | * AliFMDEventInspector& GetEventInspector() { return fInspector; } | |
30 | * const AliFMDEventInspector& GetEventInspector() const{ return fInspector; } | |
31 | * Bool_t Book() | |
32 | * { | |
33 | * fNeededCorrections = AliForwardCorrectionManager::kELossFits; | |
34 | * fSharingFilter.CreateUserObject(fList); | |
35 | * return true; | |
36 | * } | |
37 | * Bool_t PreData(const TAxis& vertex, const TAxis& eta) | |
38 | * { | |
39 | * fSharingFilter.SetupForData(eta); | |
40 | * return true; | |
41 | * } | |
42 | * Bool_t PreEvent() { fESDFMD.Clear(); return true; } | |
43 | * Bool_t PostEvent() { return true; } | |
44 | * Bool_t Event(AliESDEvent& esd) | |
45 | * { | |
46 | * Bool_t lowFlux = kFALSE; | |
47 | * UInt_t triggers = 0; | |
48 | * UShort_t ivz = 0; | |
49 | * TVector3 ip; | |
50 | * Double_t cent = -1; | |
51 | * UShort_t nClusters = 0; | |
52 | * UInt_t found = fEventInspector.Process(esd, triggers, lowFlux, | |
53 | * ivz, ip, cent, nClusters); | |
54 | * if (found & AliFMDEventInspector::kNoEvent) return false; | |
55 | * if (found & AliFMDEventInspector::kNoTriggers) return false; | |
56 | * if (found & AliFMDEventInspector::kNoSPD) return; | |
57 | * if (found & AliFMDEventInspector::kNoFMD) return; | |
58 | * if (found & AliFMDEventInspector::kNoVertex) return; | |
59 | * if (triggers & AliAODForwardMult::kPileUp) return; | |
60 | * if (found & AliFMDEventInspector::kBadVertex) return; | |
61 | * | |
62 | * Bool_t ret = fSharingFilter.Filter(esd, lowFlux, fESDFMD, ip.Z()); | |
63 | * return ret; | |
64 | * } | |
65 | * Bool_t Finalize() | |
66 | * { | |
67 | * GetSharingFilter().Terminate(fList,fResults,Int_t(nTr)); | |
68 | * return true; | |
69 | * } | |
70 | * protected: | |
71 | * AliFMDEventInsepctor fInspector; | |
72 | * AliFMDSharingFilter fSharingFilter; | |
73 | * AliESDFMD fESDFMD; | |
74 | * }; | |
75 | * @endcode | |
76 | * | |
77 | */ | |
78 | class AliBaseESDTask : public AliAnalysisTaskSE | |
79 | { | |
80 | public: | |
81 | /** | |
82 | * Default (I/O) constructor - do not use directly | |
83 | */ | |
84 | AliBaseESDTask(); | |
85 | /** | |
86 | * User constructor | |
87 | * | |
88 | * @param name Name of the task | |
89 | * @param title Class name used in configuration script | |
90 | * @param manager Correction manager | |
91 | */ | |
92 | AliBaseESDTask(const char* name, const char* title, | |
93 | AliCorrectionManagerBase* manager); | |
94 | /** | |
95 | * Add this task to the manager and connect the outputs. If @a | |
96 | * sumFile is null or the empty string, then the sum container is | |
97 | * stored in the default output file of the manager. If @a resFile | |
98 | * is null or the empty string, then it is set to @a resFile if | |
99 | * defined, otherwise to the default output file of the manager. | |
100 | * | |
101 | * @param sumFile Output file for sums | |
102 | * @param resFile Output file for sums | |
103 | * | |
104 | * @return true on success | |
105 | */ | |
106 | virtual Bool_t Connect(const char* sumFile=0, const char* resFile=0); | |
0b7de667 | 107 | /** |
108 | * Called when initializing the train | |
109 | */ | |
110 | virtual Bool_t Setup() { return true; } | |
c8b1a7db | 111 | /** |
112 | * Book output objects. Derived class should define this to book | |
113 | * output objects on the processing output list @c fList before the | |
114 | * actual event processing. This is called on the master and on | |
115 | * each slave. | |
116 | * | |
117 | * If this member function returns false, the execution is stopped | |
118 | * with a fatal signal. | |
119 | * | |
120 | * @return true on success. | |
121 | */ | |
122 | virtual Bool_t Book() = 0; | |
0ccdab7b | 123 | /** |
124 | * Called on first event _before_ reading corrections. Here, the | |
125 | * user class can do additional checking to see if the some (more or | |
126 | * less) corrections are needed. | |
127 | * | |
128 | * @param esd Event | |
129 | */ | |
130 | virtual void PreCorrections(const AliESDEvent* esd); | |
c8b1a7db | 131 | /** |
132 | * Called after reading in the first event. Here we can setup stuff | |
133 | * depending on the conditions we're running under. | |
134 | * | |
135 | * @return true on success. If this returns false, then we turn the | |
136 | * task into a zombie and we do no more processing. | |
137 | */ | |
138 | virtual Bool_t PreData(const TAxis& vertex, const TAxis& eta); | |
139 | /** | |
140 | * Called before processing a single event - should not do anything | |
141 | * but clear data, etc. | |
142 | * | |
143 | * @return true on success | |
144 | */ | |
145 | virtual Bool_t PreEvent() { return true; } | |
146 | /** | |
147 | * Process a single event | |
148 | * | |
149 | * @param esd Input event | |
150 | * | |
151 | * @return true on success | |
152 | */ | |
153 | virtual Bool_t Event(AliESDEvent& esd) = 0; | |
154 | /** | |
155 | * Called after processing a single event - should not do anything | |
156 | * but clear data, etc. | |
157 | * | |
158 | * @return true on success | |
159 | */ | |
160 | virtual Bool_t PostEvent() { return true; } | |
161 | /** | |
162 | * Do the final analysis on the merged output. | |
163 | * | |
164 | * @return true on success | |
165 | */ | |
166 | virtual Bool_t Finalize() { return true; } | |
167 | /** | |
168 | * @{ | |
169 | * @name Utility methods | |
170 | */ | |
171 | /** | |
172 | * Print information | |
173 | * | |
174 | * @param option Not used | |
175 | */ | |
176 | virtual void Print(Option_t* option="") const; | |
177 | /** | |
178 | * Set the debug level | |
179 | * | |
180 | * @param dbg | |
181 | */ | |
182 | virtual void SetDebug(Int_t dbg); | |
183 | /** | |
184 | * Overload super class method for setting debug level to call our | |
185 | * SetDebug member function. | |
186 | * | |
187 | * @param dbg Debug level (0: no output, 1: essentials, 3: a whole lot) | |
188 | */ | |
189 | virtual void SetDebugLevel(Int_t dbg) | |
190 | { | |
191 | AliAnalysisTaskSE::SetDebugLevel(dbg); | |
192 | SetDebug(dbg); | |
193 | } | |
194 | /* @} */ | |
195 | // --- Configuration etc ------------------------------------------- | |
196 | /** @{ | |
197 | * @name Access sub-components | |
198 | */ | |
199 | /** | |
200 | * Configure this task via a macro | |
201 | * | |
202 | * @param macro Macro to configure va | |
203 | * | |
204 | * @return true on success, false otherwise | |
205 | */ | |
7c0b3e50 | 206 | virtual Bool_t Configure(const char* macro="-default-"); |
c8b1a7db | 207 | /** |
208 | * Get a reference to the event inspector. User must override this | |
209 | * to return proper object | |
210 | * | |
211 | * @return Reference to the event inspector | |
212 | */ | |
213 | virtual AliFMDEventInspector& GetEventInspector() = 0; | |
214 | /** | |
215 | * Get a reference to the event inspector. User must override this | |
216 | * to return proper object | |
217 | * | |
218 | * @return Reference to the event inspector | |
219 | */ | |
220 | virtual const AliFMDEventInspector& GetEventInspector() const = 0; | |
221 | /* @} */ | |
222 | protected: | |
223 | /** | |
224 | * Copy constructor - left undefined | |
225 | * | |
226 | * @param o Object to copy from | |
227 | */ | |
228 | AliBaseESDTask(const AliBaseESDTask& o); | |
229 | /** | |
230 | * Assignment operator - left undefined | |
231 | * | |
232 | * @param o Object to assign from | |
233 | * | |
234 | * @return Reference to this object. | |
235 | */ | |
236 | AliBaseESDTask& operator=(const AliBaseESDTask& o); | |
237 | // --- Customize --------------------------------------------------- | |
238 | /** | |
239 | * Evaluate wether this is for MC. User class can override this | |
240 | * | |
241 | * @return true if we're to initialize corrections for MC input | |
242 | */ | |
243 | virtual Bool_t IsMC() const { return false; } | |
244 | /** | |
245 | * Set the default eta axis to use in case we didn't get one from | |
246 | * the read-in corretions. Override this if the sub class should go | |
247 | * on even without a valid eta axis from the corrections (e.g. QA | |
248 | * task) | |
249 | * | |
250 | * @return null | |
251 | */ | |
77f97e3f | 252 | virtual TAxis* DefaultEtaAxis() const; |
c8b1a7db | 253 | /** |
254 | * Set the default eta axis to use in case we didn't get one from | |
255 | * the read-in corretions. Override this if the sub class should go | |
256 | * on even without a valid eta axis from the corrections (e.g. QA | |
257 | * task) | |
258 | * | |
259 | * @return null | |
260 | */ | |
77f97e3f | 261 | virtual TAxis* DefaultVertexAxis() const; |
c8b1a7db | 262 | /** |
263 | * Get the correction mananger. Derived class should overload this | |
264 | * to return the proper object. | |
265 | * | |
266 | * @return Pointer to correction manager | |
267 | */ | |
268 | virtual AliCorrectionManagerBase* GetManager() const { return fCorrManager; } | |
269 | /** | |
270 | * Get the correction mananger. Derived class should overload this | |
271 | * to return the proper object. | |
272 | * | |
273 | * @return Pointer to correction manager | |
274 | */ | |
275 | virtual AliCorrectionManagerBase* GetManager() { return fCorrManager; } | |
276 | ||
277 | // --- Task methods ------------------------------------------------ | |
278 | /** | |
279 | * @{ | |
280 | * @name Task interface methods | |
281 | */ | |
282 | /** | |
283 | * Initialize the task | |
284 | */ | |
0b7de667 | 285 | void LocalInit(); |
c8b1a7db | 286 | /** |
287 | * Create output objects | |
288 | */ | |
0b7de667 | 289 | void UserCreateOutputObjects(); |
c8b1a7db | 290 | /** |
291 | * Process each event | |
292 | * | |
293 | * @param option Not used | |
294 | */ | |
0b7de667 | 295 | void UserExec(Option_t* option); |
c8b1a7db | 296 | /** |
297 | * End of job | |
298 | * | |
299 | * @param option Not used | |
300 | */ | |
0b7de667 | 301 | void Terminate(Option_t* option); |
c8b1a7db | 302 | /** |
303 | * @} | |
304 | */ | |
305 | // --- Services for derived classes -------------------------------- | |
306 | /** | |
307 | * Create output branches - called from UserCreateOutputObjects | |
308 | */ | |
309 | virtual void CreateBranches(AliAODHandler*) {} | |
310 | /** | |
311 | * Mark this event as one to store in the AOD | |
312 | * | |
313 | */ | |
314 | virtual void MarkEventForStore() const; | |
315 | /** | |
316 | * Check if all needed corrections are there and accounted for. If not, | |
317 | * do a Fatal exit | |
318 | * | |
319 | * @param what Which corrections is needed | |
320 | * | |
321 | * @return true if all present, false otherwise | |
322 | */ | |
323 | virtual Bool_t CheckCorrections(UInt_t what) const; | |
324 | /** | |
325 | * Read corrections | |
326 | * | |
327 | * | |
328 | * @param pe On return, the eta axis | |
329 | * @param pv On return ,the vertex axis | |
330 | * @param mc True assume MC input | |
331 | * @param sat True if we need for satellite interactions too | |
332 | * | |
333 | * @return true ons succcss | |
334 | */ | |
335 | virtual Bool_t ReadCorrections(const TAxis*& pe, | |
336 | const TAxis*& pv, | |
337 | Bool_t mc=false, | |
338 | Bool_t sat=false); | |
339 | /** | |
340 | * Get the ESD event. IF this is the first event, initialise | |
341 | * | |
342 | * @return Pointer to ESD event structore | |
343 | */ | |
344 | virtual AliESDEvent* GetESDEvent(); | |
345 | ||
7c0b3e50 | 346 | virtual const char* DefaultConfig() const |
347 | { | |
348 | return "ForwardAODConfig.C"; | |
349 | } | |
350 | ||
c8b1a7db | 351 | // --- Members ----------------------------------------------------- |
352 | Bool_t fFirstEvent; // Wheter we're waiting for the first event | |
353 | TList* fList; // Output list | |
354 | TList* fResults; // Results list | |
355 | UInt_t fNeededCorrections; // Set this to bit-mask of corrections we need | |
356 | UInt_t fExtraCorrections; // Set this to bit-mask of corrections we'd like | |
357 | Bool_t fCloneList; // Result list is a clone of sum list | |
358 | private: | |
359 | /** | |
360 | * A pointer to the corrections manager. This is here to make the | |
361 | * corrections manager persistent - that is, when we write the | |
362 | * analysis train to a file (as done in PROOF) we should also write | |
363 | * down the corrections mananger. This pointer ensures that. | |
364 | * | |
365 | */ | |
366 | AliCorrectionManagerBase* fCorrManager; // Pointer to corrections manager | |
367 | ||
368 | ClassDef(AliBaseESDTask,1); | |
369 | }; | |
0ccdab7b | 370 | inline void AliBaseESDTask::PreCorrections(const AliESDEvent*) {} |
c8b1a7db | 371 | #endif |
372 | // Local Variables: | |
373 | // mode: C++ | |
374 | // End: |