]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliFMDEventInspector.h
Merge branch 'master' into TPCdev
[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    * Destructor 
158    */
159   virtual ~AliFMDEventInspector();
160
161   /** 
162    * Initialize the object 
163    * 
164    * @param vtxAxis Vertex axis in use 
165    */
166   virtual void SetupForData(const TAxis& vtxAxis);
167   /** 
168    * Process the event 
169    * 
170    * @param event     Input event 
171    * @param triggers  On return, the triggers fired 
172    * @param lowFlux   On return, true if the event is considered a low-flux 
173    *                  event (according to the setting of fLowFluxCut) 
174    * @param ivz       On return, the found vertex bin (1-based).  A zero
175    *                  means outside of the defined vertex range
176    * @param ip        On return, coordinates of interaction point
177    * @param cent      On return, the centrality (in percent) or < 0 
178    *                  if not found
179    * @param nClusters On return, number of SPD clusters in @f$ |\eta|<1@f$ 
180    * 
181    * @return 0 (or kOk) on success, otherwise a bit mask of error codes 
182    */
183   UInt_t Process(const AliESDEvent* event, 
184                  UInt_t&            triggers,
185                  Bool_t&            lowFlux,
186                  UShort_t&          ivz, 
187                  TVector3&          ip,
188                  Double_t&          cent,
189                  UShort_t&          nClusters);
190   /** 
191    * Define the output histograms.  These are put in a sub list of the
192    * passed list.   The histograms are merged before the parent task calls 
193    * AliAnalysisTaskSE::Terminate 
194    * 
195    * @param dir Directory to add to 
196    */
197   void CreateOutputObjects(TList* dir);
198   /** 
199    * Set the number of SPD tracklets for which we consider the event a
200    * low-flux event or not .
201    * 
202    * @param c Cut (default 1000)
203    */
204   void SetLowFluxCut(Int_t c) { fLowFluxCut = c; }
205   /** 
206    * Set the maximum error on @f$ v_z@f$
207    * 
208    * @param c Maximum error (in centimeters)
209    */
210   void SetMaxVzErr(Double_t c=0.1) { fMaxVzErr = c; }
211   /** 
212    * Use the first physics vtx code.   
213    * 
214    * @param use Use it or not 
215    */
216   void SetUseFirstPhysicsVtx(Bool_t use) {fUseFirstPhysicsVertex = use; }
217  /** 
218    * Use the first physics vtx code.   
219    * 
220    * @param use Use it or not 
221    */
222   void SetpA2012Vtx(Bool_t use) {fUsepA2012Vertex= use; }
223  /** 
224    * Use the 2012 pA vtx code.   
225    * 
226    * @param use Use it or not 
227    */
228
229   void SetUseV0AndForNSD(Bool_t use=true) {fUseV0AND = use; }
230   /** 
231    * Set the minimum number of contributors for a 2nd pile-up vertex 
232    * 
233    * @param nContrib Least number of contributors 
234    */
235   void SetMinPileupContributors(UShort_t nContrib=3) 
236   { 
237     fMinPileupContrib = nContrib;
238   }
239   /** 
240    * Set minimum distance from primary vertex to 2nd pile-up vertex 
241    * 
242    * @param cm Distance (in centimeters)
243    */
244   void SetMinPileupDistance(Double_t cm=0.8)
245   {
246     fMinPileupDistance = cm;
247   }
248   /** 
249    * Enable selection of displaced vertices. 
250    * 
251    * @param use whether to use
252    */
253   void SetUseDisplacedVertices(Bool_t use=true)
254   {
255     fUseDisplacedVertices = use;
256   }  
257   Bool_t IsUseDisplacedVertices() const { return fUseDisplacedVertices; }
258   /** 
259    * Set the lower centrality cut - if negative, do not use 
260    *
261    * @deprecated We should accept all events in the AOD pass
262    * 
263    * @param mincent Lower cut on centrality
264    */
265   void SetMinCentrality(Double_t mincent=-1.0);
266   /** 
267    * Set the upper centrality cut - if negative, do not use 
268    *
269    * @deprecated We should accept all events in the AOD pass
270    * 
271    * @param maxcent Upper cut on centrality
272    */
273   void SetMaxCentrality(Double_t maxcent=-1.0);
274   /** 
275    * Set the centrality method to use.  Possible values are 
276    *
277    * - VOM      - VZERO multiplicity 
278    * - V0A      - VZERO amplitude
279    * - V0C      - VZERO charge
280    * - FMD      - FMD scaled energy loss
281    * - TRK      - Number of tracks
282    * - TKL      - Number of tracks
283    * - CL0      - 
284    * - CL1      - 
285    * - CND      - 
286    * - NPA      - Neutral particles 
287    * - ZNA      - ZDC neutron amplitude 
288    * - V0MvsFMD - VZERO versus FMD 
289    * - TKLvsVOM - Tracks versus VZERO 
290    * - ZEMvsZDC - ZDC 
291    * 
292    * @param m 
293    */
294   void SetCentralityMethod(const TString& m) { fCentMethod = m; }
295   /** 
296    * Set the centrality method
297    * 
298    * @param m Method identifier 
299    */
300   void SetCentralityMethod(ECentMethod m);
301   /** 
302    * Set the debug level.  The higher the value the more output 
303    * 
304    * @param dbg Debug level 
305    */
306   void SetDebug(Int_t dbg=1) { fDebug = dbg; }
307   /** 
308    * Set whether this is MC or not.  Needed by energy loss fitter task
309    * that never instantices AliFMDMCEventInspector.  In particular, we
310    * need this to make sure we ignore the FAST partition flag in MC
311    * for 2.76TeV pp.
312    * 
313    * @param isMC If true, assume MC input 
314    */
315   void SetMC(Bool_t isMC=true) { fMC = isMC; }
316   /** 
317    * Fetch our histograms from the passed list 
318    * 
319    * @param d             Input
320    * @param hEventsTr     On return, pointer to histogram, or null
321    * @param hEventsTrVtx  On return, pointer to histogram, or null
322    * @param hEventsAcc    On return, pointer to histogram, or null
323    * @param hTriggers     On return, pointer to histogram, or null
324    * 
325    * @return true on success, false otherwise 
326    */
327   Bool_t FetchHistograms(const TList* d, 
328                          TH1I*& hEventsTr, 
329                          TH1I*& hEventsTrVtx, 
330                          TH1I*& hEventsAcc,
331                          TH1I*& hTriggers) const;
332   /** 
333    * Read the collision system, collision energy, and L3 field setting
334    * from the ESD
335    * 
336    * @param esd ESD to get information from 
337    * 
338    * @return true on success, false 
339    */
340   Bool_t ReadRunDetails(const AliESDEvent* esd);
341   /** 
342    * Get the collision system (one of the value in ECollisionSystem)
343    * 
344    * @return Collision system 
345    */
346   UShort_t GetCollisionSystem() const { return fCollisionSystem; }
347   /** 
348    * Get the center of mass energy (per nucleon pair) in GeV 
349    * 
350    * @return center of mass energy (per nucleon pair) in GeV 
351    */
352   UShort_t GetEnergy() const { return fEnergy; }
353   /** 
354    * Get the magnetic field setting of the L3 magnet in kilo Gauss. 
355    * 
356    * @return The magnetic field setting 
357    */
358   Short_t  GetField() const { return fField; }
359   /** 
360    * Get the current run number 
361    * 
362    * @return The current run number 
363    */
364   ULong_t GetRunNumber() const { return fRunNumber; }
365   /** 
366    * Get the production year.
367    * 
368    * - For real data, this is the year of the data taking 
369    * - For MC this is the year the production is anchored to.
370    * 
371    * @return A two-digit year (post millennium), or -1
372    */
373   Short_t GetProductionYear() const { return fProdYear; }
374   /** 
375    * Get the production period. 
376    * 
377    * - For real data, this is the period identifier of the data taking 
378    * - For MC data, this is the period identifier the production was
379    *   anchored to
380    * 
381    * @return Period identifier or null
382    */
383   Char_t  GetProductionPeriod() const { return fProdLetter; } 
384   /** 
385    * Get the AliROOT revision used for this production
386    * 
387    * @return SVN revision number or -1
388    */
389   Short_t GetProductionRevision() const { return fProdSVN; } 
390   /** 
391    * Check if the production was an MC production anchored in some
392    * real data.
393    * 
394    * @return true if this (MC) production was anchored 
395    */
396   Bool_t  IsProductionMC() const { return fProdMC; }
397   
398   /** 
399    * Print information
400    * 
401    * @param option Not used 
402    */
403   void Print(Option_t* option="") const;
404   // getter for fmincentrality
405   // Double_t GetMinCentrality() const { return fMinCent;}
406   // gettter for fmaxcentrality 
407   // Double_t GetMaxCentrality() const { return fMaxCent;}
408   /** 
409    * Store information about running conditions in output list 
410    * 
411    * 3 TNamed objects are defined.   The names are fixed, but the
412    * title is a string representation of the information, and the
413    * unique ID contains the identifier 
414    *
415    * - sys   Contains the collision system string and identifier. 
416    * - sNN   Contains the center-of-mass energy per nucleon (GeV)
417    * - field Contains the L3 magnetic field (kG)
418    * - run   Contains the run number
419    * 
420    */
421   virtual void StoreInformation();
422   /** 
423    * Store - if possible - production information in a sub-list 
424    * 
425    */
426   virtual void StoreProduction();
427   /** 
428    * Return a string representing the return code 
429    * 
430    * @param mask Code 
431    * 
432    * @return String representation 
433    */
434   static const char* CodeString(UInt_t mask);
435 protected:
436   /** 
437    * Copy constructor - not implemented
438    * 
439    * @param o Object to copy from 
440    */
441   AliFMDEventInspector(const AliFMDEventInspector& o);
442   /** 
443    * Assignement operator - not implemented
444    * 
445    * @param o Object to assign from 
446    * 
447    * @return Reference to this object
448    */
449   AliFMDEventInspector& operator=(const AliFMDEventInspector& o);
450   /** 
451    * Cache the configure trigger classes from the physis selection.  
452    * 
453    * @param cache   where to cache the trigger class. 
454    * @param classes List of configured classes. 
455    * @param o       Object from OADB with config
456    */
457   void CacheConfiguredTriggerClasses(TList& cache, 
458                                      const TList* classes,
459                                      AliOADBPhysicsSelection* o);
460   /** 
461    * Read the trigger information from the ESD event 
462    * 
463    * @param esd        ESD event 
464    * @param triggers   On return, contains the trigger bits 
465    * @param nClusters  On return, number of SPD clusters in @f$ |\eta|<1@f$ 
466    * 
467    * @return @c true on success, @c false otherwise 
468    */
469   Bool_t ReadTriggers(const AliESDEvent& esd, UInt_t& triggers, 
470                       UShort_t& nClusters);
471   /** 
472    * Possible extra check for p-Pb from 2012/13 - require V0AND.
473    * 
474    * @param esd Event structure 
475    * 
476    * @return true on success
477    */
478   Bool_t CheckpAExtraV0(const AliESDEvent& esd) const;
479   /** 
480    * Check, for the @f$\sqrt{s}=2.76GeV@f$ pp run wether this event
481    * was in the fast partition, and if so, filter it out.
482    * 
483    * @param fastonly Event was in fast-only partition 
484    * 
485    * @return true if event was in the fast-only partition, for the run
486    * period.
487    */
488   virtual Bool_t CheckFastPartition(bool fastonly) const;
489   /** 
490    * Check if we have an NSD trigger for pp runs 
491    * 
492    * @param esd      Data
493    * @param triggers Trigger mask to be filled 
494    * 
495    * @return true if we have an NSD trigger 
496    */
497   virtual Bool_t CheckNSD(const AliESDEvent& esd, UInt_t& triggers) const;
498   /** 
499    * Check if we have an INEL&gt;0 trigger 
500    *  
501    * @param esd        Data 
502    * @param nClusters  On return, number of clusters
503    * @param triggers   Trigger mask to be filled
504    * 
505    * @return true if we have an INEL&gt;0 trigger 
506    */
507   virtual Bool_t CheckINELGT0(const AliESDEvent& esd, UShort_t& nClusters, 
508                               UInt_t& triggers) const;
509   /** 
510    * Check if this is a pile-up event
511    * 
512    * @param esd       Data
513    * @param triggers Trigger mask to be filled
514    * 
515    * @return true if this is a pile-up event
516    */
517   virtual Bool_t CheckPileup(const AliESDEvent& esd, UInt_t& triggers) const;
518   /** 
519    * Check for multi-vertex pile-up 
520    * 
521    * @param esd ESD event 
522    * @param checkOtherBC Also check other BC's 
523    * 
524    * @return true if multiple vertices found 
525    */
526   virtual Bool_t CheckMultiVertex(const AliESDEvent& esd, 
527                                   Bool_t checkOtherBC=false) const;
528   /** 
529    * Check if we have a cosmic trigger.  These should be filtered out. 
530    * 
531    * @param trigStri Trigger string 
532    * 
533    * @return true if we have a cosmic trigger
534    */
535   virtual Bool_t CheckCosmics(const TString& trigStri) const;
536   /** 
537    * Check if the trigger string corresponds to an empty event 
538    * 
539    * @param trigStr  Trigger string 
540    * @param triggers Trigger mask to be filled
541    * 
542    * @return true if the trigger string corresponds to an empty event 
543    */
544   virtual Bool_t CheckEmpty(const TString& trigStr, UInt_t& triggers) const;
545   /** 
546    * Check the trigger words to see if we have a B, A, C, or E event. 
547    * 
548    * @param esd       Data
549    * @param triggers  Trigger mask to be filled
550    * 
551    * @return always true
552    */
553   virtual Bool_t CheckWords(const AliESDEvent& esd, UInt_t& triggers) const;
554   /** 
555    * Read the vertex information from the ESD event 
556    * 
557    * @param esd  ESD event 
558    * @param ip   On return, the coordinates of the IP
559    * 
560    * @return @c true on success, @c false otherwise 
561    */
562   Bool_t ReadVertex(const AliESDEvent& esd, TVector3& ip);
563   /** 
564    * Check the vertex using the method used in PWG-UD.  That is 
565    *
566    * - Check we have a vertex and status is OK
567    * - Check if we have an SPD vertex and that it's status is OK 
568    * - Check if the vertex is from the Z-vertexer, and if it is, 
569    *   - Check that the dispersion and resolution is OK 
570    * 
571    * @param esd Data 
572    * @param ip  On return, the coordinates of the IP
573    * 
574    * @return status
575    */
576   virtual EVtxStatus CheckPWGUDVertex(const AliESDEvent& esd, 
577                                       TVector3& ip) const;
578   /** 
579    * Check the vertex. That is
580    *
581    * - Check if we have an SPD vertex and that it's status is OK 
582    * - Check that we have enough contributors 
583    * - Check that the reslution is OK 
584    * 
585    * @param esd Data 
586    * @param ip  On return, the coordinates of the IP
587    * 
588    * @return status
589    */
590   virtual EVtxStatus CheckpA2012Vertex(const AliESDEvent& esd, 
591                                      TVector3& ip) const;
592   /** 
593    * Check the vertex for pA 2012 settings. That is
594    *
595    * 
596    * @param esd Data 
597    * @param ip  On return, the coordinates of the IP
598    * 
599    * @return true if the vertex was found and met the requirements
600    */
601
602
603
604
605   virtual EVtxStatus CheckVertex(const AliESDEvent& esd, TVector3& ip) const;
606   /** 
607    * Read centrality from event 
608    * 
609    * @param esd  Event 
610    * @param cent On return, the centrality or negative if not found
611    * @param qual On return, centrality quality flag
612    * 
613    * @return False on error, true otherwise 
614    */
615   virtual Bool_t ReadCentrality(const AliESDEvent& esd, Double_t& cent,
616                                 UShort_t& qual) const;
617
618   TH1I*    fHEventsTr;            //! Histogram of events w/trigger
619   TH1I*    fHEventsTrVtx;         //! Events w/trigger and vertex 
620   TH1I*    fHEventsAccepted;      //! Events w/trigger and vertex in range 
621   TH2D*    fHEventsAcceptedXY;    //! XY vtx with trigger and Z vertex in range 
622   TH1I*    fHTriggers;            //! Triggers
623   TH2I*    fHTriggerCorr;         //! Correlation of triggers
624   TH1I*    fHType;                //! Type (low/high flux) of event
625   TH1I*    fHWords;               //! Trigger words 
626   TH1F*    fHCent;                //! Centrality 
627   TH2F*    fHCentVsQual;          //! Centrality vs quality 
628   TH1I*    fHStatus;              //! Event processing status 
629   TH1I*    fHVtxStatus;           //! Vertex processing status 
630   TH1I*    fHTrgStatus;           //! Trigger processing status 
631   Int_t    fLowFluxCut;           //  Low flux cut
632   Double_t fMaxVzErr;             //  Maximum error on v_z
633   TList*   fList;                 //! Histogram container 
634   UShort_t fEnergy;               // CMS energy (per nucleon pair) [GeV]
635   Short_t  fField;                // L3 magnetic field [kG]
636   UShort_t fCollisionSystem;      //  Collision system
637   Int_t    fDebug;                //  Debug level 
638   TAxis*   fCentAxis;             // Centrality axis used in histograms
639   TAxis    fVtxAxis;              // IP_z Axis 
640   Bool_t   fUseFirstPhysicsVertex;//Use the vtx code from p+p first physics
641   Bool_t   fUseV0AND;             // Use the vtx code from p+p first physics
642   UShort_t fMinPileupContrib;     // Min contributors to 2nd pile-up IP
643   Double_t fMinPileupDistance;    // Min distance of 2nd pile-up IP
644   Bool_t   fUseDisplacedVertices; // Analyze displaced vertices?
645   AliDisplacedVertexSelection fDisplacedVertex; //Displaced vertex selector
646   TList    fCollWords;            //! Configured collision words 
647   TList    fBgWords;              //! Configured background words 
648   TString  fCentMethod;           // Centrality method
649   Double_t fMinCent;              // min centrality
650   Double_t fMaxCent;              // max centrailty
651   Bool_t   fUsepA2012Vertex;      // flag to use pA2012 Veretx selection
652   ULong_t  fRunNumber;            // Current run number 
653   Bool_t   fMC;                   // Is this MC input
654   Short_t  fProdYear;             // Production year 
655   Char_t   fProdLetter;           // Production letter 
656   Short_t  fProdPass;             // Pass number 
657   Int_t    fProdSVN;              // AliROOT revision used in production
658   Bool_t   fProdMC;               // True if anchor production
659
660   ClassDef(AliFMDEventInspector,12); // Inspect the event 
661 };
662
663 #endif
664 // Local Variables:
665 //   mode: C++
666 // End:
667
668
669