]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliBaseESDTask.h
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliBaseESDTask.h
CommitLineData
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>
9class AliFMDEventInspector;
10class AliCorrectionManagerBase;
11class AliAODHandler;
12class AliESDEvent;
13class TAxis;
14class 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 */
78class AliBaseESDTask : public AliAnalysisTaskSE
79{
80public:
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 */
2d7a08a0 106 virtual Bool_t Connect(const char* sumFile=0,
4945defe 107 const char* resFile=0)
108 {
109 return Connect(sumFile, resFile, false);
110 }
111 /**
112 * Add this task to the manager and connect the outputs. If @a
113 * sumFile is null or the empty string, then the sum container is
114 * stored in the default output file of the manager. If @a resFile
115 * is null or the empty string, then it is set to @a resFile if
116 * defined, otherwise to the default output file of the manager.
117 *
118 * @param sumFile Output file for sums
119 * @param resFile Output file for sums
120 * @param old Use old names
121 *
122 * @return true on success
123 */
124 virtual Bool_t Connect(const char* sumFile,
125 const char* resFile,
126 Bool_t old);
0b7de667 127 /**
128 * Called when initializing the train
129 */
130 virtual Bool_t Setup() { return true; }
c8b1a7db 131 /**
132 * Book output objects. Derived class should define this to book
133 * output objects on the processing output list @c fList before the
134 * actual event processing. This is called on the master and on
135 * each slave.
136 *
137 * If this member function returns false, the execution is stopped
138 * with a fatal signal.
139 *
140 * @return true on success.
141 */
142 virtual Bool_t Book() = 0;
0ccdab7b 143 /**
144 * Called on first event _before_ reading corrections. Here, the
145 * user class can do additional checking to see if the some (more or
146 * less) corrections are needed.
147 *
148 * @param esd Event
149 */
150 virtual void PreCorrections(const AliESDEvent* esd);
c8b1a7db 151 /**
152 * Called after reading in the first event. Here we can setup stuff
153 * depending on the conditions we're running under.
154 *
155 * @return true on success. If this returns false, then we turn the
156 * task into a zombie and we do no more processing.
157 */
158 virtual Bool_t PreData(const TAxis& vertex, const TAxis& eta);
159 /**
160 * Called before processing a single event - should not do anything
161 * but clear data, etc.
162 *
163 * @return true on success
164 */
165 virtual Bool_t PreEvent() { return true; }
166 /**
167 * Process a single event
168 *
169 * @param esd Input event
170 *
171 * @return true on success
172 */
173 virtual Bool_t Event(AliESDEvent& esd) = 0;
174 /**
175 * Called after processing a single event - should not do anything
176 * but clear data, etc.
177 *
178 * @return true on success
179 */
180 virtual Bool_t PostEvent() { return true; }
181 /**
182 * Do the final analysis on the merged output.
183 *
184 * @return true on success
185 */
186 virtual Bool_t Finalize() { return true; }
187 /**
188 * @{
189 * @name Utility methods
190 */
191 /**
192 * Print information
193 *
194 * @param option Not used
195 */
196 virtual void Print(Option_t* option="") const;
197 /**
198 * Set the debug level
199 *
200 * @param dbg
201 */
202 virtual void SetDebug(Int_t dbg);
203 /**
204 * Overload super class method for setting debug level to call our
205 * SetDebug member function.
206 *
207 * @param dbg Debug level (0: no output, 1: essentials, 3: a whole lot)
208 */
209 virtual void SetDebugLevel(Int_t dbg)
210 {
211 AliAnalysisTaskSE::SetDebugLevel(dbg);
212 SetDebug(dbg);
213 }
214 /* @} */
215 // --- Configuration etc -------------------------------------------
216 /** @{
217 * @name Access sub-components
218 */
219 /**
220 * Configure this task via a macro
221 *
222 * @param macro Macro to configure va
223 *
224 * @return true on success, false otherwise
225 */
7c0b3e50 226 virtual Bool_t Configure(const char* macro="-default-");
c8b1a7db 227 /**
228 * Get a reference to the event inspector. User must override this
229 * to return proper object
230 *
231 * @return Reference to the event inspector
232 */
233 virtual AliFMDEventInspector& GetEventInspector() = 0;
234 /**
235 * Get a reference to the event inspector. User must override this
236 * to return proper object
237 *
238 * @return Reference to the event inspector
239 */
240 virtual const AliFMDEventInspector& GetEventInspector() const = 0;
241 /* @} */
242protected:
243 /**
244 * Copy constructor - left undefined
245 *
246 * @param o Object to copy from
247 */
248 AliBaseESDTask(const AliBaseESDTask& o);
249 /**
250 * Assignment operator - left undefined
251 *
252 * @param o Object to assign from
253 *
254 * @return Reference to this object.
255 */
256 AliBaseESDTask& operator=(const AliBaseESDTask& o);
257 // --- Customize ---------------------------------------------------
258 /**
259 * Evaluate wether this is for MC. User class can override this
260 *
261 * @return true if we're to initialize corrections for MC input
262 */
263 virtual Bool_t IsMC() const { return false; }
264 /**
265 * Set the default eta axis to use in case we didn't get one from
266 * the read-in corretions. Override this if the sub class should go
267 * on even without a valid eta axis from the corrections (e.g. QA
268 * task)
269 *
270 * @return null
271 */
77f97e3f 272 virtual TAxis* DefaultEtaAxis() const;
c8b1a7db 273 /**
274 * Set the default eta axis to use in case we didn't get one from
275 * the read-in corretions. Override this if the sub class should go
276 * on even without a valid eta axis from the corrections (e.g. QA
277 * task)
278 *
279 * @return null
280 */
77f97e3f 281 virtual TAxis* DefaultVertexAxis() const;
c8b1a7db 282 /**
283 * Get the correction mananger. Derived class should overload this
284 * to return the proper object.
285 *
286 * @return Pointer to correction manager
287 */
288 virtual AliCorrectionManagerBase* GetManager() const { return fCorrManager; }
289 /**
290 * Get the correction mananger. Derived class should overload this
291 * to return the proper object.
292 *
293 * @return Pointer to correction manager
294 */
295 virtual AliCorrectionManagerBase* GetManager() { return fCorrManager; }
296
297 // --- Task methods ------------------------------------------------
298 /**
299 * @{
300 * @name Task interface methods
301 */
302 /**
303 * Initialize the task
304 */
0b7de667 305 void LocalInit();
c8b1a7db 306 /**
307 * Create output objects
308 */
0b7de667 309 void UserCreateOutputObjects();
c8b1a7db 310 /**
311 * Process each event
312 *
313 * @param option Not used
314 */
0b7de667 315 void UserExec(Option_t* option);
c8b1a7db 316 /**
317 * End of job
318 *
319 * @param option Not used
320 */
0b7de667 321 void Terminate(Option_t* option);
c8b1a7db 322 /**
323 * @}
324 */
325 // --- Services for derived classes --------------------------------
326 /**
327 * Create output branches - called from UserCreateOutputObjects
328 */
329 virtual void CreateBranches(AliAODHandler*) {}
330 /**
331 * Mark this event as one to store in the AOD
332 *
333 */
334 virtual void MarkEventForStore() const;
335 /**
336 * Check if all needed corrections are there and accounted for. If not,
337 * do a Fatal exit
338 *
339 * @param what Which corrections is needed
340 *
341 * @return true if all present, false otherwise
342 */
343 virtual Bool_t CheckCorrections(UInt_t what) const;
344 /**
345 * Read corrections
346 *
347 *
348 * @param pe On return, the eta axis
349 * @param pv On return ,the vertex axis
350 * @param mc True assume MC input
351 * @param sat True if we need for satellite interactions too
352 *
353 * @return true ons succcss
354 */
355 virtual Bool_t ReadCorrections(const TAxis*& pe,
356 const TAxis*& pv,
357 Bool_t mc=false,
358 Bool_t sat=false);
359 /**
360 * Get the ESD event. IF this is the first event, initialise
361 *
362 * @return Pointer to ESD event structore
363 */
364 virtual AliESDEvent* GetESDEvent();
365
7c0b3e50 366 virtual const char* DefaultConfig() const
367 {
368 return "ForwardAODConfig.C";
369 }
370
c8b1a7db 371 // --- Members -----------------------------------------------------
372 Bool_t fFirstEvent; // Wheter we're waiting for the first event
373 TList* fList; // Output list
374 TList* fResults; // Results list
375 UInt_t fNeededCorrections; // Set this to bit-mask of corrections we need
376 UInt_t fExtraCorrections; // Set this to bit-mask of corrections we'd like
377 Bool_t fCloneList; // Result list is a clone of sum list
378private:
379 /**
380 * A pointer to the corrections manager. This is here to make the
381 * corrections manager persistent - that is, when we write the
382 * analysis train to a file (as done in PROOF) we should also write
383 * down the corrections mananger. This pointer ensures that.
384 *
385 */
386 AliCorrectionManagerBase* fCorrManager; // Pointer to corrections manager
387
388 ClassDef(AliBaseESDTask,1);
389};
0ccdab7b 390inline void AliBaseESDTask::PreCorrections(const AliESDEvent*) {}
c8b1a7db 391#endif
392// Local Variables:
393// mode: C++
394// End: