]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AliForwardFlowTaskQC.h
7a39fa2f0fbaa71b23f866a3cb28bce2c2fa0db1
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliForwardFlowTaskQC.h
1 //
2 // Calculate the flow in the forward regions using the Q cumulants method
3 //
4 #ifndef ALIFORWARDFLOWTASKQC_H
5 #define ALIFORWARDFLOWTASKQC_H
6 /**
7  * @file AliForwardFlowTaskQC.h
8  * @author Alexander Hansen
9  * 
10  * @brief
11  * 
12  * 
13  * @ingroup pwglf_forward_flow
14  */
15 #include "AliAnalysisTaskSE.h"
16 #include "TString.h"
17 #include "TArrayI.h"
18 class AliAODForwardMult;
19 class TH1D;
20 class TH2F;
21 class TH2D;
22 class TH3D;
23 class TAxis;
24 /**
25  * @defgroup pwglf_forward_tasks_flow Flow tasks 
26  *
27  * Code to do with flow 
28  *
29  * @ingroup pwglf_forward_tasks
30  */
31 /**
32  * Calculate the flow in the forward regions using the Q cumulants method
33  *
34  * @par Inputs:
35  *   - AliAODEvent
36  *
37  * Outputs:
38  *   - AnalysisResults.root
39  *
40  * @ingroup pwglf_forward_tasks_flow
41  * @ingroup pwglf_forward_flow
42  *
43  */
44 class AliForwardFlowTaskQC : public AliAnalysisTaskSE
45 {
46 public:
47   /** 
48    * Constructor 
49    */
50   AliForwardFlowTaskQC();
51   /** 
52    * Constructor
53    * 
54    * @param name Name of task 
55    */
56   AliForwardFlowTaskQC(const char* name);
57   /**
58    * Destructor
59    */
60   virtual ~AliForwardFlowTaskQC() {}
61   /** 
62    * @{ 
63    * @name Task interface methods 
64    */
65   /** 
66    * Create output objects 
67    */
68   virtual void UserCreateOutputObjects();
69   /**
70    * Initialize the task
71    */
72   virtual void Init() {} 
73   /** 
74    * Process each event 
75    *
76    * @param option Not used
77    */  
78   virtual void UserExec(Option_t *option);
79   /** 
80    * End of job
81    * 
82    * @param option Not used 
83    */
84   virtual void Terminate(Option_t *option);
85   /* @} */
86   /**
87    * Returns the outputlist
88    * 
89    * @return TList* 
90    */
91   TList* GetOutputList() { return fOutputList; }
92   /**
93    * Set which flow moments to calculate.
94    * 
95    * @param  n Do @f$ v_{n}@f$
96    * 
97    * @return void 
98    */
99   void AddFlowMoment(Short_t n); 
100   /**
101    * Set non-default vertex binning and range
102    *
103    * @param axis Use this vtx axis
104    */
105   void SetVertexAxis(TAxis* axis) { fVtxAxis = axis; }
106   /**
107    * Set detector sigma cuts
108    *
109    * @param fmdCut FMD sigma cut
110    * @param spdCut SPD sigma cut
111    */
112   void SetDetectorCuts(Double_t fmdCut, Double_t spdCut) { fFMDCut = fmdCut; fSPDCut = spdCut; }
113   /**
114    * Set flow flags, @f$\eta@f$-gap, sym. around @f$\eta=0@f$ or
115    * sat. vtx. interactions
116    *
117    * @param flags EFlowFlags 
118    */
119   void SetFlowFlags(UShort_t flags) { fFlowFlags = flags; }
120   /**
121    * Enum for flow flags
122    */
123   enum EFlowFlags {
124     kEtaGap  = 0x1,
125     kSymEta  = 0x2,
126     kSatVtx  = 0x4
127   };
128   /**
129    *  Set @f$|\eta|@f$ value to make cut for @f$\eta@f$ gap at
130    *
131    * @param eg gap value
132    */
133   void SetEtaGapValue(Double_t eg) { fEtaGap = eg; }
134 protected:
135   /**
136    * Enum for reference flow (eta-gap) mode
137    */
138   enum EFillFlow {
139     kFillRef  = 0x1,
140     kFillDiff = 0x2,
141     kFillBoth = 0x3
142   };
143   // ----------------- Being nested class ---------------------
144   /**
145    * Nested class to handle cumulant calculations in vertex bins
146    */
147   class VertexBin : public TNamed
148   {
149   public:
150     /*
151      * Constructor
152      */
153     VertexBin();
154     /**
155      * Constructor
156      * 
157      * @param vLow Min vertex z-coordinate
158      * @param vHigh Max vertex z-coordinate
159      * @param moment Flow moment
160      * @param type Data type (FMD/SPD/FMDTR/SPDTR/MC)
161      * @param flags Flags
162      * @param cut Cut value 
163      * @param etaGap @f$\eta@f$ gap 
164      */
165     VertexBin(Int_t vLow, Int_t vHigh, 
166               UShort_t moment, TString type,
167               UShort_t flags = kSymEta, 
168               Double_t cut = -1, Double_t etaGap = 2.);
169     /**
170      * Copy constructor 
171      * 
172      * @param o Object to copy from
173      * 
174      * @return VertexBin
175      */
176     VertexBin(const VertexBin& o);
177     /**
178      * Assignment operator 
179      * 
180      * @param v Object to assing from
181      * 
182      * @return reference to this 
183      */
184     VertexBin& operator=(const VertexBin& v);
185     /**
186      * Destructor 
187      */
188     ~VertexBin(){}
189     /**
190      * Add vertex bin output to list
191      * 
192      * @param list Histograms are added to this list
193      * 
194      * @return void 
195      */
196     virtual void AddOutput(TList* list);
197     /**
198      * Fill reference and differential flow histograms for analysis
199      *
200      * @param dNdetadphi 2D data histogram
201      * @param cent Centrality
202      * @param mode fill ref/diff or both
203      *
204      * @return false if bad event (det. hotspot)
205      */
206     Bool_t FillHists(const TH2D& dNdetadphi, Double_t cent, EFillFlow mode = kFillBoth);
207     /**
208      * Do cumulants calculations for current event with 
209      * centrality cent
210      * 
211      * @param cent Event centrality
212      * @param skipFourP Skip ?
213      *
214      * @return void 
215      */
216     void CumulantsAccumulate(Double_t cent, Bool_t skipFourP = kFALSE);
217     /**
218      * Finish cumulants calculations. Takes input and
219      * output lists in case Terminate is called separately
220      * 
221      * @param inlist List with input histograms
222      * @param outlist List with output histograms
223      * 
224      * @return void 
225      */
226     void CumulantsTerminate(TList* inlist, TList* outlist);
227
228   protected:
229     /*
230      * Enumeration for ref/diff histograms
231      */
232     enum { kHmultA = 1, kHmultB, kHQnReA, kHQnImA, kHQnReB, kHQnImB, kHQ2nRe, kHQ2nIm };
233     /*
234      * Enumeration for cumulant histograms
235      */
236     enum { kW2Two = 1, 
237            kW2, 
238            kW4Four, 
239            kW4, 
240            kQnReA, 
241            kQnImA, 
242            kMA,
243            kQnReB, 
244            kQnImB, 
245            kMB,
246            kCosphi1phi2, 
247            kSinphi1phi2, 
248            kCosphi1phi2phi3m, 
249            kSinphi1phi2phi3m, 
250            kMm1m2, 
251            kw2two, 
252            kw2, 
253            kw4four, 
254            kw4, 
255            kpnRe, 
256            kpnIm, 
257            kmp, 
258            kCospsi1phi2, 
259            kSinpsi1phi2, 
260            kCospsi1phi2phi3m, 
261            kSinpsi1phi2phi3m,
262            kmpmq, 
263            kCospsi1phi2phi3p, 
264            kSinpsi1phi2phi3p };
265     /**
266      * Set centrality axis
267      *
268      * @param axis Centrality axis
269      *
270      * @return void
271      */
272     void SetupCentAxis(TAxis* axis);
273
274     const UShort_t fMoment;        // flow moment 
275     const Int_t    fVzMin;         // z-vertex min must be in whole [cm]
276     const Int_t    fVzMax;         // z-vertex max must be in whoe [cm]
277     TString        fType;          // data type
278     const UShort_t fFlags;         // Flow flags, e.g., eta-gap sat. vtx
279     const Double_t fSigmaCut;      // Detector specific cut for outlier events
280     const Double_t fEtaGap;        // Eta gap value
281     TH2D*          fCumuRef;       // histogram for reference flow
282     TH2D*          fCumuDiff;      // histogram for differential flow
283     TH3D*          fCumuHist;      // histogram for cumulants calculations
284     TH2F*          fdNdedpAcc;     // Diagnostics histogram to make acc. maps
285     TH2F*          fOutliers;      // Sigma <M> histogram 
286     UShort_t       fDebug;         // Debug flag
287
288     ClassDef(VertexBin, 3); // object for cumulants ananlysis in FMD
289   };
290   // ---------- End of nested class -------------
291   /** 
292    * Copy constructor 
293    * 
294    * @param o Object to copy from 
295    */
296   AliForwardFlowTaskQC(const AliForwardFlowTaskQC& o);
297   /** 
298    * Assignment operator 
299    * 
300    * @return Reference to this object 
301    */
302   AliForwardFlowTaskQC& operator=(const AliForwardFlowTaskQC&);
303   /**
304    * Initiate vertex bin objects
305    */
306   virtual void InitVertexBins();
307   /**
308    * Initiate diagnostics histograms
309    */
310   virtual void InitHists();
311   /**
312    * Analyze event
313    *
314    * @return true on success
315    */
316   virtual Bool_t Analyze();
317   /**
318    * Finalize analysis
319    */
320   virtual void Finalize();
321   /**
322    * Loops of vertex bins in list and runs analysis on those for current vertex
323    *
324    * @param list List of vertex bins
325    * @param h dN/detadphi histogram
326    * @param vtx Current vertex bin
327    *
328    * @return true on success
329    */
330   Bool_t FillVtxBinList(const TList& list, const TH2D& h, Int_t vtx) const;
331   /**
332    * Loops of vertex bins in list and runs analysis on those for current vertex
333    *
334    * @param list List of vertex bins
335    * @param href dN/detadphi histogram for ref flow
336    * @param hdiff dN/detadphi histogram for diff flow
337    * @param vtx Current vertex bin
338    *
339    * @return true on success
340    */
341   Bool_t FillVtxBinListEtaGap(const TList& list, const TH2D& href, const TH2D& hdiff, Int_t vtx) const;
342
343   /**
344    * Loops over VertexBin list and calls terminate on each
345    *
346    * @param list VertexBin list
347    */
348   void EndVtxBinList(const TList& list) const;
349   /**
350    * Projects a list of TProfile2D's with flow
351    * results to TH1's in centrality bins
352    *
353    * @param list List of flow results
354    *
355    * @return void
356    */
357   void MakeCentralityHists(TList* list);
358   /**
359    * Check AODevent object for trigger, vertex and centrality
360    * returns true if event is OK
361    *
362    * @param aodfm AliAODForwardMultObject
363    * 
364    * @return Bool_t 
365    */
366   Bool_t CheckEvent(const AliAODForwardMult* aodfm);
367   /**
368    * Check trigger from AODForwardMult object
369    * returns true if offline trigger is present
370    *
371    * @param aodfm AliAODForwardMultObject
372    * 
373    * @return Bool_t 
374    */
375   virtual Bool_t CheckTrigger(const AliAODForwardMult* aodfm) const;
376   /**
377    * Check for centrality in AliAODForwardMult object, 
378    * if present return true - also sets fCent value
379    *
380    * @param aodfm AliAODForwardMultObject
381    * 
382    * @return Bool_t 
383    */
384   virtual Bool_t GetCentrality(const AliAODForwardMult* aodfm);
385   /**
386    * Check for vertex in AliAODForwardMult
387    * returns true if in range of fVtxAXis, also sets fVtx value
388    *
389    * @param aodfm AliAODForwardMultObject
390    * 
391    * @return Bool_t 
392    */
393   virtual Bool_t GetVertex(const AliAODForwardMult* aodfm);
394   /**
395    * Make diagnostics hitogram
396    *
397    * @return void
398    */
399   void MakeQualityHist(const Char_t* name) const;
400   /**
401    * Print the setup of the task
402    *
403    * @return void
404    */
405   virtual void PrintFlowSetup() const;
406
407   TAxis*         fVtxAxis;          //  Axis to control vertex binning
408   Double_t       fFMDCut;           //  FMD sigma cut for outlier events
409   Double_t       fSPDCut;           //  SPD sigma cut for outlier events
410   UShort_t       fFlowFlags;        //  Flow flags, e.g., eta-gap, sat. vtx.
411   Double_t       fEtaGap;           //  Eta gap value
412   TList          fBinsFMD;          //  list with FMD VertexBin objects 
413   TList          fBinsSPD;          //  list with SPD VertexBin objects
414   TList*         fSumList;          //  sum list
415   TList*         fOutputList;       //  Output list
416   AliAODEvent*   fAOD;              //  AOD event
417   TArrayI        fV;                //  Calculate v_{n} flag
418   Float_t        fVtx;              //  Z vertex bin
419   Double_t       fCent;             //  Centrality
420   TH1D*          fHistCent;         //  Diagnostics hist for centrality
421   TH1D*          fHistVertexSel;    //  Diagnostics hist for selected vertices
422
423   ClassDef(AliForwardFlowTaskQC, 3); // Analysis task for FMD analysis
424 };
425
426 #endif
427 // Local Variables:
428 //   mode: C++ 
429 // End: