]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FORWARD/analysis2/AliAODForwardMult.h
The revisited SPD cluster analysis in the new AOD framework and the corrections for...
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliAODForwardMult.h
CommitLineData
f49fc45d 1//
2// See implementation or Doxygen comments for more information
3//
4#ifndef ALIAODFORWARDMULT_H
5#define ALIAODFORWARDMULT_H
7e4038b5 6#include <TObject.h>
7#include <TH2D.h>
8class TBrowser;
9/**
10 * Class that contains the forward multiplicity data per event
11 *
12 * This class contains a histogram of
13 * @f[
14 * \frac{d^2N_{ch}}{d\eta d\phi}\quad,
15 * @f]
16 * as well as a trigger mask for each analysed event.
17 *
18 * The eta acceptance of the event is stored in the underflow bins of
19 * the histogram. So to build the final histogram, one needs to
20 * correct for this acceptance (properly weighted by the events), and
21 * the vertex efficiency. This simply boils down to defining a 2D
22 * histogram and summing the event histograms in that histogram. One
23 * should of course also do proper book-keeping of the accepted event.
24 *
25 * @code
fa4236ed 26 * TTree* GetAODTree()
27 * {
28 * TFile* file = TFile::Open("AliAODs.root","READ");
29 * TTree* tree = static_cast<TTree*>(file->Get("aodTree"));
30 * return tree;
31 * }
32 *
33 * void Analyse()
34 * {
35 * TH2D* sum = 0; // Summed hist
36 * TTree* tree = GetAODTree(); // AOD tree
37 * AliAODForwardMult* mult = 0; // AOD object
38 * Int_t nTriggered = 0; // # of triggered ev.
39 * Int_t nWithVertex= 0; // # of ev. w/vertex
40 * Int_t nAccepted = 0; // # of ev. used
41 * Int_t nAvailable = tree->GetEntries(); // How many entries
42 * Float_t vzLow = -10; // Lower ip cut
43 * Float_t vzHigh = 10; // Upper ip cut
44 * Int_t mask = AliAODForwardMult::kInel;// Trigger mask
45 * tree->SetBranchAddress("forward", &forward); // Set the address
7e4038b5 46 *
47 * for (int i = 0; i < nAvailable; i++) {
48 * // Create sum histogram on first event - to match binning to input
49 * if (!sum) sum = static_cast<TH2D*>(mult->Clone("d2ndetadphi"));
50 *
51 * tree->GetEntry(i);
52 *
53 * // Other trigger/event requirements could be defined
54 * if (!mult->IsTriggerBits(mask)) continue;
55 * nTriggered++;
fa4236ed 56 *
57 * // Check if we have vertex
58 * if (!mult->HasIpZ()) continue;
59 * nWithVertex++;
7e4038b5 60 *
61 * // Select vertex range (in centimeters)
62 * if (!mult->InRange(vzLow, vzHigh) continue;
63 * nAccepted++;
64 *
65 * // Add contribution from this event
66 * sum->Add(&(mult->GetHistogram()));
67 * }
68 *
69 * // Get acceptance normalisation from underflow bins
70 * TH1D* norm = sum->Projection("norm", 0, 1, "");
71 * // Project onto eta axis - _ignoring_underflow_bins_!
72 * TH1D* dndeta = sum->Projection("dndeta", 1, -1, "e");
73 * // Normalize to the acceptance
74 * dndeta->Divide(norm);
75 * // Scale by the vertex efficiency
fa4236ed 76 * dndeta->Scale(Double_t(nWithVertex)/nTriggered, "width");
7e4038b5 77 * // And draw the result
78 * dndeta->Draw();
fa4236ed 79 * }
7e4038b5 80 * @endcode
81 *
82 * The above code will draw the final @f$ dN_{ch}/d\eta@f$ for the
83 * selected event class and vertex range
84 *
85 * The histogram can be used as input for other kinds of analysis too,
86 * like flow, event-plane, centrality, and so on.
87 *
7c1a1f1d 88 * @ingroup pwg2_forward
7e4038b5 89 */
90class AliAODForwardMult : public TObject
91{
92public:
93 /**
94 * Bits of the trigger pattern
95 */
96 enum {
97 /** In-elastic collision */
98 kInel = 0x001,
99 /** In-elastic collision with at least one SPD tracklet */
100 kInelGt0 = 0x002,
101 /** Non-single diffractive collision */
102 kNSD = 0x004,
103 /** Empty bunch crossing */
104 kEmpty = 0x008,
105 /** A-side trigger */
106 kA = 0x010,
107 /** B(arrel) trigger */
108 kB = 0x020,
109 /** C-side trigger */
110 kC = 0x080,
111 /** Empty trigger */
112 kE = 0x100
113 };
114 /**
115 * Default constructor
116 *
117 * Used by ROOT I/O sub-system - do not use
118 */
119 AliAODForwardMult();
120 /**
121 * Constructor
122 *
f49fc45d 123 * @param isMC Whether this was from MC or not
7e4038b5 124 */
f49fc45d 125 AliAODForwardMult(Bool_t isMC);
7e4038b5 126 /**
127 * Destructor
128 */
f49fc45d 129 virtual ~AliAODForwardMult() {} // Destructor
7e4038b5 130 /**
131 * Initialize
132 *
133 * @param etaAxis Pseudo-rapidity axis
134 */
135 void Init(const TAxis& etaAxis);
136 /**
137 * Get the @f$ d^2N_{ch}/d\eta d\phi@f$ histogram,
138 *
139 * @return @f$ d^2N_{ch}/d\eta d\phi@f$ histogram,
140 */
f49fc45d 141 const TH2D& GetHistogram() const { return fHist; } // Get histogram
7e4038b5 142 /**
143 * Get the @f$ d^2N_{ch}/d\eta d\phi@f$ histogram,
144 *
145 * @return @f$ d^2N_{ch}/d\eta d\phi@f$ histogram,
146 */
f49fc45d 147 TH2D& GetHistogram() { return fHist; } // Get histogram
7e4038b5 148 /**
149 * Get the trigger mask
150 *
151 * @return Trigger mask
152 */
f49fc45d 153 UInt_t GetTriggerMask() const { return fTriggers; } // Get triggers
7e4038b5 154 /**
155 * Set the trigger mask
156 *
157 * @param trg Trigger mask
158 */
f49fc45d 159 void SetTriggerMask(UInt_t trg) { fTriggers = trg; } // Set triggers
7e4038b5 160 /**
161 * Set bit(s) in trigger mask
162 *
163 * @param bits bit(s) to set
164 */
f49fc45d 165 void SetTriggerBits(UInt_t bits) { fTriggers |= bits; } // Set trigger bits
7e4038b5 166 /**
167 * Check if bit(s) are set in the trigger mask
168 *
169 * @param bits Bits to test for
170 *
171 * @return
172 */
173 Bool_t IsTriggerBits(UInt_t bits) const;
174 /**
175 * Whether we have any trigger bits
176 */
f49fc45d 177 Bool_t HasTrigger() const { return fTriggers != 0; } // Check for triggers
7e4038b5 178 /**
179 * Clear all data
180 *
181 * @param option Passed on to TH2::Reset verbatim
182 */
183 void Clear(Option_t* option="");
184 /**
185 * browse this object
186 *
187 * @param b Browser
188 */
189 void Browse(TBrowser* b);
190 /**
191 * This is a folder
192 *
193 * @return Always true
194 */
f49fc45d 195 Bool_t IsFolder() const { return kTRUE; } // Always true
7e4038b5 196 /**
197 * Print content
198 *
199 * @param option Passed verbatim to TH2::Print
200 */
201 void Print(Option_t* option="") const;
202 /**
203 * Set the z coordinate of the interaction point
204 *
205 * @param ipZ Interaction point z coordinate
206 */
f49fc45d 207 void SetIpZ(Float_t ipZ) { fIpZ = ipZ; } // Set Ip's Z coordinate
b2e7f2d6 208 /**
209 * Set the center of mass energy per nucleon-pair. This is stored
210 * in the (0,0) of the histogram
211 *
212 * @param sNN Center of mass energy per nucleon pair (GeV)
213 */
214 void SetSNN(UShort_t sNN);
215 /**
216 * Get the collision system number
217 * - 0: Unknown
218 * - 1: pp
219 * - 2: PbPb
220 *
221 * @param sys Collision system number
222 */
223 void SetSystem(UShort_t sys);
7e4038b5 224 /**
225 * Set the z coordinate of the interaction point
226 *
227 * @return Interaction point z coordinate
228 */
f49fc45d 229 Float_t GetIpZ() const { return fIpZ; } // Get Ip's Z coordinate
7e4038b5 230 /**
231 * Check if we have a valid z coordinate of the interaction point
232 *
233 * @return True if we have a valid interaction point z coordinate
234 */
235 Bool_t HasIpZ() const;
b2e7f2d6 236 /**
237 * Get the center of mass energy per nucleon pair (GeV)
238 *
239 * @return Center of mass energy per nucleon pair (GeV)
240 */
241 UShort_t GetSNN() const;
242 /**
243 * Get the collision system number
244 * - 0: Unknown
245 * - 1: pp
246 * - 2: PbPb
247 *
248 * @return Collision system number
249 */
250 UShort_t GetSystem() const;
7e4038b5 251 /**
252 * Check if the z coordinate of the interaction point is within the
253 * given limits. Note that the convention used corresponds to the
254 * convention used in ROOTs TAxis.
255 *
256 * @param low Lower cut (inclusive)
257 * @param high Upper cut (exclusive)
258 *
259 * @return true if @f$ low \ge ipz < high@f$
260 */
261 Bool_t InRange(Float_t low, Float_t high) const;
262 /**
263 * Get the name of the object
264 *
265 * @return Name of object
266 */
f49fc45d 267 const Char_t* GetName() const { return (fIsMC ? "ForwardMC" : "Forward"); }
7e4038b5 268 /**
269 * Get a string correspondig to the trigger mask
270 *
271 * @param mask Trigger mask
272 *
273 * @return Static string (copy before use)
274 */
275 static const Char_t* GetTriggerString(UInt_t mask);
276protected:
f49fc45d 277 Bool_t fIsMC; // Whether this is from MC
7e4038b5 278 TH2D fHist; // Histogram of d^2N_{ch}/(deta dphi) for this event
279 UInt_t fTriggers; // Trigger bit mask
280 Float_t fIpZ; // Z coordinate of the interaction point
281
282 static const Float_t fgkInvalidIpZ; // Invalid IpZ value
283 ClassDef(AliAODForwardMult,1); // AOD forward multiplicity
284};
285
286//____________________________________________________________________
287inline Bool_t
288AliAODForwardMult::InRange(Float_t low, Float_t high) const
289{
290 return HasIpZ() && fIpZ >= low && fIpZ < high;
291}
292
293//____________________________________________________________________
294inline Bool_t
295AliAODForwardMult::IsTriggerBits(UInt_t bits) const
296{
297 return HasTrigger() && ((fTriggers & bits) != 0);
298}
7e4038b5 299
300#endif
301// Local Variables:
302// mode: C++
303// End:
304