]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliFMDEventInspector.h
Added correlation of MC triggers
[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 TVector3;
30 // class TList;
31
32 /** 
33  * This class inspects the event 
34  *
35  * @par Input:
36  *   - AliESDFMD object possibly corrected for sharing
37  *
38  * @par Output:
39  *   - A histogram of v_z of events with triggers. 
40  *   - A histogram of v_z of events with vertex and triggers 
41  *   - A histogram of trigger counters 
42  * 
43  * Note, that these are added to the master output list 
44  *
45  * @par Corrections used: 
46  *   - None
47  *
48  * @ingroup pwglf_forward_algo 
49  * @ingroup pwglf_forward_aod
50  */
51 class AliFMDEventInspector : public TNamed
52 {
53 public:
54   /** 
55    * Return codes 
56    */
57   enum ECodes {
58     /** all ok - bin 1 */
59     kOk = 0,
60     /** No ESD event - bin 2 */
61     kNoEvent = 0x1, 
62     /** No triggers found - bin 3 */
63     kNoTriggers = 0x2, 
64     /** No SPD data - bin 4 */ 
65     kNoSPD = 0x4, 
66     /** No FMD data - bin 5 */
67     kNoFMD = 0x8, 
68     /** No vertex found - bin 6 */
69     kNoVertex = 0x10, 
70     /** Vertex out of range - bin 7 */
71     kBadVertex = 0x20
72   };
73   /** 
74    * Trigger bins 
75    */
76   enum ETrgBins { 
77     kInel, 
78     kInelGt0, 
79     kNSD,
80     kV0AND, 
81     kEmpty, 
82     kA, 
83     kB, 
84     kC, 
85     kE,
86     kPileUp,
87     kMCNSD,
88     kSatellite,
89     kOffline
90   };
91   /** 
92    * Centrality methods 
93    */
94   enum ECentMethod { 
95     kV0Multiplicity, 
96     kV0Amplitude, 
97     kV0Charge, 
98     kFMDRough, 
99     kNTracks, 
100     kLTracks, 
101     kCL0, 
102     kCL1, 
103     kCND, 
104     kNParticles,
105     kNeutrons,
106     kV0vsFMD, 
107     kV0vsNTracks, 
108     kZEMvsZDC
109   };
110
111   /** 
112    * Collision systems
113    */
114   enum ECollisionSystem { 
115     kUnknown,
116     kPP, 
117     kPbPb
118   };
119   enum EVtxStatus { 
120     kVtxOK = 1, 
121     kNoVtx, 
122     kNoSPDVtx, 
123     kFewContrib, 
124     kUncertain,
125     kNotVtxZ
126   }; 
127   enum ETrgStatus {
128     kNoTrgWords=1,
129     kPP2760Fast, 
130     kMUON,
131     kTriggered,
132     kMinBias,
133     kMinBiasNoSPD,
134     kV0AndTrg,
135     kHighMult,
136     kCentral, 
137     kSemiCentral, 
138     kDiffractive,
139     kUser,
140     kOther
141   };
142   /** 
143    * Folder name 
144    */
145   static const char* fgkFolderName;
146   /** 
147    * Constructor 
148    */
149   AliFMDEventInspector();
150   /** 
151    * Constructor 
152    * 
153    * @param name Name of object
154    */
155   AliFMDEventInspector(const char* name);
156   /** 
157    * Copy constructor 
158    * 
159    * @param o Object to copy from 
160    */
161   AliFMDEventInspector(const AliFMDEventInspector& o);
162   /** 
163    * Destructor 
164    */
165   virtual ~AliFMDEventInspector();
166   /** 
167    * Assignement operator
168    * 
169    * @param o Object to assign from 
170    * 
171    * @return Reference to this object
172    */
173   AliFMDEventInspector& operator=(const AliFMDEventInspector&);
174
175   /** 
176    * Initialize the object 
177    * 
178    * @param vtxAxis Vertex axis in use 
179    */
180   virtual void SetupForData(const TAxis& vtxAxis);
181   /** 
182    * Process the event 
183    * 
184    * @param event     Input event 
185    * @param triggers  On return, the triggers fired 
186    * @param lowFlux   On return, true if the event is considered a low-flux 
187    *                  event (according to the setting of fLowFluxCut) 
188    * @param ivz       On return, the found vertex bin (1-based).  A zero
189    *                  means outside of the defined vertex range
190    * @param ip        On return, coordinates of interaction point
191    * @param cent      On return, the centrality (in percent) or < 0 
192    *                  if not found
193    * @param nClusters On return, number of SPD clusters in @f$ |\eta|<1@f$ 
194    * 
195    * @return 0 (or kOk) on success, otherwise a bit mask of error codes 
196    */
197   UInt_t Process(const AliESDEvent* event, 
198                  UInt_t&            triggers,
199                  Bool_t&            lowFlux,
200                  UShort_t&          ivz, 
201                  TVector3&          ip,
202                  Double_t&          cent,
203                  UShort_t&          nClusters);
204   /** 
205    * Define the output histograms.  These are put in a sub list of the
206    * passed list.   The histograms are merged before the parent task calls 
207    * AliAnalysisTaskSE::Terminate 
208    * 
209    * @param dir Directory to add to 
210    */
211   void CreateOutputObjects(TList* dir);
212   /** 
213    * Set the number of SPD tracklets for which we consider the event a
214    * low-flux event or not .
215    * 
216    * @param c Cut (default 1000)
217    */
218   void SetLowFluxCut(Int_t c) { fLowFluxCut = c; }
219   /** 
220    * Set the maximum error on @f$ v_z@f$
221    * 
222    * @param c Maximum error (in centimeters)
223    */
224   void SetMaxVzErr(Double_t c=0.1) { fMaxVzErr = c; }
225   /** 
226    * Use the first physics vtx code.   
227    * 
228    * @param use Use it or not 
229    */
230   void SetUseFirstPhysicsVtx(Bool_t use) {fUseFirstPhysicsVertex = use; }
231  /** 
232    * Use the first physics vtx code.   
233    * 
234    * @param use Use it or not 
235    */
236   void SetpA2012Vtx(Bool_t use) {fUsepA2012Vertex= use; }
237  /** 
238    * Use the 2012 pA vtx code.   
239    * 
240    * @param use Use it or not 
241    */
242
243   void SetUseV0AndForNSD(Bool_t use=true) {fUseV0AND = use; }
244   /** 
245    * Set the minimum number of contributors for a 2nd pile-up vertex 
246    * 
247    * @param nContrib Least number of contributors 
248    */
249   void SetMinPileupContributors(UShort_t nContrib=3) 
250   { 
251     fMinPileupContrib = nContrib;
252   }
253   /** 
254    * Set minimum distance from primary vertex to 2nd pile-up vertex 
255    * 
256    * @param cm Distance (in centimeters)
257    */
258   void SetMinPileupDistance(Double_t cm=0.8)
259   {
260     fMinPileupDistance = cm;
261   }
262   /** 
263    * Enable selection of displaced vertices. 
264    * 
265    * @param use whether to use
266    */
267   void SetUseDisplacedVertices(Bool_t use=true)
268   {
269     fUseDisplacedVertices = use;
270   }  
271   Bool_t IsUseDisplacedVertices() const { return fUseDisplacedVertices; }
272   /** 
273    * Set the lower centrality cut - if negative, do not use 
274    *
275    * @deprecated We should accept all events in the AOD pass
276    * 
277    * @param mincent Lower cut on centrality
278    */
279   void SetMinCentrality(Double_t mincent=-1.0);
280   /** 
281    * Set the upper centrality cut - if negative, do not use 
282    *
283    * @deprecated We should accept all events in the AOD pass
284    * 
285    * @param mincent Upper cut on centrality
286    */
287   void SetMaxCentrality(Double_t maxcent=-1.0);
288   /** 
289    * Set the centrality method to use.  Possible values are 
290    *
291    * - VOM      - VZERO multiplicity 
292    * - V0A      - VZERO amplitude
293    * - V0C      - VZERO charge
294    * - FMD      - FMD scaled energy loss
295    * - TRK      - Number of tracks
296    * - TKL      - Number of tracks
297    * - CL0      - 
298    * - CL1      - 
299    * - CND      - 
300    * - NPA      - Neutral particles 
301    * - ZNA      - ZDC neutron amplitude 
302    * - V0MvsFMD - VZERO versus FMD 
303    * - TKLvsVOM - Tracks versus VZERO 
304    * - ZEMvsZDC - ZDC 
305    * 
306    * @param m 
307    */
308   void SetCentralityMethod(const TString& m) { fCentMethod = m; }
309   /** 
310    * Set the centrality method
311    * 
312    * @param m Method identifier 
313    */
314   void SetCentralityMethod(ECentMethod m);
315   /** 
316    * Set the debug level.  The higher the value the more output 
317    * 
318    * @param dbg Debug level 
319    */
320   void SetDebug(Int_t dbg=1) { fDebug = dbg; }
321   /** 
322    * Set whether this is MC or not.  Needed by energy loss fitter task
323    * that never instantices AliFMDMCEventInspector.  In particular, we
324    * need this to make sure we ignore the FAST partition flag in MC
325    * for 2.76TeV pp.
326    * 
327    * @param isMC If true, assume MC input 
328    */
329   void SetMC(Bool_t isMC=true) { fMC = isMC; }
330   /** 
331    * Fetch our histograms from the passed list 
332    * 
333    * @param d             Input
334    * @param hEventsTr     On return, pointer to histogram, or null
335    * @param hEventsTrVtx  On return, pointer to histogram, or null
336    * @param hEventsAcc    On return, pointer to histogram, or null
337    * @param hTriggers     On return, pointer to histogram, or null
338    * 
339    * @return true on success, false otherwise 
340    */
341   Bool_t FetchHistograms(const TList* d, 
342                          TH1I*& hEventsTr, 
343                          TH1I*& hEventsTrVtx, 
344                          TH1I*& hEventsAcc,
345                          TH1I*& hTriggers) const;
346   /** 
347    * Read the collision system, collision energy, and L3 field setting
348    * from the ESD
349    * 
350    * @param esd ESD to get information from 
351    * 
352    * @return true on success, false 
353    */
354   Bool_t ReadRunDetails(const AliESDEvent* esd);
355   /** 
356    * Get the collision system (one of the value in ECollisionSystem)
357    * 
358    * @return Collision system 
359    */
360   UShort_t GetCollisionSystem() const { return fCollisionSystem; }
361   /** 
362    * Get the center of mass energy (per nucleon pair) in GeV 
363    * 
364    * @return center of mass energy (per nucleon pair) in GeV 
365    */
366   UShort_t GetEnergy() const { return fEnergy; }
367   /** 
368    * Get the magnetic field setting of the L3 magnet in kilo Gauss. 
369    * 
370    * @return The magnetic field setting 
371    */
372   Short_t  GetField() const { return fField; }
373   /** 
374    * Get the current run number 
375    * 
376    * @return The current run number 
377    */
378   ULong_t GetRunNumber() const { return fRunNumber; }
379   /** 
380    * Print information
381    * 
382    * @param option Not used 
383    */
384   void Print(Option_t* option="") const;
385   // getter for fmincentrality
386   // Double_t GetMinCentrality() const { return fMinCent;}
387   // gettter for fmaxcentrality 
388   // Double_t GetMaxCentrality() const { return fMaxCent;}
389   /** 
390    * Store information about running conditions in output list 
391    * 
392    * 3 TNamed objects are defined.   The names are fixed, but the
393    * title is a string representation of the information, and the
394    * unique ID contains the identifier 
395    *
396    * - sys   Contains the collision system string and identifier. 
397    * - sNN   Contains the center-of-mass energy per nucleon (GeV)
398    * - field Contains the L3 magnetic field (kG)
399    * - run   Contains the run number
400    * 
401    */
402   virtual void StoreInformation();
403   /** 
404    * Return a string representing the return code 
405    * 
406    * @param mask Code 
407    * 
408    * @return String representation 
409    */
410   static const char* CodeString(UInt_t mask);
411 protected:
412   /** 
413    * Cache the configure trigger classes from the physis selection.  
414    * 
415    * @param cache   where to cache the trigger class. 
416    * @param classes List of configured classes. 
417    * @param o       Object from OADB with config
418    */
419   void CacheConfiguredTriggerClasses(TList& cache, 
420                                      const TList* classes,
421                                      AliOADBPhysicsSelection* o);
422   /** 
423    * Read the trigger information from the ESD event 
424    * 
425    * @param esd        ESD event 
426    * @param triggers   On return, contains the trigger bits 
427    * @param nClusters  On return, number of SPD clusters in @f$ |\eta|<1@f$ 
428    * 
429    * @return @c true on success, @c false otherwise 
430    */
431   Bool_t ReadTriggers(const AliESDEvent& esd, UInt_t& triggers, 
432                       UShort_t& nClusters);
433   /** 
434    * Possible extra check for p-Pb from 2012/13 - require V0AND.
435    * 
436    * @param esd Event structure 
437    * 
438    * @return true on success
439    */
440   Bool_t CheckpAExtraV0(const AliESDEvent& esd) const;
441   /** 
442    * Check, for the @f$\sqrt{s}=2.76GeV@f$ pp run wether this event
443    * was in the fast partition, and if so, filter it out.
444    * 
445    * @param fastonly Event was in fast-only partition 
446    * 
447    * @return true if event was in the fast-only partition, for the run
448    * period.
449    */
450   virtual Bool_t CheckFastPartition(bool fastonly) const;
451   /** 
452    * Check if we have an NSD trigger for pp runs 
453    * 
454    * @param esd      Data
455    * @param triggers Trigger mask to be filled 
456    * 
457    * @return true if we have an NSD trigger 
458    */
459   virtual Bool_t CheckNSD(const AliESDEvent& esd, UInt_t& triggers) const;
460   /** 
461    * Check if we have an INEL&gt;0 trigger 
462    *  
463    * @param esd        Data 
464    * @param nClusters  On return, number of clusters
465    * @param triggers   Trigger mask to be filled
466    * 
467    * @return true if we have an INEL&gt;0 trigger 
468    */
469   virtual Bool_t CheckINELGT0(const AliESDEvent& esd, UShort_t& nClusters, 
470                               UInt_t& triggers) const;
471   /** 
472    * Check if this is a pile-up event
473    * 
474    * @param esd       Data
475    * @param triggers Trigger mask to be filled
476    * 
477    * @return true if this is a pile-up event
478    */
479   virtual Bool_t CheckPileup(const AliESDEvent& esd, UInt_t& triggers) const;
480   /** 
481    * Check for multi-vertex pile-up 
482    * 
483    * @param esd ESD event 
484    * 
485    * @return true if multiple vertices found 
486    */
487   virtual Bool_t CheckMultiVertex(const AliESDEvent& esd) const;
488   /** 
489    * Check if we have a cosmic trigger.  These should be filtered out. 
490    * 
491    * @param trigStri Trigger string 
492    * 
493    * @return true if we have a cosmic trigger
494    */
495   virtual Bool_t CheckCosmics(const TString& trigStri) const;
496   /** 
497    * Check if the trigger string corresponds to an empty event 
498    * 
499    * @param trigStr  Trigger string 
500    * @param triggers Trigger mask to be filled
501    * 
502    * @return true if the trigger string corresponds to an empty event 
503    */
504   virtual Bool_t CheckEmpty(const TString& trigStr, UInt_t& triggers) const;
505   /** 
506    * Check the trigger words to see if we have a B, A, C, or E event. 
507    * 
508    * @param esd       Data
509    * @param triggers  Trigger mask to be filled
510    * 
511    * @return always true
512    */
513   virtual Bool_t CheckWords(const AliESDEvent& esd, UInt_t& triggers) const;
514   /** 
515    * Read the vertex information from the ESD event 
516    * 
517    * @param esd  ESD event 
518    * @param ip   On return, the coordinates of the IP
519    * 
520    * @return @c true on success, @c false otherwise 
521    */
522   Bool_t ReadVertex(const AliESDEvent& esd, TVector3& ip);
523   /** 
524    * Check the vertex using the method used in PWG-UD.  That is 
525    *
526    * - Check we have a vertex and status is OK
527    * - Check if we have an SPD vertex and that it's status is OK 
528    * - Check if the vertex is from the Z-vertexer, and if it is, 
529    *   - Check that the dispersion and resolution is OK 
530    * 
531    * @param esd Data 
532    * @param ip  On return, the coordinates of the IP
533    * 
534    * @return status
535    */
536   virtual EVtxStatus CheckPWGUDVertex(const AliESDEvent& esd, 
537                                       TVector3& ip) const;
538   /** 
539    * Check the vertex. That is
540    *
541    * - Check if we have an SPD vertex and that it's status is OK 
542    * - Check that we have enough contributors 
543    * - Check that the reslution is OK 
544    * 
545    * @param esd Data 
546    * @param ip  On return, the coordinates of the IP
547    * 
548    * @return status
549    */
550   virtual EVtxStatus CheckpA2012Vertex(const AliESDEvent& esd, 
551                                      TVector3& ip) const;
552   /** 
553    * Check the vertex for pA 2012 settings. That is
554    *
555    * 
556    * @param esd Data 
557    * @param ip  On return, the coordinates of the IP
558    * 
559    * @return true if the vertex was found and met the requirements
560    */
561
562
563
564
565   virtual EVtxStatus CheckVertex(const AliESDEvent& esd, TVector3& ip) const;
566   /** 
567    * Read centrality from event 
568    * 
569    * @param esd  Event 
570    * @param cent On return, the centrality or negative if not found
571    * @param qual On return, centrality quality flag
572    * 
573    * @return False on error, true otherwise 
574    */
575   virtual Bool_t ReadCentrality(const AliESDEvent& esd, Double_t& cent,
576                                 UShort_t& qual) const;
577
578   TH1I*    fHEventsTr;    //! Histogram of events w/trigger
579   TH1I*    fHEventsTrVtx; //! Events w/trigger and vertex 
580   TH1I*    fHEventsAccepted; //! Events w/trigger and vertex in range 
581   TH2D*    fHEventsAcceptedXY; //! XY vtx with trigger and Z vertex in range 
582   TH1I*    fHTriggers;    //! Triggers
583   TH2I*    fHTriggerCorr; //! Correlation of triggers
584   TH1I*    fHType;        //! Type (low/high flux) of event
585   TH1I*    fHWords;       //! Trigger words 
586   TH1F*    fHCent;        //! Centrality 
587   TH2F*    fHCentVsQual;  //! Centrality vs quality 
588   TH1I*    fHStatus;      //! Event processing status 
589   TH1I*    fHVtxStatus;   //! Vertex processing status 
590   TH1I*    fHTrgStatus;   //! Trigger processing status 
591   Int_t    fLowFluxCut;   //  Low flux cut
592   Double_t fMaxVzErr;     //  Maximum error on v_z
593   TList*   fList;         //! Histogram container 
594   UShort_t fEnergy;       // CMS energy (per nucleon pair) [GeV]
595   Short_t  fField;        // L3 magnetic field [kG]
596   UShort_t fCollisionSystem; //  Collision system
597   Int_t    fDebug;        //  Debug level 
598   TAxis*   fCentAxis;     // Centrality axis used in histograms
599   TAxis    fVtxAxis;      //Vtx Axis 
600   Bool_t   fUseFirstPhysicsVertex; //Use the vtx code from p+p first physics
601   Bool_t   fUseV0AND;     //Use the vtx code from p+p first physics
602   UShort_t fMinPileupContrib; // Minimum number of contributors to 2nd
603                               // pile-up vertex
604   Double_t fMinPileupDistance; // Minimum distance of 2nd pile-up
605                                // vertex 
606   Bool_t   fUseDisplacedVertices; //Analyze displaced vertices?
607   AliDisplacedVertexSelection fDisplacedVertex; //Displaced vertex selector
608   TList    fCollWords;     //! Configured collision words 
609   TList    fBgWords;       //! Configured background words 
610   TString  fCentMethod;
611   Double_t fMinCent;  //min centrality
612   Double_t fMaxCent;  //max centrailty
613   Bool_t   fUsepA2012Vertex;// flag to use pA2012 Veretx selection
614   ULong_t  fRunNumber; // Current run number 
615   Bool_t   fMC;        // Is this MC input
616   ClassDef(AliFMDEventInspector,11); // Inspect the event 
617 };
618
619 #endif
620 // Local Variables:
621 //   mode: C++
622 // End:
623
624
625