2 // Calculate the flow in the forward regions using the Q cumulants method
4 #ifndef ALIFORWARDFLOWTASKQC_H
5 #define ALIFORWARDFLOWTASKQC_H
7 * @file AliForwardFlowTaskQC.h
8 * @author Alexander Hansen
12 * @ingroup pwglf_forward_flow
14 #include "AliAnalysisTaskSE.h"
17 class AliAODForwardMult;
25 class AliAnalysisFilter;
28 * @defgroup pwglf_forward_tasks_flow Flow tasks
30 * Code to do with flow
32 * @ingroup pwglf_forward_tasks
35 * Calculate the flow in the forward regions using the Q cumulants method
43 * @ingroup pwglf_forward_tasks_flow
44 * @ingroup pwglf_forward_flow
47 class AliForwardFlowTaskQC : public AliAnalysisTaskSE
53 AliForwardFlowTaskQC();
57 * @param name Name of task
59 AliForwardFlowTaskQC(const char* name);
63 virtual ~AliForwardFlowTaskQC() {}
66 * @name Task interface methods
69 * Create output objects
71 virtual void UserCreateOutputObjects();
75 virtual void Init() {}
79 * @param option Not used
81 virtual void UserExec(Option_t *option);
85 * @param option Not used
87 virtual void Terminate(Option_t *option);
90 * Returns the outputlist
94 TList* GetOutputList() { return fOutputList; }
96 * Set max flow moment to calculate.
98 * @param n Do v_2 to v_n
100 void SetMaxFlowMoment(Short_t n) { fMaxMoment = n; }
102 * Set vertex binning and range
104 * @param axis Use this vtx axis
106 void SetVertexAxis(TAxis* axis) { fVtxAxis = axis; }
108 * Set centrality/multiplicity binning and range
110 * @param axis Use this binning
112 void SetCentralityAxis(TAxis* axis) { fCentAxis = axis; }
114 * Set detector sigma cuts
116 * @param fmdCut FMD sigma cut
117 * @param spdCut SPD sigma cut
119 void SetDetectorCuts(Double_t fmdCut, Double_t spdCut) { fFMDCut = fmdCut; fSPDCut = spdCut; }
121 * Set flow flags, @f$\eta@f$-gap, sym. around @f$\eta=0@f$ or
122 * sat. vtx. interactions, also sets which forward detector to use
124 * @param flags EFlowFlags
126 void SetFlowFlags(UShort_t flags);
130 * @param flags EFlowFlags
131 * @param prepensUS prepend an underscore
135 static const Char_t* GetQCType(UShort_t flags, Bool_t prependUS = kTRUE);
137 * Set @f$|\eta|@f$ value to make cut for @f$\eta@f$ gap at
139 * @param eg gap value
141 void SetEtaGapValue(Double_t eg) { fEtaGap = eg; }
142 void SetTrackCuts(AliAnalysisFilter* trCuts) { fTrackCuts = trCuts; }
144 * Enum for flow flags
147 kStdQC = 0x0001, // Standard QC{2} and QC{4} calculations
148 kEtaGap = 0x0002, // QC{2} w/ an eta-gap
149 k3Cor = 0x0004, // 3 correlator method for QC{2} w/ an eta-gap
150 kSymEta = 0x0008, // Symmetrize ref flow in std. QC{2} and QC{4} around eta = 0
151 kSatVtx = 0x0010, // Do satellite vertex input (currently not implemented)
152 kNUAcorr = 0x0020, // Apply full NUA correction
153 kFMD = 0x0040, // Use FMD for forward flow
154 kVZERO = 0x0080, // Use VZERO for forward flow
155 kSPD = 0x0100, // SPD object flag
156 kMC = 0x0200, // MC object flag
157 kTracks = 0x1000, // Use tracks for reference flow
158 kTPC = 0x3000, // Use TPC tracks
159 kHybrid = 0x5000 // Use hybrid tracks
162 * struct to handle cumulant calculations and control histograms
164 struct CumuHistos : public TObject
170 CumuHistos() : fMaxMoment(), fRefHists(), fDiffHists(), fNUA() {}
174 * @param n max flow moment contained
175 * @param nua Make room for NUA corrected histograms
177 CumuHistos(Int_t n, UInt_t nua) : fMaxMoment(n), fRefHists(), fDiffHists(), fNUA(nua) {}
181 * @param o Object to copy from
185 CumuHistos(const CumuHistos& o)
187 fMaxMoment(o.fMaxMoment), // Max moment to compute
188 fRefHists(o.fRefHists), // List with ref hists
189 fDiffHists(o.fDiffHists), // List with diff hists
193 * Assignment operator
195 * @param o Object to assing from
197 * @return reference to this
199 CumuHistos& operator=(const CumuHistos& o)
201 if (&o == this) return *this;
202 TObject::operator=(o);
203 fMaxMoment = o.fMaxMoment;
204 fRefHists = o.fRefHists;
205 fDiffHists = o.fDiffHists;
214 * To access histograms
215 * main function of this class
217 * @param t (r)eference or (d)iff
218 * @param n flow moment
219 * @param nua nua type
221 * @return requested histogram
223 TH1* Get(Char_t t, Int_t n, UInt_t nua = 0) const;
225 * Connect internal lists to output
227 * @param name Name of VertexBin
228 * @param l Output list
230 void ConnectList(TString name, TList* l);
232 * Make histograms to one of the lists
234 * @param h Hist to add
236 void Add(TH1* h) const;
238 * Check to see of lists are connected,
239 * needed for grid/proof
241 * @return is connected?
243 Bool_t IsConnected() { return (fRefHists && fDiffHists); }
245 * enum for NUA histograms
248 kNoNUA = 0, // No NUA applied
249 kNUAOld, // NUA correction from same moment applied
250 kNUA // Full cross-moment NUA correction applied
254 * Get position of histogram in list
256 * @param n moment to get position of
257 * @param nua nua type
261 Int_t GetPos(Int_t n, UInt_t nua) const;
263 Int_t fMaxMoment; // Max flow moment contained
264 TList* fRefHists; // List of reference hists
265 TList* fDiffHists; // List of diff hists
266 UInt_t fNUA; // NUA tracker
268 ClassDef(CumuHistos, 1);
273 * Enum for filling flow histos
276 kFillRef = 0x1, // Fill only ref flow
277 kFillDiff = 0x2, // Fill only diff flow
278 kFillBoth = 0x3, // Fill both
279 kReset = 0x4, // Reset hists (used with one of the above)
282 * Enum for event diagnostics
285 kNoEvent = 1, // No event found
286 kNoForward, // No forward object found
287 kNoCentral, // No central object found
288 kNoTrigger, // No (wrong) trigger
289 kNoCent, // No centrality
290 kInvCent, // Centrality outside range
292 kInvVtx, // Vertex outside range
295 // ----------------- Being nested class ---------------------
297 * Nested class to handle cumulant calculations in vertex bins
299 class VertexBin : public TNamed
309 * @param vLow Min vertex z-coordinate
310 * @param vHigh Max vertex z-coordinate
311 * @param moment Flow moment
312 * @param type Data type (FMD/VZERO/SPD/FMDTR/SPDTR/MC)
314 * @param cut Cut value
315 * @param etaGap @f$\eta@f$ gap
317 VertexBin(Int_t vLow, Int_t vHigh,
318 UShort_t moment, TString type,
320 Double_t cut = -1, Double_t etaGap = -1.);
324 * @param o Object to copy from
328 VertexBin(const VertexBin& o){;}
330 * Assignment operator
332 * @param v Object to assing from
334 * @return reference to this
336 VertexBin& operator=(const VertexBin& v);
342 * Add vertex bin output to list
344 * @param list Histograms are added to this list
345 * @param centAxis Axis to handle centrality binning
349 void AddOutput(TList* list, TAxis* centAxis);
351 * Fill reference and differential flow histograms for analysis
352 * using histograms as input
354 * @param dNdetadphi 2D data histogram
355 * @param cent Centrality
356 * @param mode fill ref/diff or both
358 * @return false if bad event (det. hotspot)
360 Bool_t FillHists(TH2D& dNdetadphi, Double_t cent, UShort_t mode);
362 * Fill reference and differential flow histograms for analysis
363 * using tracks as input
365 * @param trList Array with tracks
366 * @param cent Centrality
367 * @param mode fill ref/diff or both
369 * @return false if bad event (det. hotspot)
371 Bool_t FillTracks(TObjArray* trList, AliESDEvent* esd, AliAnalysisFilter* trFilter, UShort_t mode);
373 * Do cumulants calculations for current event with
376 * @param cent Event centrality
378 void CumulantsAccumulate(Double_t cent);
380 * Do 3 correlator cumulants calculations for current event with
383 * @param cent Event centrality
385 void CumulantsAccumulate3Cor(Double_t cent);
387 * Get limits to do reference flow calculations for 3 correlator method
389 * @param bin Differential bin
390 * @param aLow Lowest bin to be used for v_A
391 * @param aHigh Highest bin to be used for v_A
392 * @param bLow Lowest bin to be used for v_B
393 * @param bHigh Highest bin to be used for v_B
395 void GetLimits(Int_t bin, Int_t& aLow, Int_t& aHigh, Int_t& bLow, Int_t& bHigh) const;
397 * Finish cumulants calculations. Takes input and
398 * output lists in case Terminate is called separately
400 * @param inlist List with input histograms
401 * @param outlist List with output histograms
403 void CumulantsTerminate(TList* inlist, TList* outlist);
405 * Enumeration for cumulant histograms
407 enum { kW2Two = 1, // <w2*two>
409 kW4Four, // <w4*four>
411 kCosphi1phi2, // <cos(phi1+phi2)>
412 kSinphi1phi2, // <sin(phi1+phi2)>
413 kCosphi1phi2phi3m, // <cos(phi1-phi2-phi3)>
414 kSinphi1phi2phi3m, // <sin(phi1-phi2-phi3)>
415 k3pWeight, // M(M-1)(M-1) or (mp*M-2mq)(M-1)
416 kCosphi1phi2phi3p, // <cos(phi1+phi2-phi3)>
417 kSinphi1phi2phi3p // <sin(phi1+phi2-phi3)>
421 * Calculate reference flow
423 * @param cumu2 QC2 histos
424 * @param cumu4 QC4 histos
425 * @param quality QC Quality diag. histo
426 * @param chist Centrality histogram
427 * @param dNdetaRef dN/deta histogram
429 void CalculateReferenceFlow(CumuHistos& cumu2h, CumuHistos& cumu4h, TH2I* quality, TH1D* chist, TH2D* dNdetaRef) const;
431 * Calculate differential flow
433 * @param cumu2 QC2 histos
434 * @param cumu4 QC4 histos
435 * @param quality QC Quality diag. histo
436 * @param dNdetaDiff dN/deta histogram
438 void CalculateDifferentialFlow(CumuHistos& cumu2h, CumuHistos& cumu4h, TH2I* quality, TH2D* dNdetaDiff) const;
440 * Calculate 3 correlator ref and fiff flow
442 * @param cumu2 QC2 histos
443 * @param quality QC Quality diag. histo
444 * @param chist Centrality histogram
445 * @param dNdetaRef dN/deta histogram
446 * @param dNdetaDiff dN/deta histogram
448 void Calculate3CorFlow(CumuHistos& cumu2h, TH2I* quality, TH1D* chist, TH2D* dNdetaRef, TH2D* dNdetaDiff) const;
450 * Solve coupled eqs. to get v_n
452 * @param cumu CumuHistos object with non-corrected flow results
453 * @param type reference of differential flow ('r'/'d'/'a'/'b')
455 void SolveCoupledFlowEquations(CumuHistos& cumu, Char_t type) const;
457 * Calculate NUA matrix elements to fill into the matrix
461 * @param type reference of differential flow ('r'/'d'/'a'/'b')
462 * @param binA Eta bin of phi1
463 * @param cBin Centrality bin
465 * @return maxtrix element
467 Double_t CalculateNUAMatrixElement(Int_t n, Int_t m, Char_t type, Int_t binA, Int_t cBin) const;
469 * Adds up the vertex bins to master profiles
471 * @param cumu QC histos
472 * @param list output list
473 * @param nNUA number of nua calculations
475 void AddVertexBins(CumuHistos& cumu, TList* list, UInt_t nNUA) const;
477 * Get the bin number of <<cos(nphi)>>
483 Int_t GetBinNumberCos(Int_t n = 0) const;
485 * Get the bin number of <<sin(nphi)>>
491 Int_t GetBinNumberSin(Int_t n = 0) const;
493 * Setup NUA axis with labels
495 * @param axis NUA axis
497 void SetupNUALabels(TAxis* a) const;
499 * Make diagnostics hitogram
505 TH2I* MakeQualityHist(const Char_t* name) const;
507 * Make output histogram
509 * @param qc # of particle correlations
510 * @param n flow moment
511 * @param ctype Type of flow
512 * @param nua For nua corrected hists
516 TH2D* MakeOutputHist(Int_t qc, Int_t n, const Char_t* ctype, UInt_t nua) const;
518 UShort_t fMaxMoment; // Max flow moment
519 Int_t fVzMin; // z-vertex min must be in whole [cm]
520 Int_t fVzMax; // z-vertex max must be in whole [cm]
521 TString fType; // Data type
522 UShort_t fFlags; // Flow flags, e.g., eta-gap or sat. vtx
523 Double_t fSigmaCut; // Detector specific cut for outlier events
524 Double_t fEtaGap; // Eta gap value
525 Double_t fEtaLims[6]; // Limits for binning in 3Cor method
526 TH2D* fCumuRef; // Histogram for reference flow
527 TH2D* fCumuDiff; // Histogram for differential flow
528 CumuHistos fCumuHists; // Array of histograms for cumulants calculations
529 TH3D* fCumuNUARef; // histogram for NUA terms
530 TH3D* fCumuNUADiff; // histogram for NUA terms
531 TH2F* fdNdedpRefAcc; // Diagnostics histogram for acc. maps
532 TH2F* fdNdedpDiffAcc; // Diagnostics histogram for acc. maps
533 TH2F* fOutliers; // Sigma <M> histogram
534 UShort_t fDebug; // Debug flag
536 ClassDef(VertexBin, 4); // object for eta dependent cumulants ananlysis
538 // ---------- End of nested class -------------
542 * @param o Object to copy from
544 AliForwardFlowTaskQC(const AliForwardFlowTaskQC& o);
546 * Assignment operator
548 * @return Reference to this object
550 AliForwardFlowTaskQC& operator=(const AliForwardFlowTaskQC&);
552 * Initiate vertex bin objects
554 virtual void InitVertexBins();
556 * Initiate diagnostics histograms
558 virtual void InitHists();
562 * @return true on success
564 virtual Bool_t Analyze();
568 virtual void Finalize();
570 * Loops of vertex bins in list and runs analysis on those for current vertex
572 * @param list List of vertex bins
573 * @param h dN/detadphi histogram
574 * @param vtx Current vertex bin
575 * @param flags Extra flags
577 void FillVtxBinList(const TList& list, TH2D& h1, Int_t vtx, UShort_t flags = 0x0) const;
579 * Loops of vertex bins in list and runs analysis on those for current vertex
581 * @param list List of vertex bins
582 * @param href dN/detadphi histogram for ref flow
583 * @param hdiff dN/detadphi histogram for diff flow
584 * @param vtx Current vertex bin
585 * @param flags Extra flags
587 void FillVtxBinListEtaGap(const TList& list, TH2D& href, TH2D& hdiff, Int_t vtx, UShort_t flags = 0x0) const;
589 * Loops of vertex bins in list and runs analysis on those for current vertex
591 * @param list List of vertex bins
592 * @param hcent dN/detadphi histogram for central barrel
593 * @param hfwd dN/detadphi histogram for fwd detectors
594 * @param vtx Current vertex bin
595 * @param flags Extra flags
597 void FillVtxBinList3Cor(const TList& list, TH2D& hcent, TH2D& hfwd, Int_t vtx, UShort_t flags = 0x0);
599 * Combine forward and central detector histograms to one histogram, to be used for 3 correlator method
601 * @param hcent Central data
602 * @param hfwd Forward data
604 * @return combined hist
606 TH2D& CombineHists(TH2D& hcent, TH2D& hfwd);
608 * Get Fill tracks from ESD or AOD input event
610 * @return true on success
612 Bool_t FillTracks(VertexBin* bin, UShort_t mode) const;
614 * Loops over VertexBin list and calls terminate on each
616 * @param list VertexBin list
618 void EndVtxBinList(const TList& list) const;
620 * Projects a list of TH2D's with flow
621 * results to TH1's in centrality bins
623 * @param list List of flow results
625 void MakeCentralityHists(TList* list) const;
627 * Check AODevent object for trigger, vertex and centrality
628 * uses aod header if object is null
629 * returns true if event is OK
631 * @param aodfm AliAODForwardMult object
635 virtual Bool_t CheckEvent(const AliAODForwardMult* aodfm);
637 * Check trigger from AODForwardMult object
638 * uses aod header if object is null
639 * returns true if offline trigger is present
641 * @param aodfm AliAODForwardMult object
645 virtual Bool_t CheckTrigger(const AliAODForwardMult* aodfm) const;
647 * Check for centrality in AliAODForwardMult object,
648 * uses aod header if object is null
649 * if present return true - also sets fCent value
651 * @param aodfm AliAODForwardMult object
655 virtual Bool_t GetCentrality(const AliAODForwardMult* aodfm);
657 * Check for vertex in AliAODForwardMult
658 * uses aod header if object is null
659 * returns true if in range of fVtxAXis, also sets fVtx value
661 * @param aodfm AliAODForwardMult object
665 virtual Bool_t GetVertex(const AliAODForwardMult* aodfm);
669 * @return VZERO data object
671 AliVVZERO* GetVZERO() const;
673 * Fill VZERO d^2N/detadphi hist
675 * @param aodvzero: AliAODVZERO object
677 void FillVZEROHist(AliVVZERO* vzero);
679 * Print the setup of the task
681 void PrintFlowSetup() const;
683 TAxis* fVtxAxis; // Axis to control vertex binning
684 TAxis* fCentAxis; // Axis to control centrality/multiplicity binning
685 Double_t fFMDCut; // FMD sigma cut for outlier events
686 Double_t fSPDCut; // SPD sigma cut for outlier events
687 UShort_t fFlowFlags; // Flow flags, e.g., eta-gap, sat. vtx.
688 Double_t fEtaGap; // Eta gap value
689 TList fBinsForward; // List with forward VertexBin objects
690 TList fBinsCentral; // List with central VertexBin objects
691 TList* fSumList; // Sum list
692 TList* fOutputList; // Output list
693 AliAODEvent* fAOD; // AOD event
694 AliAnalysisFilter* fTrackCuts; // ESD track cuts
695 Int_t fMaxMoment; // Calculate v_{n} flag
696 Float_t fVtx; // Z vertex bin
697 Double_t fCent; // Centrality
698 TH2D fHistdNdedpV0; // VZERO d^2N/detadphi histogram
699 TH2D fHistdNdedp3Cor;// 3 correlator d^2N/detadphi histogram
700 TH2D* fHistFMDSPDCorr;// Diagnostics hist for multiplicity correlations between FMD and SPD
701 TH1D* fHistCent; // Diagnostics hist for centrality
702 TH1D* fHistVertexSel; // Diagnostics hist for selected vertices
703 TH1I* fHistEventSel; // Diagnostics hist for event selection
705 ClassDef(AliForwardFlowTaskQC, 5); // Analysis task for flow analysis