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);
348 /*Setter of empirical correction*/
349 void SetGlobalEmpiricalcorrection(TH2D* globalempiricalcorrection){fglobalempiricalcorrection=globalempiricalcorrection;}
352 * Copy contructor - not defined
354 AliBasedNdetaTask(const AliBasedNdetaTask&);
356 * Assignment operator - not defined
361 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&);
362 // Forward declaration
365 * Check if the event corresponds to the selected trigger(s),
366 * vertex, and centrality. Derived classes can overload this to
367 * enable event processing - even if the event is not within cuts.
369 * @param forward Forward object
371 * @return true if the event is within the cuts.
373 virtual Bool_t CheckEvent(const AliAODForwardMult& forward);
375 * Create the CentralityBin objects if not already done.
378 virtual void InitializeCentBins();
380 * Retrieve the histogram
382 * @param aod AOD event
383 * @param mc Whether to get the MC histogram or not
385 * @return Retrieved histogram or null
387 virtual TH2D* GetHistogram(const AliAODEvent& aod, Bool_t mc=false) = 0;
389 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
391 * @return Marker colour
393 virtual Int_t GetColor() const { return kBlack; }
395 * Get the marker style
397 * @return Marker style
399 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
401 * Massage data histograms if needed
407 virtual void CheckEventData(Double_t vtx,
411 * Add a centrality bin
413 * @param at Where in the list to add this bin
415 * @param high High cut
417 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
419 * Make a centrality bin
421 * @param name Name used for histograms
422 * @param low Low cut in percent
423 * @param high High cut in percent
425 * @return A newly created centrality bin
427 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
430 // function which applies empirical correction to the AOD object
431 Bool_t ApplyEmpiricalCorrection(const AliAODForwardMult* aod,TH2D* data);
432 //==================================================================
434 * Class that holds the sum of the data - possibly split into 0 or
438 struct Sum : public TNamed
440 TH2D* fSum; // Sum of non-zero events
441 TH2D* fSum0; // Sum of zero events
442 TH1I* fEvents; // Distribution of events
443 Int_t fDebug; // Debug level
445 * I/O Constructor - do not use
447 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
452 * @param postfix Possible post-fix
454 Sum(const char* name, const char* postfix)
455 : TNamed(name,postfix),
464 * @param o Object to copy from
474 * Assignment operator
476 * @param o Object to assign from
478 * @return Reference to this object
480 Sum& operator=(const Sum& o)
482 if (&o == this) return *this;
483 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
491 * Initialise this object.
493 * @param list List to add histograms to
494 * @param data Format of data to be cloned here
497 void Init(TList* list, const TH2D* data, Int_t col);
501 * @param data Data to add
502 * @param isZero If this is zero event
504 void Add(const TH2D* data, Bool_t isZero=false);
506 * Get the histogram name
508 * @param name Base name
509 * @param what Which one
510 * @param post Possible postfix
514 static TString GetHistName(const char* name, Int_t what=0,
517 * Get the histogram name
519 * @param what Which one
523 TString GetHistName(Int_t what=0) const;
527 * @param o Output list
528 * @param ntotal On return, the total number of events
529 * @param zeroEff Zero-bin efficiency
530 * @param otherEff Non-zero-bin efficiency
531 * @param marker Marker to use
532 * @param rootXproj Whether to use TH2::ProjectionX
533 * @param corrEmpty Correct for empty bins
535 * @return The total sum histogram
537 TH2D* CalcSum(TList* o, Double_t& ntotal,
538 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
539 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
541 ClassDef(Sum,2); // Summed histograms
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 * @return true if the event was selected
614 virtual Bool_t ProcessEvent(const AliAODForwardMult* forward,
622 * Calculate the Event-Level normalization.
624 * The full event level normalization for trigger @f$X@f$ is given by
626 * N &=& \frac{1}{\epsilon_X}
627 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
628 * &=& \frac{1}{\epsilon_X}N_A
629 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
630 * &=& \frac{1}{\epsilon_X}N_A
631 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
632 * &=& \frac{1}{\epsilon_X}N_A
633 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
637 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
638 * efficiency evaluated in simulation.
639 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
640 * evaluated from the data
641 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
643 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
644 * @f$X@f$ which was also triggered as such.
645 * - @f$N_T@f$ is the number of data events that where triggered
646 * as type @f$X@f$ and had a collision trigger (CINT1B)
647 * - @f$N_V@f$ is the number of data events that where triggered
648 * as type @f$X@f$, had a collision trigger (CINT1B), and had
650 * - @f$N_{-V}@f$ is the number of data events that where triggered
651 * as type @f$X@f$, had a collision trigger (CINT1B), but no
653 * - @f$N_A@f$ is the number of data events that where triggered
654 * as type @f$X@f$, had a collision trigger (CINT1B), and had
655 * a vertex in the selected range.
656 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
657 * were also triggered as type @f$X@f$.
658 * - @f$N_a@f$ Number of beam-empty events also triggered as type
659 * @f$X@f$ events (CINT1-A or CINT1-AC).
660 * - @f$N_c@f$ Number of empty-beam events also triggered as type
661 * @f$X@f$ events (CINT1-C).
662 * - @f$N_e@f$ Number of empty-empty events also triggered as type
663 * @f$X@f$ events (CINT1-E).
665 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
666 * the expression simplyfies to
668 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
671 * @param t Histogram of triggers
672 * @param scheme Normalisation scheme
673 * @param trgEff Trigger efficiency
674 * @param ntotal On return, the total number of events to normalise to.
675 * @param text If non-null, fill with normalization calculation
677 * @return @f$N_A/N@f$ or negative number in case of errors.
679 virtual Double_t Normalization(const TH1I& t,
683 TString* text) const;
685 * Generate the dN/deta result from input
687 * @param sum Sum of 2D hists
688 * @param postfix Post fix on names
689 * @param rootProj Whether to use ROOT TH2::ProjectionX
690 * @param corrEmpty Correct for empty bins
691 * @param shapeCorr Shape correction to use
692 * @param scaler Event-level normalization scaler
693 * @param symmetrice Whether to make symmetric extensions
694 * @param rebin Whether to rebin
695 * @param cutEdges Whether to cut edges when rebinning
696 * @param marker Marker style
697 * @param color Color of markers
698 * @param mclist List of MC data
699 * @param truthlist List of MC truth data
701 virtual void MakeResult(const TH2D* sum,
705 const TH2F* shapeCorr,
717 * @param sums List of sums
718 * @param results Output list of results
719 * @param scheme Normalisation scheme options
720 * @param shapeCorr Shape correction or nil
721 * @param trigEff Trigger efficiency
722 * @param trigEff0 0-bin trigger efficiency
723 * @param symmetrice Whether to symmetrice the results
724 * @param rebin Whether to rebin the results
725 * @param rootProj If true, use TH2::ProjectionX
726 * @param corrEmpty Whether to correct for empty bins
727 * @param cutEdges Whether to cut edges when rebinning
728 * @param triggerMask Trigger mask
729 * @param marker Marker style
730 * @param color Color of markers
731 * @param mclist List of MC data
732 * @param truthlist List of MC truth data
734 virtual void End(TList* sums,
737 const TH2F* shapeCorr,
752 * @name Access histograms
757 * @param mc If true, return MC histogram
759 * @return Sum histogram
761 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
765 * @param mc If true, return MC histogram
767 * @return Sum histogram
769 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
771 * Get trigger histogram
773 * @return Trigger histogram
775 const TH1I* GetTriggers() const { return fTriggers; }
777 * Get trigger histogram
779 * @return Trigger histogram
781 TH1I* GetTriggers() { return fTriggers; }
783 * Get trigger histogram
785 * @return Trigger histogram
787 const TH1I* GetStatus() const { return fStatus; }
789 * Get trigger histogram
791 * @return Trigger histogram
793 TH1I* GetStatus() { return fStatus; }
797 * Get the color of the markers
799 * @param fallback Fall-back color
801 * @return Color for this centrality bin
803 Int_t GetColor(Int_t fallback=kRed+2) const;
805 * Get list of results
807 * @return List of results
809 TList* GetResults() const { return fOutput; }
811 * Get name of result histogram. Note, the returned pointer points
812 * to static memory and should be copied/used immediately.
814 * @param rebin Whether to get rebinned result
815 * @param sym Whether to get symmetric extension
816 * @param postfix Possible postfix (e.g., "MC")
820 const char* GetResultName(Int_t rebin, Bool_t sym,
821 const char* postfix="") const;
825 * @param rebin Whether to get rebinned result
826 * @param sym Whether to get symmetric extension
827 * @param postfix Possible postfix (e.g., "MC")
828 * @param verbose If true, complain about missing histogram
830 * @return Pointer to histogram or null
832 TH1* GetResult(Int_t rebin,
834 const char* postfix="",
835 Bool_t verbose=true) const;
837 * Set the debug level
839 * @param lvl Debug level
841 void SetDebugLevel(Int_t lvl);
843 * Set satellite vertex flag
847 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
850 * Read in sum hisotgram from list
852 * @param list List to read from
853 * @param mc True for MC input
855 * @return true if sum histogram is found
857 virtual Bool_t ReadSum(TList* list, bool mc=false);
859 * Create sum histogram
861 * @param data Data histogram to clone
862 * @param mc (optional) MC histogram to clone
864 virtual void CreateSums(const TH2D* data, const TH2D* mc);
866 * Check the trigger, vertex, and centrality
868 * @param forward Event input
869 * @param triggerMask The used trigger mask
870 * @param vzMin Least @f$ v_z@f$
871 * @param vzMax Largest @f$ v_z@f$
873 * @return true if the event is to be used
875 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
879 TList* fSums; // Output list
880 TList* fOutput; // Output list
881 Sum* fSum; // Sum histogram
882 Sum* fSumMC; // MC sum histogram
883 TH1I* fTriggers; // Trigger histogram
884 TH1I* fStatus; // Trigger histogram
885 UShort_t fLow; // Lower limit (inclusive)
886 UShort_t fHigh; // Upper limit (exclusive)
887 Bool_t fDoFinalMCCorrection; //Do final MC correction
888 Bool_t fSatelliteVertices; // Satellite vertex flag
889 Int_t fDebug; // Debug level
891 ClassDef(CentralityBin,4); // A centrality bin
893 Int_t fRebin; // Rebinning factor
894 Bool_t fCutEdges; // Whether to cut edges when rebinning
895 Bool_t fSymmetrice; // Whether to symmetrice data
896 Bool_t fCorrEmpty; // Correct for empty bins
897 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
898 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
899 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
900 TH2F* fShapeCorr; // Shape correction
901 TObjArray* fListOfCentralities; // Centrality bins
902 UShort_t fNormalizationScheme; // Normalization scheme
903 TString fFinalMCCorrFile; //Filename for final MC corr
904 Bool_t fSatelliteVertices; // satellite vertex flag
905 TH2D* fglobalempiricalcorrection; // the ratio of PbPb analysis normal displace vertex
906 TH2D* fmeabsignalvscentr; //mean signal per event vs cent
907 ClassDef(AliBasedNdetaTask,14); // Determine charged particle density