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>
17 #include <TParameter.h>
25 class AliAODForwardMult;
29 * @defgroup pwglf_forward_tasks_dndeta dN/deta tasks
31 * Code to produce @f$ dN/d\eta@f$
33 * @ingroup pwglf_forward_tasks
36 * @defgroup pwglf_forward_dndeta dN/deta
38 * @f$ dN/d\eta@f$ code
40 * @ingroup pwglf_forward_topical
43 * Base class for tasks to determine @f$ dN/d\eta@f$
45 * @ingroup pwglf_forward_tasks_dndeta
46 * @ingroup pwglf_forward_dndeta
48 class AliBasedNdetaTask : public AliAnalysisTaskSE
52 * Bit mask values of the normalisation scheme
55 /** Only normalize to accepted events */
58 * Do the full normalisation
60 * N = \frac{1}{\epsilon_X}(N_A-N_A/N_V(N_T-N_V)) =
61 * \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
66 * Do the shape correction
70 * Correct for background events (A+C-E). Not implemented yet
74 * Correct for the trigger efficiency from MC
76 kTriggerEfficiency = 0x8,
78 * Correct using zero-bin efficiency only
82 * Do the full correction
84 kFull = kEventLevel | kShape | kBackground | kTriggerEfficiency,
94 * @param name Name of task
96 AliBasedNdetaTask(const char* name);
101 virtual ~AliBasedNdetaTask();
105 * @name Task configuration
108 * Set the debug level
110 * @param level Debug level
112 virtual void SetDebugLevel(Int_t level);
114 * Set the vertex range to use
116 * @param min Minimum (in centermeter)
117 * @param max Maximum (in centermeter)
119 void SetVertexRange(Double_t min, Double_t max) { fVtxMin=min; fVtxMax=max; }
121 * Set the rebinning factor
123 * @param rebin Rebinning factor
125 void SetRebinning(Int_t rebin) { fRebin = rebin; }
127 * Set the trigger maskl
129 * @param mask Trigger mask
131 void SetTriggerMask(UShort_t mask);
133 * Set the trigger mask
135 * @param mask trigger mask
137 void SetTriggerMask(const char* mask);
139 * Set the centrality bins to use.
142 * UShort_t bins[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
143 * task->SetCentralityBins(11, bins);
146 * @param n Number of bins (elements in @a bins minus 1)
147 * @param bins Bin limits
149 void SetCentralityAxis(UShort_t n, Short_t* bins);
151 * Whether to cut edges when merging
153 * @param cut If true, cut edges
155 void SetCutEdges(Bool_t cut) {fCutEdges = cut;}
157 * Set whether to correct for empty bins when projecting on the X axis.
159 * @param use Whether to correct for empty bins
161 void SetCorrEmpty(Bool_t use) { fCorrEmpty = use; }
163 * Set whether to use the ROOT TH2::ProjectionX method when
164 * projecting on the X axis.
166 * @param use Whether to use TH2::ProjectionX
168 void SetUseROOTProjectX(Bool_t use) { fUseROOTProj = use; }
170 * Trigger efficiency for selected trigger(s)
172 * @param e Trigger efficiency
174 void SetTriggerEff(Double_t e) { fTriggerEff = e; }
176 * Set the shape correction (a.k.a., track correction) for selected
179 * @param h Correction
181 void SetShapeCorrection(const TH2F* h);
183 * Get a string representing the normalization scheme
185 * @param scheme Normalization scheme bits
187 * @return String representation
189 static const Char_t* NormalizationSchemeString(UShort_t scheme);
191 * Parse a string representing the normalization scheme
193 * @param what String of the normalization scheme
195 * @return normalization scheme bits
197 static UShort_t ParseNormalizationScheme(const Char_t* what);
199 * Setthe normalisation scheme to use
201 * @param scheme Normalisation scheme
203 void SetNormalizationScheme(UShort_t scheme);
205 * Space, pipe, or comma separated list of options
207 * @param what List of options
209 void SetNormalizationScheme(const char* what);
211 * Filename of final MC correction
213 * @param filename filename
215 void SetMCFinalCorrFilename(const char* filename) {
216 fFinalMCCorrFile.Clear();
217 fFinalMCCorrFile.Append(filename);
220 * Load the normalization data - done automatically if not set from outside
223 * @param energy energy
225 void LoadNormalizationData(UShort_t sys, UShort_t energy);
230 * @param option Not used
232 void Print(Option_t* option="") const;
234 * @name Task interface
237 * Initialise on master - does nothing
240 virtual void Init() {}
242 * Create output objects.
244 * This is called once per slave process
246 virtual void UserCreateOutputObjects();
248 * Process a single event
250 * @param option Not used
252 virtual void UserExec(Option_t* option);
254 * Called at end of event processing.
256 * This is called once in the master
258 * @param option Not used
260 virtual void Terminate(Option_t* option);
265 * @name Services member functions
268 * Make a copy of the input histogram and rebin that histogram
270 * @param h Histogram to rebin
271 * @param rebin Rebinning factor
272 * @param cutEdges Whether to cut edges when rebinning
274 * @return New (rebinned) histogram
276 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
278 * Make an extension of @a h to make it symmetric about 0
280 * @param h Histogram to symmertrice
282 * @return Symmetric extension of @a h
284 static TH1* Symmetrice(const TH1* h);
286 * Project onto the X axis
288 * @param h 2D histogram
289 * @param name New name
290 * @param firstbin First bin to use
291 * @param lastbin Last bin to use
292 * @param useROOT Use TH2::ProjectionX instead of custom code
293 * @param corr Whether to do corrections or not
294 * @param error Whether to calculate errors
296 * @return Newly created histogram or null
298 static TH1D* ProjectX(const TH2D* h,
306 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
308 * @param copy Data to scale
309 * @param norm Coverage histogram
311 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
313 * Set histogram graphical options, etc.
315 * @param h Histogram to modify
316 * @param colour Marker color
317 * @param marker Marker style
318 * @param title Title of histogram
319 * @param ytitle Title on y-axis.
321 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
323 const char* ytitle="#frac{1}{N} #frac{dN_{ch}}{d#eta}");
335 kDownTriangle = 0x008,
341 * Get the marker style from option bits
343 * @param bits Option bits
345 * @return Marker style
347 static Int_t GetMarkerStyle(UShort_t bits);
349 * Get the marker option bits from a style
353 * @return option bits
355 static UShort_t GetMarkerBits(Int_t style);
359 * @param style Style parameter
363 static Int_t FlipHollowStyle(Int_t style);
368 AliBasedNdetaTask(const AliBasedNdetaTask&);
370 * Assignment operator
375 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&) { return *this; }
376 // Forward declaration
379 * Create the CentralityBin objects if not already done.
382 virtual void InitializeCentBins();
384 * Retrieve the histogram
386 * @param aod AOD event
387 * @param mc Whether to get the MC histogram or not
389 * @return Retrieved histogram or null
391 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
393 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
395 * @return Marker colour
397 virtual Int_t GetColor() const { return kBlack; }
399 * Get the marker style
401 * @return Marker style
403 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
405 * Add a centrality bin
407 * @param at Where in the list to add this bin
409 * @param high High cut
411 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
413 * Make a centrality bin
415 * @param name Name used for histograms
416 * @param low Low cut in percent
417 * @param high High cut in percent
419 * @return A newly created centrality bin
421 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
424 //==================================================================
426 * Class that holds the sum of the data - possibly split into 0 or
430 struct Sum : public TNamed
432 TH2D* fSum; // Sum of non-zero events
433 TH2D* fSum0; // Sum of zero events
434 TH1I* fEvents; // Distribution of events
435 Int_t fDebug; // Debug level
437 * I/O Constructor - do not use
439 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
444 * @param postfix Possible post-fix
446 Sum(const char* name, const char* postfix)
447 : TNamed(name,postfix),
456 * @param o Object to copy from
466 * Assignment operator
468 * @param o Object to assign from
470 * @return Reference to this object
472 Sum& operator=(const Sum& o) {
473 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
481 * Initialise this object.
483 * @param list List to add histograms to
484 * @param data Format of data to be cloned here
487 void Init(TList* list, const TH2D* data, Int_t col);
491 * @param data Data to add
492 * @param isZero If this is zero event
494 void Add(const TH2D* data, Bool_t isZero=false);
496 * Get the histogram name
498 * @param name Base name
499 * @param what Which one
500 * @param post Possible postfix
504 static TString GetHistName(const char* name, Int_t what=0,
507 * Get the histogram name
509 * @param what Which one
513 TString GetHistName(Int_t what=0) const;
517 * @param o Output list
518 * @param ntotal On return, the total number of events
519 * @param zeroEff Zero-bin efficiency
520 * @param otherEff Non-zero-bin efficiency
521 * @param marker Marker to use
522 * @param rootXproj Whether to use TH2::ProjectionX
523 * @param corrEmpty Correct for empty bins
525 * @return The total sum histogram
527 TH2D* CalcSum(TList* o, Double_t& ntotal,
528 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
529 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
532 //==================================================================
534 * Calculations done per centrality
537 class CentralityBin : public TNamed
547 * @param name Name used for histograms (e.g., Forward)
548 * @param low Lower centrality cut in percent
549 * @param high Upper centrality cut in percent
551 CentralityBin(const char* name, Short_t low, Short_t high);
555 * @param other Object to copy from
557 CentralityBin(const CentralityBin& other);
561 virtual ~CentralityBin();
563 * Assignment operator
565 * @param other Object to assign from
567 * @return Reference to this
569 CentralityBin& operator=(const CentralityBin& other);
571 * Check if this is the 'all' bin
573 * @return true if low and high cuts are both zero
575 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
581 const char* GetListName() const;
583 * Create output objects
585 * @param dir Parent list
587 virtual void CreateOutputObjects(TList* dir);
591 * @param forward Forward data (for trigger, vertex, & centrality)
592 * @param triggerMask Trigger mask
593 * @param isZero True if this is a zero bin event
594 * @param vzMin Minimum IP z coordinate
595 * @param vzMax Maximum IP z coordinate
596 * @param data Data histogram
597 * @param mc MC histogram
599 virtual void ProcessEvent(const AliAODForwardMult* forward,
607 * Calculate the Event-Level normalization.
609 * The full event level normalization for trigger @f$X@f$ is given by
611 * N &=& \frac{1}{\epsilon_X}
612 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
613 * &=& \frac{1}{\epsilon_X}N_A
614 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
615 * &=& \frac{1}{\epsilon_X}N_A
616 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
617 * &=& \frac{1}{\epsilon_X}N_A
618 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
622 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
623 * efficiency evaluated in simulation.
624 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
625 * evaluated from the data
626 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
628 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
629 * @f$X@f$ which was also triggered as such.
630 * - @f$N_T@f$ is the number of data events that where triggered
631 * as type @f$X@f$ and had a collision trigger (CINT1B)
632 * - @f$N_V@f$ is the number of data events that where triggered
633 * as type @f$X@f$, had a collision trigger (CINT1B), and had
635 * - @f$N_{-V}@f$ is the number of data events that where triggered
636 * as type @f$X@f$, had a collision trigger (CINT1B), but no
638 * - @f$N_A@f$ is the number of data events that where triggered
639 * as type @f$X@f$, had a collision trigger (CINT1B), and had
640 * a vertex in the selected range.
641 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
642 * were also triggered as type @f$X@f$.
643 * - @f$N_a@f$ Number of beam-empty events also triggered as type
644 * @f$X@f$ events (CINT1-A or CINT1-AC).
645 * - @f$N_c@f$ Number of empty-beam events also triggered as type
646 * @f$X@f$ events (CINT1-C).
647 * - @f$N_e@f$ Number of empty-empty events also triggered as type
648 * @f$X@f$ events (CINT1-E).
650 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
651 * the expression simplyfies to
653 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
656 * @param t Histogram of triggers
657 * @param scheme Normalisation scheme
658 * @param trgEff Trigger efficiency
659 * @param ntotal On return, the total number of events to normalise to.
661 * @return @f$N_A/N@f$ or negative number in case of errors.
663 virtual Double_t Normalization(const TH1I& t,
666 Double_t& ntotal) const;
668 * Generate the dN/deta result from input
670 * @param sum Sum of 2D hists
671 * @param postfix Post fix on names
672 * @param rootProj Whether to use ROOT TH2::ProjectionX
673 * @param corrEmpty Correct for empty bins
674 * @param shapeCorr Shape correction to use
675 * @param scaler Event-level normalization scaler
676 * @param symmetrice Whether to make symmetric extensions
677 * @param rebin Whether to rebin
678 * @param cutEdges Whether to cut edges when rebinning
679 * @param marker Marker style
680 * @param color Color of markers
681 * @param mclist List of MC data
682 * @param truthlist List of MC truth data
684 virtual void MakeResult(const TH2D* sum,
688 const TH2F* shapeCorr,
700 * @param sums List of sums
701 * @param results Output list of results
702 * @param scheme Normalisation scheme options
703 * @param shapeCorr Shape correction or nil
704 * @param trigEff Trigger efficiency
705 * @param symmetrice Whether to symmetrice the results
706 * @param rebin Whether to rebin the results
707 * @param rootProj If true, use TH2::ProjectionX
708 * @param corrEmpty Whether to correct for empty bins
709 * @param cutEdges Whether to cut edges when rebinning
710 * @param triggerMask Trigger mask
711 * @param marker Marker style
712 * @param color Color of markers
713 * @param mclist List of MC data
714 * @param truthlist List of MC truth data
716 virtual void End(TList* sums,
719 const TH2F* shapeCorr,
733 * @name Access histograms
738 * @param mc If true, return MC histogram
740 * @return Sum histogram
742 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
746 * @param mc If true, return MC histogram
748 * @return Sum histogram
750 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
752 * Get trigger histogram
754 * @return Trigger histogram
756 const TH1I* GetTriggers() const { return fTriggers; }
758 * Get trigger histogram
760 * @return Trigger histogram
762 TH1I* GetTrigggers() { return fTriggers; }
766 * Get the color of the markers
768 * @param fallback Fall-back color
770 * @return Color for this centrality bin
772 Int_t GetColor(Int_t fallback=kRed+2) const;
774 * Get list of results
777 * @return List of results
779 TList* GetResults() const { return fOutput; }
781 * Get name of result histogram
789 const char* GetResultName(Int_t rebin, Bool_t sym,
790 const char* postfix="") const;
800 TH1* GetResult(Int_t rebin, Bool_t sym,
801 const char* postfix="") const;
803 * Set the debug level
805 * @param lvl Debug level
807 void SetDebugLevel(Int_t lvl);
810 * Read in sum hisotgram from list
812 * @param list List to read from
813 * @param mc True for MC input
815 * @return true if sum histogram is found
817 virtual Bool_t ReadSum(TList* list, bool mc=false);
819 * Create sum histogram
821 * @param data Data histogram to clone
822 * @param mc (optional) MC histogram to clone
824 virtual void CreateSums(const TH2D* data, const TH2D* mc);
826 * Check the trigger, vertex, and centrality
828 * @param forward Event input
829 * @param triggerMask The used trigger mask
830 * @param vzMin Least @f$ v_z@f$
831 * @param vzMax Largest @f$ v_z@f$
833 * @return true if the event is to be used
835 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
839 TList* fSums; // Output list
840 TList* fOutput; // Output list
841 Sum* fSum; // Sum histogram
842 Sum* fSumMC; // MC sum histogram
843 TH1I* fTriggers; // Trigger histogram
844 UShort_t fLow; // Lower limit (inclusive)
845 UShort_t fHigh; // Upper limit (exclusive)
846 Bool_t fDoFinalMCCorrection; //Do final MC correction
847 Int_t fDebug; // Debug level
849 ClassDef(CentralityBin,2); // A centrality bin
851 TList* fSums; // Container of sums
852 TList* fOutput; // Container of outputs
853 Double_t fVtxMin; // Minimum v_z
854 Double_t fVtxMax; // Maximum v_z
855 Int_t fTriggerMask; // Trigger mask
856 Int_t fRebin; // Rebinning factor
857 Bool_t fCutEdges; // Whether to cut edges when rebinning
858 Bool_t fSymmetrice; // Whether to symmetrice data
859 Bool_t fCorrEmpty; // Correct for empty bins
860 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
861 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
862 TH2F* fShapeCorr; // Shape correction
863 TObjArray* fListOfCentralities; // Centrality bins
865 TNamed* fSNNString; // sqrt(s_NN) string
866 TNamed* fSysString; // Collision system string
868 TParameter<int>* fSNNString; // sqrt(s_NN) string
869 TParameter<int>* fSysString; // Collision system string
871 TH1D* fCent; // Centrality distribution
872 TAxis* fCentAxis; // Centrality axis
873 UShort_t fNormalizationScheme; // Normalization scheme
875 TNamed* fSchemeString; // Normalization scheme string
876 TNamed* fTriggerString; // Trigger string
878 TParameter<int>* fSchemeString; // Normalization scheme string
879 TParameter<int>* fTriggerString; // Trigger string
881 TString fFinalMCCorrFile; //Filename for final MC corr
883 ClassDef(AliBasedNdetaTask,7); // Determine multiplicity in base area