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 * Set which centrality estimator to use - if not set, use the one
164 * from the Forward AOD object. Note, the string is diagnosed, and
165 * if found not to be valid, then a the program terminates via a
168 * @param method String definining centrality method (case insensitive)
180 * @return true if @a method is valid estimator
182 Bool_t SetCentralityMethod(const TString& method);
184 * Get a string representing the normalization scheme
186 * @param scheme Normalization scheme bits
188 * @return String representation
190 static const Char_t* NormalizationSchemeString(UShort_t scheme);
192 * Parse a string representing the normalization scheme
194 * @param what String of the normalization scheme
196 * @return normalization scheme bits
198 static UShort_t ParseNormalizationScheme(const Char_t* what);
200 * Setthe normalisation scheme to use
202 * @param scheme Normalisation scheme
204 void SetNormalizationScheme(UShort_t scheme);
206 * Space, pipe, or comma separated list of options
208 * @param what List of options
210 void SetNormalizationScheme(const char* what);
212 * Filename of final MC correction
214 * @param filename filename
216 void SetMCFinalCorrFilename(const char* filename) {
217 fFinalMCCorrFile.Clear();
218 fFinalMCCorrFile.Append(filename);
221 * Load the normalization data - done automatically if not set from outside
224 * @param energy energy
226 void LoadNormalizationData(UShort_t sys, UShort_t energy);
231 * @param option Not used
233 void Print(Option_t* option="") const;
235 * @name Task interface
238 * Create output objects.
240 * This is called once per slave process
242 * @return true on success
244 virtual Bool_t Book();
246 * Process a single event
248 * @return true on success
250 virtual Bool_t Event(AliAODEvent& aod);
252 * Called at end of event processing.
254 * This is called once in the master
256 * @return true on success
258 virtual Bool_t Finalize();
263 * @name Services member functions
266 * Make a copy of the input histogram and rebin that histogram
268 * @param h Histogram to rebin
269 * @param rebin Rebinning factor
270 * @param cutEdges Whether to cut edges when rebinning
272 * @return New (rebinned) histogram
274 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
276 * Make an extension of @a h to make it symmetric about 0
278 * @param h Histogram to symmertrice
280 * @return Symmetric extension of @a h
282 static TH1* Symmetrice(const TH1* h);
284 * Project onto the X axis
286 * @param h 2D histogram
287 * @param name New name
288 * @param firstbin First bin to use
289 * @param lastbin Last bin to use
290 * @param useROOT Use TH2::ProjectionX instead of custom code
291 * @param corr Whether to do corrections or not
292 * @param error Whether to calculate errors
294 * @return Newly created histogram or null
296 static TH1D* ProjectX(const TH2D* h,
304 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
306 * @param copy Data to scale
307 * @param norm Coverage histogram
309 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
311 * Scale the copy of the 1D histogram by coverage in supplied 1D histogram
313 * @param copy Data to scale
314 * @param norm Coverage histogram
316 static void ScaleToCoverage(TH1D* copy, const TH1D* norm);
318 * Set histogram graphical options, etc.
320 * @param h Histogram to modify
321 * @param colour Marker color
322 * @param marker Marker style
323 * @param title Title of histogram
324 * @param ytitle Title on y-axis.
326 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
328 const char* ytitle=0);
340 kDownTriangle = 0x008,
346 * Get the marker style from option bits
348 * @param bits Option bits
350 * @return Marker style
352 static Int_t GetMarkerStyle(UShort_t bits);
354 * Get the marker option bits from a style
358 * @return option bits
360 static UShort_t GetMarkerBits(Int_t style);
364 * @param style Style parameter
368 static Int_t FlipHollowStyle(Int_t style);
370 * Setter of empirical correction
372 * @param h 2D histogram of ratio of nominal @f$ 1/N
373 * dN_{ch}/d\eta@f$ to satellite @f$ 1/N dN_{ch}/d\eta@f$ in PbPb
374 * collisions as a function of @f$\eta@f$ and interaction point
375 * Z-coordinate @f$ IP_{z}@f$
377 void SetGlobalEmpiricalcorrection(TH2D* h){fEmpiricalCorrection=h;}
380 * Copy contructor - not defined
382 AliBasedNdetaTask(const AliBasedNdetaTask&);
384 * Assignment operator - not defined
389 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&);
390 // Forward declaration
393 * Check if the event corresponds to the selected trigger(s),
394 * vertex, and centrality. Derived classes can overload this to
395 * enable event processing - even if the event is not within cuts.
397 * @param forward Forward object
399 * @return true if the event is within the cuts.
401 virtual Bool_t CheckEvent(const AliAODForwardMult& forward);
403 * Create the CentralityBin objects if not already done.
406 virtual void InitializeCentBins();
408 * Retrieve the histogram
410 * @param aod AOD event
411 * @param mc Whether to get the MC histogram or not
413 * @return Retrieved histogram or null
415 virtual TH2D* GetHistogram(const AliAODEvent& aod, Bool_t mc=false) = 0;
417 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
419 * @return Marker colour
421 virtual Int_t GetColor() const { return kBlack; }
423 * Get the marker style
425 * @return Marker style
427 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
429 * Massage data histograms if needed
435 virtual void CheckEventData(Double_t vtx,
439 * Add a centrality bin
441 * @param at Where in the list to add this bin
443 * @param high High cut
445 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
447 * Make a centrality bin
449 * @param name Name used for histograms
450 * @param low Low cut in percent
451 * @param high High cut in percent
453 * @return A newly created centrality bin
455 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
458 // function which applies empirical correction to the AOD object
459 Bool_t ApplyEmpiricalCorrection(const AliAODForwardMult* aod,TH2D* data);
460 //==================================================================
462 * Class that holds the sum of the data - possibly split into 0 or
466 struct Sum : public TNamed
468 TH2D* fSum; // Sum of non-zero events
469 TH2D* fSum0; // Sum of zero events
470 TH1I* fEvents; // Distribution of events
471 Int_t fDebug; // Debug level
473 * I/O Constructor - do not use
475 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
480 * @param postfix Possible post-fix
482 Sum(const char* name, const char* postfix)
483 : TNamed(name,postfix),
492 * @param o Object to copy from
502 * Assignment operator
504 * @param o Object to assign from
506 * @return Reference to this object
508 Sum& operator=(const Sum& o)
510 if (&o == this) return *this;
511 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
519 * Initialise this object.
521 * @param list List to add histograms to
522 * @param data Format of data to be cloned here
525 void Init(TList* list, const TH2D* data, Int_t col);
529 * @param data Data to add
530 * @param isZero If this is zero event
532 void Add(const TH2D* data, Bool_t isZero=false);
534 * Get the histogram name
536 * @param name Base name
537 * @param what Which one
538 * @param post Possible postfix
542 static TString GetHistName(const char* name, Int_t what=0,
545 * Get the histogram name
547 * @param what Which one
551 TString GetHistName(Int_t what=0) const;
555 * @param o Output list
556 * @param ntotal On return, the total number of events
557 * @param zeroEff Zero-bin efficiency
558 * @param otherEff Non-zero-bin efficiency
559 * @param marker Marker to use
560 * @param rootXproj Whether to use TH2::ProjectionX
561 * @param corrEmpty Correct for empty bins
563 * @return The total sum histogram
565 TH2D* CalcSum(TList* o, Double_t& ntotal,
566 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
567 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
569 ClassDef(Sum,2); // Summed histograms
572 //==================================================================
574 * Calculations done per centrality
577 class CentralityBin : public TNamed
587 * @param name Name used for histograms (e.g., Forward)
588 * @param low Lower centrality cut in percent
589 * @param high Upper centrality cut in percent
591 CentralityBin(const char* name, Short_t low, Short_t high);
595 * @param other Object to copy from
597 CentralityBin(const CentralityBin& other);
601 virtual ~CentralityBin();
603 * Assignment operator
605 * @param other Object to assign from
607 * @return Reference to this
609 CentralityBin& operator=(const CentralityBin& other);
611 * Check if this is the 'all' bin
613 * @return true if low and high cuts are both zero
615 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
621 const char* GetListName() const;
623 * Create output objects
625 * @param dir Parent list
626 * @param mask Trigger mask
628 virtual void CreateOutputObjects(TList* dir, Int_t mask);
632 * @param forward Forward data (for trigger, vertex, & centrality)
633 * @param triggerMask Trigger mask
634 * @param isZero True if this is a zero bin event
635 * @param vzMin Minimum IP z coordinate
636 * @param vzMax Maximum IP z coordinate
637 * @param data Data histogram
638 * @param mc MC histogram
640 * @return true if the event was selected
642 virtual Bool_t ProcessEvent(const AliAODForwardMult* forward,
650 * Calculate the Event-Level normalization.
652 * The full event level normalization for trigger @f$X@f$ is given by
654 * N &=& \frac{1}{\epsilon_X}
655 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
656 * &=& \frac{1}{\epsilon_X}N_A
657 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
658 * &=& \frac{1}{\epsilon_X}N_A
659 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
660 * &=& \frac{1}{\epsilon_X}N_A
661 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
665 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
666 * efficiency evaluated in simulation.
667 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
668 * evaluated from the data
669 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
671 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
672 * @f$X@f$ which was also triggered as such.
673 * - @f$N_T@f$ is the number of data events that where triggered
674 * as type @f$X@f$ and had a collision trigger (CINT1B)
675 * - @f$N_V@f$ is the number of data events that where triggered
676 * as type @f$X@f$, had a collision trigger (CINT1B), and had
678 * - @f$N_{-V}@f$ is the number of data events that where triggered
679 * as type @f$X@f$, had a collision trigger (CINT1B), but no
681 * - @f$N_A@f$ is the number of data events that where triggered
682 * as type @f$X@f$, had a collision trigger (CINT1B), and had
683 * a vertex in the selected range.
684 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
685 * were also triggered as type @f$X@f$.
686 * - @f$N_a@f$ Number of beam-empty events also triggered as type
687 * @f$X@f$ events (CINT1-A or CINT1-AC).
688 * - @f$N_c@f$ Number of empty-beam events also triggered as type
689 * @f$X@f$ events (CINT1-C).
690 * - @f$N_e@f$ Number of empty-empty events also triggered as type
691 * @f$X@f$ events (CINT1-E).
693 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
694 * the expression simplyfies to
696 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
699 * @param t Histogram of triggers
700 * @param scheme Normalisation scheme
701 * @param trgEff Trigger efficiency
702 * @param ntotal On return, the total number of events to normalise to.
703 * @param text If non-null, fill with normalization calculation
705 * @return @f$N_A/N@f$ or negative number in case of errors.
707 virtual Double_t Normalization(const TH1I& t,
711 TString* text) const;
713 * Generate the dN/deta result from input
715 * @param sum Sum of 2D hists
716 * @param postfix Post fix on names
717 * @param rootProj Whether to use ROOT TH2::ProjectionX
718 * @param corrEmpty Correct for empty bins
719 * @param shapeCorr Shape correction to use
720 * @param scaler Event-level normalization scaler
721 * @param symmetrice Whether to make symmetric extensions
722 * @param rebin Whether to rebin
723 * @param cutEdges Whether to cut edges when rebinning
724 * @param marker Marker style
725 * @param color Color of markers
726 * @param mclist List of MC data
727 * @param truthlist List of MC truth data
729 virtual void MakeResult(const TH2D* sum,
733 const TH2F* shapeCorr,
745 * @param sums List of sums
746 * @param results Output list of results
747 * @param scheme Normalisation scheme options
748 * @param shapeCorr Shape correction or nil
749 * @param trigEff Trigger efficiency
750 * @param trigEff0 0-bin trigger efficiency
751 * @param symmetrice Whether to symmetrice the results
752 * @param rebin Whether to rebin the results
753 * @param rootProj If true, use TH2::ProjectionX
754 * @param corrEmpty Whether to correct for empty bins
755 * @param cutEdges Whether to cut edges when rebinning
756 * @param triggerMask Trigger mask
757 * @param marker Marker style
758 * @param color Color of markers
759 * @param mclist List of MC data
760 * @param truthlist List of MC truth data
762 virtual void End(TList* sums,
765 const TH2F* shapeCorr,
780 * @name Access histograms
785 * @param mc If true, return MC histogram
787 * @return Sum histogram
789 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
793 * @param mc If true, return MC histogram
795 * @return Sum histogram
797 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
799 * Get trigger histogram
801 * @return Trigger histogram
803 const TH1I* GetTriggers() const { return fTriggers; }
805 * Get trigger histogram
807 * @return Trigger histogram
809 TH1I* GetTriggers() { return fTriggers; }
811 * Get trigger histogram
813 * @return Trigger histogram
815 const TH1I* GetStatus() const { return fStatus; }
817 * Get trigger histogram
819 * @return Trigger histogram
821 TH1I* GetStatus() { return fStatus; }
825 * Get the color of the markers
827 * @param fallback Fall-back color
829 * @return Color for this centrality bin
831 Int_t GetColor(Int_t fallback=kRed+2) const;
833 * Get list of results
835 * @return List of results
837 TList* GetResults() const { return fOutput; }
839 * Get name of result histogram. Note, the returned pointer points
840 * to static memory and should be copied/used immediately.
842 * @param rebin Whether to get rebinned result
843 * @param sym Whether to get symmetric extension
844 * @param postfix Possible postfix (e.g., "MC")
848 const char* GetResultName(Int_t rebin, Bool_t sym,
849 const char* postfix="") const;
853 * @param rebin Whether to get rebinned result
854 * @param sym Whether to get symmetric extension
855 * @param postfix Possible postfix (e.g., "MC")
856 * @param verbose If true, complain about missing histogram
858 * @return Pointer to histogram or null
860 TH1* GetResult(Int_t rebin,
862 const char* postfix="",
863 Bool_t verbose=true) const;
865 * Set the debug level
867 * @param lvl Debug level
869 void SetDebugLevel(Int_t lvl);
871 * Set satellite vertex flag
875 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
878 * Read in sum hisotgram from list
880 * @param list List to read from
881 * @param mc True for MC input
883 * @return true if sum histogram is found
885 virtual Bool_t ReadSum(TList* list, bool mc=false);
887 * Create sum histogram
889 * @param data Data histogram to clone
890 * @param mc (optional) MC histogram to clone
892 virtual void CreateSums(const TH2D* data, const TH2D* mc);
894 * Check the trigger, vertex, and centrality
896 * @param forward Event input
897 * @param triggerMask The used trigger mask
898 * @param vzMin Least @f$ v_z@f$
899 * @param vzMax Largest @f$ v_z@f$
901 * @return true if the event is to be used
903 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
907 TList* fSums; // Output list
908 TList* fOutput; // Output list
909 Sum* fSum; // Sum histogram
910 Sum* fSumMC; // MC sum histogram
911 TH1I* fTriggers; // Trigger histogram
912 TH1I* fStatus; // Trigger histogram
913 UShort_t fLow; // Lower limit (inclusive)
914 UShort_t fHigh; // Upper limit (exclusive)
915 Bool_t fDoFinalMCCorrection; //Do final MC correction
916 Bool_t fSatelliteVertices; // Satellite vertex flag
917 Int_t fDebug; // Debug level
919 ClassDef(CentralityBin,4); // A centrality bin
921 Int_t fRebin; // Rebinning factor
922 Bool_t fCutEdges; // Whether to cut edges when rebinning
923 Bool_t fSymmetrice; // Whether to symmetrice data
924 Bool_t fCorrEmpty; // Correct for empty bins
925 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
926 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
927 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
928 TH2F* fShapeCorr; // Shape correction
929 TObjArray* fListOfCentralities; // Centrality bins
930 UShort_t fNormalizationScheme; // Normalization scheme
931 TString fFinalMCCorrFile; //Filename for final MC corr
932 Bool_t fSatelliteVertices; // satellite vertex flag
933 TH2D* fEmpiricalCorrection; // Empirical correction
934 TH2D* fMeanVsC; //mean signal per event vs cent
935 TString fCentMethod; // Centrality estimator
936 ClassDef(AliBasedNdetaTask,15); // Determine charged particle density