2 // See implementation or Doxygen comments for more information
4 #ifndef ALIAODFORWARDMULT_H
5 #define ALIAODFORWARDMULT_H
7 * @file AliAODForwardMult.h
8 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
9 * @date Wed Mar 23 13:58:00 2011
13 * @ingroup pwglf_forward_aod
21 * Class that contains the forward multiplicity data per event
23 * This class contains a histogram of
25 * \frac{d^2N_{ch}}{d\eta d\phi}\quad,
27 * as well as a trigger mask for each analysed event.
29 * The eta acceptance of the event is stored in the underflow bins of
30 * the histogram. So to build the final histogram, one needs to
31 * correct for this acceptance (properly weighted by the events), and
32 * the vertex efficiency. This simply boils down to defining a 2D
33 * histogram and summing the event histograms in that histogram. One
34 * should of course also do proper book-keeping of the accepted event.
39 * TFile* file = TFile::Open("AliAODs.root","READ");
40 * TTree* tree = static_cast<TTree*>(file->Get("aodTree"));
46 * TH2D* sum = 0; // Summed hist
47 * TTree* tree = GetAODTree(); // AOD tree
48 * AliAODForwardMult* mult = 0; // AOD object
49 * Int_t nTriggered = 0; // # of triggered ev.
50 * Int_t nWithVertex= 0; // # of ev. w/vertex
51 * Int_t nAccepted = 0; // # of ev. used
52 * Int_t nAvailable = tree->GetEntries(); // How many entries
53 * Float_t vzLow = -10; // Lower ip cut
54 * Float_t vzHigh = 10; // Upper ip cut
55 * Int_t mask = AliAODForwardMult::kInel;// Trigger mask
56 * tree->SetBranchAddress("forward", &forward); // Set the address
58 * for (int i = 0; i < nAvailable; i++) {
59 * // Create sum histogram on first event - to match binning to input
60 * if (!sum) sum = static_cast<TH2D*>(mult->Clone("d2ndetadphi"));
64 * // Other trigger/event requirements could be defined
65 * if (!mult->IsTriggerBits(mask)) continue;
68 * // Check if we have vertex
69 * if (!mult->HasIpZ()) continue;
72 * // Select vertex range (in centimeters)
73 * if (!mult->InRange(vzLow, vzHigh) continue;
76 * // Add contribution from this event
77 * sum->Add(&(mult->GetHistogram()));
80 * // Get acceptance normalisation from underflow bins
81 * TH1D* norm = sum->ProjectionX("norm", 0, 1, "");
82 * // Project onto eta axis - _ignoring_underflow_bins_!
83 * TH1D* dndeta = sum->Projection("dndeta", 1, -1, "e");
84 * // Normalize to the acceptance
85 * dndeta->Divide(norm);
86 * // Scale by the vertex efficiency
87 * dndeta->Scale(Double_t(nWithVertex)/nTriggered, "width");
88 * // And draw the result
93 * The above code will draw the final @f$ dN_{ch}/d\eta@f$ for the
94 * selected event class and vertex range
96 * The histogram can be used as input for other kinds of analysis too,
97 * like flow, event-plane, centrality, and so on.
99 * @ingroup pwglf_forward
100 * @ingroup pwglf_forward_aod
102 class AliAODForwardMult : public TObject
106 * Bits of the trigger pattern
109 /** In-elastic collision */
111 /** In-elastic collision with at least one SPD tracklet */
113 /** Non-single diffractive collision */
115 /** Empty bunch crossing */
117 /** A-side trigger */
119 /** B(arrel) trigger */
121 /** C-side trigger */
125 /** pileup from SPD */
127 /** true NSD from MC */
129 /** Offline MB triggered */
131 /** At least one SPD cluster */
132 kNClusterGt0 = 0x1000,
133 /** V0-AND trigger */
135 /** Satellite event */
139 * Bin numbers in trigger histograms
161 * User bits of these objects (bits 14-23 can be used)
164 /** Secondary correction maps where applied */
165 kSecondary = (1 << 14),
166 /** Vertex bias correction was applied */
167 kVertexBias = (1 << 15),
168 /** Acceptance correction was applied */
169 kAcceptance = (1 << 16),
170 /** Merging efficiency correction was applied */
171 kMergingEfficiency = (1 << 17),
172 /** Signal in overlaps is the sum */
174 /** Used eta dependent empirical correction - to be implemented */
175 kEmpirical = (1 << 19)
178 * Return codes of CheckEvent
181 /** Event accepted by cuts */
183 /** Event centrality not in range */
185 /** Event trigger isn't in the supplied mask */
187 /** Event is a pile-up event */
189 /** Event has no interaction point information */
191 /** Event interaction point is out of range */
196 * Default constructor
198 * Used by ROOT I/O sub-system - do not use
204 * @param isMC Whether this was from MC or not
206 AliAODForwardMult(Bool_t isMC);
210 virtual ~AliAODForwardMult() {} // Destructor
214 * @param etaAxis Pseudo-rapidity axis
216 void Init(const TAxis& etaAxis);
218 * Get the @f$ d^2N_{ch}/d\eta d\phi@f$ histogram,
220 * @return @f$ d^2N_{ch}/d\eta d\phi@f$ histogram,
222 const TH2D& GetHistogram() const { return fHist; } // Get histogram
224 * Get the @f$ d^2N_{ch}/d\eta d\phi@f$ histogram,
226 * @return @f$ d^2N_{ch}/d\eta d\phi@f$ histogram,
228 TH2D& GetHistogram() { return fHist; } // Get histogram
230 * Get the trigger bits
232 * @return Trigger bits
234 UInt_t GetTriggerBits() const { return fTriggers; } // Get triggers
236 * Set the trigger mask
238 * @param trg Trigger mask
240 void SetTriggerMask(UInt_t trg) { fTriggers = trg; } // Set triggers
242 * Set bit(s) in trigger mask
244 * @param bits bit(s) to set
246 void SetTriggerBits(UInt_t bits) { fTriggers |= bits; } // Set trigger bits
248 * Check if all bit(s) are set in the trigger mask. Note, this is
249 * an @e and between the bits. If you need an @e or you should use
250 * the member function IsTriggerOrBits
252 * @param bits Bits to test for
254 * @return true if all enabled bits in the argument is also set in
257 Bool_t IsTriggerBits(UInt_t bits) const;
259 * Check if any of bit(s) are enabled in the trigger word. This is
260 * an @e or between the selected bits. If you need and @a and you
261 * should use the member function IsTriggerBits;
263 * @param bits Bits to check for
265 * @return true if any of the enabled bits in the arguments are also
266 * enabled in the trigger mask
268 Bool_t IsTriggerOrBits(UInt_t bits) const;
270 * Whether we have any trigger bits
272 * @return true if we have some trigger
274 Bool_t HasTrigger() const { return fTriggers != 0; } // Check for triggers
278 * @param option Passed on to TH2::Reset verbatim
280 void Clear(Option_t* option="");
286 void Browse(TBrowser* b);
290 * @return Always true
292 Bool_t IsFolder() const { return kTRUE; } // Always true
294 Bool_t IsSecondaryCorrected() const { return TestBit(kSecondary); }
295 Bool_t IsVertexBiasCorrected() const { return TestBit(kVertexBias); }
296 Bool_t IsAcceptanceCorrected() const { return TestBit(kAcceptance); }
297 Bool_t IsMergingEfficiencyCorrected() const {
298 return TestBit(kMergingEfficiency); }
299 Bool_t IsEmpiricalCorrected() const { return TestBit(kEmpirical); }
300 Bool_t IsSumSignal() const { return TestBit(kSum); }
304 * @param option Passed verbatim to TH2::Print
306 void Print(Option_t* option="") const;
308 * Set the z coordinate of the interaction point
310 * @param ipZ Interaction point z coordinate
312 void SetIpZ(Float_t ipZ) { fIpZ = ipZ; } // Set Ip's Z coordinate
314 * Set the center of mass energy per nucleon-pair. This is stored
315 * in the (0,0) of the histogram
317 * @param sNN Center of mass energy per nucleon pair (GeV)
319 void SetSNN(UShort_t sNN);
321 * Get the collision system number
326 * @param sys Collision system number
328 void SetSystem(UShort_t sys);
330 * Set the event centrality
332 * @param c Centrality
334 void SetCentrality(Float_t c) { fCentrality = c; }
336 * Set the z coordinate of the interaction point
338 * @return Interaction point z coordinate
340 Float_t GetIpZ() const { return fIpZ; } // Get Ip's Z coordinate
342 * Check if we have a valid z coordinate of the interaction point
344 * @return True if we have a valid interaction point z coordinate
346 Bool_t HasIpZ() const;
348 * Get the center of mass energy per nucleon pair (GeV)
350 * @return Center of mass energy per nucleon pair (GeV)
352 UShort_t GetSNN() const;
354 * Get the collision system number
359 * @return Collision system number
361 UShort_t GetSystem() const;
363 * Check if the z coordinate of the interaction point is within the
364 * given limits. Note that the convention used corresponds to the
365 * convention used in ROOTs TAxis.
367 * @param low Lower cut (inclusive)
368 * @param high Upper cut (exclusive)
370 * @return true if @f$ low \ge ipz < high@f$
372 Bool_t InRange(Float_t low, Float_t high) const;
374 * Get the event centrality
379 Float_t GetCentrality() const { return fCentrality; }
381 * Check if we have a valid centrality
386 Bool_t HasCentrality() const { return !(fCentrality < 0); }
388 * Get the number of SPD clusters seen in @f$ |\eta|<1@f$
390 * @return Number of SPD clusters seen
392 UShort_t GetNClusters() const { return fNClusters; }
394 * Set the number of SPD clusters seen in @f$ |\eta|<1@f$
396 * @param n Number of SPD clusters
398 void SetNClusters(UShort_t n) { fNClusters = n; }
400 * Get the name of the object
402 * @return Name of object
404 const Char_t* GetName() const { return (fIsMC ? "ForwardMC" : "Forward"); }
406 * Check if event meets the passses requirements.
408 * It returns true if @e all of the following is true
410 * - The trigger is within the bit mask passed.
411 * - The vertex is within the specified limits.
412 * - The centrality is within the specified limits, or if lower
413 * limit is equal to or larger than the upper limit.
415 * Note, for data with out a centrality estimate (e.g., pp), one
416 * must pass equal centrality cuts, or no data will be accepted. In
417 * other words, for pp data, always pass cMin=0, cMax=0
419 * If a histogram is passed in the last parameter, then that
420 * histogram is filled with the trigger bits.
422 * @param triggerMask Trigger mask
423 * @param vzMin Minimum @f$ v_z@f$ (in centimeters)
424 * @param vzMax Maximum @f$ v_z@f$ (in centimeters)
425 * @param cMin Minimum centrality (in percent)
426 * @param cMax Maximum centrality (in percent)
427 * @param hist Histogram to fill
428 * @param status Histogram to fill
431 * @return @c true if the event meets the requirements
433 Bool_t CheckEvent(Int_t triggerMask=kInel,
434 Double_t vzMin=-10, Double_t vzMax=10,
435 UShort_t cMin=0, UShort_t cMax=100,
437 TH1* status=0) const;
439 * Get a string correspondig to the trigger mask
441 * @param mask Trigger mask
443 * @return Static string (copy before use)
445 static const Char_t* GetTriggerString(UInt_t mask);
447 * Make a histogram to record triggers in.
449 * The bins defined by the trigger enumeration in this class. One
450 * can use this enumeration to retrieve the number of triggers for
453 * @param name Name of the histogram
454 * @param mask Trigger mask
456 * @return Newly allocated histogram
458 static TH1I* MakeTriggerHistogram(const char* name="triggers",
461 * Make a histogram to record status in.
463 * The bins defined by the status enumeration in this class.
465 * @param name Name of the histogram
467 * @return Newly allocated histogram
469 static TH1I* MakeStatusHistogram(const char* name="status");
471 * Utility function to make a trigger mask from the passed string.
473 * The string is a comma or space seperated list of case-insensitive
480 * @param what Which triggers to put in the mask.
482 * @return The generated trigger mask.
484 static UInt_t MakeTriggerMask(const char* what);
486 /** From MC or not */
487 Bool_t fIsMC; // Whether this is from MC
488 /** Histogram of @f$d^2N_{ch}/(d\eta d\phi)@f$ for this event */
489 TH2D fHist; // Histogram of d^2N_{ch}/(deta dphi) for this event
491 UInt_t fTriggers; // Trigger bit mask
492 /** Interaction point @f$z@f$ coordinate */
493 Float_t fIpZ; // Z coordinate of the interaction point
495 Float_t fCentrality; // Event centrality
496 /** Number of clusters in @f$|\eta|<1@f$ */
497 UShort_t fNClusters; // Number of SPD clusters in |eta|<1
498 /** Invalid value for interaction point @f$z@f$ coordiante */
499 static const Float_t fgkInvalidIpZ; // Invalid IpZ value
500 ClassDef(AliAODForwardMult,5); // AOD forward multiplicity
503 //____________________________________________________________________
505 AliAODForwardMult::InRange(Float_t low, Float_t high) const
507 return HasIpZ() && fIpZ >= low && fIpZ < high;
510 //____________________________________________________________________
512 AliAODForwardMult::IsTriggerBits(UInt_t bits) const
514 return HasTrigger() && ((fTriggers & bits) == bits);
516 //____________________________________________________________________
518 AliAODForwardMult::IsTriggerOrBits(UInt_t bits) const
520 return HasTrigger() && ((fTriggers & bits) != 0);