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 * Trigger efficiency for 0-bin for selected trigger(s)
177 * @param e Trigger efficiency for 0-bin
179 void SetTriggerEff0(Double_t e) { fTriggerEff0 = e; }
181 * Set the shape correction (a.k.a., track correction) for selected
184 * @param h Correction
186 void SetShapeCorrection(const TH2F* h);
188 * Get a string representing the normalization scheme
190 * @param scheme Normalization scheme bits
192 * @return String representation
194 static const Char_t* NormalizationSchemeString(UShort_t scheme);
196 * Parse a string representing the normalization scheme
198 * @param what String of the normalization scheme
200 * @return normalization scheme bits
202 static UShort_t ParseNormalizationScheme(const Char_t* what);
204 * Setthe normalisation scheme to use
206 * @param scheme Normalisation scheme
208 void SetNormalizationScheme(UShort_t scheme);
210 * Space, pipe, or comma separated list of options
212 * @param what List of options
214 void SetNormalizationScheme(const char* what);
216 * Filename of final MC correction
218 * @param filename filename
220 void SetMCFinalCorrFilename(const char* filename) {
221 fFinalMCCorrFile.Clear();
222 fFinalMCCorrFile.Append(filename);
225 * Load the normalization data - done automatically if not set from outside
228 * @param energy energy
230 void LoadNormalizationData(UShort_t sys, UShort_t energy);
235 * @param option Not used
237 void Print(Option_t* option="") const;
239 * @name Task interface
242 * Initialise on master - does nothing
245 virtual void Init() {}
247 * Create output objects.
249 * This is called once per slave process
251 virtual void UserCreateOutputObjects();
253 * Process a single event
255 * @param option Not used
257 virtual void UserExec(Option_t* option);
259 * Called at end of event processing.
261 * This is called once in the master
263 * @param option Not used
265 virtual void Terminate(Option_t* option);
270 * @name Services member functions
273 * Make a copy of the input histogram and rebin that histogram
275 * @param h Histogram to rebin
276 * @param rebin Rebinning factor
277 * @param cutEdges Whether to cut edges when rebinning
279 * @return New (rebinned) histogram
281 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
283 * Make an extension of @a h to make it symmetric about 0
285 * @param h Histogram to symmertrice
287 * @return Symmetric extension of @a h
289 static TH1* Symmetrice(const TH1* h);
291 * Project onto the X axis
293 * @param h 2D histogram
294 * @param name New name
295 * @param firstbin First bin to use
296 * @param lastbin Last bin to use
297 * @param useROOT Use TH2::ProjectionX instead of custom code
298 * @param corr Whether to do corrections or not
299 * @param error Whether to calculate errors
301 * @return Newly created histogram or null
303 static TH1D* ProjectX(const TH2D* h,
311 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
313 * @param copy Data to scale
314 * @param norm Coverage histogram
316 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
318 * Scale the copy of the 1D histogram by coverage in supplied 1D histogram
320 * @param copy Data to scale
321 * @param norm Coverage histogram
323 static void ScaleToCoverage(TH1D* copy, const TH1D* norm);
325 * Set histogram graphical options, etc.
327 * @param h Histogram to modify
328 * @param colour Marker color
329 * @param marker Marker style
330 * @param title Title of histogram
331 * @param ytitle Title on y-axis.
333 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
335 const char* ytitle="#frac{1}{N} #frac{dN_{ch}}{d#eta}");
347 kDownTriangle = 0x008,
353 * Get the marker style from option bits
355 * @param bits Option bits
357 * @return Marker style
359 static Int_t GetMarkerStyle(UShort_t bits);
361 * Get the marker option bits from a style
365 * @return option bits
367 static UShort_t GetMarkerBits(Int_t style);
371 * @param style Style parameter
375 static Int_t FlipHollowStyle(Int_t style);
380 AliBasedNdetaTask(const AliBasedNdetaTask&);
382 * Assignment operator
387 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&) { return *this; }
388 // Forward declaration
391 * Create the CentralityBin objects if not already done.
394 virtual void InitializeCentBins();
396 * Retrieve the histogram
398 * @param aod AOD event
399 * @param mc Whether to get the MC histogram or not
401 * @return Retrieved histogram or null
403 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
405 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
407 * @return Marker colour
409 virtual Int_t GetColor() const { return kBlack; }
411 * Get the marker style
413 * @return Marker style
415 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
417 * Add a centrality bin
419 * @param at Where in the list to add this bin
421 * @param high High cut
423 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
425 * Make a centrality bin
427 * @param name Name used for histograms
428 * @param low Low cut in percent
429 * @param high High cut in percent
431 * @return A newly created centrality bin
433 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
436 //==================================================================
438 * Class that holds the sum of the data - possibly split into 0 or
442 struct Sum : public TNamed
444 TH2D* fSum; // Sum of non-zero events
445 TH2D* fSum0; // Sum of zero events
446 TH1I* fEvents; // Distribution of events
447 Int_t fDebug; // Debug level
449 * I/O Constructor - do not use
451 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
456 * @param postfix Possible post-fix
458 Sum(const char* name, const char* postfix)
459 : TNamed(name,postfix),
468 * @param o Object to copy from
478 * Assignment operator
480 * @param o Object to assign from
482 * @return Reference to this object
484 Sum& operator=(const Sum& o) {
485 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
493 * Initialise this object.
495 * @param list List to add histograms to
496 * @param data Format of data to be cloned here
499 void Init(TList* list, const TH2D* data, Int_t col);
503 * @param data Data to add
504 * @param isZero If this is zero event
506 void Add(const TH2D* data, Bool_t isZero=false);
508 * Get the histogram name
510 * @param name Base name
511 * @param what Which one
512 * @param post Possible postfix
516 static TString GetHistName(const char* name, Int_t what=0,
519 * Get the histogram name
521 * @param what Which one
525 TString GetHistName(Int_t what=0) const;
529 * @param o Output list
530 * @param ntotal On return, the total number of events
531 * @param zeroEff Zero-bin efficiency
532 * @param otherEff Non-zero-bin efficiency
533 * @param marker Marker to use
534 * @param rootXproj Whether to use TH2::ProjectionX
535 * @param corrEmpty Correct for empty bins
537 * @return The total sum histogram
539 TH2D* CalcSum(TList* o, Double_t& ntotal,
540 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
541 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
544 //==================================================================
546 * Calculations done per centrality
549 class CentralityBin : public TNamed
559 * @param name Name used for histograms (e.g., Forward)
560 * @param low Lower centrality cut in percent
561 * @param high Upper centrality cut in percent
563 CentralityBin(const char* name, Short_t low, Short_t high);
567 * @param other Object to copy from
569 CentralityBin(const CentralityBin& other);
573 virtual ~CentralityBin();
575 * Assignment operator
577 * @param other Object to assign from
579 * @return Reference to this
581 CentralityBin& operator=(const CentralityBin& other);
583 * Check if this is the 'all' bin
585 * @return true if low and high cuts are both zero
587 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
593 const char* GetListName() const;
595 * Create output objects
597 * @param dir Parent list
598 * @param mask Trigger mask
600 virtual void CreateOutputObjects(TList* dir, Int_t mask);
604 * @param forward Forward data (for trigger, vertex, & centrality)
605 * @param triggerMask Trigger mask
606 * @param isZero True if this is a zero bin event
607 * @param vzMin Minimum IP z coordinate
608 * @param vzMax Maximum IP z coordinate
609 * @param data Data histogram
610 * @param mc MC histogram
612 virtual void ProcessEvent(const AliAODForwardMult* forward,
620 * Calculate the Event-Level normalization.
622 * The full event level normalization for trigger @f$X@f$ is given by
624 * N &=& \frac{1}{\epsilon_X}
625 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
626 * &=& \frac{1}{\epsilon_X}N_A
627 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
628 * &=& \frac{1}{\epsilon_X}N_A
629 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
630 * &=& \frac{1}{\epsilon_X}N_A
631 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
635 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
636 * efficiency evaluated in simulation.
637 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
638 * evaluated from the data
639 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
641 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
642 * @f$X@f$ which was also triggered as such.
643 * - @f$N_T@f$ is the number of data events that where triggered
644 * as type @f$X@f$ and had a collision trigger (CINT1B)
645 * - @f$N_V@f$ is the number of data events that where triggered
646 * as type @f$X@f$, had a collision trigger (CINT1B), and had
648 * - @f$N_{-V}@f$ is the number of data events that where triggered
649 * as type @f$X@f$, had a collision trigger (CINT1B), but no
651 * - @f$N_A@f$ is the number of data events that where triggered
652 * as type @f$X@f$, had a collision trigger (CINT1B), and had
653 * a vertex in the selected range.
654 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
655 * were also triggered as type @f$X@f$.
656 * - @f$N_a@f$ Number of beam-empty events also triggered as type
657 * @f$X@f$ events (CINT1-A or CINT1-AC).
658 * - @f$N_c@f$ Number of empty-beam events also triggered as type
659 * @f$X@f$ events (CINT1-C).
660 * - @f$N_e@f$ Number of empty-empty events also triggered as type
661 * @f$X@f$ events (CINT1-E).
663 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
664 * the expression simplyfies to
666 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
669 * @param t Histogram of triggers
670 * @param scheme Normalisation scheme
671 * @param trgEff Trigger efficiency
672 * @param ntotal On return, the total number of events to normalise to.
673 * @param text If non-null, fill with normalization calculation
675 * @return @f$N_A/N@f$ or negative number in case of errors.
677 virtual Double_t Normalization(const TH1I& t,
681 TString* text) const;
683 * Generate the dN/deta result from input
685 * @param sum Sum of 2D hists
686 * @param postfix Post fix on names
687 * @param rootProj Whether to use ROOT TH2::ProjectionX
688 * @param corrEmpty Correct for empty bins
689 * @param shapeCorr Shape correction to use
690 * @param scaler Event-level normalization scaler
691 * @param symmetrice Whether to make symmetric extensions
692 * @param rebin Whether to rebin
693 * @param cutEdges Whether to cut edges when rebinning
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 MakeResult(const TH2D* sum,
703 const TH2F* shapeCorr,
715 * @param sums List of sums
716 * @param results Output list of results
717 * @param scheme Normalisation scheme options
718 * @param shapeCorr Shape correction or nil
719 * @param trigEff Trigger efficiency
720 * @param trigEff0 0-bin trigger efficiency
721 * @param symmetrice Whether to symmetrice the results
722 * @param rebin Whether to rebin the results
723 * @param rootProj If true, use TH2::ProjectionX
724 * @param corrEmpty Whether to correct for empty bins
725 * @param cutEdges Whether to cut edges when rebinning
726 * @param triggerMask Trigger mask
727 * @param marker Marker style
728 * @param color Color of markers
729 * @param mclist List of MC data
730 * @param truthlist List of MC truth data
732 virtual void End(TList* sums,
735 const TH2F* shapeCorr,
750 * @name Access histograms
755 * @param mc If true, return MC histogram
757 * @return Sum histogram
759 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
763 * @param mc If true, return MC histogram
765 * @return Sum histogram
767 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
769 * Get trigger histogram
771 * @return Trigger histogram
773 const TH1I* GetTriggers() const { return fTriggers; }
775 * Get trigger histogram
777 * @return Trigger histogram
779 TH1I* GetTrigggers() { return fTriggers; }
783 * Get the color of the markers
785 * @param fallback Fall-back color
787 * @return Color for this centrality bin
789 Int_t GetColor(Int_t fallback=kRed+2) const;
791 * Get list of results
794 * @return List of results
796 TList* GetResults() const { return fOutput; }
798 * Get name of result histogram
806 const char* GetResultName(Int_t rebin, Bool_t sym,
807 const char* postfix="") const;
817 TH1* GetResult(Int_t rebin, Bool_t sym,
818 const char* postfix="") const;
820 * Set the debug level
822 * @param lvl Debug level
824 void SetDebugLevel(Int_t lvl);
827 * Read in sum hisotgram from list
829 * @param list List to read from
830 * @param mc True for MC input
832 * @return true if sum histogram is found
834 virtual Bool_t ReadSum(TList* list, bool mc=false);
836 * Create sum histogram
838 * @param data Data histogram to clone
839 * @param mc (optional) MC histogram to clone
841 virtual void CreateSums(const TH2D* data, const TH2D* mc);
843 * Check the trigger, vertex, and centrality
845 * @param forward Event input
846 * @param triggerMask The used trigger mask
847 * @param vzMin Least @f$ v_z@f$
848 * @param vzMax Largest @f$ v_z@f$
850 * @return true if the event is to be used
852 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
856 TList* fSums; // Output list
857 TList* fOutput; // Output list
858 Sum* fSum; // Sum histogram
859 Sum* fSumMC; // MC sum histogram
860 TH1I* fTriggers; // Trigger histogram
861 UShort_t fLow; // Lower limit (inclusive)
862 UShort_t fHigh; // Upper limit (exclusive)
863 Bool_t fDoFinalMCCorrection; //Do final MC correction
864 Int_t fDebug; // Debug level
866 ClassDef(CentralityBin,3); // A centrality bin
868 TList* fSums; // Container of sums
869 TList* fOutput; // Container of outputs
870 Double_t fVtxMin; // Minimum v_z
871 Double_t fVtxMax; // Maximum v_z
872 Int_t fTriggerMask; // Trigger mask
873 Int_t fRebin; // Rebinning factor
874 Bool_t fCutEdges; // Whether to cut edges when rebinning
875 Bool_t fSymmetrice; // Whether to symmetrice data
876 Bool_t fCorrEmpty; // Correct for empty bins
877 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
878 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
879 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
880 TH2F* fShapeCorr; // Shape correction
881 TObjArray* fListOfCentralities; // Centrality bins
882 TObject* fSNNString; // sqrt(s_NN) string
883 TObject* fSysString; // Collision system string
884 TH1D* fCent; // Centrality distribution
885 TAxis* fCentAxis; // Centrality axis
886 UShort_t fNormalizationScheme; // Normalization scheme
887 TObject* fSchemeString; // Normalization scheme string
888 TObject* fTriggerString; // Trigger string
889 TString fFinalMCCorrFile; //Filename for final MC corr
891 ClassDef(AliBasedNdetaTask,10); // Determine charged particle density