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 "AliBaseAODTask.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 AliBaseAODTask
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 rebinning factor
115 * @param rebin Rebinning factor
117 void SetRebinning(Int_t rebin) { fRebin = rebin; }
119 * Whether to cut edges when merging
121 * @param cut If true, cut edges
123 void SetCutEdges(Bool_t cut) {fCutEdges = cut;}
125 * Set whether to correct for empty bins when projecting on the X axis.
127 * @param use Whether to correct for empty bins
129 void SetCorrEmpty(Bool_t use) { fCorrEmpty = use; }
131 * Set whether to use the ROOT TH2::ProjectionX method when
132 * projecting on the X axis.
134 * @param use Whether to use TH2::ProjectionX
136 void SetUseROOTProjectX(Bool_t use) { fUseROOTProj = use; }
138 * Trigger efficiency for selected trigger(s)
140 * @param e Trigger efficiency
142 void SetTriggerEff(Double_t e) { fTriggerEff = e; }
144 * Trigger efficiency for 0-bin for selected trigger(s)
146 * @param e Trigger efficiency for 0-bin
148 void SetTriggerEff0(Double_t e) { fTriggerEff0 = e; }
150 * Set the shape correction (a.k.a., track correction) for selected
153 * @param h Correction
155 void SetShapeCorrection(const TH2F* h);
157 * Set satellite vertex flag
161 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
163 * Get a string representing the normalization scheme
165 * @param scheme Normalization scheme bits
167 * @return String representation
169 static const Char_t* NormalizationSchemeString(UShort_t scheme);
171 * Parse a string representing the normalization scheme
173 * @param what String of the normalization scheme
175 * @return normalization scheme bits
177 static UShort_t ParseNormalizationScheme(const Char_t* what);
179 * Setthe normalisation scheme to use
181 * @param scheme Normalisation scheme
183 void SetNormalizationScheme(UShort_t scheme);
185 * Space, pipe, or comma separated list of options
187 * @param what List of options
189 void SetNormalizationScheme(const char* what);
191 * Filename of final MC correction
193 * @param filename filename
195 void SetMCFinalCorrFilename(const char* filename) {
196 fFinalMCCorrFile.Clear();
197 fFinalMCCorrFile.Append(filename);
200 * Load the normalization data - done automatically if not set from outside
203 * @param energy energy
205 void LoadNormalizationData(UShort_t sys, UShort_t energy);
210 * @param option Not used
212 void Print(Option_t* option="") const;
214 * @name Task interface
217 * Create output objects.
219 * This is called once per slave process
221 * @return true on success
223 virtual Bool_t Book();
225 * Process a single event
227 * @return true on success
229 virtual Bool_t Event(AliAODEvent& aod);
231 * Called at end of event processing.
233 * This is called once in the master
235 * @return true on success
237 virtual Bool_t Finalize();
242 * @name Services member functions
245 * Make a copy of the input histogram and rebin that histogram
247 * @param h Histogram to rebin
248 * @param rebin Rebinning factor
249 * @param cutEdges Whether to cut edges when rebinning
251 * @return New (rebinned) histogram
253 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
255 * Make an extension of @a h to make it symmetric about 0
257 * @param h Histogram to symmertrice
259 * @return Symmetric extension of @a h
261 static TH1* Symmetrice(const TH1* h);
263 * Project onto the X axis
265 * @param h 2D histogram
266 * @param name New name
267 * @param firstbin First bin to use
268 * @param lastbin Last bin to use
269 * @param useROOT Use TH2::ProjectionX instead of custom code
270 * @param corr Whether to do corrections or not
271 * @param error Whether to calculate errors
273 * @return Newly created histogram or null
275 static TH1D* ProjectX(const TH2D* h,
283 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
285 * @param copy Data to scale
286 * @param norm Coverage histogram
288 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
290 * Scale the copy of the 1D histogram by coverage in supplied 1D histogram
292 * @param copy Data to scale
293 * @param norm Coverage histogram
295 static void ScaleToCoverage(TH1D* copy, const TH1D* norm);
297 * Set histogram graphical options, etc.
299 * @param h Histogram to modify
300 * @param colour Marker color
301 * @param marker Marker style
302 * @param title Title of histogram
303 * @param ytitle Title on y-axis.
305 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
307 const char* ytitle=0);
319 kDownTriangle = 0x008,
325 * Get the marker style from option bits
327 * @param bits Option bits
329 * @return Marker style
331 static Int_t GetMarkerStyle(UShort_t bits);
333 * Get the marker option bits from a style
337 * @return option bits
339 static UShort_t GetMarkerBits(Int_t style);
343 * @param style Style parameter
347 static Int_t FlipHollowStyle(Int_t style);
349 * Setter of empirical correction
351 * @param h 2D histogram of ratio of nominal @f$ 1/N
352 * dN_{ch}/d\eta@f$ to satellite @f$ 1/N dN_{ch}/d\eta@f$ in PbPb
353 * collisions as a function of @f$\eta@f$ and interaction point
354 * Z-coordinate @f$ IP_{z}@f$
356 void SetGlobalEmpiricalcorrection(TH2D* h){fEmpiricalCorrection=h;}
359 * Copy contructor - not defined
361 AliBasedNdetaTask(const AliBasedNdetaTask&);
363 * Assignment operator - not defined
368 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&);
369 // Forward declaration
372 * Check if the event corresponds to the selected trigger(s),
373 * vertex, and centrality. Derived classes can overload this to
374 * enable event processing - even if the event is not within cuts.
376 * @param forward Forward object
378 * @return true if the event is within the cuts.
380 virtual Bool_t CheckEvent(const AliAODForwardMult& forward);
382 * Create the CentralityBin objects if not already done.
385 virtual void InitializeCentBins();
387 * Retrieve the histogram
389 * @param aod AOD event
390 * @param mc Whether to get the MC histogram or not
392 * @return Retrieved histogram or null
394 virtual TH2D* GetHistogram(const AliAODEvent& aod, Bool_t mc=false) = 0;
396 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
398 * @return Marker colour
400 virtual Int_t GetColor() const { return kBlack; }
402 * Get the marker style
404 * @return Marker style
406 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
408 * Massage data histograms if needed
414 virtual void CheckEventData(Double_t vtx,
418 * Add a centrality bin
420 * @param at Where in the list to add this bin
422 * @param high High cut
424 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
426 * Make a centrality bin
428 * @param name Name used for histograms
429 * @param low Low cut in percent
430 * @param high High cut in percent
432 * @return A newly created centrality bin
434 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
437 // function which applies empirical correction to the AOD object
438 Bool_t ApplyEmpiricalCorrection(const AliAODForwardMult* aod,TH2D* data);
439 //==================================================================
441 * Class that holds the sum of the data - possibly split into 0 or
445 struct Sum : public TNamed
447 TH2D* fSum; // Sum of non-zero events
448 TH2D* fSum0; // Sum of zero events
449 TH1I* fEvents; // Distribution of events
450 Int_t fDebug; // Debug level
452 * I/O Constructor - do not use
454 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
459 * @param postfix Possible post-fix
461 Sum(const char* name, const char* postfix)
462 : TNamed(name,postfix),
471 * @param o Object to copy from
481 * Assignment operator
483 * @param o Object to assign from
485 * @return Reference to this object
487 Sum& operator=(const Sum& o)
489 if (&o == this) return *this;
490 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
498 * Initialise this object.
500 * @param list List to add histograms to
501 * @param data Format of data to be cloned here
504 void Init(TList* list, const TH2D* data, Int_t col);
508 * @param data Data to add
509 * @param isZero If this is zero event
511 void Add(const TH2D* data, Bool_t isZero=false);
513 * Get the histogram name
515 * @param name Base name
516 * @param what Which one
517 * @param post Possible postfix
521 static TString GetHistName(const char* name, Int_t what=0,
524 * Get the histogram name
526 * @param what Which one
530 TString GetHistName(Int_t what=0) const;
534 * @param o Output list
535 * @param ntotal On return, the total number of events
536 * @param zeroEff Zero-bin efficiency
537 * @param otherEff Non-zero-bin efficiency
538 * @param marker Marker to use
539 * @param rootXproj Whether to use TH2::ProjectionX
540 * @param corrEmpty Correct for empty bins
542 * @return The total sum histogram
544 TH2D* CalcSum(TList* o, Double_t& ntotal,
545 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
546 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
548 ClassDef(Sum,2); // Summed histograms
551 //==================================================================
553 * Calculations done per centrality
556 class CentralityBin : public TNamed
566 * @param name Name used for histograms (e.g., Forward)
567 * @param low Lower centrality cut in percent
568 * @param high Upper centrality cut in percent
570 CentralityBin(const char* name, Short_t low, Short_t high);
574 * @param other Object to copy from
576 CentralityBin(const CentralityBin& other);
580 virtual ~CentralityBin();
582 * Assignment operator
584 * @param other Object to assign from
586 * @return Reference to this
588 CentralityBin& operator=(const CentralityBin& other);
590 * Check if this is the 'all' bin
592 * @return true if low and high cuts are both zero
594 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
600 const char* GetListName() const;
602 * Create output objects
604 * @param dir Parent list
605 * @param mask Trigger mask
607 virtual void CreateOutputObjects(TList* dir, Int_t mask);
611 * @param forward Forward data (for trigger, vertex, & centrality)
612 * @param triggerMask Trigger mask
613 * @param isZero True if this is a zero bin event
614 * @param vzMin Minimum IP z coordinate
615 * @param vzMax Maximum IP z coordinate
616 * @param data Data histogram
617 * @param mc MC histogram
619 * @return true if the event was selected
621 virtual Bool_t ProcessEvent(const AliAODForwardMult* forward,
629 * Calculate the Event-Level normalization.
631 * The full event level normalization for trigger @f$X@f$ is given by
633 * N &=& \frac{1}{\epsilon_X}
634 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
635 * &=& \frac{1}{\epsilon_X}N_A
636 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
637 * &=& \frac{1}{\epsilon_X}N_A
638 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
639 * &=& \frac{1}{\epsilon_X}N_A
640 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
644 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
645 * efficiency evaluated in simulation.
646 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
647 * evaluated from the data
648 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
650 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
651 * @f$X@f$ which was also triggered as such.
652 * - @f$N_T@f$ is the number of data events that where triggered
653 * as type @f$X@f$ and had a collision trigger (CINT1B)
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), and had
657 * - @f$N_{-V}@f$ is the number of data events that where triggered
658 * as type @f$X@f$, had a collision trigger (CINT1B), but no
660 * - @f$N_A@f$ is the number of data events that where triggered
661 * as type @f$X@f$, had a collision trigger (CINT1B), and had
662 * a vertex in the selected range.
663 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
664 * were also triggered as type @f$X@f$.
665 * - @f$N_a@f$ Number of beam-empty events also triggered as type
666 * @f$X@f$ events (CINT1-A or CINT1-AC).
667 * - @f$N_c@f$ Number of empty-beam events also triggered as type
668 * @f$X@f$ events (CINT1-C).
669 * - @f$N_e@f$ Number of empty-empty events also triggered as type
670 * @f$X@f$ events (CINT1-E).
672 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
673 * the expression simplyfies to
675 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
678 * @param t Histogram of triggers
679 * @param scheme Normalisation scheme
680 * @param trgEff Trigger efficiency
681 * @param ntotal On return, the total number of events to normalise to.
682 * @param text If non-null, fill with normalization calculation
684 * @return @f$N_A/N@f$ or negative number in case of errors.
686 virtual Double_t Normalization(const TH1I& t,
690 TString* text) const;
692 * Generate the dN/deta result from input
694 * @param sum Sum of 2D hists
695 * @param postfix Post fix on names
696 * @param rootProj Whether to use ROOT TH2::ProjectionX
697 * @param corrEmpty Correct for empty bins
698 * @param shapeCorr Shape correction to use
699 * @param scaler Event-level normalization scaler
700 * @param symmetrice Whether to make symmetric extensions
701 * @param rebin Whether to rebin
702 * @param cutEdges Whether to cut edges when rebinning
703 * @param marker Marker style
704 * @param color Color of markers
705 * @param mclist List of MC data
706 * @param truthlist List of MC truth data
708 virtual void MakeResult(const TH2D* sum,
712 const TH2F* shapeCorr,
724 * @param sums List of sums
725 * @param results Output list of results
726 * @param scheme Normalisation scheme options
727 * @param shapeCorr Shape correction or nil
728 * @param trigEff Trigger efficiency
729 * @param trigEff0 0-bin trigger efficiency
730 * @param symmetrice Whether to symmetrice the results
731 * @param rebin Whether to rebin the results
732 * @param rootProj If true, use TH2::ProjectionX
733 * @param corrEmpty Whether to correct for empty bins
734 * @param cutEdges Whether to cut edges when rebinning
735 * @param triggerMask Trigger mask
736 * @param marker Marker style
737 * @param color Color of markers
738 * @param mclist List of MC data
739 * @param truthlist List of MC truth data
741 virtual void End(TList* sums,
744 const TH2F* shapeCorr,
759 * @name Access histograms
764 * @param mc If true, return MC histogram
766 * @return Sum histogram
768 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
772 * @param mc If true, return MC histogram
774 * @return Sum histogram
776 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
778 * Get trigger histogram
780 * @return Trigger histogram
782 const TH1I* GetTriggers() const { return fTriggers; }
784 * Get trigger histogram
786 * @return Trigger histogram
788 TH1I* GetTriggers() { return fTriggers; }
790 * Get trigger histogram
792 * @return Trigger histogram
794 const TH1I* GetStatus() const { return fStatus; }
796 * Get trigger histogram
798 * @return Trigger histogram
800 TH1I* GetStatus() { return fStatus; }
804 * Get the color of the markers
806 * @param fallback Fall-back color
808 * @return Color for this centrality bin
810 Int_t GetColor(Int_t fallback=kRed+2) const;
812 * Get list of results
814 * @return List of results
816 TList* GetResults() const { return fOutput; }
818 * Get name of result histogram. Note, the returned pointer points
819 * to static memory and should be copied/used immediately.
821 * @param rebin Whether to get rebinned result
822 * @param sym Whether to get symmetric extension
823 * @param postfix Possible postfix (e.g., "MC")
827 const char* GetResultName(Int_t rebin, Bool_t sym,
828 const char* postfix="") const;
832 * @param rebin Whether to get rebinned result
833 * @param sym Whether to get symmetric extension
834 * @param postfix Possible postfix (e.g., "MC")
835 * @param verbose If true, complain about missing histogram
837 * @return Pointer to histogram or null
839 TH1* GetResult(Int_t rebin,
841 const char* postfix="",
842 Bool_t verbose=true) const;
844 * Set the debug level
846 * @param lvl Debug level
848 void SetDebugLevel(Int_t lvl);
850 * Set satellite vertex flag
854 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
857 * Read in sum hisotgram from list
859 * @param list List to read from
860 * @param mc True for MC input
862 * @return true if sum histogram is found
864 virtual Bool_t ReadSum(TList* list, bool mc=false);
866 * Create sum histogram
868 * @param data Data histogram to clone
869 * @param mc (optional) MC histogram to clone
871 virtual void CreateSums(const TH2D* data, const TH2D* mc);
873 * Check the trigger, vertex, and centrality
875 * @param forward Event input
876 * @param triggerMask The used trigger mask
877 * @param vzMin Least @f$ v_z@f$
878 * @param vzMax Largest @f$ v_z@f$
880 * @return true if the event is to be used
882 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
886 TList* fSums; // Output list
887 TList* fOutput; // Output list
888 Sum* fSum; // Sum histogram
889 Sum* fSumMC; // MC sum histogram
890 TH1I* fTriggers; // Trigger histogram
891 TH1I* fStatus; // Trigger histogram
892 UShort_t fLow; // Lower limit (inclusive)
893 UShort_t fHigh; // Upper limit (exclusive)
894 Bool_t fDoFinalMCCorrection; //Do final MC correction
895 Bool_t fSatelliteVertices; // Satellite vertex flag
896 Int_t fDebug; // Debug level
898 ClassDef(CentralityBin,4); // A centrality bin
900 Int_t fRebin; // Rebinning factor
901 Bool_t fCutEdges; // Whether to cut edges when rebinning
902 Bool_t fSymmetrice; // Whether to symmetrice data
903 Bool_t fCorrEmpty; // Correct for empty bins
904 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
905 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
906 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
907 TH2F* fShapeCorr; // Shape correction
908 TObjArray* fListOfCentralities; // Centrality bins
909 UShort_t fNormalizationScheme; // Normalization scheme
910 TString fFinalMCCorrFile; //Filename for final MC corr
911 Bool_t fSatelliteVertices; // satellite vertex flag
912 TH2D* fEmpiricalCorrection; // Empirical correction
913 TH2D* fMeanVsC; //mean signal per event vs cent
914 ClassDef(AliBasedNdetaTask,14); // Determine charged particle density