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
332 * Retrieve the histogram
334 * @param aod AOD event
335 * @param mc Whether to get the MC histogram or not
337 * @return Retrieved histogram or null
339 virtual TH2D* GetHistogram(const AliAODEvent* aod, Bool_t mc=false) = 0;
341 * Get the colour to use for markers (only pp - in PbPb we use a rainbow)
343 * @return Marker colour
345 virtual Int_t GetColor() const { return kBlack; }
347 * Get the marker style
349 * @return Marker style
351 virtual Int_t GetMarker() const { return GetMarkerStyle(kCircle); }
353 * Add a centrality bin
355 * @param at Where in the list to add this bin
357 * @param high High cut
359 void AddCentralityBin(UShort_t at, Short_t low, Short_t high);
361 * Make a centrality bin
363 * @param name Name used for histograms
364 * @param low Low cut in percent
365 * @param high High cut in percent
367 * @return A newly created centrality bin
369 virtual CentralityBin* MakeCentralityBin(const char* name, Short_t low,
372 //==================================================================
374 * Class that holds the sum of the data - possibly split into 0 or
378 struct Sum : public TNamed
380 TH2D* fSum; // Sum of non-zero events
381 TH2D* fSum0; // Sum of zero events
382 TH1I* fEvents; // Distribution of events
384 * I/O Constructor - do not use
386 Sum() : fSum(0), fSum0(0), fEvents(0) {}
391 * @param postfix Possible post-fix
393 Sum(const char* name, const char* postfix)
394 : TNamed(name,postfix),
402 * @param o Object to copy from
411 * Assignment operator
413 * @param o Object to assign from
415 * @return Reference to this object
417 Sum& operator=(const Sum& o) {
418 SetName(o.GetName()); fSum = o.fSum; fSum0 = o.fSum0; fEvents=o.fEvents;
426 * Initialise this object.
428 * @param list List to add histograms to
429 * @param data Format of data to be cloned here
432 void Init(TList* list, const TH2D* data, Int_t col);
436 * @param data Data to add
437 * @param isZero If this is zero event
439 void Add(const TH2D* data, Bool_t isZero=false);
441 * Get the histogram name
443 * @param what Which one
447 TString GetHistName(Int_t what=0) const;
451 * @param l List to get histograms from
452 * @param o Output list
453 * @param ntotal On return, the total number of events
454 * @param zeroEff Zero-bin efficiency
455 * @param otherEff Non-zero-bin efficiency
456 * @param marker Marker to use
457 * @param rootXproj Whether to use TH2::ProjectionX
458 * @param corrEmpty Correct for empty bins
460 * @return The total sum histogram
462 TH2D* GetSum(const TList* l, TList* o, Double_t& ntotal,
463 Double_t zeroEff, Double_t otherEff=1, Int_t marker=20,
464 Bool_t rootXproj=false, Bool_t corrEmpty=true) const;
467 //==================================================================
469 * Calculations done per centrality
472 class CentralityBin : public TNamed
482 * @param name Name used for histograms (e.g., Forward)
483 * @param low Lower centrality cut in percent
484 * @param high Upper centrality cut in percent
486 CentralityBin(const char* name, Short_t low, Short_t high);
490 * @param other Object to copy from
492 CentralityBin(const CentralityBin& other);
496 virtual ~CentralityBin();
498 * Assignment operator
500 * @param other Object to assign from
502 * @return Reference to this
504 CentralityBin& operator=(const CentralityBin& other);
506 * Check if this is the 'all' bin
508 * @return true if low and high cuts are both zero
510 Bool_t IsAllBin() const { return fLow == 0 && fHigh == 0; }
516 const char* GetListName() const;
518 * Create output objects
520 * @param dir Parent list
522 virtual void CreateOutputObjects(TList* dir);
526 * @param forward Forward data (for trigger, vertex, & centrality)
527 * @param triggerMask Trigger mask
528 * @param isZero True if this is a zero bin event
529 * @param vzMin Minimum IP z coordinate
530 * @param vzMax Maximum IP z coordinate
531 * @param data Data histogram
532 * @param mc MC histogram
534 virtual void ProcessEvent(const AliAODForwardMult* forward,
542 * Calculate the Event-Level normalization.
544 * The full event level normalization for trigger @f$X@f$ is given by
546 * N &=& \frac{1}{\epsilon_X}
547 * \left(N_A+\frac{N_A}{N_V}(N_{-V}-\beta)\right)\\
548 * &=& \frac{1}{\epsilon_X}N_A
549 * \left(1+\frac{1}{N_V}(N_T-N_V-\beta)\right)\\
550 * &=& \frac{1}{\epsilon_X}N_A
551 * \left(1+\frac{N_T}{N_V}-1-\frac{\beta}{N_V}\right)\\
552 * &=& \frac{1}{\epsilon_X}N_A
553 * \left(\frac{1}{\epsilon_V}-\frac{\beta}{N_V}\right)
557 * - @f$\epsilon_X=\frac{N_{T,X}}{N_X}@f$ is the trigger
558 * efficiency evaluated in simulation.
559 * - @f$\epsilon_V=\frac{N_V}{N_T}@f$ is the vertex efficiency
560 * evaluated from the data
561 * - @f$N_X@f$ is the Monte-Carlo truth number of events of type
563 * - @f$N_{T,X}@f$ is the Monte-Carlo truth number of events of type
564 * @f$X@f$ which was also triggered as such.
565 * - @f$N_T@f$ is the number of data events that where triggered
566 * as type @f$X@f$ and had a collision trigger (CINT1B)
567 * - @f$N_V@f$ is the number of data events that where triggered
568 * as type @f$X@f$, had a collision trigger (CINT1B), and had
570 * - @f$N_{-V}@f$ is the number of data events that where triggered
571 * as type @f$X@f$, had a collision trigger (CINT1B), but no
573 * - @f$N_A@f$ is the number of data events that where triggered
574 * as type @f$X@f$, had a collision trigger (CINT1B), and had
575 * a vertex in the selected range.
576 * - @f$\beta=N_a+N_c-N_e@f$ is the number of control triggers that
577 * were also triggered as type @f$X@f$.
578 * - @f$N_a@f$ Number of beam-empty events also triggered as type
579 * @f$X@f$ events (CINT1-A or CINT1-AC).
580 * - @f$N_c@f$ Number of empty-beam events also triggered as type
581 * @f$X@f$ events (CINT1-C).
582 * - @f$N_e@f$ Number of empty-empty events also triggered as type
583 * @f$X@f$ events (CINT1-E).
585 * Note, that if @f$ \beta \ll N_A@f$ the last term can be ignored, and
586 * the expression simplyfies to
588 * N = \frac{1}{\epsilon_X}\frac{1}{\epsilon_V}N_A
591 * @param t Histogram of triggers
592 * @param scheme Normalisation scheme
593 * @param trgEff Trigger efficiency
594 * @param ntotal On return, the total number of events to normalise to.
596 * @return @f$N_A/N@f$ or negative number in case of errors.
598 virtual Double_t Normalization(const TH1I& t,
601 Double_t& ntotal) const;
603 * Generate the dN/deta result from input
605 * @param sum Sum of 2D hists
606 * @param postfix Post fix on names
607 * @param rootProj Whether to use ROOT TH2::ProjectionX
608 * @param corrEmpty Correct for empty bins
609 * @param shapeCorr Shape correction to use
610 * @param scaler Event-level normalization scaler
611 * @param symmetrice Whether to make symmetric extensions
612 * @param rebin Whether to rebin
613 * @param cutEdges Whether to cut edges when rebinning
614 * @param marker Marker style
615 * @param color Color of markers
616 * @param mclist List of MC data
617 * @param truthlist List of MC truth data
619 virtual void MakeResult(const TH2D* sum,
623 const TH1* shapeCorr,
635 * @param sums List of sums
636 * @param results Output list of results
637 * @param scheme Normalisation scheme options
638 * @param shapeCorr Shape correction or nil
639 * @param trigEff Trigger efficiency
640 * @param symmetrice Whether to symmetrice the results
641 * @param rebin Whether to rebin the results
642 * @param rootProj If true, use TH2::ProjectionX
643 * @param corrEmpty Whether to correct for empty bins
644 * @param cutEdges Whether to cut edges when rebinning
645 * @param triggerMask Trigger mask
646 * @param marker Marker style
647 * @param color Color of markers
648 * @param mclist List of MC data
649 * @param truthlist List of MC truth data
651 virtual void End(TList* sums,
654 const TH1* shapeCorr,
668 * @name Access histograms
673 * @param mc If true, return MC histogram
675 * @return Sum histogram
677 const Sum* GetSum(Bool_t mc=false) const { return mc ? fSumMC : fSum; }
681 * @param mc If true, return MC histogram
683 * @return Sum histogram
685 Sum* GetSum(Bool_t mc=false) { return mc ? fSumMC : fSum; }
687 * Get trigger histogram
689 * @return Trigger histogram
691 const TH1I* GetTriggers() const { return fTriggers; }
693 * Get trigger histogram
695 * @return Trigger histogram
697 TH1I* GetTrigggers() { return fTriggers; }
701 * Get the color of the markers
705 Int_t GetColor(Int_t fallback=kRed+2) const;
707 * Get list of results
712 TList* GetResults() const { return fOutput; }
714 * Get name of result histogram
722 const char* GetResultName(Int_t rebin, Bool_t sym,
723 const char* postfix="") const;
733 TH1* GetResult(Int_t rebin, Bool_t sym,
734 const char* postfix="") const;
738 * Create sum histogram
740 * @param data Data histogram to clone
741 * @param mc (optional) MC histogram to clone
743 virtual void CreateSums(const TH2D* data, const TH2D* mc);
745 * Check the trigger, vertex, and centrality
747 * @param forward Event input
748 * @param triggerMask The used trigger mask
749 * @param vzMin Least @f$ v_z@f$
750 * @param vzMax Largest @f$ v_z@f$
752 * @return true if the event is to be used
754 virtual Bool_t CheckEvent(const AliAODForwardMult* forward,
758 TList* fSums; // Output list
759 TList* fOutput; // Output list
760 Sum* fSum; // Sum histogram
761 Sum* fSumMC; // MC sum histogram
762 TH1I* fTriggers; // Trigger histogram
763 UShort_t fLow; // Lower limit (inclusive)
764 UShort_t fHigh; // Upper limit (exclusive)
765 Bool_t fDoFinalMCCorrection; //Do final MC correction
767 ClassDef(CentralityBin,1); // A centrality bin
769 TList* fSums; // Container of sums
770 TList* fOutput; // Container of outputs
771 Double_t fVtxMin; // Minimum v_z
772 Double_t fVtxMax; // Maximum v_z
773 Int_t fTriggerMask; // Trigger mask
774 Int_t fRebin; // Rebinning factor
775 Bool_t fCutEdges; // Whether to cut edges when rebinning
776 Bool_t fSymmetrice; // Whether to symmetrice data
777 Bool_t fCorrEmpty; // Correct for empty bins
778 Bool_t fUseROOTProj; // Whether to use ROOT's ProjectionX
779 Double_t fTriggerEff; // Trigger efficiency for selected trigger(s)
780 TH1* fShapeCorr; // Shape correction
781 TObjArray* fListOfCentralities; // Centrality bins
782 TNamed* fSNNString; // sqrt(s_NN) string
783 TNamed* fSysString; // Collision system string
784 TH1D* fCent; // Centrality distribution
785 TAxis* fCentAxis; // Centrality axis
786 UShort_t fNormalizationScheme; // Normalization scheme
787 TNamed* fSchemeString;
788 TNamed* fTriggerString;
789 TString fFinalMCCorrFile; //Filename for final MC corr
791 ClassDef(AliBasedNdetaTask,4); // Determine multiplicity in base area