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>
23 class AliAODForwardMult;
27 * @defgroup pwglf_forward_tasks_dndeta dN/deta tasks
28 * @ingroup pwglf_forward_tasks
31 * @defgroup pwglf_forward_dndeta dN/deta
33 * @f$ dN/d\eta@f$ code
35 * @ingroup pwglf_forward_topical
38 * Base class for tasks to determine @f$ dN/d\eta@f$
40 * @ingroup pwglf_forward_tasks_dndeta
41 * @ingroup pwglf_forward_dndeta
43 class AliBasedNdetaTask : public AliAnalysisTaskSE
47 * Bit mask values of the normalisation scheme
50 /** Only normalize to accepted events */
53 * Do the full normalisation
55 * N = \frac{1}{\epsilon_X}(N_A-N_A/N_V(N_T-N_V)) =
56 * \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
61 * Do the shape correction
65 * Correct for background events (A+C-E). Not implemented yet
69 * Correct for the trigger efficiency from MC
71 kTriggerEfficiency = 0x8,
73 * Correct using zero-bin efficiency only
77 * Do the full correction
79 kFull = kEventLevel | kShape | kBackground | kTriggerEfficiency,
89 * @param name Name of task
91 AliBasedNdetaTask(const char* name);
96 virtual ~AliBasedNdetaTask();
100 * @name Task configuration
103 * Set the vertex range to use
105 * @param min Minimum (in centermeter)
106 * @param max Maximum (in centermeter)
108 void SetVertexRange(Double_t min, Double_t max) { fVtxMin=min; fVtxMax=max; }
110 * Set the rebinning factor
112 * @param rebin Rebinning factor
114 void SetRebinning(Int_t rebin) { fRebin = rebin; }
116 * Set the trigger maskl
118 * @param mask Trigger mask
120 void SetTriggerMask(UShort_t mask);
122 * Set the trigger mask
124 * @param mask trigger mask
126 void SetTriggerMask(const char* mask);
128 * Set the centrality bins to use.
131 * UShort_t bins[] = { 0, 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
132 * task->SetCentralityBins(11, bins);
135 * @param n Number of bins (elements in @a bins minus 1)
136 * @param bins Bin limits
138 void SetCentralityAxis(UShort_t n, Short_t* bins);
140 * Whether to cut edges when merging
142 * @param cut If true, cut edges
144 void SetCutEdges(Bool_t cut) {fCutEdges = cut;}
146 * Set whether to correct for empty bins when projecting on the X axis.
148 * @param use Whether to correct for empty bins
150 void SetCorrEmpty(Bool_t use) { fCorrEmpty = use; }
152 * Set whether to use the ROOT TH2::ProjectionX method when
153 * projecting on the X axis.
155 * @param use Whether to use TH2::ProjectionX
157 void SetUseROOTProjectX(Bool_t use) { fUseROOTProj = use; }
159 * Trigger efficiency for selected trigger(s)
161 * @param e Trigger efficiency
163 void SetTriggerEff(Double_t e) { fTriggerEff = e; }
165 * Set the shape correction (a.k.a., track correction) for selected
168 * @param h Correction
170 void SetShapeCorrection(const TH1* h);
172 * Setthe normalisation scheme to use
174 * @param scheme Normalisation scheme
176 void SetNormalizationScheme(UShort_t scheme);
178 * Space, pipe, or comma separated list of options
180 * @param what List of options
182 void SetNormalizationScheme(const char* what);
184 * Filename of final MC correction
186 * @param filename filename
188 void SetMCFinalCorrFilename(const char* filename) {
189 fFinalMCCorrFile.Clear();
190 fFinalMCCorrFile.Append(filename);
193 * Load the normalization data - done automatically if not set from outside
196 * @param energy energy
198 void LoadNormalizationData(UShort_t sys, UShort_t energy);
203 * @param option Not used
205 void Print(Option_t* option="") const;
207 * @name Task interface
210 * Initialise on master - does nothing
213 virtual void Init() {}
215 * Create output objects.
217 * This is called once per slave process
219 virtual void UserCreateOutputObjects();
221 * Process a single event
223 * @param option Not used
225 virtual void UserExec(Option_t* option);
227 * Called at end of event processing.
229 * This is called once in the master
231 * @param option Not used
233 virtual void Terminate(Option_t* option);
238 * @name Services member functions
241 * Make a copy of the input histogram and rebin that histogram
243 * @param h Histogram to rebin
244 * @param rebin Rebinning factor
245 * @param cutEdges Whether to cut edges when rebinning
247 * @return New (rebinned) histogram
249 static TH1D* Rebin(const TH1D* h, Int_t rebin, Bool_t cutEdges=false);
251 * Make an extension of @a h to make it symmetric about 0
253 * @param h Histogram to symmertrice
255 * @return Symmetric extension of @a h
257 static TH1* Symmetrice(const TH1* h);
259 * Project onto the X axis
261 * @param h 2D histogram
262 * @param name New name
263 * @param firstbin First bin to use
264 * @param lastbin Last bin to use
265 * @param useROOT Use TH2::ProjectionX instead of custom code
266 * @param corr Whether to do corrections or not
267 * @param error Whether to calculate errors
269 * @return Newly created histogram or null
271 static TH1D* ProjectX(const TH2D* h,
279 * Scale the copy of the 2D histogram by coverage in supplied 1D histogram
281 * @param copy Data to scale
282 * @param norm Coverage histogram
284 static void ScaleToCoverage(TH2D* copy, const TH1D* norm);
286 * Set histogram graphical options, etc.
288 * @param h Histogram to modify
289 * @param colour Marker color
290 * @param marker Marker style
291 * @param title Title of histogram
292 * @param ytitle Title on y-axis.
294 static void SetHistogramAttributes(TH1D* h, Int_t colour, Int_t marker,
296 const char* ytitle="#frac{1}{N} #frac{dN_{ch}}{d#eta}");
308 kDownTriangle = 0x008,
313 static Int_t GetMarkerStyle(UShort_t bits);
314 static UShort_t GetMarkerBits(Int_t style);
315 static Int_t FlipHollowStyle(Int_t style);
320 AliBasedNdetaTask(const AliBasedNdetaTask&);
322 * Assignment operator
327 AliBasedNdetaTask& operator=(const AliBasedNdetaTask&) { return *this; }
328 // Forward declaration
331 * Retrieve the AOD event
333 * @param isESD If true, assume the AOD event is the output
335 * @return Pointer to AOD event or null
337 AliAODEvent* GetAODEvent(Bool_t isESD=false);
340 * Retrieve the histogram
342 * @param aod AOD event
343 * @param mc Whether to get the MC histogram or not
345 * @return Retrieved histogram or null
347 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
349 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
351 * @return Marker colour
353 virtual Int_t GetColor() const { return kBlack; }
355 * Get the marker style
357 * @return Marker style
359 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
361 * Add a centrality bin
363 * @param at Where in the list to add this bin
365 * @param high High cut
367 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
369 * Make a centrality bin
371 * @param name Name used for histograms
372 * @param low Low cut in percent
373 * @param high High cut in percent
375 * @return A newly created centrality bin
377 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
380 //==================================================================
382 * Class that holds the sum of the data - possibly split into 0 or
386 struct Sum : public TNamed
388 TH2D* fSum; // Sum of non-zero events
389 TH2D* fSum0; // Sum of zero events
390 TH1I* fEvents; // Distribution of events
392 * I/O Constructor - do not use
394 Sum() : fSum(0), fSum0(0), fEvents(0) {}
399 * @param postfix Possible post-fix
401 Sum(const char* name, const char* postfix)
402 : TNamed(name,postfix),
410 * @param o Object to copy from
419 * Assignment operator
421 * @param o Object to assign from
423 * @return Reference to this object
425 Sum& operator=(const Sum& o) {
426 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
434 * Initialise this object.
436 * @param list List to add histograms to
437 * @param data Format of data to be cloned here
440 void Init(TList* list, const TH2D* data, Int_t col);
444 * @param data Data to add
445 * @param isZero If this is zero event
447 void Add(const TH2D* data, Bool_t isZero=false);
449 * Get the histogram name
451 * @param what Which one
455 TString GetHistName(Int_t what=0) const;
459 * @param l List to get histograms from
460 * @param o Output list
461 * @param ntotal On return, the total number of events
462 * @param zeroEff Zero-bin efficiency
463 * @param otherEff Non-zero-bin efficiency
464 * @param marker Marker to use
465 * @param rootXproj Whether to use TH2::ProjectionX
466 * @param corrEmpty Correct for empty bins
468 * @return The total sum histogram
470 TH2D* GetSum(const TList* l, TList* o, Double_t& ntotal,
471 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
472 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
475 //==================================================================
477 * Calculations done per centrality
480 class CentralityBin : public TNamed
490 * @param name Name used for histograms (e.g., Forward)
491 * @param low Lower centrality cut in percent
492 * @param high Upper centrality cut in percent
494 CentralityBin(const char* name, Short_t low, Short_t high);
498 * @param other Object to copy from
500 CentralityBin(const CentralityBin& other);
504 virtual ~CentralityBin();
506 * Assignment operator
508 * @param other Object to assign from
510 * @return Reference to this
512 CentralityBin& operator=(const CentralityBin& other);
514 * Check if this is the 'all' bin
516 * @return true if low and high cuts are both zero
518 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
524 const char* GetListName() const;
526 * Create output objects
528 * @param dir Parent list
530 virtual void CreateOutputObjects(TList* dir);
534 * @param forward Forward data (for trigger, vertex, & centrality)
535 * @param triggerMask Trigger mask
536 * @param isZero True if this is a zero bin event
537 * @param vzMin Minimum IP z coordinate
538 * @param vzMax Maximum IP z coordinate
539 * @param data Data histogram
540 * @param mc MC histogram
542 virtual void ProcessEvent(const AliAODForwardMult* forward,
550 * Calculate the Event-Level normalization.
552 * The full event level normalization for trigger @f$X@f$ is given by
554 * N &=& \frac{1}{\epsilon_X}
555 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
556 * &=& \frac{1}{\epsilon_X}N_A
557 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
558 * &=& \frac{1}{\epsilon_X}N_A
559 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
560 * &=& \frac{1}{\epsilon_X}N_A
561 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
565 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
566 * efficiency evaluated in simulation.
567 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
568 * evaluated from the data
569 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
571 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
572 * @f$X@f$ which was also triggered as such.
573 * - @f$N_T@f$ is the number of data events that where triggered
574 * as type @f$X@f$ and had a collision trigger (CINT1B)
575 * - @f$N_V@f$ is the number of data events that where triggered
576 * as type @f$X@f$, had a collision trigger (CINT1B), and had
578 * - @f$N_{-V}@f$ is the number of data events that where triggered
579 * as type @f$X@f$, had a collision trigger (CINT1B), but no
581 * - @f$N_A@f$ is the number of data events that where triggered
582 * as type @f$X@f$, had a collision trigger (CINT1B), and had
583 * a vertex in the selected range.
584 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
585 * were also triggered as type @f$X@f$.
586 * - @f$N_a@f$ Number of beam-empty events also triggered as type
587 * @f$X@f$ events (CINT1-A or CINT1-AC).
588 * - @f$N_c@f$ Number of empty-beam events also triggered as type
589 * @f$X@f$ events (CINT1-C).
590 * - @f$N_e@f$ Number of empty-empty events also triggered as type
591 * @f$X@f$ events (CINT1-E).
593 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
594 * the expression simplyfies to
596 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
599 * @param t Histogram of triggers
600 * @param scheme Normalisation scheme
601 * @param trgEff Trigger efficiency
602 * @param ntotal On return, the total number of events to normalise to.
604 * @return @f$N_A/N@f$ or negative number in case of errors.
606 virtual Double_t Normalization(const TH1I& t,
609 Double_t& ntotal) const;
611 * Generate the dN/deta result from input
613 * @param sum Sum of 2D hists
614 * @param postfix Post fix on names
615 * @param rootProj Whether to use ROOT TH2::ProjectionX
616 * @param corrEmpty Correct for empty bins
617 * @param shapeCorr Shape correction to use
618 * @param scaler Event-level normalization scaler
619 * @param symmetrice Whether to make symmetric extensions
620 * @param rebin Whether to rebin
621 * @param cutEdges Whether to cut edges when rebinning
622 * @param marker Marker style
623 * @param color Color of markers
624 * @param mclist List of MC data
625 * @param truthlist List of MC truth data
627 virtual void MakeResult(const TH2D* sum,
631 const TH1* shapeCorr,
643 * @param sums List of sums
644 * @param results Output list of results
645 * @param scheme Normalisation scheme options
646 * @param shapeCorr Shape correction or nil
647 * @param trigEff Trigger efficiency
648 * @param symmetrice Whether to symmetrice the results
649 * @param rebin Whether to rebin the results
650 * @param rootProj If true, use TH2::ProjectionX
651 * @param corrEmpty Whether to correct for empty bins
652 * @param cutEdges Whether to cut edges when rebinning
653 * @param triggerMask Trigger mask
654 * @param marker Marker style
655 * @param color Color of markers
656 * @param mclist List of MC data
657 * @param truthlist List of MC truth data
659 virtual void End(TList* sums,
662 const TH1* shapeCorr,
676 * @name Access histograms
681 * @param mc If true, return MC histogram
683 * @return Sum histogram
685 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
689 * @param mc If true, return MC histogram
691 * @return Sum histogram
693 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
695 * Get trigger histogram
697 * @return Trigger histogram
699 const TH1I* GetTriggers() const { return fTriggers; }
701 * Get trigger histogram
703 * @return Trigger histogram
705 TH1I* GetTrigggers() { return fTriggers; }
709 * Get the color of the markers
713 Int_t GetColor(Int_t fallback=kRed+2) const;
715 * Get list of results
720 TList* GetResults() const { return fOutput; }
722 * Get name of result histogram
730 const char* GetResultName(Int_t rebin, Bool_t sym,
731 const char* postfix="") const;
741 TH1* GetResult(Int_t rebin, Bool_t sym,
742 const char* postfix="") const;
746 * Create sum histogram
748 * @param data Data histogram to clone
749 * @param mc (optional) MC histogram to clone
751 virtual void CreateSums(const TH2D* data, const TH2D* mc);
753 * Check the trigger, vertex, and centrality
755 * @param forward Event input
756 * @param triggerMask The used trigger mask
757 * @param vzMin Least @f$ v_z@f$
758 * @param vzMax Largest @f$ v_z@f$
760 * @return true if the event is to be used
762 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
766 TList* fSums; // Output list
767 TList* fOutput; // Output list
768 Sum* fSum; // Sum histogram
769 Sum* fSumMC; // MC sum histogram
770 TH1I* fTriggers; // Trigger histogram
771 UShort_t fLow; // Lower limit (inclusive)
772 UShort_t fHigh; // Upper limit (exclusive)
773 Bool_t fDoFinalMCCorrection; //Do final MC correction
775 ClassDef(CentralityBin,1); // A centrality bin
777 TList* fSums; // Container of sums
778 TList* fOutput; // Container of outputs
779 Double_t fVtxMin; // Minimum v_z
780 Double_t fVtxMax; // Maximum v_z
781 Int_t fTriggerMask; // Trigger mask
782 Int_t fRebin; // Rebinning factor
783 Bool_t fCutEdges; // Whether to cut edges when rebinning
784 Bool_t fSymmetrice; // Whether to symmetrice data
785 Bool_t fCorrEmpty; // Correct for empty bins
786 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
787 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
788 TH1* fShapeCorr; // Shape correction
789 TObjArray* fListOfCentralities; // Centrality bins
790 TNamed* fSNNString; // sqrt(s_NN) string
791 TNamed* fSysString; // Collision system string
792 TH1D* fCent; // Centrality distribution
793 TAxis* fCentAxis; // Centrality axis
794 UShort_t fNormalizationScheme; // Normalization scheme
795 TNamed* fSchemeString; // Normalization scheme string
796 TNamed* fTriggerString; // Trigger string
797 TString fFinalMCCorrFile; //Filename for final MC corr
798 Bool_t fIsESD; // Whether we have ESD input or not
800 ClassDef(AliBasedNdetaTask,5); // Determine multiplicity in base area