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)
506 if (&o == this) return *this;
507 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
515 * Initialise this object.
517 * @param list List to add histograms to
518 * @param data Format of data to be cloned here
521 void Init(TList* list, const TH2D* data, Int_t col);
525 * @param data Data to add
526 * @param isZero If this is zero event
528 void Add(const TH2D* data, Bool_t isZero=false);
530 * Get the histogram name
532 * @param name Base name
533 * @param what Which one
534 * @param post Possible postfix
538 static TString GetHistName(const char* name, Int_t what=0,
541 * Get the histogram name
543 * @param what Which one
547 TString GetHistName(Int_t what=0) const;
551 * @param o Output list
552 * @param ntotal On return, the total number of events
553 * @param zeroEff Zero-bin efficiency
554 * @param otherEff Non-zero-bin efficiency
555 * @param marker Marker to use
556 * @param rootXproj Whether to use TH2::ProjectionX
557 * @param corrEmpty Correct for empty bins
559 * @return The total sum histogram
561 TH2D* CalcSum(TList* o, Double_t& ntotal,
562 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
563 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
565 ClassDef(Sum,1); // Summed histograms
568 //==================================================================
570 * Calculations done per centrality
573 class CentralityBin : public TNamed
583 * @param name Name used for histograms (e.g., Forward)
584 * @param low Lower centrality cut in percent
585 * @param high Upper centrality cut in percent
587 CentralityBin(const char* name, Short_t low, Short_t high);
591 * @param other Object to copy from
593 CentralityBin(const CentralityBin& other);
597 virtual ~CentralityBin();
599 * Assignment operator
601 * @param other Object to assign from
603 * @return Reference to this
605 CentralityBin& operator=(const CentralityBin& other);
607 * Check if this is the 'all' bin
609 * @return true if low and high cuts are both zero
611 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
617 const char* GetListName() const;
619 * Create output objects
621 * @param dir Parent list
622 * @param mask Trigger mask
624 virtual void CreateOutputObjects(TList* dir, Int_t mask);
628 * @param forward Forward data (for trigger, vertex, & centrality)
629 * @param triggerMask Trigger mask
630 * @param isZero True if this is a zero bin event
631 * @param vzMin Minimum IP z coordinate
632 * @param vzMax Maximum IP z coordinate
633 * @param data Data histogram
634 * @param mc MC histogram
636 * @return true if the event was selected
638 virtual Bool_t ProcessEvent(const AliAODForwardMult* forward,
646 * Calculate the Event-Level normalization.
648 * The full event level normalization for trigger @f$X@f$ is given by
650 * N &=& \frac{1}{\epsilon_X}
651 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
652 * &=& \frac{1}{\epsilon_X}N_A
653 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
654 * &=& \frac{1}{\epsilon_X}N_A
655 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
656 * &=& \frac{1}{\epsilon_X}N_A
657 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
661 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
662 * efficiency evaluated in simulation.
663 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
664 * evaluated from the data
665 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
667 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
668 * @f$X@f$ which was also triggered as such.
669 * - @f$N_T@f$ is the number of data events that where triggered
670 * as type @f$X@f$ and had a collision trigger (CINT1B)
671 * - @f$N_V@f$ is the number of data events that where triggered
672 * as type @f$X@f$, had a collision trigger (CINT1B), and had
674 * - @f$N_{-V}@f$ is the number of data events that where triggered
675 * as type @f$X@f$, had a collision trigger (CINT1B), but no
677 * - @f$N_A@f$ is the number of data events that where triggered
678 * as type @f$X@f$, had a collision trigger (CINT1B), and had
679 * a vertex in the selected range.
680 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
681 * were also triggered as type @f$X@f$.
682 * - @f$N_a@f$ Number of beam-empty events also triggered as type
683 * @f$X@f$ events (CINT1-A or CINT1-AC).
684 * - @f$N_c@f$ Number of empty-beam events also triggered as type
685 * @f$X@f$ events (CINT1-C).
686 * - @f$N_e@f$ Number of empty-empty events also triggered as type
687 * @f$X@f$ events (CINT1-E).
689 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
690 * the expression simplyfies to
692 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
695 * @param t Histogram of triggers
696 * @param scheme Normalisation scheme
697 * @param trgEff Trigger efficiency
698 * @param ntotal On return, the total number of events to normalise to.
699 * @param text If non-null, fill with normalization calculation
701 * @return @f$N_A/N@f$ or negative number in case of errors.
703 virtual Double_t Normalization(const TH1I& t,
707 TString* text) const;
709 * Generate the dN/deta result from input
711 * @param sum Sum of 2D hists
712 * @param postfix Post fix on names
713 * @param rootProj Whether to use ROOT TH2::ProjectionX
714 * @param corrEmpty Correct for empty bins
715 * @param shapeCorr Shape correction to use
716 * @param scaler Event-level normalization scaler
717 * @param symmetrice Whether to make symmetric extensions
718 * @param rebin Whether to rebin
719 * @param cutEdges Whether to cut edges when rebinning
720 * @param marker Marker style
721 * @param color Color of markers
722 * @param mclist List of MC data
723 * @param truthlist List of MC truth data
725 virtual void MakeResult(const TH2D* sum,
729 const TH2F* shapeCorr,
741 * @param sums List of sums
742 * @param results Output list of results
743 * @param scheme Normalisation scheme options
744 * @param shapeCorr Shape correction or nil
745 * @param trigEff Trigger efficiency
746 * @param trigEff0 0-bin trigger efficiency
747 * @param symmetrice Whether to symmetrice the results
748 * @param rebin Whether to rebin the results
749 * @param rootProj If true, use TH2::ProjectionX
750 * @param corrEmpty Whether to correct for empty bins
751 * @param cutEdges Whether to cut edges when rebinning
752 * @param triggerMask Trigger mask
753 * @param marker Marker style
754 * @param color Color of markers
755 * @param mclist List of MC data
756 * @param truthlist List of MC truth data
758 virtual void End(TList* sums,
761 const TH2F* shapeCorr,
776 * @name Access histograms
781 * @param mc If true, return MC histogram
783 * @return Sum histogram
785 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
789 * @param mc If true, return MC histogram
791 * @return Sum histogram
793 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
795 * Get trigger histogram
797 * @return Trigger histogram
799 const TH1I* GetTriggers() const { return fTriggers; }
801 * Get trigger histogram
803 * @return Trigger histogram
805 TH1I* GetTriggers() { return fTriggers; }
807 * Get trigger histogram
809 * @return Trigger histogram
811 const TH1I* GetStatus() const { return fStatus; }
813 * Get trigger histogram
815 * @return Trigger histogram
817 TH1I* GetStatus() { return fStatus; }
821 * Get the color of the markers
823 * @param fallback Fall-back color
825 * @return Color for this centrality bin
827 Int_t GetColor(Int_t fallback=kRed+2) const;
829 * Get list of results
832 * @return List of results
834 TList* GetResults() const { return fOutput; }
836 * Get name of result histogram
844 const char* GetResultName(Int_t rebin, Bool_t sym,
845 const char* postfix="") const;
855 TH1* GetResult(Int_t rebin, Bool_t sym,
856 const char* postfix="") const;
858 * Set the debug level
860 * @param lvl Debug level
862 void SetDebugLevel(Int_t lvl);
864 * Set satellite vertex flag
868 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
871 * Read in sum hisotgram from list
873 * @param list List to read from
874 * @param mc True for MC input
876 * @return true if sum histogram is found
878 virtual Bool_t ReadSum(TList* list, bool mc=false);
880 * Create sum histogram
882 * @param data Data histogram to clone
883 * @param mc (optional) MC histogram to clone
885 virtual void CreateSums(const TH2D* data, const TH2D* mc);
887 * Check the trigger, vertex, and centrality
889 * @param forward Event input
890 * @param triggerMask The used trigger mask
891 * @param vzMin Least @f$ v_z@f$
892 * @param vzMax Largest @f$ v_z@f$
894 * @return true if the event is to be used
896 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
900 TList* fSums; // Output list
901 TList* fOutput; // Output list
902 Sum* fSum; // Sum histogram
903 Sum* fSumMC; // MC sum histogram
904 TH1I* fTriggers; // Trigger histogram
905 TH1I* fStatus; // Trigger histogram
906 UShort_t fLow; // Lower limit (inclusive)
907 UShort_t fHigh; // Upper limit (exclusive)
908 Bool_t fDoFinalMCCorrection; //Do final MC correction
909 Bool_t fSatelliteVertices; // Satellite vertex flag
910 Int_t fDebug; // Debug level
912 ClassDef(CentralityBin,3); // A centrality bin
914 TList* fSums; // Container of sums
915 TList* fOutput; // Container of outputs
916 Double_t fVtxMin; // Minimum v_z
917 Double_t fVtxMax; // Maximum v_z
918 Int_t fTriggerMask; // Trigger mask
919 Int_t fRebin; // Rebinning factor
920 Bool_t fCutEdges; // Whether to cut edges when rebinning
921 Bool_t fSymmetrice; // Whether to symmetrice data
922 Bool_t fCorrEmpty; // Correct for empty bins
923 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
924 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
925 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
926 TH2F* fShapeCorr; // Shape correction
927 TObjArray* fListOfCentralities; // Centrality bins
928 TObject* fSNNString; // sqrt(s_NN) string
929 TObject* fSysString; // Collision system string
930 TH1D* fCent; // Centrality distribution
931 TAxis* fCentAxis; // Centrality axis
932 TH1D* fVtx; // Vertex hist
933 UShort_t fNormalizationScheme; // Normalization scheme
934 TObject* fSchemeString; // Normalization scheme string
935 TObject* fTriggerString; // Trigger string
936 TString fFinalMCCorrFile; //Filename for final MC corr
937 Bool_t fSatelliteVertices; // satellite vertex flag
938 TH2D* fglobalempiricalcorrection; // the ratio of PbPb analysis normal displace vertex
939 TH2D* fmeabsignalvscentr; //mean signal per event vs cent
940 ClassDef(AliBasedNdetaTask,13); // Determine charged particle density