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 <AliAnalysisTaskSE.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 AliAnalysisTaskSE
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 vertex range to use
115 * @param min Minimum (in centermeter)
116 * @param max Maximum (in centermeter)
118 void SetVertexRange(Double_t min, Double_t max) { fVtxMin=min; fVtxMax=max; }
120 * Set the rebinning factor
122 * @param rebin Rebinning factor
124 void SetRebinning(Int_t rebin) { fRebin = rebin; }
126 * Set the trigger maskl
128 * @param mask Trigger mask
130 void SetTriggerMask(UShort_t mask);
132 * Set the trigger mask
134 * @param mask trigger mask
136 void SetTriggerMask(const char* mask);
138 * Set the centrality bins to use.
141 * UShort_t bins[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
142 * task->SetCentralityBins(11, bins);
145 * @param n Number of bins (elements in @a bins minus 1)
146 * @param bins Bin limits
148 void SetCentralityAxis(UShort_t n, Short_t* bins);
150 * Whether to cut edges when merging
152 * @param cut If true, cut edges
154 void SetCutEdges(Bool_t cut) {fCutEdges = cut;}
156 * Set whether to correct for empty bins when projecting on the X axis.
158 * @param use Whether to correct for empty bins
160 void SetCorrEmpty(Bool_t use) { fCorrEmpty = use; }
162 * Set whether to use the ROOT TH2::ProjectionX method when
163 * projecting on the X axis.
165 * @param use Whether to use TH2::ProjectionX
167 void SetUseROOTProjectX(Bool_t use) { fUseROOTProj = use; }
169 * Trigger efficiency for selected trigger(s)
171 * @param e Trigger efficiency
173 void SetTriggerEff(Double_t e) { fTriggerEff = e; }
175 * Set the shape correction (a.k.a., track correction) for selected
178 * @param h Correction
180 void SetShapeCorrection(const TH2F* h);
182 * Get a string representing the normalization scheme
184 * @param scheme Normalization scheme bits
186 * @return String representation
188 static const Char_t* NormalizationSchemeString(UShort_t scheme);
190 * Parse a string representing the normalization scheme
192 * @param what String of the normalization scheme
194 * @return normalization scheme bits
196 static UShort_t ParseNormalizationScheme(const Char_t* what);
198 * Setthe normalisation scheme to use
200 * @param scheme Normalisation scheme
202 void SetNormalizationScheme(UShort_t scheme);
204 * Space, pipe, or comma separated list of options
206 * @param what List of options
208 void SetNormalizationScheme(const char* what);
210 * Filename of final MC correction
212 * @param filename filename
214 void SetMCFinalCorrFilename(const char* filename) {
215 fFinalMCCorrFile.Clear();
216 fFinalMCCorrFile.Append(filename);
219 * Load the normalization data - done automatically if not set from outside
222 * @param energy energy
224 void LoadNormalizationData(UShort_t sys, UShort_t energy);
229 * @param option Not used
231 void Print(Option_t* option="") const;
233 * @name Task interface
236 * Initialise on master - does nothing
239 virtual void Init() {}
241 * Create output objects.
243 * This is called once per slave process
245 virtual void UserCreateOutputObjects();
247 * Process a single event
249 * @param option Not used
251 virtual void UserExec(Option_t* option);
253 * Called at end of event processing.
255 * This is called once in the master
257 * @param option Not used
259 virtual void Terminate(Option_t* option);
264 * @name Services member functions
267 * Make a copy of the input histogram and rebin that histogram
269 * @param h Histogram to rebin
270 * @param rebin Rebinning factor
271 * @param cutEdges Whether to cut edges when rebinning
273 * @return New (rebinned) histogram
275 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
277 * Make an extension of @a h to make it symmetric about 0
279 * @param h Histogram to symmertrice
281 * @return Symmetric extension of @a h
283 static TH1* Symmetrice(const TH1* h);
285 * Project onto the X axis
287 * @param h 2D histogram
288 * @param name New name
289 * @param firstbin First bin to use
290 * @param lastbin Last bin to use
291 * @param useROOT Use TH2::ProjectionX instead of custom code
292 * @param corr Whether to do corrections or not
293 * @param error Whether to calculate errors
295 * @return Newly created histogram or null
297 static TH1D* ProjectX(const TH2D* h,
305 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
307 * @param copy Data to scale
308 * @param norm Coverage histogram
310 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
312 * Set histogram graphical options, etc.
314 * @param h Histogram to modify
315 * @param colour Marker color
316 * @param marker Marker style
317 * @param title Title of histogram
318 * @param ytitle Title on y-axis.
320 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
322 const char* ytitle="#frac{1}{N} #frac{dN_{ch}}{d#eta}");
334 kDownTriangle = 0x008,
340 * Get the marker style from option bits
342 * @param bits Option bits
344 * @return Marker style
346 static Int_t GetMarkerStyle(UShort_t bits);
348 * Get the marker option bits from a style
352 * @return option bits
354 static UShort_t GetMarkerBits(Int_t style);
358 * @param style Style parameter
362 static Int_t FlipHollowStyle(Int_t style);
367 AliBasedNdetaTask(const AliBasedNdetaTask&);
369 * Assignment operator
374 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&) { return *this; }
375 // Forward declaration
378 * Create the CentralityBin objects if not already done.
381 virtual void InitializeCentBins();
383 * Retrieve the histogram
385 * @param aod AOD event
386 * @param mc Whether to get the MC histogram or not
388 * @return Retrieved histogram or null
390 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
392 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
394 * @return Marker colour
396 virtual Int_t GetColor() const { return kBlack; }
398 * Get the marker style
400 * @return Marker style
402 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
404 * Add a centrality bin
406 * @param at Where in the list to add this bin
408 * @param high High cut
410 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
412 * Make a centrality bin
414 * @param name Name used for histograms
415 * @param low Low cut in percent
416 * @param high High cut in percent
418 * @return A newly created centrality bin
420 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
423 //==================================================================
425 * Class that holds the sum of the data - possibly split into 0 or
429 struct Sum : public TNamed
431 TH2D* fSum; // Sum of non-zero events
432 TH2D* fSum0; // Sum of zero events
433 TH1I* fEvents; // Distribution of events
434 Int_t fDebug; // Debug level
436 * I/O Constructor - do not use
438 Sum() : fSum(0), fSum0(0), fEvents(0), fDebug(0) {}
443 * @param postfix Possible post-fix
445 Sum(const char* name, const char* postfix)
446 : TNamed(name,postfix),
455 * @param o Object to copy from
465 * Assignment operator
467 * @param o Object to assign from
469 * @return Reference to this object
471 Sum& operator=(const Sum& o) {
472 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
480 * Initialise this object.
482 * @param list List to add histograms to
483 * @param data Format of data to be cloned here
486 void Init(TList* list, const TH2D* data, Int_t col);
490 * @param data Data to add
491 * @param isZero If this is zero event
493 void Add(const TH2D* data, Bool_t isZero=false);
495 * Get the histogram name
497 * @param name Base name
498 * @param what Which one
499 * @param post Possible postfix
503 static TString GetHistName(const char* name, Int_t what=0,
506 * Get the histogram name
508 * @param what Which one
512 TString GetHistName(Int_t what=0) const;
516 * @param o Output list
517 * @param ntotal On return, the total number of events
518 * @param zeroEff Zero-bin efficiency
519 * @param otherEff Non-zero-bin efficiency
520 * @param marker Marker to use
521 * @param rootXproj Whether to use TH2::ProjectionX
522 * @param corrEmpty Correct for empty bins
524 * @return The total sum histogram
526 TH2D* CalcSum(TList* o, Double_t& ntotal,
527 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
528 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
531 //==================================================================
533 * Calculations done per centrality
536 class CentralityBin : public TNamed
546 * @param name Name used for histograms (e.g., Forward)
547 * @param low Lower centrality cut in percent
548 * @param high Upper centrality cut in percent
550 CentralityBin(const char* name, Short_t low, Short_t high);
554 * @param other Object to copy from
556 CentralityBin(const CentralityBin& other);
560 virtual ~CentralityBin();
562 * Assignment operator
564 * @param other Object to assign from
566 * @return Reference to this
568 CentralityBin& operator=(const CentralityBin& other);
570 * Check if this is the 'all' bin
572 * @return true if low and high cuts are both zero
574 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
580 const char* GetListName() const;
582 * Create output objects
584 * @param dir Parent list
586 virtual void CreateOutputObjects(TList* dir);
590 * @param forward Forward data (for trigger, vertex, & centrality)
591 * @param triggerMask Trigger mask
592 * @param isZero True if this is a zero bin event
593 * @param vzMin Minimum IP z coordinate
594 * @param vzMax Maximum IP z coordinate
595 * @param data Data histogram
596 * @param mc MC histogram
598 virtual void ProcessEvent(const AliAODForwardMult* forward,
606 * Calculate the Event-Level normalization.
608 * The full event level normalization for trigger @f$X@f$ is given by
610 * N &=& \frac{1}{\epsilon_X}
611 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
612 * &=& \frac{1}{\epsilon_X}N_A
613 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
614 * &=& \frac{1}{\epsilon_X}N_A
615 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
616 * &=& \frac{1}{\epsilon_X}N_A
617 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
621 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
622 * efficiency evaluated in simulation.
623 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
624 * evaluated from the data
625 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
627 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
628 * @f$X@f$ which was also triggered as such.
629 * - @f$N_T@f$ is the number of data events that where triggered
630 * as type @f$X@f$ and had a collision trigger (CINT1B)
631 * - @f$N_V@f$ is the number of data events that where triggered
632 * as type @f$X@f$, had a collision trigger (CINT1B), and had
634 * - @f$N_{-V}@f$ is the number of data events that where triggered
635 * as type @f$X@f$, had a collision trigger (CINT1B), but no
637 * - @f$N_A@f$ is the number of data events that where triggered
638 * as type @f$X@f$, had a collision trigger (CINT1B), and had
639 * a vertex in the selected range.
640 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
641 * were also triggered as type @f$X@f$.
642 * - @f$N_a@f$ Number of beam-empty events also triggered as type
643 * @f$X@f$ events (CINT1-A or CINT1-AC).
644 * - @f$N_c@f$ Number of empty-beam events also triggered as type
645 * @f$X@f$ events (CINT1-C).
646 * - @f$N_e@f$ Number of empty-empty events also triggered as type
647 * @f$X@f$ events (CINT1-E).
649 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
650 * the expression simplyfies to
652 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
655 * @param t Histogram of triggers
656 * @param scheme Normalisation scheme
657 * @param trgEff Trigger efficiency
658 * @param ntotal On return, the total number of events to normalise to.
660 * @return @f$N_A/N@f$ or negative number in case of errors.
662 virtual Double_t Normalization(const TH1I& t,
665 Double_t& ntotal) const;
667 * Generate the dN/deta result from input
669 * @param sum Sum of 2D hists
670 * @param postfix Post fix on names
671 * @param rootProj Whether to use ROOT TH2::ProjectionX
672 * @param corrEmpty Correct for empty bins
673 * @param shapeCorr Shape correction to use
674 * @param scaler Event-level normalization scaler
675 * @param symmetrice Whether to make symmetric extensions
676 * @param rebin Whether to rebin
677 * @param cutEdges Whether to cut edges when rebinning
678 * @param marker Marker style
679 * @param color Color of markers
680 * @param mclist List of MC data
681 * @param truthlist List of MC truth data
683 virtual void MakeResult(const TH2D* sum,
687 const TH2F* shapeCorr,
699 * @param sums List of sums
700 * @param results Output list of results
701 * @param scheme Normalisation scheme options
702 * @param shapeCorr Shape correction or nil
703 * @param trigEff Trigger efficiency
704 * @param symmetrice Whether to symmetrice the results
705 * @param rebin Whether to rebin the results
706 * @param rootProj If true, use TH2::ProjectionX
707 * @param corrEmpty Whether to correct for empty bins
708 * @param cutEdges Whether to cut edges when rebinning
709 * @param triggerMask Trigger mask
710 * @param marker Marker style
711 * @param color Color of markers
712 * @param mclist List of MC data
713 * @param truthlist List of MC truth data
715 virtual void End(TList* sums,
718 const TH2F* shapeCorr,
732 * @name Access histograms
737 * @param mc If true, return MC histogram
739 * @return Sum histogram
741 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
745 * @param mc If true, return MC histogram
747 * @return Sum histogram
749 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
751 * Get trigger histogram
753 * @return Trigger histogram
755 const TH1I* GetTriggers() const { return fTriggers; }
757 * Get trigger histogram
759 * @return Trigger histogram
761 TH1I* GetTrigggers() { return fTriggers; }
765 * Get the color of the markers
767 * @param fallback Fall-back color
769 * @return Color for this centrality bin
771 Int_t GetColor(Int_t fallback=kRed+2) const;
773 * Get list of results
776 * @return List of results
778 TList* GetResults() const { return fOutput; }
780 * Get name of result histogram
788 const char* GetResultName(Int_t rebin, Bool_t sym,
789 const char* postfix="") const;
799 TH1* GetResult(Int_t rebin, Bool_t sym,
800 const char* postfix="") const;
802 * Set the debug level
804 * @param lvl Debug level
806 void SetDebugLevel(Int_t lvl);
809 * Read in sum hisotgram from list
811 * @param list List to read from
812 * @param mc True for MC input
814 * @return true if sum histogram is found
816 virtual Bool_t ReadSum(TList* list, bool mc=false);
818 * Create sum histogram
820 * @param data Data histogram to clone
821 * @param mc (optional) MC histogram to clone
823 virtual void CreateSums(const TH2D* data, const TH2D* mc);
825 * Check the trigger, vertex, and centrality
827 * @param forward Event input
828 * @param triggerMask The used trigger mask
829 * @param vzMin Least @f$ v_z@f$
830 * @param vzMax Largest @f$ v_z@f$
832 * @return true if the event is to be used
834 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
838 TList* fSums; // Output list
839 TList* fOutput; // Output list
840 Sum* fSum; // Sum histogram
841 Sum* fSumMC; // MC sum histogram
842 TH1I* fTriggers; // Trigger histogram
843 UShort_t fLow; // Lower limit (inclusive)
844 UShort_t fHigh; // Upper limit (exclusive)
845 Bool_t fDoFinalMCCorrection; //Do final MC correction
846 Int_t fDebug; // Debug level
848 ClassDef(CentralityBin,2); // A centrality bin
850 TList* fSums; // Container of sums
851 TList* fOutput; // Container of outputs
852 Double_t fVtxMin; // Minimum v_z
853 Double_t fVtxMax; // Maximum v_z
854 Int_t fTriggerMask; // Trigger mask
855 Int_t fRebin; // Rebinning factor
856 Bool_t fCutEdges; // Whether to cut edges when rebinning
857 Bool_t fSymmetrice; // Whether to symmetrice data
858 Bool_t fCorrEmpty; // Correct for empty bins
859 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
860 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
861 TH2F* fShapeCorr; // Shape correction
862 TObjArray* fListOfCentralities; // Centrality bins
864 TNamed* fSNNString; // sqrt(s_NN) string
865 TNamed* fSysString; // Collision system string
867 TObject* fSNNString; // sqrt(s_NN) string
868 TObject* fSysString; // Collision system string
870 TH1D* fCent; // Centrality distribution
871 TAxis* fCentAxis; // Centrality axis
872 UShort_t fNormalizationScheme; // Normalization scheme
874 TNamed* fSchemeString; // Normalization scheme string
875 TNamed* fTriggerString; // Trigger string
877 TObject* fSchemeString; // Normalization scheme string
878 TObject* fTriggerString; // Trigger string
880 TString fFinalMCCorrFile; //Filename for final MC corr
882 ClassDef(AliBasedNdetaTask,8); // Determine multiplicity in base area