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);
376 /*Setter of empirical correction*/
377 void SetGlobalEmpiricalcorrection(TH2D* globalempiricalcorrection){fglobalempiricalcorrection=globalempiricalcorrection;}
382 AliBasedNdetaTask(const AliBasedNdetaTask&);
384 * Assignment operator
389 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&) { return *this; }
390 // Forward declaration
393 * Create the CentralityBin objects if not already done.
396 virtual void InitializeCentBins();
398 * Retrieve the histogram
400 * @param aod AOD event
401 * @param mc Whether to get the MC histogram or not
403 * @return Retrieved histogram or null
405 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
407 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
409 * @return Marker colour
411 virtual Int_t GetColor() const { return kBlack; }
413 * Get the marker style
415 * @return Marker style
417 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
419 * Add a centrality bin
421 * @param at Where in the list to add this bin
423 * @param high High cut
425 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
427 * Make a centrality bin
429 * @param name Name used for histograms
430 * @param low Low cut in percent
431 * @param high High cut in percent
433 * @return A newly created centrality bin
435 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
438 // function which applies empirical correction to the AOD object
439 Bool_t ApplyEmpiricalCorrection(const AliAODForwardMult* aod,TH2D* data);
440 //==================================================================
442 * Class that holds the sum of the data - possibly split into 0 or
446 struct Sum : public TNamed
448 TH2D* fSum; // Sum of non-zero events
449 TH2D* fSum0; // Sum of zero events
450 TH1I* fEvents; // Distribution of events
451 Int_t fDebug; // Debug level
453 * I/O Constructor - do not use
455 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
460 * @param postfix Possible post-fix
462 Sum(const char* name, const char* postfix)
463 : TNamed(name,postfix),
472 * @param o Object to copy from
482 * Assignment operator
484 * @param o Object to assign from
486 * @return Reference to this object
488 Sum& operator=(const Sum& o) {
489 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
497 * Initialise this object.
499 * @param list List to add histograms to
500 * @param data Format of data to be cloned here
503 void Init(TList* list, const TH2D* data, Int_t col);
507 * @param data Data to add
508 * @param isZero If this is zero event
510 void Add(const TH2D* data, Bool_t isZero=false);
512 * Get the histogram name
514 * @param name Base name
515 * @param what Which one
516 * @param post Possible postfix
520 static TString GetHistName(const char* name, Int_t what=0,
523 * Get the histogram name
525 * @param what Which one
529 TString GetHistName(Int_t what=0) const;
533 * @param o Output list
534 * @param ntotal On return, the total number of events
535 * @param zeroEff Zero-bin efficiency
536 * @param otherEff Non-zero-bin efficiency
537 * @param marker Marker to use
538 * @param rootXproj Whether to use TH2::ProjectionX
539 * @param corrEmpty Correct for empty bins
541 * @return The total sum histogram
543 TH2D* CalcSum(TList* o, Double_t& ntotal,
544 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
545 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
547 ClassDef(Sum,1); // Summed histograms
550 //==================================================================
552 * Calculations done per centrality
555 class CentralityBin : public TNamed
565 * @param name Name used for histograms (e.g., Forward)
566 * @param low Lower centrality cut in percent
567 * @param high Upper centrality cut in percent
569 CentralityBin(const char* name, Short_t low, Short_t high);
573 * @param other Object to copy from
575 CentralityBin(const CentralityBin& other);
579 virtual ~CentralityBin();
581 * Assignment operator
583 * @param other Object to assign from
585 * @return Reference to this
587 CentralityBin& operator=(const CentralityBin& other);
589 * Check if this is the 'all' bin
591 * @return true if low and high cuts are both zero
593 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
599 const char* GetListName() const;
601 * Create output objects
603 * @param dir Parent list
604 * @param mask Trigger mask
606 virtual void CreateOutputObjects(TList* dir, Int_t mask);
610 * @param forward Forward data (for trigger, vertex, & centrality)
611 * @param triggerMask Trigger mask
612 * @param isZero True if this is a zero bin event
613 * @param vzMin Minimum IP z coordinate
614 * @param vzMax Maximum IP z coordinate
615 * @param data Data histogram
616 * @param mc MC histogram
618 virtual void ProcessEvent(const AliAODForwardMult* forward,
626 * Calculate the Event-Level normalization.
628 * The full event level normalization for trigger @f$X@f$ is given by
630 * N &=& \frac{1}{\epsilon_X}
631 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
632 * &=& \frac{1}{\epsilon_X}N_A
633 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
634 * &=& \frac{1}{\epsilon_X}N_A
635 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
636 * &=& \frac{1}{\epsilon_X}N_A
637 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
641 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
642 * efficiency evaluated in simulation.
643 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
644 * evaluated from the data
645 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
647 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
648 * @f$X@f$ which was also triggered as such.
649 * - @f$N_T@f$ is the number of data events that where triggered
650 * as type @f$X@f$ and had a collision trigger (CINT1B)
651 * - @f$N_V@f$ is the number of data events that where triggered
652 * as type @f$X@f$, had a collision trigger (CINT1B), and had
654 * - @f$N_{-V}@f$ is the number of data events that where triggered
655 * as type @f$X@f$, had a collision trigger (CINT1B), but no
657 * - @f$N_A@f$ is the number of data events that where triggered
658 * as type @f$X@f$, had a collision trigger (CINT1B), and had
659 * a vertex in the selected range.
660 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
661 * were also triggered as type @f$X@f$.
662 * - @f$N_a@f$ Number of beam-empty events also triggered as type
663 * @f$X@f$ events (CINT1-A or CINT1-AC).
664 * - @f$N_c@f$ Number of empty-beam events also triggered as type
665 * @f$X@f$ events (CINT1-C).
666 * - @f$N_e@f$ Number of empty-empty events also triggered as type
667 * @f$X@f$ events (CINT1-E).
669 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
670 * the expression simplyfies to
672 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
675 * @param t Histogram of triggers
676 * @param scheme Normalisation scheme
677 * @param trgEff Trigger efficiency
678 * @param ntotal On return, the total number of events to normalise to.
679 * @param text If non-null, fill with normalization calculation
681 * @return @f$N_A/N@f$ or negative number in case of errors.
683 virtual Double_t Normalization(const TH1I& t,
687 TString* text) const;
689 * Generate the dN/deta result from input
691 * @param sum Sum of 2D hists
692 * @param postfix Post fix on names
693 * @param rootProj Whether to use ROOT TH2::ProjectionX
694 * @param corrEmpty Correct for empty bins
695 * @param shapeCorr Shape correction to use
696 * @param scaler Event-level normalization scaler
697 * @param symmetrice Whether to make symmetric extensions
698 * @param rebin Whether to rebin
699 * @param cutEdges Whether to cut edges when rebinning
700 * @param marker Marker style
701 * @param color Color of markers
702 * @param mclist List of MC data
703 * @param truthlist List of MC truth data
705 virtual void MakeResult(const TH2D* sum,
709 const TH2F* shapeCorr,
721 * @param sums List of sums
722 * @param results Output list of results
723 * @param scheme Normalisation scheme options
724 * @param shapeCorr Shape correction or nil
725 * @param trigEff Trigger efficiency
726 * @param trigEff0 0-bin trigger efficiency
727 * @param symmetrice Whether to symmetrice the results
728 * @param rebin Whether to rebin the results
729 * @param rootProj If true, use TH2::ProjectionX
730 * @param corrEmpty Whether to correct for empty bins
731 * @param cutEdges Whether to cut edges when rebinning
732 * @param triggerMask Trigger mask
733 * @param marker Marker style
734 * @param color Color of markers
735 * @param mclist List of MC data
736 * @param truthlist List of MC truth data
738 virtual void End(TList* sums,
741 const TH2F* shapeCorr,
756 * @name Access histograms
761 * @param mc If true, return MC histogram
763 * @return Sum histogram
765 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
769 * @param mc If true, return MC histogram
771 * @return Sum histogram
773 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
775 * Get trigger histogram
777 * @return Trigger histogram
779 const TH1I* GetTriggers() const { return fTriggers; }
781 * Get trigger histogram
783 * @return Trigger histogram
785 TH1I* GetTrigggers() { return fTriggers; }
789 * Get the color of the markers
791 * @param fallback Fall-back color
793 * @return Color for this centrality bin
795 Int_t GetColor(Int_t fallback=kRed+2) const;
797 * Get list of results
800 * @return List of results
802 TList* GetResults() const { return fOutput; }
804 * Get name of result histogram
812 const char* GetResultName(Int_t rebin, Bool_t sym,
813 const char* postfix="") const;
823 TH1* GetResult(Int_t rebin, Bool_t sym,
824 const char* postfix="") const;
826 * Set the debug level
828 * @param lvl Debug level
830 void SetDebugLevel(Int_t lvl);
833 * Read in sum hisotgram from list
835 * @param list List to read from
836 * @param mc True for MC input
838 * @return true if sum histogram is found
840 virtual Bool_t ReadSum(TList* list, bool mc=false);
842 * Create sum histogram
844 * @param data Data histogram to clone
845 * @param mc (optional) MC histogram to clone
847 virtual void CreateSums(const TH2D* data, const TH2D* mc);
849 * Check the trigger, vertex, and centrality
851 * @param forward Event input
852 * @param triggerMask The used trigger mask
853 * @param vzMin Least @f$ v_z@f$
854 * @param vzMax Largest @f$ v_z@f$
856 * @return true if the event is to be used
858 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
862 TList* fSums; // Output list
863 TList* fOutput; // Output list
864 Sum* fSum; // Sum histogram
865 Sum* fSumMC; // MC sum histogram
866 TH1I* fTriggers; // Trigger histogram
867 UShort_t fLow; // Lower limit (inclusive)
868 UShort_t fHigh; // Upper limit (exclusive)
869 Bool_t fDoFinalMCCorrection; //Do final MC correction
870 Int_t fDebug; // Debug level
872 ClassDef(CentralityBin,3); // A centrality bin
874 TList* fSums; // Container of sums
875 TList* fOutput; // Container of outputs
876 Double_t fVtxMin; // Minimum v_z
877 Double_t fVtxMax; // Maximum v_z
878 Int_t fTriggerMask; // Trigger mask
879 Int_t fRebin; // Rebinning factor
880 Bool_t fCutEdges; // Whether to cut edges when rebinning
881 Bool_t fSymmetrice; // Whether to symmetrice data
882 Bool_t fCorrEmpty; // Correct for empty bins
883 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
884 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
885 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
886 TH2F* fShapeCorr; // Shape correction
887 TObjArray* fListOfCentralities; // Centrality bins
888 TObject* fSNNString; // sqrt(s_NN) string
889 TObject* fSysString; // Collision system string
890 TH1D* fCent; // Centrality distribution
891 TAxis* fCentAxis; // Centrality axis
892 UShort_t fNormalizationScheme; // Normalization scheme
893 TObject* fSchemeString; // Normalization scheme string
894 TObject* fTriggerString; // Trigger string
895 TString fFinalMCCorrFile; //Filename for final MC corr
896 TH2D* fglobalempiricalcorrection; // the ratio of PbPb analysis normal displace vertex
897 TH2D* fmeabsignalvscentr; //mean signal per event vs cent
898 ClassDef(AliBasedNdetaTask,12); // Determine charged particle density