Fixes for V0 condition in pA
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDEventInspector.h
CommitLineData
7984e5f7 1//
2// This class inspects the event
3//
4#ifndef ALIFMDEVENTINSPECTOR_H
5#define ALIFMDEVENTINSPECTOR_H
ffca499d 6/**
7 * @file AliFMDEventInspector.h
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 14:02:48 2011
10 *
11 * @brief
12 *
13 *
bd6f5206 14 * @ingroup pwglf_forward_aod
ffca499d 15 */
8565b10b 16#include <TNamed.h>
5bb5d1f6 17#include <TAxis.h>
241cca4d 18#include <TList.h>
65abd48b 19#include "AliDisplacedVertexSelection.h"
8565b10b 20class AliESDEvent;
241cca4d 21class AliOADBPhysicsSelection;
8565b10b 22class TH2D;
23class TH1D;
24class TH1I;
5e4d905e 25class TH1F;
e308a636 26class TH2F;
8565b10b 27class TAxis;
241cca4d 28// class TList;
8565b10b 29
30/**
31 * This class inspects the event
32 *
33 * @par Input:
34 * - AliESDFMD object possibly corrected for sharing
35 *
36 * @par Output:
37 * - A histogram of v_z of events with triggers.
38 * - A histogram of v_z of events with vertex and triggers
39 * - A histogram of trigger counters
40 *
41 * Note, that these are added to the master output list
42 *
43 * @par Corrections used:
44 * - None
45 *
bd6f5206 46 * @ingroup pwglf_forward_algo
47 * @ingroup pwglf_forward_aod
8565b10b 48 */
49class AliFMDEventInspector : public TNamed
50{
51public:
52 /**
53 * Return codes
54 */
55 enum ECodes {
241cca4d 56 /** all ok - bin 1 */
8565b10b 57 kOk = 0,
241cca4d 58 /** No ESD event - bin 2 */
8565b10b 59 kNoEvent = 0x1,
241cca4d 60 /** No triggers found - bin 3 */
8565b10b 61 kNoTriggers = 0x2,
241cca4d 62 /** No SPD data - bin 4 */
8565b10b 63 kNoSPD = 0x4,
241cca4d 64 /** No FMD data - bin 5 */
8565b10b 65 kNoFMD = 0x8,
241cca4d 66 /** No vertex found - bin 6 */
8565b10b 67 kNoVertex = 0x10,
241cca4d 68 /** Vertex out of range - bin 7 */
0be6c8cd 69 kBadVertex = 0x20
8565b10b 70 };
71 /**
72 * Trigger bins
73 */
74 enum ETrgBins {
75 kInel,
76 kInelGt0,
e6463868 77 kNSD,
78 kV0AND,
8565b10b 79 kEmpty,
80 kA,
81 kB,
82 kC,
0be6c8cd 83 kE,
84 kPileUp,
85 kMCNSD,
86 kOffline
8565b10b 87 };
88 /**
0bd4b00f 89 * Collision systems
90 */
91 enum ECollisionSystem {
92 kUnknown,
93 kPP,
94 kPbPb
95 };
96 /**
8565b10b 97 * Constructor
98 */
99 AliFMDEventInspector();
100 /**
101 * Constructor
102 *
103 * @param name Name of object
104 */
105 AliFMDEventInspector(const char* name);
106 /**
107 * Copy constructor
108 *
109 * @param o Object to copy from
110 */
111 AliFMDEventInspector(const AliFMDEventInspector& o);
112 /**
113 * Destructor
114 */
115 virtual ~AliFMDEventInspector();
116 /**
117 * Assignement operator
118 *
119 * @param o Object to assign from
120 *
121 * @return Reference to this object
122 */
123 AliFMDEventInspector& operator=(const AliFMDEventInspector&);
124
125 /**
126 * Initialize the object
127 *
128 * @param vtxAxis Vertex axis in use
129 */
e1f47419 130 virtual void Init(const TAxis& vtxAxis);
8565b10b 131 /**
132 * Process the event
133 *
134 * @param event Input event
135 * @param triggers On return, the triggers fired
136 * @param lowFlux On return, true if the event is considered a low-flux
137 * event (according to the setting of fLowFluxCut)
0bd4b00f 138 * @param ivz On return, the found vertex bin (1-based). A zero
139 * means outside of the defined vertex range
c389303e 140 * @param vz On return, the z position of the interaction
5e4d905e 141 * @param cent On return, the centrality (in percent) or < 0
142 * if not found
5bb5d1f6 143 * @param nClusters On return, number of SPD clusters in @f$ |\eta|<1@f$
8565b10b 144 *
145 * @return 0 (or kOk) on success, otherwise a bit mask of error codes
146 */
147 UInt_t Process(const AliESDEvent* event,
148 UInt_t& triggers,
149 Bool_t& lowFlux,
0bd4b00f 150 UShort_t& ivz,
5e4d905e 151 Double_t& vz,
5bb5d1f6 152 Double_t& cent,
153 UShort_t& nClusters);
8565b10b 154 /**
155 * Define the output histograms. These are put in a sub list of the
156 * passed list. The histograms are merged before the parent task calls
157 * AliAnalysisTaskSE::Terminate
158 *
159 * @param dir Directory to add to
160 */
161 void DefineOutput(TList* dir);
162 /**
163 * Set the number of SPD tracklets for which we consider the event a
164 * low-flux event or not .
165 *
166 * @param c Cut (default 1000)
167 */
168 void SetLowFluxCut(Int_t c) { fLowFluxCut = c; }
169 /**
170 * Set the maximum error on @f$ v_z@f$
171 *
172 * @param c Maximum error (in centimeters)
173 */
174 void SetMaxVzErr(Double_t c=0.1) { fMaxVzErr = c; }
175 /**
e83d0620 176 * Use the first physics vtx code.
177 *
178 * @param use Use it or not
179 */
180 void SetUseFirstPhysicsVtx(Bool_t use) {fUseFirstPhysicsVertex = use; }
31554871 181 /**
182 * Use the first physics vtx code.
183 *
184 * @param use Use it or not
185 */
e6463868 186 void SetUseV0AndForNSD(Bool_t use=true) {fUseV0AND = use; }
187 /**
188 * Set the minimum number of contributors for a 2nd pile-up vertex
189 *
190 * @param nContrib Least number of contributors
191 */
192 void SetMinPileupContributors(UShort_t nContrib=3)
193 {
194 fMinPileupContrib = nContrib;
195 }
196 /**
197 * Set minimum distance from primary vertex to 2nd pile-up vertex
198 *
199 * @param cm Distance (in centimeters)
200 */
201 void SetMinPileupDistance(Double_t cm=0.8)
202 {
203 fMinPileupDistance = cm;
204 }
e83d0620 205 /**
65abd48b 206 * Enable selection of displaced vertices.
207 *
208 * @param use whether to use
209 */
210 void SetUseDisplacedVertices(Bool_t use=true)
211 {
212 fUseDisplacedVertices = use;
213 }
214
215 /**
8565b10b 216 * Set the debug level. The higher the value the more output
217 *
218 * @param dbg Debug level
219 */
220 void SetDebug(Int_t dbg=1) { fDebug = dbg; }
221 /**
222 * Fetch our histograms from the passed list
223 *
224 * @param d Input
225 * @param hEventsTr On return, pointer to histogram, or null
226 * @param hEventsTrVtx On return, pointer to histogram, or null
227 * @param hTriggers On return, pointer to histogram, or null
228 *
229 * @return true on success, false otherwise
230 */
fb3430ac 231 Bool_t FetchHistograms(const TList* d,
8565b10b 232 TH1I*& hEventsTr,
233 TH1I*& hEventsTrVtx,
234 TH1I*& hTriggers) const;
0bd4b00f 235 /**
236 * Read the collision system, collision energy, and L3 field setting
237 * from the ESD
238 *
239 * @param esd ESD to get information from
240 *
241 * @return true on success, false
242 */
243 Bool_t ReadRunDetails(const AliESDEvent* esd);
244 /**
245 * Get the collision system (one of the value in ECollisionSystem)
246 *
247 * @return Collision system
248 */
249 UShort_t GetCollisionSystem() const { return fCollisionSystem; }
250 /**
251 * Get the center of mass energy (per nucleon pair) in GeV
252 *
253 * @return center of mass energy (per nucleon pair) in GeV
254 */
255 UShort_t GetEnergy() const { return fEnergy; }
256 /**
257 * Get the magnetic field setting of the L3 magnet in kilo Gauss.
258 *
259 * @return The magnetic field setting
260 */
261 Short_t GetField() const { return fField; }
262 /**
263 * Print information
264 *
265 * @param option Not used
266 */
267 void Print(Option_t* option="") const;
f7cfc454 268 /**
269 * Store information about running conditions in output list
270 *
271 * 3 TNamed objects are defined. The names are fixed, but the
272 * title is a string representation of the information, and the
273 * unique ID contains the identifier
274 *
275 * - sys Contains the collision system string and identifier.
276 * - sNN Contains the center-of-mass energy per nucleon (GeV)
277 * - field Contains the L3 magnetic field (kG)
9b2f2e39 278 * - run Contains the run number
f7cfc454 279 *
9b2f2e39 280 * @param runNo Run number - read off from ESD event
f7cfc454 281 */
9b2f2e39 282 virtual void StoreInformation(Int_t runNo);
241cca4d 283 /**
284 * Return a string representing the return code
285 *
286 * @param mask Code
287 *
288 * @return String representation
289 */
290 static const char* CodeString(UInt_t mask);
8565b10b 291protected:
292 /**
241cca4d 293 * Cache the configure trigger classes from the physis selection.
294 *
295 * @param cache where to cache the trigger class.
296 * @param classes List of configured classes.
297 * @param o Object from OADB with config
298 */
299 void CacheConfiguredTriggerClasses(TList& cache,
300 const TList* classes,
301 AliOADBPhysicsSelection* o);
302 /**
8565b10b 303 * Read the trigger information from the ESD event
304 *
305 * @param esd ESD event
306 * @param triggers On return, contains the trigger bits
5bb5d1f6 307 * @param nClusters On return, number of SPD clusters in @f$ |\eta|<1@f$
8565b10b 308 *
309 * @return @c true on success, @c false otherwise
310 */
241cca4d 311 Bool_t ReadTriggers(const AliESDEvent& esd, UInt_t& triggers,
5bb5d1f6 312 UShort_t& nClusters);
da70cd6a 313 Bool_t CheckpAExtraV0(const AliESDEvent& esd) const;
8565b10b 314 /**
241cca4d 315 * Check, for the @f$\sqrt{s}=2.76GeV@f$ pp run wether this event
316 * was in the fast partition, and if so, filter it out.
317 *
318 * @param fastonly Event was in fast-only partition
319 *
320 * @return true if event was in the fast-only partition, for the run
321 * period.
322 */
323 virtual Bool_t CheckFastPartition(bool fastonly) const;
324 /**
325 * Check if we have an NSD trigger for pp runs
326 *
327 * @param esd Data
328 * @param triggers Trigger mask to be filled
329 *
330 * @return true if we have an NSD trigger
331 */
332 virtual Bool_t CheckNSD(const AliESDEvent& esd, UInt_t& triggers) const;
333 /**
334 * Check if we have an INEL&gt;0 trigger
335 *
336 * @param esd Data
337 * @param nClusters On return, number of clusters
338 * @param triggers Trigger mask to be filled
339 *
340 * @return true if we have an INEL&gt;0 trigger
341 */
342 virtual Bool_t CheckINELGT0(const AliESDEvent& esd, UShort_t& nClusters,
343 UInt_t& triggers) const;
344 /**
345 * Check if this is a pile-up event
346 *
347 * @param esd Data
348 * @param triggers Trigger mask to be filled
349 *
350 * @return true if this is a pile-up event
351 */
352 virtual Bool_t CheckPileup(const AliESDEvent& esd, UInt_t& triggers) const;
353 /**
354 * Check if we have a cosmic trigger. These should be filtered out.
355 *
356 * @param trigStri Trigger string
357 *
358 * @return true if we have a cosmic trigger
359 */
360 virtual Bool_t CheckCosmics(const TString& trigStri) const;
361 /**
362 * Check if the trigger string corresponds to an empty event
363 *
364 * @param trigStr Trigger string
365 * @param triggers Trigger mask to be filled
366 *
367 * @return true if the trigger string corresponds to an empty event
368 */
369 virtual Bool_t CheckEmpty(const TString& trigStr, UInt_t& triggers) const;
370 /**
371 * Check the trigger words to see if we have a B, A, C, or E event.
372 *
373 * @param esd Data
374 * @param triggers Trigger mask to be filled
375 *
376 * @return always true
377 */
378 virtual Bool_t CheckWords(const AliESDEvent& esd, UInt_t& triggers) const;
379 /**
8565b10b 380 * Read the vertex information from the ESD event
381 *
382 * @param esd ESD event
383 * @param vz On return, the vertex Z position
290052e7 384 * @param vx On return, the vertex X position
385 * @param vy On return, the vertex Y position
8565b10b 386 *
387 * @return @c true on success, @c false otherwise
388 */
241cca4d 389 Bool_t ReadVertex(const AliESDEvent& esd,
290052e7 390 Double_t& vz,
391 Double_t& vx,
392 Double_t& vy);
e1f47419 393 /**
241cca4d 394 * Check the vertex using the method used in PWG-UD. That is
395 *
396 * - Check we have a vertex and status is OK
397 * - Check if we have an SPD vertex and that it's status is OK
398 * - Check if the vertex is from the Z-vertexer, and if it is,
399 * - Check that the dispersion and resolution is OK
400 *
401 * @param esd Data
402 * @param vz On return, the Z coordinate of the IP
403 * @param vx On return, possibly the X coordinate of the IP
404 * @param vy On return, possibly the Y coordinate of the IP
405 *
406 * @return true if the vertex was found and met the requirements
407 */
408 virtual Bool_t CheckPWGUDVertex(const AliESDEvent& esd,
409 Double_t& vz,
410 Double_t& vx,
411 Double_t& vy) const;
412 /**
413 * Check the vertex. That is
414 *
415 * - Check if we have an SPD vertex and that it's status is OK
416 * - Check that we have enough contributors
417 * - Check that the reslution is OK
418 *
419 * @param esd Data
420 * @param vz On return, the Z coordinate of the IP
421 * @param vx On return, possibly the X coordinate of the IP
422 * @param vy On return, possibly the Y coordinate of the IP
423 *
424 * @return true if the vertex was found and met the requirements
425 */
426 virtual Bool_t CheckVertex(const AliESDEvent& esd,
427 Double_t& vz,
428 Double_t& vx,
429 Double_t& vy) const;
430 /**
e1f47419 431 * Read centrality from event
432 *
433 * @param esd Event
434 * @param cent On return, the centrality or negative if not found
ffca499d 435 * @param qual On return, centrality quality flag
e1f47419 436 *
437 * @return False on error, true otherwise
438 */
241cca4d 439 Bool_t ReadCentrality(const AliESDEvent& esd, Double_t& cent,
440 UShort_t& qual) const;
8565b10b 441
442 TH1I* fHEventsTr; //! Histogram of events w/trigger
443 TH1I* fHEventsTrVtx; //! Events w/trigger and vertex
5bb5d1f6 444 TH1I* fHEventsAccepted; //! Events w/trigger and vertex in range
96110c91 445 TH2D* fHEventsAcceptedXY; //! XY vtx with trigger and Z vertex in range
8565b10b 446 TH1I* fHTriggers; //! Triggers
0bd4b00f 447 TH1I* fHType; //! Type (low/high flux) of event
fe52e455 448 TH1I* fHWords; //! Trigger words
5e4d905e 449 TH1F* fHCent; //! Centrality
e308a636 450 TH2F* fHCentVsQual; //! Centrality vs quality
241cca4d 451 TH1I* fHStatus; //! Event processing status
8565b10b 452 Int_t fLowFluxCut; // Low flux cut
453 Double_t fMaxVzErr; // Maximum error on v_z
454 TList* fList; //! Histogram container
0bd4b00f 455 UShort_t fEnergy; // CMS energy (per nucleon pair) [GeV]
456 Short_t fField; // L3 magnetic field [kG]
fb3430ac 457 UShort_t fCollisionSystem; // Collision system
8565b10b 458 Int_t fDebug; // Debug level
e308a636 459 TAxis* fCentAxis; // Centrality axis used in histograms
31554871 460 TAxis fVtxAxis; //Vtx Axis
e83d0620 461 Bool_t fUseFirstPhysicsVertex; //Use the vtx code from p+p first physics
31554871 462 Bool_t fUseV0AND; //Use the vtx code from p+p first physics
e6463868 463 UShort_t fMinPileupContrib; // Minimum number of contributors to 2nd
464 // pile-up vertex
465 Double_t fMinPileupDistance; // Minimum distance of 2nd pile-up
466 // vertex
65abd48b 467 Bool_t fUseDisplacedVertices; //Analyze displaced vertices?
468 AliDisplacedVertexSelection fDisplacedVertex; //Displaced vertex selector
241cca4d 469 TList fCollWords; //! Configured collision words
470 TList fBgWords; //! Configured background words
da70cd6a 471 ClassDef(AliFMDEventInspector,5); // Inspect the event
8565b10b 472};
473
474#endif
475// Local Variables:
476// mode: C++
477// End:
478
479
480