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"
17 #include <AliAnalysisUtils.h>
25 class AliAODForwardMult;
29 * @defgroup pwglf_forward_tasks_dndeta dN/deta tasks
31 * Code to produce @f$ dN/d\eta@f$
33 * @ingroup pwglf_forward_tasks
36 * @defgroup pwglf_forward_dndeta dN/deta
38 * @f$ dN/d\eta@f$ code
40 * @ingroup pwglf_forward_topical
43 * Base class for tasks to determine @f$ dN/d\eta@f$
45 * @ingroup pwglf_forward_tasks_dndeta
46 * @ingroup pwglf_forward_dndeta
48 class AliBasedNdetaTask : public AliBaseAODTask
52 * Bit mask values of the normalisation scheme
55 /** Only normalize to accepted events */
58 * Do the full normalisation
60 * N = \frac{1}{\epsilon_X}(N_A-N_A/N_V(N_T-N_V)) =
61 * \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
70 * Correct for background events (A+C-E). Not implemented yet
74 * Correct for the trigger efficiency from MC
76 kTriggerEfficiency = 0x8,
78 * Correct using zero-bin efficiency only
82 * Do the full correction
84 kFull = kEventLevel | kBackground | kTriggerEfficiency,
87 * Mask for selecting pile-up
91 * Use the flag from AOD
95 * Check the pile-up flag from SPD
99 * Check the pileup flag from tracks
103 * Check the out-of-bunch pileup flag
107 * Use the flag from AOD
113 kPileupIgnore = 0x10,
115 * Use analysis utility class
120 enum ECentralityEstimator {
122 kCentDefault, // What ever stored in AOD
123 kCentV0M, // VZERO multiplcity
125 kCentV0A123, // VZERO-A
129 kCentTkl, // Tracklets
130 kCentCL0, // Clusters in SPD-0
131 kCentCL1, // Clusters in SPD-1
132 kCentCND, // Clusters
133 kCentZNA, // ZDC neutrons A-side
134 kCentZNC, // ZDC neutrons C-side
135 kCentZPA, // ZDC protons A-side
136 kCentZPC, // ZDC protons C-side
138 kCentV0MvsFMD, // V0M vs FMD
139 kCentTklvsV0M, // Tracks vs V0M
140 kCentZEMvsZDC, // ZDC veto vs neutrons
152 * @param name Name of task
154 AliBasedNdetaTask(const char* name);
159 virtual ~AliBasedNdetaTask();
163 * @name Task configuration
166 * Set the debug level
168 * @param level Debug level
170 virtual void SetDebugLevel(Int_t level);
172 * Set whether to correct for empty bins when projecting on the X axis.
174 * @param use Whether to correct for empty bins
176 void SetCorrEmpty(Bool_t use) { fCorrEmpty = use; }
178 * Set whether to use the ROOT TH2::ProjectionX method when
179 * projecting on the X axis.
181 * @param use Whether to use TH2::ProjectionX
183 void SetUseROOTProjectX(Bool_t use) { fUseROOTProj = use; }
185 * Trigger efficiency for selected trigger(s)
187 * @param e Trigger efficiency
189 void SetTriggerEff(Double_t e) { fTriggerEff = e; }
191 * Trigger efficiency for 0-bin for selected trigger(s)
193 * @param e Trigger efficiency for 0-bin
195 void SetTriggerEff0(Double_t e) { fTriggerEff0 = e; }
197 * Set satellite vertex flag
201 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
203 * Set which centrality estimator to use - if not set, use the one
204 * from the Forward AOD object. Note, the string is diagnosed, and
205 * if found not to be valid, then a the program terminates via a
208 * @param method String definining centrality method (case insensitive)
220 * @return true if @a method is valid estimator
222 Bool_t SetCentralityMethod(const TString& method);
224 * Get reference to the analysis utility
226 * @return reference to the AliAnalysisUtils object
228 AliAnalysisUtils& GetAnalysisUtils() { return fAnaUtil; }
230 * Get a string representing the normalization scheme
232 * @param scheme Normalization scheme bits
234 * @return String representation
236 static const Char_t* NormalizationSchemeString(UShort_t scheme);
238 * Parse a string representing the normalization scheme
240 * @param what String of the normalization scheme
242 * @return normalization scheme bits
244 static UShort_t ParseNormalizationScheme(const Char_t* what);
246 * Setthe normalisation scheme to use
248 * @param scheme Normalisation scheme
250 void SetNormalizationScheme(UShort_t scheme);
252 * Space, pipe, or comma separated list of options
254 * @param what List of options
256 void SetNormalizationScheme(const char* what);
258 * Set the mask for checking pile-up events
260 * @param bits A bit pattern of EPileupMask bits
262 void SetPileupMask(UShort_t bits) { fPileupMask = bits; }
264 * Filename of final MC correction
266 * @param filename filename
268 void SetMCFinalCorrFilename(const char* filename) {
269 fFinalMCCorrFile.Clear();
270 fFinalMCCorrFile.Append(filename);
273 * Flag whether we should disregard SPD outlier events, as flagged
274 * by AliTriggerAnalysis::IsSPDClusterVsTrackletBG. The default
275 * setting for this flags events as outliers if
278 N_{cluster} > 65 + 4 N_{tracklet}
281 * where @f$N_{cluster}@f$ is the total number of clusters in both
282 * SPD layers, and @f$N_{tracklet}@f$ is the total number of
283 * tracklets in the SPD.
285 * @param check If true, then check for SPD outlier events before processing.
287 void SetCheckSPDOutlier(Bool_t check=true) { fCheckSPDOutlier = check; }
292 * @param option Not used
294 void Print(Option_t* option="") const;
296 * @name Task interface
299 * Create output objects.
301 * This is called once per slave process
303 * @return true on success
305 virtual Bool_t Book();
307 * Process a single event
309 * @return true on success
311 virtual Bool_t Event(AliAODEvent& aod);
313 * Called at end of event processing.
315 * This is called once in the master
317 * @return true on success
319 virtual Bool_t Finalize();
324 * @name Services member functions
327 * Project onto the X axis
329 * @param h 2D histogram
330 * @param name New name
331 * @param firstbin First bin to use
332 * @param lastbin Last bin to use
333 * @param useROOT Use TH2::ProjectionX instead of custom code
334 * @param corr Whether to do corrections or not
335 * @param error Whether to calculate errors
337 * @return Newly created histogram or null
339 static TH1D* ProjectX(const TH2D* h,
347 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
349 * @param copy Data to scale
350 * @param norm Coverage histogram
352 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
354 * Scale the copy of the 1D histogram by coverage in supplied 1D histogram
356 * @param copy Data to scale
357 * @param norm Coverage histogram
359 static void ScaleToCoverage(TH1D* copy, const TH1D* norm);
361 * Set histogram graphical options, etc.
363 * @param h Histogram to modify
364 * @param colour Marker color
365 * @param marker Marker style
366 * @param title Title of histogram
367 * @param ytitle Title on y-axis.
369 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
371 const char* ytitle=0);
383 kDownTriangle = 0x008,
389 * Get the marker style from option bits
391 * @param bits Option bits
393 * @return Marker style
395 static Int_t GetMarkerStyle(UShort_t bits);
397 * Get the marker option bits from a style
401 * @return option bits
403 static UShort_t GetMarkerBits(Int_t style);
407 * @param style Style parameter
411 static Int_t FlipHollowStyle(Int_t style);
413 * Setter of empirical correction
415 * @param h 2D histogram of ratio of nominal @f$ 1/N
416 * dN_{ch}/d\eta@f$ to satellite @f$ 1/N dN_{ch}/d\eta@f$ in PbPb
417 * collisions as a function of @f$\eta@f$ and interaction point
418 * Z-coordinate @f$ IP_{z}@f$
420 void SetGlobalEmpiricalcorrection(TH2D* h){fEmpiricalCorrection=h;}
423 * Copy contructor - not defined
425 AliBasedNdetaTask(const AliBasedNdetaTask&);
427 * Assignment operator - not defined
432 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&);
433 // Forward declaration
436 * Check if the event corresponds to the selected trigger(s),
437 * vertex, and centrality. Derived classes can overload this to
438 * enable event processing - even if the event is not within cuts.
440 * @param forward Forward object
442 * @return true if the event is within the cuts.
444 virtual Bool_t CheckEvent(const AliAODForwardMult& forward);
446 * Create the CentralityBin objects if not already done.
449 virtual void InitializeCentBins();
451 * Retrieve the histogram
453 * @param aod AOD event
454 * @param mc Whether to get the MC histogram or not
456 * @return Retrieved histogram or null
458 virtual TH2D* GetHistogram(const AliAODEvent& aod, Bool_t mc=false) = 0;
460 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
462 * @return Marker colour
464 virtual Int_t GetColor() const { return kBlack; }
466 * Get the marker style
468 * @return Marker style
470 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
472 * Massage data histograms if needed
478 virtual void CheckEventData(Double_t vtx,
482 * Add a centrality bin
484 * @param at Where in the list to add this bin
486 * @param high High cut
488 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
490 * Make a centrality bin
492 * @param name Name used for histograms
493 * @param low Low cut in percent
494 * @param high High cut in percent
496 * @return A newly created centrality bin
498 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
501 // function which applies empirical correction to the AOD object
502 Bool_t ApplyEmpiricalCorrection(const AliAODForwardMult* aod,TH2D* data);
505 static Int_t GetCentMethodID(const TString& meth);
506 static const char* GetCentMethod(UShort_t id);
508 //==================================================================
510 * Class that holds the sum of the data - possibly split into 0 or
514 struct Sum : public TNamed
516 TH2D* fSum; // Sum of non-zero events
517 TH2D* fSum0; // Sum of zero events
518 TH1I* fEvents; // Distribution of events
519 Int_t fDebug; // Debug level
521 * I/O Constructor - do not use
523 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
528 * @param postfix Possible post-fix
530 Sum(const char* name, const char* postfix)
531 : TNamed(name,postfix),
540 * @param o Object to copy from
550 * Assignment operator
552 * @param o Object to assign from
554 * @return Reference to this object
556 Sum& operator=(const Sum& o)
558 if (&o == this) return *this;
559 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
567 * Initialise this object.
569 * @param list List to add histograms to
570 * @param data Format of data to be cloned here
573 void Init(TList* list, const TH2D* data, Int_t col);
577 * @param data Data to add
578 * @param isZero If this is zero event
580 void Add(const TH2D* data, Bool_t isZero=false);
582 * Get the histogram name
584 * @param name Base name
585 * @param what Which one
586 * @param post Possible postfix
590 static TString GetHistName(const char* name, Int_t what=0,
593 * Get the histogram name
595 * @param what Which one
599 TString GetHistName(Int_t what=0) const;
603 * @param o Output list
604 * @param ntotal On return, the total number of events
605 * @param zeroEff Zero-bin efficiency
606 * @param otherEff Non-zero-bin efficiency
607 * @param marker Marker to use
608 * @param rootXproj Whether to use TH2::ProjectionX
609 * @param corrEmpty Correct for empty bins
611 * @return The total sum histogram
613 TH2D* CalcSum(TList* o, Double_t& ntotal,
614 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
615 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
617 ClassDef(Sum,2); // Summed histograms
620 //==================================================================
622 * Calculations done per centrality
625 class CentralityBin : public TNamed
635 * @param name Name used for histograms (e.g., Forward)
636 * @param low Lower centrality cut in percent
637 * @param high Upper centrality cut in percent
639 CentralityBin(const char* name, Short_t low, Short_t high);
643 * @param other Object to copy from
645 CentralityBin(const CentralityBin& other);
649 virtual ~CentralityBin();
651 * Assignment operator
653 * @param other Object to assign from
655 * @return Reference to this
657 CentralityBin& operator=(const CentralityBin& other);
659 * Check if this is the 'all' bin
661 * @return true if low and high cuts are both zero
663 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
669 const char* GetListName() const;
671 * Create output objects
673 * @param dir Parent list
674 * @param mask Trigger mask
676 virtual void CreateOutputObjects(TList* dir, Int_t mask);
680 * @param forward Forward data (for trigger, vertex, & centrality)
681 * @param triggerMask Trigger mask
682 * @param isZero True if this is a zero bin event
683 * @param vzMin Minimum IP z coordinate
684 * @param vzMax Maximum IP z coordinate
685 * @param data Data histogram
686 * @param mc MC histogram
687 * @param checkPileup If true, disregard pile-up events (global flag)
689 * @return true if the event was selected
691 virtual Bool_t ProcessEvent(const AliAODForwardMult* forward,
700 * Calculate the Event-Level normalization.
702 * The full event level normalization for trigger @f$X@f$ is given by
704 * N &=& \frac{1}{\epsilon_X}
705 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
706 * &=& \frac{1}{\epsilon_X}N_A
707 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
708 * &=& \frac{1}{\epsilon_X}N_A
709 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
710 * &=& \frac{1}{\epsilon_X}N_A
711 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
715 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
716 * efficiency evaluated in simulation.
717 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
718 * evaluated from the data
719 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
721 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
722 * @f$X@f$ which was also triggered as such.
723 * - @f$N_T@f$ is the number of data events that where triggered
724 * as type @f$X@f$ and had a collision trigger (CINT1B)
725 * - @f$N_V@f$ is the number of data events that where triggered
726 * as type @f$X@f$, had a collision trigger (CINT1B), and had
728 * - @f$N_{-V}@f$ is the number of data events that where triggered
729 * as type @f$X@f$, had a collision trigger (CINT1B), but no
731 * - @f$N_A@f$ is the number of data events that where triggered
732 * as type @f$X@f$, had a collision trigger (CINT1B), and had
733 * a vertex in the selected range.
734 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
735 * were also triggered as type @f$X@f$.
736 * - @f$N_a@f$ Number of beam-empty events also triggered as type
737 * @f$X@f$ events (CINT1-A or CINT1-AC).
738 * - @f$N_c@f$ Number of empty-beam events also triggered as type
739 * @f$X@f$ events (CINT1-C).
740 * - @f$N_e@f$ Number of empty-empty events also triggered as type
741 * @f$X@f$ events (CINT1-E).
743 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
744 * the expression simplyfies to
746 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
749 * @param t Histogram of triggers
750 * @param scheme Normalisation scheme
751 * @param trgEff Trigger efficiency
752 * @param ntotal On return, the total number of events to normalise to.
753 * @param text If non-null, fill with normalization calculation
755 * @return @f$N_A/N@f$ or negative number in case of errors.
757 virtual Double_t Normalization(const TH1I& t,
761 TString* text) const;
763 * Generate the dN/deta result from input
765 * @param sum Sum of 2D hists
766 * @param postfix Post fix on names
767 * @param rootProj Whether to use ROOT TH2::ProjectionX
768 * @param corrEmpty Correct for empty bins
769 * @param scaler Event-level normalization scaler
770 * @param marker Marker style
771 * @param color Color of markers
772 * @param mclist List of MC data
773 * @param truthlist List of MC truth data
775 virtual void MakeResult(const TH2D* sum,
787 * @param sums List of sums
788 * @param results Output list of results
789 * @param scheme Normalisation scheme options
790 * @param trigEff Trigger efficiency
791 * @param trigEff0 0-bin trigger efficiency
792 * @param rootProj If true, use TH2::ProjectionX
793 * @param corrEmpty Whether to correct for empty bins
794 * @param triggerMask Trigger mask
795 * @param marker Marker style
796 * @param color Color of markers
797 * @param mclist List of MC data
798 * @param truthlist List of MC truth data
800 virtual void End(TList* sums,
814 * @name Access histograms
819 * @param mc If true, return MC histogram
821 * @return Sum histogram
823 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
827 * @param mc If true, return MC histogram
829 * @return Sum histogram
831 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
833 * Get trigger histogram
835 * @return Trigger histogram
837 const TH1I* GetTriggers() const { return fTriggers; }
839 * Get trigger histogram
841 * @return Trigger histogram
843 TH1I* GetTriggers() { return fTriggers; }
845 * Get trigger histogram
847 * @return Trigger histogram
849 const TH1I* GetStatus() const { return fStatus; }
851 * Get trigger histogram
853 * @return Trigger histogram
855 TH1I* GetStatus() { return fStatus; }
859 * Get the color of the markers
861 * @param fallback Fall-back color
863 * @return Color for this centrality bin
865 Int_t GetColor(Int_t fallback=kRed+2) const;
867 * Get list of results
869 * @return List of results
871 TList* GetResults() const { return fOutput; }
873 * Get name of result histogram. Note, the returned pointer points
874 * to static memory and should be copied/used immediately.
876 * @param rebin Whether to get rebinned result
877 * @param sym Whether to get symmetric extension
878 * @param postfix Possible postfix (e.g., "MC")
882 const char* GetResultName(const char* postfix="") const;
886 * @param postfix Possible postfix (e.g., "MC")
887 * @param verbose If true, complain about missing histogram
889 * @return Pointer to histogram or null
891 TH1* GetResult(const char* postfix="",
892 Bool_t verbose=true) const;
894 * Set the debug level
896 * @param lvl Debug level
898 void SetDebugLevel(Int_t lvl);
900 * Set satellite vertex flag
904 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
907 * Read in sum hisotgram from list
909 * @param list List to read from
910 * @param mc True for MC input
912 * @return true if sum histogram is found
914 virtual Bool_t ReadSum(TList* list, bool mc=false);
916 * Create sum histogram
918 * @param data Data histogram to clone
919 * @param mc (optional) MC histogram to clone
921 virtual void CreateSums(const TH2D* data, const TH2D* mc);
923 * Check the trigger, vertex, and centrality
925 * @param forward Event input
926 * @param triggerMask The used trigger mask
927 * @param vzMin Least @f$ v_z@f$
928 * @param vzMax Largest @f$ v_z@f$
930 * @return true if the event is to be used
932 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
937 TList* fSums; // Output list
938 TList* fOutput; // Output list
939 Sum* fSum; // Sum histogram
940 Sum* fSumMC; // MC sum histogram
941 TH1I* fTriggers; // Trigger histogram
942 TH1I* fStatus; // Trigger histogram
943 UShort_t fLow; // Lower limit (inclusive)
944 UShort_t fHigh; // Upper limit (exclusive)
945 Bool_t fDoFinalMCCorrection; //Do final MC correction
946 Bool_t fSatelliteVertices; // Satellite vertex flag
947 Int_t fDebug; // Debug level
949 ClassDef(CentralityBin,4); // A centrality bin
951 Bool_t fCorrEmpty; // Correct for empty bins
952 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
953 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
954 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
955 TObjArray* fListOfCentralities; // Centrality bins
956 UShort_t fNormalizationScheme; // Normalization scheme
957 TString fFinalMCCorrFile; //Filename for final MC corr
958 Bool_t fSatelliteVertices; // satellite vertex flag
959 TH2D* fEmpiricalCorrection; // Empirical correction
960 TH2D* fMeanVsC; //mean signal per event vs cent
961 TString fCentMethod; // Centrality estimator
962 UShort_t fPileupMask; // Pile-up checks
963 AliAnalysisUtils fAnaUtil; // Analysis utility
964 Bool_t fCheckSPDOutlier; // Check for SPD outliers
965 ClassDef(AliBasedNdetaTask,17); // Determine charged particle density