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