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
5 #ifndef ALIFMDESDTASK_H
6 #define ALIFMDESDTASK_H
8 #include <AliAnalysisTaskSE.h>
9 class AliFMDEventInspector;
10 class AliCorrectionManagerBase;
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:
22 * class MyFMDESDTask : public AliBaseESDTask
25 * MyFMDESDTask() : AliBaseESDTask() {}
26 * MyFMDESDTask(const char* name) : AliBaseESDTask(name)
29 * AliFMDEventInspector& GetEventInspector() { return fInspector; }
30 * const AliFMDEventInspector& GetEventInspector() const{ return fInspector; }
33 * fNeededCorrections = AliForwardCorrectionManager::kELossFits;
34 * fSharingFilter.CreateUserObject(fList);
37 * Bool_t PreData(const TAxis& vertex, const TAxis& eta)
39 * fSharingFilter.SetupForData(eta);
42 * Bool_t PreEvent() { fESDFMD.Clear(); return true; }
43 * Bool_t PostEvent() { return true; }
44 * Bool_t Event(AliESDEvent& esd)
46 * Bool_t lowFlux = kFALSE;
47 * UInt_t triggers = 0;
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;
62 * Bool_t ret = fSharingFilter.Filter(esd, lowFlux, fESDFMD, ip.Z());
67 * GetSharingFilter().Terminate(fList,fResults,Int_t(nTr));
71 * AliFMDEventInsepctor fInspector;
72 * AliFMDSharingFilter fSharingFilter;
78 class AliBaseESDTask : public AliAnalysisTaskSE
82 * Default (I/O) constructor - do not use directly
88 * @param name Name of the task
89 * @param title Class name used in configuration script
90 * @param manager Correction manager
92 AliBaseESDTask(const char* name, const char* title,
93 AliCorrectionManagerBase* manager);
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.
101 * @param sumFile Output file for sums
102 * @param resFile Output file for sums
104 * @return true on success
106 virtual Bool_t Connect(const char* sumFile=0,
107 const char* resFile=0)
109 return Connect(sumFile, resFile, false);
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.
118 * @param sumFile Output file for sums
119 * @param resFile Output file for sums
120 * @param old Use old names
122 * @return true on success
124 virtual Bool_t Connect(const char* sumFile,
128 * Called when initializing the train
130 virtual Bool_t Setup() { return true; }
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
137 * If this member function returns false, the execution is stopped
138 * with a fatal signal.
140 * @return true on success.
142 virtual Bool_t Book() = 0;
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.
150 virtual void PreCorrections(const AliESDEvent* esd);
152 * Called after reading in the first event. Here we can setup stuff
153 * depending on the conditions we're running under.
155 * @return true on success. If this returns false, then we turn the
156 * task into a zombie and we do no more processing.
158 virtual Bool_t PreData(const TAxis& vertex, const TAxis& eta);
160 * Called before processing a single event - should not do anything
161 * but clear data, etc.
163 * @return true on success
165 virtual Bool_t PreEvent() { return true; }
167 * Process a single event
169 * @param esd Input event
171 * @return true on success
173 virtual Bool_t Event(AliESDEvent& esd) = 0;
175 * Called after processing a single event - should not do anything
176 * but clear data, etc.
178 * @return true on success
180 virtual Bool_t PostEvent() { return true; }
182 * Do the final analysis on the merged output.
184 * @return true on success
186 virtual Bool_t Finalize() { return true; }
189 * @name Utility methods
194 * @param option Not used
196 virtual void Print(Option_t* option="") const;
198 * Set the debug level
202 virtual void SetDebug(Int_t dbg);
204 * Overload super class method for setting debug level to call our
205 * SetDebug member function.
207 * @param dbg Debug level (0: no output, 1: essentials, 3: a whole lot)
209 virtual void SetDebugLevel(Int_t dbg)
211 AliAnalysisTaskSE::SetDebugLevel(dbg);
215 // --- Configuration etc -------------------------------------------
217 * @name Access sub-components
220 * Configure this task via a macro
222 * @param macro Macro to configure va
224 * @return true on success, false otherwise
226 virtual Bool_t Configure(const char* macro="-default-");
228 * Get a reference to the event inspector. User must override this
229 * to return proper object
231 * @return Reference to the event inspector
233 virtual AliFMDEventInspector& GetEventInspector() = 0;
235 * Get a reference to the event inspector. User must override this
236 * to return proper object
238 * @return Reference to the event inspector
240 virtual const AliFMDEventInspector& GetEventInspector() const = 0;
244 * Copy constructor - left undefined
246 * @param o Object to copy from
248 AliBaseESDTask(const AliBaseESDTask& o);
250 * Assignment operator - left undefined
252 * @param o Object to assign from
254 * @return Reference to this object.
256 AliBaseESDTask& operator=(const AliBaseESDTask& o);
257 // --- Customize ---------------------------------------------------
259 * Evaluate wether this is for MC. User class can override this
261 * @return true if we're to initialize corrections for MC input
263 virtual Bool_t IsMC() const { return false; }
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
272 virtual TAxis* DefaultEtaAxis() const;
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
281 virtual TAxis* DefaultVertexAxis() const;
283 * Get the correction mananger. Derived class should overload this
284 * to return the proper object.
286 * @return Pointer to correction manager
288 virtual AliCorrectionManagerBase* GetManager() const { return fCorrManager; }
290 * Get the correction mananger. Derived class should overload this
291 * to return the proper object.
293 * @return Pointer to correction manager
295 virtual AliCorrectionManagerBase* GetManager() { return fCorrManager; }
297 // --- Task methods ------------------------------------------------
300 * @name Task interface methods
303 * Initialize the task
307 * Create output objects
309 void UserCreateOutputObjects();
313 * @param option Not used
315 void UserExec(Option_t* option);
319 * @param option Not used
321 void Terminate(Option_t* option);
325 // --- Services for derived classes --------------------------------
327 * Create output branches - called from UserCreateOutputObjects
329 virtual void CreateBranches(AliAODHandler*) {}
331 * Mark this event as one to store in the AOD
334 virtual void MarkEventForStore() const;
336 * Check if all needed corrections are there and accounted for. If not,
339 * @param what Which corrections is needed
341 * @return true if all present, false otherwise
343 virtual Bool_t CheckCorrections(UInt_t what) const;
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
353 * @return true ons succcss
355 virtual Bool_t ReadCorrections(const TAxis*& pe,
360 * Get the ESD event. IF this is the first event, initialise
362 * @return Pointer to ESD event structore
364 virtual AliESDEvent* GetESDEvent();
366 virtual const char* DefaultConfig() const
368 return "ForwardAODConfig.C";
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
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.
386 AliCorrectionManagerBase* fCorrManager; // Pointer to corrections manager
388 ClassDef(AliBaseESDTask,1);
390 inline void AliBaseESDTask::PreCorrections(const AliESDEvent*) {}