2 // Task to analyse the AOD for for dN/deta in the base regions
4 #ifndef ALIBASEDNDETATASK_H
5 #define ALIBASEDNDETATASK_H
7 * @file AliBasedNdetaTask.h
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 13:58:12 2011
13 * @ingroup pwglf_forward_dndeta
16 #include <AliAnalysisTaskSE.h>
24 class AliAODForwardMult;
28 * @defgroup pwglf_forward_tasks_dndeta dN/deta tasks
30 * Code to produce @f$ dN/d\eta@f$
32 * @ingroup pwglf_forward_tasks
35 * @defgroup pwglf_forward_dndeta dN/deta
37 * @f$ dN/d\eta@f$ code
39 * @ingroup pwglf_forward_topical
42 * Base class for tasks to determine @f$ dN/d\eta@f$
44 * @ingroup pwglf_forward_tasks_dndeta
45 * @ingroup pwglf_forward_dndeta
47 class AliBasedNdetaTask : public AliAnalysisTaskSE
51 * Bit mask values of the normalisation scheme
54 /** Only normalize to accepted events */
57 * Do the full normalisation
59 * N = \frac{1}{\epsilon_X}(N_A-N_A/N_V(N_T-N_V)) =
60 * \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
65 * Do the shape correction
69 * Correct for background events (A+C-E). Not implemented yet
73 * Correct for the trigger efficiency from MC
75 kTriggerEfficiency = 0x8,
77 * Correct using zero-bin efficiency only
81 * Do the full correction
83 kFull = kEventLevel | kShape | kBackground | kTriggerEfficiency,
93 * @param name Name of task
95 AliBasedNdetaTask(const char* name);
100 virtual ~AliBasedNdetaTask();
104 * @name Task configuration
107 * Set the debug level
109 * @param level Debug level
111 virtual void SetDebugLevel(Int_t level);
113 * Set the vertex range to use
115 * @param min Minimum (in centermeter)
116 * @param max Maximum (in centermeter)
118 void SetVertexRange(Double_t min, Double_t max) { fVtxMin=min; fVtxMax=max; }
120 * Set the rebinning factor
122 * @param rebin Rebinning factor
124 void SetRebinning(Int_t rebin) { fRebin = rebin; }
126 * Set the trigger maskl
128 * @param mask Trigger mask
130 void SetTriggerMask(UShort_t mask);
132 * Set the trigger mask
134 * @param mask trigger mask
136 void SetTriggerMask(const char* mask);
138 * Set the centrality bins to use.
141 * UShort_t bins[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
142 * task->SetCentralityBins(11, bins);
145 * @param n Number of bins (elements in @a bins minus 1)
146 * @param bins Bin limits
148 void SetCentralityAxis(UShort_t n, Short_t* bins);
150 * Whether to cut edges when merging
152 * @param cut If true, cut edges
154 void SetCutEdges(Bool_t cut) {fCutEdges = cut;}
156 * Set whether to correct for empty bins when projecting on the X axis.
158 * @param use Whether to correct for empty bins
160 void SetCorrEmpty(Bool_t use) { fCorrEmpty = use; }
162 * Set whether to use the ROOT TH2::ProjectionX method when
163 * projecting on the X axis.
165 * @param use Whether to use TH2::ProjectionX
167 void SetUseROOTProjectX(Bool_t use) { fUseROOTProj = use; }
169 * Trigger efficiency for selected trigger(s)
171 * @param e Trigger efficiency
173 void SetTriggerEff(Double_t e) { fTriggerEff = e; }
175 * Set the shape correction (a.k.a., track correction) for selected
178 * @param h Correction
180 void SetShapeCorrection(const TH2F* h);
182 * Setthe normalisation scheme to use
184 * @param scheme Normalisation scheme
186 void SetNormalizationScheme(UShort_t scheme);
188 * Space, pipe, or comma separated list of options
190 * @param what List of options
192 void SetNormalizationScheme(const char* what);
194 * Filename of final MC correction
196 * @param filename filename
198 void SetMCFinalCorrFilename(const char* filename) {
199 fFinalMCCorrFile.Clear();
200 fFinalMCCorrFile.Append(filename);
203 * Load the normalization data - done automatically if not set from outside
206 * @param energy energy
208 void LoadNormalizationData(UShort_t sys, UShort_t energy);
213 * @param option Not used
215 void Print(Option_t* option="") const;
217 * @name Task interface
220 * Initialise on master - does nothing
223 virtual void Init() {}
225 * Create output objects.
227 * This is called once per slave process
229 virtual void UserCreateOutputObjects();
231 * Process a single event
233 * @param option Not used
235 virtual void UserExec(Option_t* option);
237 * Called at end of event processing.
239 * This is called once in the master
241 * @param option Not used
243 virtual void Terminate(Option_t* option);
248 * @name Services member functions
251 * Make a copy of the input histogram and rebin that histogram
253 * @param h Histogram to rebin
254 * @param rebin Rebinning factor
255 * @param cutEdges Whether to cut edges when rebinning
257 * @return New (rebinned) histogram
259 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
261 * Make an extension of @a h to make it symmetric about 0
263 * @param h Histogram to symmertrice
265 * @return Symmetric extension of @a h
267 static TH1* Symmetrice(const TH1* h);
269 * Project onto the X axis
271 * @param h 2D histogram
272 * @param name New name
273 * @param firstbin First bin to use
274 * @param lastbin Last bin to use
275 * @param useROOT Use TH2::ProjectionX instead of custom code
276 * @param corr Whether to do corrections or not
277 * @param error Whether to calculate errors
279 * @return Newly created histogram or null
281 static TH1D* ProjectX(const TH2D* h,
289 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
291 * @param copy Data to scale
292 * @param norm Coverage histogram
294 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
296 * Set histogram graphical options, etc.
298 * @param h Histogram to modify
299 * @param colour Marker color
300 * @param marker Marker style
301 * @param title Title of histogram
302 * @param ytitle Title on y-axis.
304 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
306 const char* ytitle="#frac{1}{N} #frac{dN_{ch}}{d#eta}");
318 kDownTriangle = 0x008,
324 * Get the marker style from option bits
326 * @param bits Option bits
328 * @return Marker style
330 static Int_t GetMarkerStyle(UShort_t bits);
332 * Get the marker option bits from a style
336 * @return option bits
338 static UShort_t GetMarkerBits(Int_t style);
342 * @param style Style parameter
346 static Int_t FlipHollowStyle(Int_t style);
351 AliBasedNdetaTask(const AliBasedNdetaTask&);
353 * Assignment operator
358 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&) { return *this; }
359 // Forward declaration
362 * Create the CentralityBin objects if not already done.
365 virtual void InitializeCentBins();
367 * Retrieve the histogram
369 * @param aod AOD event
370 * @param mc Whether to get the MC histogram or not
372 * @return Retrieved histogram or null
374 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
376 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
378 * @return Marker colour
380 virtual Int_t GetColor() const { return kBlack; }
382 * Get the marker style
384 * @return Marker style
386 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
388 * Add a centrality bin
390 * @param at Where in the list to add this bin
392 * @param high High cut
394 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
396 * Make a centrality bin
398 * @param name Name used for histograms
399 * @param low Low cut in percent
400 * @param high High cut in percent
402 * @return A newly created centrality bin
404 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
407 //==================================================================
409 * Class that holds the sum of the data - possibly split into 0 or
413 struct Sum : public TNamed
415 TH2D* fSum; // Sum of non-zero events
416 TH2D* fSum0; // Sum of zero events
417 TH1I* fEvents; // Distribution of events
418 Int_t fDebug; // Debug level
420 * I/O Constructor - do not use
422 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
427 * @param postfix Possible post-fix
429 Sum(const char* name, const char* postfix)
430 : TNamed(name,postfix),
439 * @param o Object to copy from
449 * Assignment operator
451 * @param o Object to assign from
453 * @return Reference to this object
455 Sum& operator=(const Sum& o) {
456 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
464 * Initialise this object.
466 * @param list List to add histograms to
467 * @param data Format of data to be cloned here
470 void Init(TList* list, const TH2D* data, Int_t col);
474 * @param data Data to add
475 * @param isZero If this is zero event
477 void Add(const TH2D* data, Bool_t isZero=false);
479 * Get the histogram name
481 * @param name Base name
482 * @param what Which one
483 * @param post Possible postfix
487 static TString GetHistName(const char* name, Int_t what=0,
490 * Get the histogram name
492 * @param what Which one
496 TString GetHistName(Int_t what=0) const;
500 * @param o Output list
501 * @param ntotal On return, the total number of events
502 * @param zeroEff Zero-bin efficiency
503 * @param otherEff Non-zero-bin efficiency
504 * @param marker Marker to use
505 * @param rootXproj Whether to use TH2::ProjectionX
506 * @param corrEmpty Correct for empty bins
508 * @return The total sum histogram
510 TH2D* CalcSum(TList* o, Double_t& ntotal,
511 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
512 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
515 //==================================================================
517 * Calculations done per centrality
520 class CentralityBin : public TNamed
530 * @param name Name used for histograms (e.g., Forward)
531 * @param low Lower centrality cut in percent
532 * @param high Upper centrality cut in percent
534 CentralityBin(const char* name, Short_t low, Short_t high);
538 * @param other Object to copy from
540 CentralityBin(const CentralityBin& other);
544 virtual ~CentralityBin();
546 * Assignment operator
548 * @param other Object to assign from
550 * @return Reference to this
552 CentralityBin& operator=(const CentralityBin& other);
554 * Check if this is the 'all' bin
556 * @return true if low and high cuts are both zero
558 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
564 const char* GetListName() const;
566 * Create output objects
568 * @param dir Parent list
570 virtual void CreateOutputObjects(TList* dir);
574 * @param forward Forward data (for trigger, vertex, & centrality)
575 * @param triggerMask Trigger mask
576 * @param isZero True if this is a zero bin event
577 * @param vzMin Minimum IP z coordinate
578 * @param vzMax Maximum IP z coordinate
579 * @param data Data histogram
580 * @param mc MC histogram
582 virtual void ProcessEvent(const AliAODForwardMult* forward,
590 * Calculate the Event-Level normalization.
592 * The full event level normalization for trigger @f$X@f$ is given by
594 * N &=& \frac{1}{\epsilon_X}
595 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
596 * &=& \frac{1}{\epsilon_X}N_A
597 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
598 * &=& \frac{1}{\epsilon_X}N_A
599 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
600 * &=& \frac{1}{\epsilon_X}N_A
601 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
605 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
606 * efficiency evaluated in simulation.
607 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
608 * evaluated from the data
609 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
611 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
612 * @f$X@f$ which was also triggered as such.
613 * - @f$N_T@f$ is the number of data events that where triggered
614 * as type @f$X@f$ and had a collision trigger (CINT1B)
615 * - @f$N_V@f$ is the number of data events that where triggered
616 * as type @f$X@f$, had a collision trigger (CINT1B), and had
618 * - @f$N_{-V}@f$ is the number of data events that where triggered
619 * as type @f$X@f$, had a collision trigger (CINT1B), but no
621 * - @f$N_A@f$ is the number of data events that where triggered
622 * as type @f$X@f$, had a collision trigger (CINT1B), and had
623 * a vertex in the selected range.
624 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
625 * were also triggered as type @f$X@f$.
626 * - @f$N_a@f$ Number of beam-empty events also triggered as type
627 * @f$X@f$ events (CINT1-A or CINT1-AC).
628 * - @f$N_c@f$ Number of empty-beam events also triggered as type
629 * @f$X@f$ events (CINT1-C).
630 * - @f$N_e@f$ Number of empty-empty events also triggered as type
631 * @f$X@f$ events (CINT1-E).
633 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
634 * the expression simplyfies to
636 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
639 * @param t Histogram of triggers
640 * @param scheme Normalisation scheme
641 * @param trgEff Trigger efficiency
642 * @param ntotal On return, the total number of events to normalise to.
644 * @return @f$N_A/N@f$ or negative number in case of errors.
646 virtual Double_t Normalization(const TH1I& t,
649 Double_t& ntotal) const;
651 * Generate the dN/deta result from input
653 * @param sum Sum of 2D hists
654 * @param postfix Post fix on names
655 * @param rootProj Whether to use ROOT TH2::ProjectionX
656 * @param corrEmpty Correct for empty bins
657 * @param shapeCorr Shape correction to use
658 * @param scaler Event-level normalization scaler
659 * @param symmetrice Whether to make symmetric extensions
660 * @param rebin Whether to rebin
661 * @param cutEdges Whether to cut edges when rebinning
662 * @param marker Marker style
663 * @param color Color of markers
664 * @param mclist List of MC data
665 * @param truthlist List of MC truth data
667 virtual void MakeResult(const TH2D* sum,
671 const TH2F* shapeCorr,
683 * @param sums List of sums
684 * @param results Output list of results
685 * @param scheme Normalisation scheme options
686 * @param shapeCorr Shape correction or nil
687 * @param trigEff Trigger efficiency
688 * @param symmetrice Whether to symmetrice the results
689 * @param rebin Whether to rebin the results
690 * @param rootProj If true, use TH2::ProjectionX
691 * @param corrEmpty Whether to correct for empty bins
692 * @param cutEdges Whether to cut edges when rebinning
693 * @param triggerMask Trigger mask
694 * @param marker Marker style
695 * @param color Color of markers
696 * @param mclist List of MC data
697 * @param truthlist List of MC truth data
699 virtual void End(TList* sums,
702 const TH2F* shapeCorr,
716 * @name Access histograms
721 * @param mc If true, return MC histogram
723 * @return Sum histogram
725 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
729 * @param mc If true, return MC histogram
731 * @return Sum histogram
733 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
735 * Get trigger histogram
737 * @return Trigger histogram
739 const TH1I* GetTriggers() const { return fTriggers; }
741 * Get trigger histogram
743 * @return Trigger histogram
745 TH1I* GetTrigggers() { return fTriggers; }
749 * Get the color of the markers
751 * @param fallback Fall-back color
753 * @return Color for this centrality bin
755 Int_t GetColor(Int_t fallback=kRed+2) const;
757 * Get list of results
760 * @return List of results
762 TList* GetResults() const { return fOutput; }
764 * Get name of result histogram
772 const char* GetResultName(Int_t rebin, Bool_t sym,
773 const char* postfix="") const;
783 TH1* GetResult(Int_t rebin, Bool_t sym,
784 const char* postfix="") const;
786 * Set the debug level
788 * @param lvl Debug level
790 void SetDebugLevel(Int_t lvl);
793 * Read in sum hisotgram from list
795 * @param list List to read from
796 * @param mc True for MC input
798 * @return true if sum histogram is found
800 virtual Bool_t ReadSum(TList* list, bool mc=false);
802 * Create sum histogram
804 * @param data Data histogram to clone
805 * @param mc (optional) MC histogram to clone
807 virtual void CreateSums(const TH2D* data, const TH2D* mc);
809 * Check the trigger, vertex, and centrality
811 * @param forward Event input
812 * @param triggerMask The used trigger mask
813 * @param vzMin Least @f$ v_z@f$
814 * @param vzMax Largest @f$ v_z@f$
816 * @return true if the event is to be used
818 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
822 TList* fSums; // Output list
823 TList* fOutput; // Output list
824 Sum* fSum; // Sum histogram
825 Sum* fSumMC; // MC sum histogram
826 TH1I* fTriggers; // Trigger histogram
827 UShort_t fLow; // Lower limit (inclusive)
828 UShort_t fHigh; // Upper limit (exclusive)
829 Bool_t fDoFinalMCCorrection; //Do final MC correction
830 Int_t fDebug; // Debug level
832 ClassDef(CentralityBin,2); // A centrality bin
834 TList* fSums; // Container of sums
835 TList* fOutput; // Container of outputs
836 Double_t fVtxMin; // Minimum v_z
837 Double_t fVtxMax; // Maximum v_z
838 Int_t fTriggerMask; // Trigger mask
839 Int_t fRebin; // Rebinning factor
840 Bool_t fCutEdges; // Whether to cut edges when rebinning
841 Bool_t fSymmetrice; // Whether to symmetrice data
842 Bool_t fCorrEmpty; // Correct for empty bins
843 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
844 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
845 TH2F* fShapeCorr; // Shape correction
846 TObjArray* fListOfCentralities; // Centrality bins
847 TNamed* fSNNString; // sqrt(s_NN) string
848 TNamed* fSysString; // Collision system string
849 TH1D* fCent; // Centrality distribution
850 TAxis* fCentAxis; // Centrality axis
851 UShort_t fNormalizationScheme; // Normalization scheme
852 TNamed* fSchemeString; // Normalization scheme string
853 TNamed* fTriggerString; // Trigger string
854 TString fFinalMCCorrFile; //Filename for final MC corr
856 ClassDef(AliBasedNdetaTask,6); // Determine multiplicity in base area