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