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 = (N_A-N_A/N_V(N_T-N_V)) = \frac{1}{\epsilon_V}N_A
69 * Correct for background events (A+C-E)
73 * Correct for the trigger efficiency
76 * N = N_A \frac{1}{\epsilon_X}
79 kTriggerEfficiency = 0x8,
81 * Correct using zero-bin efficiency only
85 * Do the full correction
87 kFull = kEventLevel | kBackground | kTriggerEfficiency,
90 * Mask for selecting pile-up
94 * Use the flag from AOD
98 * Check the pile-up flag from SPD
102 * Check the pileup flag from tracks
106 * Check the out-of-bunch pileup flag
110 * Use the flag from AOD
116 kPileupIgnore = 0x10,
118 * Use analysis utility class
123 enum ECentralityEstimator {
125 kCentDefault, // What ever stored in AOD
126 kCentV0M, // VZERO multiplcity
128 kCentV0A123, // VZERO-A
132 kCentTkl, // Tracklets
133 kCentCL0, // Clusters in SPD-0
134 kCentCL1, // Clusters in SPD-1
135 kCentCND, // Clusters
136 kCentZNA, // ZDC neutrons A-side
137 kCentZNC, // ZDC neutrons C-side
138 kCentZPA, // ZDC protons A-side
139 kCentZPC, // ZDC protons C-side
141 kCentV0MvsFMD, // V0M vs FMD
142 kCentTklvsV0M, // Tracks vs V0M
143 kCentZEMvsZDC, // ZDC veto vs neutrons
155 * @param name Name of task
157 AliBasedNdetaTask(const char* name);
162 virtual ~AliBasedNdetaTask();
166 * @name Task configuration
169 * Set the debug level
171 * @param level Debug level
173 virtual void SetDebugLevel(Int_t level);
175 * Set whether to correct for empty bins when projecting on the X axis.
177 * @param use Whether to correct for empty bins
179 void SetCorrEmpty(Bool_t use) { fCorrEmpty = use; }
181 * Set whether to use the ROOT TH2::ProjectionX method when
182 * projecting on the X axis.
184 * @param use Whether to use TH2::ProjectionX
186 void SetUseROOTProjectX(Bool_t use) { fUseROOTProj = use; }
188 * Trigger efficiency for selected trigger(s)
190 * @param e Trigger efficiency
192 void SetTriggerEff(Double_t e) { fTriggerEff = e; }
194 * Trigger efficiency for 0-bin for selected trigger(s)
196 * @param e Trigger efficiency for 0-bin
198 void SetTriggerEff0(Double_t e) { fTriggerEff0 = e; }
200 * Set satellite vertex flag
204 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
206 * Set which centrality estimator to use - if not set, use the one
207 * from the Forward AOD object. Note, the string is diagnosed, and
208 * if found not to be valid, then a the program terminates via a
211 * @param method String definining centrality method (case insensitive)
223 * @return true if @a method is valid estimator
225 Bool_t SetCentralityMethod(const TString& method);
227 * Get reference to the analysis utility
229 * @return reference to the AliAnalysisUtils object
231 AliAnalysisUtils& GetAnalysisUtils() { return fAnaUtil; }
233 * Get a string representing the normalization scheme
235 * @param scheme Normalization scheme bits
237 * @return String representation
239 static const Char_t* NormalizationSchemeString(UShort_t scheme);
241 * Parse a string representing the normalization scheme
243 * @param what String of the normalization scheme
245 * @return normalization scheme bits
247 static UShort_t ParseNormalizationScheme(const Char_t* what);
249 * Setthe normalisation scheme to use
251 * @param scheme Normalisation scheme
253 void SetNormalizationScheme(UShort_t scheme);
255 * Space, pipe, or comma separated list of options
257 * @param what List of options
259 void SetNormalizationScheme(const char* what);
261 * Set the mask for checking pile-up events
263 * @param bits A bit pattern of EPileupMask bits
265 void SetPileupMask(UShort_t bits) { fPileupMask = bits; }
267 * Filename of final MC correction
269 * @param filename filename
271 void SetMCFinalCorrFilename(const char* filename) {
272 fFinalMCCorrFile.Clear();
273 fFinalMCCorrFile.Append(filename);
276 * Flag whether we should disregard SPD outlier events, as flagged
277 * by AliTriggerAnalysis::IsSPDClusterVsTrackletBG. The default
278 * setting for this flags events as outliers if
281 N_{cluster} > 65 + 4 N_{tracklet}
284 * where @f$N_{cluster}@f$ is the total number of clusters in both
285 * SPD layers, and @f$N_{tracklet}@f$ is the total number of
286 * tracklets in the SPD.
288 * @param check If true, then check for SPD outlier events before processing.
290 void SetCheckSPDOutlier(Bool_t check=true) { fCheckSPDOutlier = check; }
295 * @param option Not used
297 void Print(Option_t* option="") const;
299 * @name Task interface
302 * Create output objects.
304 * This is called once per slave process
306 * @return true on success
308 virtual Bool_t Book();
310 * Process a single event
312 * @return true on success
314 virtual Bool_t Event(AliAODEvent& aod);
316 * Called at end of event processing.
318 * This is called once in the master
320 * @return true on success
322 virtual Bool_t Finalize();
327 * @name Services member functions
330 * Project onto the X axis
332 * @param h 2D histogram
333 * @param name New name
334 * @param firstbin First bin to use
335 * @param lastbin Last bin to use
336 * @param useROOT Use TH2::ProjectionX instead of custom code
337 * @param corr Whether to do corrections or not
338 * @param error Whether to calculate errors
340 * @return Newly created histogram or null
342 static TH1D* ProjectX(const TH2D* h,
350 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
352 * @param copy Data to scale
353 * @param norm Coverage histogram
355 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
357 * Scale the copy of the 1D histogram by coverage in supplied 1D histogram
359 * @param copy Data to scale
360 * @param norm Coverage histogram
362 static void ScaleToCoverage(TH1D* copy, const TH1D* norm);
364 * Set histogram graphical options, etc.
366 * @param h Histogram to modify
367 * @param colour Marker color
368 * @param marker Marker style
369 * @param title Title of histogram
370 * @param ytitle Title on y-axis.
372 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
374 const char* ytitle=0);
386 kDownTriangle = 0x008,
392 * Get the marker style from option bits
394 * @param bits Option bits
396 * @return Marker style
398 static Int_t GetMarkerStyle(UShort_t bits);
400 * Get the marker option bits from a style
404 * @return option bits
406 static UShort_t GetMarkerBits(Int_t style);
410 * @param style Style parameter
414 static Int_t FlipHollowStyle(Int_t style);
416 * Setter of empirical correction
418 * @param h 2D histogram of ratio of nominal @f$ 1/N
419 * dN_{ch}/d\eta@f$ to satellite @f$ 1/N dN_{ch}/d\eta@f$ in PbPb
420 * collisions as a function of @f$\eta@f$ and interaction point
421 * Z-coordinate @f$ IP_{z}@f$
423 void SetGlobalEmpiricalcorrection(TH2D* h){fEmpiricalCorrection=h;}
426 * Copy contructor - not defined
428 AliBasedNdetaTask(const AliBasedNdetaTask&);
430 * Assignment operator - not defined
435 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&);
436 // Forward declaration
439 * Check if the event corresponds to the selected trigger(s),
440 * vertex, and centrality. Derived classes can overload this to
441 * enable event processing - even if the event is not within cuts.
443 * @param forward Forward object
445 * @return true if the event is within the cuts.
447 virtual Bool_t CheckEvent(const AliAODForwardMult& forward);
449 * Create the CentralityBin objects if not already done.
452 virtual void InitializeCentBins();
454 * Retrieve the histogram
456 * @param aod AOD event
457 * @param mc Whether to get the MC histogram or not
459 * @return Retrieved histogram or null
461 virtual TH2D* GetHistogram(const AliAODEvent& aod, Bool_t mc=false) = 0;
463 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
465 * @return Marker colour
467 virtual Int_t GetColor() const { return kBlack; }
469 * Get the marker style
471 * @return Marker style
473 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
475 * Massage data histograms if needed
481 virtual void CheckEventData(Double_t vtx,
485 * Add a centrality bin
487 * @param at Where in the list to add this bin
489 * @param high High cut
491 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
493 * Make a centrality bin
495 * @param name Name used for histograms
496 * @param low Low cut in percent
497 * @param high High cut in percent
499 * @return A newly created centrality bin
501 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
504 // function which applies empirical correction to the AOD object
505 Bool_t ApplyEmpiricalCorrection(const AliAODForwardMult* aod,TH2D* data);
508 static Int_t GetCentMethodID(const TString& meth);
509 static const char* GetCentMethod(UShort_t id);
511 //==================================================================
513 * Class that holds the sum of the data - possibly split into 0 or
517 struct Sum : public TNamed
519 TH2D* fSum; // Sum of non-zero events
520 TH2D* fSum0; // Sum of zero events
521 TH1I* fEvents; // Distribution of events
522 Int_t fDebug; // Debug level
524 * I/O Constructor - do not use
526 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
531 * @param postfix Possible post-fix
533 Sum(const char* name, const char* postfix)
534 : TNamed(name,postfix),
543 * @param o Object to copy from
553 * Assignment operator
555 * @param o Object to assign from
557 * @return Reference to this object
559 Sum& operator=(const Sum& o)
561 if (&o == this) return *this;
562 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
570 * Initialise this object.
572 * @param list List to add histograms to
573 * @param data Format of data to be cloned here
576 void Init(TList* list, const TH2D* data, Int_t col);
580 * @param data Data to add
581 * @param isZero If this is zero event
583 void Add(const TH2D* data, Bool_t isZero=false);
585 * Get the histogram name
587 * @param name Base name
588 * @param what Which one
589 * @param post Possible postfix
593 static TString GetHistName(const char* name, Int_t what=0,
596 * Get the histogram name
598 * @param what Which one
602 TString GetHistName(Int_t what=0) const;
606 * @param o Output list
607 * @param ntotal On return, the total number of events
608 * @param zeroEff Zero-bin efficiency
609 * @param otherEff Non-zero-bin efficiency
610 * @param marker Marker to use
611 * @param rootXproj Whether to use TH2::ProjectionX
612 * @param corrEmpty Correct for empty bins
614 * @return The total sum histogram
616 TH2D* CalcSum(TList* o, Double_t& ntotal,
617 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
618 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
620 ClassDef(Sum,2); // Summed histograms
623 //==================================================================
625 * Calculations done per centrality
628 class CentralityBin : public TNamed
638 * @param name Name used for histograms (e.g., Forward)
639 * @param low Lower centrality cut in percent
640 * @param high Upper centrality cut in percent
642 CentralityBin(const char* name, Short_t low, Short_t high);
646 * @param other Object to copy from
648 CentralityBin(const CentralityBin& other);
652 virtual ~CentralityBin();
654 * Assignment operator
656 * @param other Object to assign from
658 * @return Reference to this
660 CentralityBin& operator=(const CentralityBin& other);
662 * Check if this is the 'all' bin
664 * @return true if low and high cuts are both zero
666 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
672 const char* GetListName() const;
674 * Create output objects
676 * @param dir Parent list
677 * @param mask Trigger mask
679 virtual void CreateOutputObjects(TList* dir, Int_t mask);
683 * @param forward Forward data (for trigger, vertex, & centrality)
684 * @param triggerMask Trigger mask
685 * @param isZero True if this is a zero bin event
686 * @param vzMin Minimum IP z coordinate
687 * @param vzMax Maximum IP z coordinate
688 * @param data Data histogram
689 * @param mc MC histogram
690 * @param checkPileup If true, disregard pile-up events (global flag)
692 * @return true if the event was selected
694 virtual Bool_t ProcessEvent(const AliAODForwardMult* forward,
703 * Calculate the Event-Level normalization.
705 * The full event level normalization for trigger @f$X@f$ is given by
707 * N &=& \frac{1}{\epsilon_X}
708 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
709 * &=& \frac{1}{\epsilon_X}N_A
710 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
711 * &=& \frac{1}{\epsilon_X}N_A
712 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
713 * &=& \frac{1}{\epsilon_X}N_A
714 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
718 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
719 * efficiency evaluated in simulation.
720 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
721 * evaluated from the data
722 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
724 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
725 * @f$X@f$ which was also triggered as such.
726 * - @f$N_T@f$ is the number of data events that where triggered
727 * as type @f$X@f$ and had a collision trigger (CINT1B)
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), and had
731 * - @f$N_{-V}@f$ is the number of data events that where triggered
732 * as type @f$X@f$, had a collision trigger (CINT1B), but no
734 * - @f$N_A@f$ is the number of data events that where triggered
735 * as type @f$X@f$, had a collision trigger (CINT1B), and had
736 * a vertex in the selected range.
737 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
738 * were also triggered as type @f$X@f$.
739 * - @f$N_a@f$ Number of beam-empty events also triggered as type
740 * @f$X@f$ events (CINT1-A or CINT1-AC).
741 * - @f$N_c@f$ Number of empty-beam events also triggered as type
742 * @f$X@f$ events (CINT1-C).
743 * - @f$N_e@f$ Number of empty-empty events also triggered as type
744 * @f$X@f$ events (CINT1-E).
746 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
747 * the expression simplyfies to
749 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
752 * @param t Histogram of triggers
753 * @param scheme Normalisation scheme
754 * @param trgEff Trigger efficiency
755 * @param ntotal On return, the total number of events to normalise to.
756 * @param text If non-null, fill with normalization calculation
758 * @return @f$N_A/N@f$ or negative number in case of errors.
760 virtual Double_t Normalization(const TH1I& t,
764 TString* text) const;
766 * Generate the dN/deta result from input
768 * @param sum Sum of 2D hists
769 * @param postfix Post fix on names
770 * @param rootProj Whether to use ROOT TH2::ProjectionX
771 * @param corrEmpty Correct for empty bins
772 * @param scaler Event-level normalization scaler
773 * @param marker Marker style
774 * @param color Color of markers
775 * @param mclist List of MC data
776 * @param truthlist List of MC truth data
778 virtual void MakeResult(const TH2D* sum,
790 * @param sums List of sums
791 * @param results Output list of results
792 * @param scheme Normalisation scheme options
793 * @param trigEff Trigger efficiency
794 * @param trigEff0 0-bin trigger efficiency
795 * @param rootProj If true, use TH2::ProjectionX
796 * @param corrEmpty Whether to correct for empty bins
797 * @param triggerMask Trigger mask
798 * @param marker Marker style
799 * @param color Color of markers
800 * @param mclist List of MC data
801 * @param truthlist List of MC truth data
803 virtual void End(TList* sums,
817 * @name Access histograms
822 * @param mc If true, return MC histogram
824 * @return Sum histogram
826 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
830 * @param mc If true, return MC histogram
832 * @return Sum histogram
834 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
836 * Get trigger histogram
838 * @return Trigger histogram
840 const TH1I* GetTriggers() const { return fTriggers; }
842 * Get trigger histogram
844 * @return Trigger histogram
846 TH1I* GetTriggers() { return fTriggers; }
848 * Get trigger histogram
850 * @return Trigger histogram
852 const TH1I* GetStatus() const { return fStatus; }
854 * Get trigger histogram
856 * @return Trigger histogram
858 TH1I* GetStatus() { return fStatus; }
862 * Get the color of the markers
864 * @param fallback Fall-back color
866 * @return Color for this centrality bin
868 Int_t GetColor(Int_t fallback=kRed+2) const;
870 * Get list of results
872 * @return List of results
874 TList* GetResults() const { return fOutput; }
876 * Get name of result histogram. Note, the returned pointer points
877 * to static memory and should be copied/used immediately.
879 * @param rebin Whether to get rebinned result
880 * @param sym Whether to get symmetric extension
881 * @param postfix Possible postfix (e.g., "MC")
885 const char* GetResultName(const char* postfix="") const;
889 * @param postfix Possible postfix (e.g., "MC")
890 * @param verbose If true, complain about missing histogram
892 * @return Pointer to histogram or null
894 TH1* GetResult(const char* postfix="",
895 Bool_t verbose=true) const;
897 * Set the debug level
899 * @param lvl Debug level
901 void SetDebugLevel(Int_t lvl);
903 * Set satellite vertex flag
907 void SetSatelliteVertices(Bool_t satVtx) { fSatelliteVertices = satVtx; }
910 * Read in sum hisotgram from list
912 * @param list List to read from
913 * @param mc True for MC input
915 * @return true if sum histogram is found
917 virtual Bool_t ReadSum(TList* list, bool mc=false);
919 * Create sum histogram
921 * @param data Data histogram to clone
922 * @param mc (optional) MC histogram to clone
924 virtual void CreateSums(const TH2D* data, const TH2D* mc);
926 * Check the trigger, vertex, and centrality
928 * @param forward Event input
929 * @param triggerMask The used trigger mask
930 * @param vzMin Least @f$ v_z@f$
931 * @param vzMax Largest @f$ v_z@f$
933 * @return true if the event is to be used
935 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
940 TList* fSums; // Output list
941 TList* fOutput; // Output list
942 Sum* fSum; // Sum histogram
943 Sum* fSumMC; // MC sum histogram
944 TH1I* fTriggers; // Trigger histogram
945 TH1I* fStatus; // Trigger histogram
946 UShort_t fLow; // Lower limit (inclusive)
947 UShort_t fHigh; // Upper limit (exclusive)
948 Bool_t fDoFinalMCCorrection; //Do final MC correction
949 Bool_t fSatelliteVertices; // Satellite vertex flag
950 Int_t fDebug; // Debug level
952 ClassDef(CentralityBin,4); // A centrality bin
954 Bool_t fCorrEmpty; // Correct for empty bins
955 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
956 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
957 Double_t fTriggerEff0; // Bin-0 Trigger efficiency for sel trigger(s)
958 TObjArray* fListOfCentralities; // Centrality bins
959 UShort_t fNormalizationScheme; // Normalization scheme
960 TString fFinalMCCorrFile; //Filename for final MC corr
961 Bool_t fSatelliteVertices; // satellite vertex flag
962 TH2D* fEmpiricalCorrection; // Empirical correction
963 TH2D* fMeanVsC; //mean signal per event vs cent
964 TString fCentMethod; // Centrality estimator
965 UShort_t fPileupMask; // Pile-up checks
966 AliAnalysisUtils fAnaUtil; // Analysis utility
967 Bool_t fCheckSPDOutlier; // Check for SPD outliers
968 ClassDef(AliBasedNdetaTask,17); // Determine charged particle density