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 * Set satellite vertex flag
192 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
194 * Get a string representing the normalization scheme
196 * @param scheme Normalization scheme bits
198 * @return String representation
200 static const Char_t* NormalizationSchemeString(UShort_t scheme);
202 * Parse a string representing the normalization scheme
204 * @param what String of the normalization scheme
206 * @return normalization scheme bits
208 static UShort_t ParseNormalizationScheme(const Char_t* what);
210 * Setthe normalisation scheme to use
212 * @param scheme Normalisation scheme
214 void SetNormalizationScheme(UShort_t scheme);
216 * Space, pipe, or comma separated list of options
218 * @param what List of options
220 void SetNormalizationScheme(const char* what);
222 * Filename of final MC correction
224 * @param filename filename
226 void SetMCFinalCorrFilename(const char* filename) {
227 fFinalMCCorrFile.Clear();
228 fFinalMCCorrFile.Append(filename);
231 * Load the normalization data - done automatically if not set from outside
234 * @param energy energy
236 void LoadNormalizationData(UShort_t sys, UShort_t energy);
241 * @param option Not used
243 void Print(Option_t* option="") const;
245 * @name Task interface
248 * Initialise on master - does nothing
251 virtual void Init() {}
253 * Create output objects.
255 * This is called once per slave process
257 virtual void UserCreateOutputObjects();
259 * Process a single event
261 * @param option Not used
263 virtual void UserExec(Option_t* option);
265 * Called at end of event processing.
267 * This is called once in the master
269 * @param option Not used
271 virtual void Terminate(Option_t* option);
276 * @name Services member functions
279 * Make a copy of the input histogram and rebin that histogram
281 * @param h Histogram to rebin
282 * @param rebin Rebinning factor
283 * @param cutEdges Whether to cut edges when rebinning
285 * @return New (rebinned) histogram
287 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
289 * Make an extension of @a h to make it symmetric about 0
291 * @param h Histogram to symmertrice
293 * @return Symmetric extension of @a h
295 static TH1* Symmetrice(const TH1* h);
297 * Project onto the X axis
299 * @param h 2D histogram
300 * @param name New name
301 * @param firstbin First bin to use
302 * @param lastbin Last bin to use
303 * @param useROOT Use TH2::ProjectionX instead of custom code
304 * @param corr Whether to do corrections or not
305 * @param error Whether to calculate errors
307 * @return Newly created histogram or null
309 static TH1D* ProjectX(const TH2D* h,
317 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
319 * @param copy Data to scale
320 * @param norm Coverage histogram
322 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
324 * Scale the copy of the 1D histogram by coverage in supplied 1D histogram
326 * @param copy Data to scale
327 * @param norm Coverage histogram
329 static void ScaleToCoverage(TH1D* copy, const TH1D* norm);
331 * Set histogram graphical options, etc.
333 * @param h Histogram to modify
334 * @param colour Marker color
335 * @param marker Marker style
336 * @param title Title of histogram
337 * @param ytitle Title on y-axis.
339 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
341 const char* ytitle="#frac{1}{N} #frac{dN_{ch}}{d#eta}");
353 kDownTriangle = 0x008,
359 * Get the marker style from option bits
361 * @param bits Option bits
363 * @return Marker style
365 static Int_t GetMarkerStyle(UShort_t bits);
367 * Get the marker option bits from a style
371 * @return option bits
373 static UShort_t GetMarkerBits(Int_t style);
377 * @param style Style parameter
381 static Int_t FlipHollowStyle(Int_t style);
382 /*Setter of empirical correction*/
383 void SetGlobalEmpiricalcorrection(TH2D* globalempiricalcorrection){fglobalempiricalcorrection=globalempiricalcorrection;}
388 AliBasedNdetaTask(const AliBasedNdetaTask&);
390 * Assignment operator
395 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&) { return *this; }
396 // Forward declaration
399 * Create the CentralityBin objects if not already done.
402 virtual void InitializeCentBins();
404 * Retrieve the histogram
406 * @param aod AOD event
407 * @param mc Whether to get the MC histogram or not
409 * @return Retrieved histogram or null
411 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
413 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
415 * @return Marker colour
417 virtual Int_t GetColor() const { return kBlack; }
419 * Get the marker style
421 * @return Marker style
423 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
425 * Massage data histograms if needed
431 virtual void CheckEventData(Double_t vtx,
435 * Add a centrality bin
437 * @param at Where in the list to add this bin
439 * @param high High cut
441 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
443 * Make a centrality bin
445 * @param name Name used for histograms
446 * @param low Low cut in percent
447 * @param high High cut in percent
449 * @return A newly created centrality bin
451 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
454 // function which applies empirical correction to the AOD object
455 Bool_t ApplyEmpiricalCorrection(const AliAODForwardMult* aod,TH2D* data);
456 //==================================================================
458 * Class that holds the sum of the data - possibly split into 0 or
462 struct Sum : public TNamed
464 TH2D* fSum; // Sum of non-zero events
465 TH2D* fSum0; // Sum of zero events
466 TH1I* fEvents; // Distribution of events
467 Int_t fDebug; // Debug level
469 * I/O Constructor - do not use
471 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
476 * @param postfix Possible post-fix
478 Sum(const char* name, const char* postfix)
479 : TNamed(name,postfix),
488 * @param o Object to copy from
498 * Assignment operator
500 * @param o Object to assign from
502 * @return Reference to this object
504 Sum& operator=(const Sum& o) {
505 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
513 * Initialise this object.
515 * @param list List to add histograms to
516 * @param data Format of data to be cloned here
519 void Init(TList* list, const TH2D* data, Int_t col);
523 * @param data Data to add
524 * @param isZero If this is zero event
526 void Add(const TH2D* data, Bool_t isZero=false);
528 * Get the histogram name
530 * @param name Base name
531 * @param what Which one
532 * @param post Possible postfix
536 static TString GetHistName(const char* name, Int_t what=0,
539 * Get the histogram name
541 * @param what Which one
545 TString GetHistName(Int_t what=0) const;
549 * @param o Output list
550 * @param ntotal On return, the total number of events
551 * @param zeroEff Zero-bin efficiency
552 * @param otherEff Non-zero-bin efficiency
553 * @param marker Marker to use
554 * @param rootXproj Whether to use TH2::ProjectionX
555 * @param corrEmpty Correct for empty bins
557 * @return The total sum histogram
559 TH2D* CalcSum(TList* o, Double_t& ntotal,
560 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
561 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
563 ClassDef(Sum,1); // Summed histograms
566 //==================================================================
568 * Calculations done per centrality
571 class CentralityBin : public TNamed
581 * @param name Name used for histograms (e.g., Forward)
582 * @param low Lower centrality cut in percent
583 * @param high Upper centrality cut in percent
585 CentralityBin(const char* name, Short_t low, Short_t high);
589 * @param other Object to copy from
591 CentralityBin(const CentralityBin& other);
595 virtual ~CentralityBin();
597 * Assignment operator
599 * @param other Object to assign from
601 * @return Reference to this
603 CentralityBin& operator=(const CentralityBin& other);
605 * Check if this is the 'all' bin
607 * @return true if low and high cuts are both zero
609 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
615 const char* GetListName() const;
617 * Create output objects
619 * @param dir Parent list
620 * @param mask Trigger mask
622 virtual void CreateOutputObjects(TList* dir, Int_t mask);
626 * @param forward Forward data (for trigger, vertex, & centrality)
627 * @param triggerMask Trigger mask
628 * @param isZero True if this is a zero bin event
629 * @param vzMin Minimum IP z coordinate
630 * @param vzMax Maximum IP z coordinate
631 * @param data Data histogram
632 * @param mc MC histogram
634 * @return true if the event was selected
636 virtual Bool_t ProcessEvent(const AliAODForwardMult* forward,
644 * Calculate the Event-Level normalization.
646 * The full event level normalization for trigger @f$X@f$ is given by
648 * N &=& \frac{1}{\epsilon_X}
649 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
650 * &=& \frac{1}{\epsilon_X}N_A
651 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
652 * &=& \frac{1}{\epsilon_X}N_A
653 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
654 * &=& \frac{1}{\epsilon_X}N_A
655 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
659 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
660 * efficiency evaluated in simulation.
661 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
662 * evaluated from the data
663 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
665 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
666 * @f$X@f$ which was also triggered as such.
667 * - @f$N_T@f$ is the number of data events that where triggered
668 * as type @f$X@f$ and had a collision trigger (CINT1B)
669 * - @f$N_V@f$ is the number of data events that where triggered
670 * as type @f$X@f$, had a collision trigger (CINT1B), and had
672 * - @f$N_{-V}@f$ is the number of data events that where triggered
673 * as type @f$X@f$, had a collision trigger (CINT1B), but no
675 * - @f$N_A@f$ is the number of data events that where triggered
676 * as type @f$X@f$, had a collision trigger (CINT1B), and had
677 * a vertex in the selected range.
678 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
679 * were also triggered as type @f$X@f$.
680 * - @f$N_a@f$ Number of beam-empty events also triggered as type
681 * @f$X@f$ events (CINT1-A or CINT1-AC).
682 * - @f$N_c@f$ Number of empty-beam events also triggered as type
683 * @f$X@f$ events (CINT1-C).
684 * - @f$N_e@f$ Number of empty-empty events also triggered as type
685 * @f$X@f$ events (CINT1-E).
687 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
688 * the expression simplyfies to
690 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
693 * @param t Histogram of triggers
694 * @param scheme Normalisation scheme
695 * @param trgEff Trigger efficiency
696 * @param ntotal On return, the total number of events to normalise to.
697 * @param text If non-null, fill with normalization calculation
699 * @return @f$N_A/N@f$ or negative number in case of errors.
701 virtual Double_t Normalization(const TH1I& t,
705 TString* text) const;
707 * Generate the dN/deta result from input
709 * @param sum Sum of 2D hists
710 * @param postfix Post fix on names
711 * @param rootProj Whether to use ROOT TH2::ProjectionX
712 * @param corrEmpty Correct for empty bins
713 * @param shapeCorr Shape correction to use
714 * @param scaler Event-level normalization scaler
715 * @param symmetrice Whether to make symmetric extensions
716 * @param rebin Whether to rebin
717 * @param cutEdges Whether to cut edges when rebinning
718 * @param marker Marker style
719 * @param color Color of markers
720 * @param mclist List of MC data
721 * @param truthlist List of MC truth data
723 virtual void MakeResult(const TH2D* sum,
727 const TH2F* shapeCorr,
739 * @param sums List of sums
740 * @param results Output list of results
741 * @param scheme Normalisation scheme options
742 * @param shapeCorr Shape correction or nil
743 * @param trigEff Trigger efficiency
744 * @param trigEff0 0-bin trigger efficiency
745 * @param symmetrice Whether to symmetrice the results
746 * @param rebin Whether to rebin the results
747 * @param rootProj If true, use TH2::ProjectionX
748 * @param corrEmpty Whether to correct for empty bins
749 * @param cutEdges Whether to cut edges when rebinning
750 * @param triggerMask Trigger mask
751 * @param marker Marker style
752 * @param color Color of markers
753 * @param mclist List of MC data
754 * @param truthlist List of MC truth data
756 virtual void End(TList* sums,
759 const TH2F* shapeCorr,
774 * @name Access histograms
779 * @param mc If true, return MC histogram
781 * @return Sum histogram
783 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
787 * @param mc If true, return MC histogram
789 * @return Sum histogram
791 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
793 * Get trigger histogram
795 * @return Trigger histogram
797 const TH1I* GetTriggers() const { return fTriggers; }
799 * Get trigger histogram
801 * @return Trigger histogram
803 TH1I* GetTriggers() { return fTriggers; }
805 * Get trigger histogram
807 * @return Trigger histogram
809 const TH1I* GetStatus() const { return fStatus; }
811 * Get trigger histogram
813 * @return Trigger histogram
815 TH1I* GetStatus() { return fStatus; }
819 * Get the color of the markers
821 * @param fallback Fall-back color
823 * @return Color for this centrality bin
825 Int_t GetColor(Int_t fallback=kRed+2) const;
827 * Get list of results
830 * @return List of results
832 TList* GetResults() const { return fOutput; }
834 * Get name of result histogram
842 const char* GetResultName(Int_t rebin, Bool_t sym,
843 const char* postfix="") const;
853 TH1* GetResult(Int_t rebin, Bool_t sym,
854 const char* postfix="") const;
856 * Set the debug level
858 * @param lvl Debug level
860 void SetDebugLevel(Int_t lvl);
862 * Set satellite vertex flag
866 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
869 * Read in sum hisotgram from list
871 * @param list List to read from
872 * @param mc True for MC input
874 * @return true if sum histogram is found
876 virtual Bool_t ReadSum(TList* list, bool mc=false);
878 * Create sum histogram
880 * @param data Data histogram to clone
881 * @param mc (optional) MC histogram to clone
883 virtual void CreateSums(const TH2D* data, const TH2D* mc);
885 * Check the trigger, vertex, and centrality
887 * @param forward Event input
888 * @param triggerMask The used trigger mask
889 * @param vzMin Least @f$ v_z@f$
890 * @param vzMax Largest @f$ v_z@f$
892 * @return true if the event is to be used
894 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
898 TList* fSums; // Output list
899 TList* fOutput; // Output list
900 Sum* fSum; // Sum histogram
901 Sum* fSumMC; // MC sum histogram
902 TH1I* fTriggers; // Trigger histogram
903 TH1I* fStatus; // Trigger histogram
904 UShort_t fLow; // Lower limit (inclusive)
905 UShort_t fHigh; // Upper limit (exclusive)
906 Bool_t fDoFinalMCCorrection; //Do final MC correction
907 Bool_t fSatelliteVertices; // Satellite vertex flag
908 Int_t fDebug; // Debug level
910 ClassDef(CentralityBin,3); // A centrality bin
912 TList* fSums; // Container of sums
913 TList* fOutput; // Container of outputs
914 Double_t fVtxMin; // Minimum v_z
915 Double_t fVtxMax; // Maximum v_z
916 Int_t fTriggerMask; // Trigger mask
917 Int_t fRebin; // Rebinning factor
918 Bool_t fCutEdges; // Whether to cut edges when rebinning
919 Bool_t fSymmetrice; // Whether to symmetrice data
920 Bool_t fCorrEmpty; // Correct for empty bins
921 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
922 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
923 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
924 TH2F* fShapeCorr; // Shape correction
925 TObjArray* fListOfCentralities; // Centrality bins
926 TObject* fSNNString; // sqrt(s_NN) string
927 TObject* fSysString; // Collision system string
928 TH1D* fCent; // Centrality distribution
929 TAxis* fCentAxis; // Centrality axis
930 TH1D* fVtx; // Vertex hist
931 UShort_t fNormalizationScheme; // Normalization scheme
932 TObject* fSchemeString; // Normalization scheme string
933 TObject* fTriggerString; // Trigger string
934 TString fFinalMCCorrFile; //Filename for final MC corr
935 Bool_t fSatelliteVertices; // satellite vertex flag
936 TH2D* fglobalempiricalcorrection; // the ratio of PbPb analysis normal displace vertex
937 TH2D* fmeabsignalvscentr; //mean signal per event vs cent
938 ClassDef(AliBasedNdetaTask,13); // Determine charged particle density