]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliAODForwardHeader.h
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliAODForwardHeader.h
CommitLineData
7e1a1613
CHC
1//
2// See implementation or Doxygen comments for more information
3//
4#ifndef ALIAODFORWARDHEADER_H
5#define ALIAODFORWARDHEADER_H
6/**
7 * @file AliAODForwardHeader.h
8 * @author Christian Holm Christensen <cholm@nbi.dk>
9 * @date Mon Dec 2 09:31:05 2013
10 *
11 * @brief Header for forward data in stand-alone AOD
12 *
13 * @ingroup pwglf_forward_aod
14 */
15#include <TObject.h>
16class TBrowser;
17
18class AliAODForwardHeader : public TObject
19{
20public:
21 /**
22 * Bits of the trigger pattern
23 */
24 enum {
25 /** In-elastic collision */
26 kInel = 0x0001,
27 /** In-elastic collision with at least one SPD tracklet */
28 kInelGt0 = 0x0002,
29 /** Non-single diffractive collision */
30 kNSD = 0x0004,
31 /** Empty bunch crossing */
32 kEmpty = 0x0008,
33 /** A-side trigger */
34 kA = 0x0010,
35 /** B(arrel) trigger */
36 kB = 0x0020,
37 /** C-side trigger */
38 kC = 0x0080,
39 /** Empty trigger */
40 kE = 0x0100,
41 /** pileup from SPD */
42 kPileUp = 0x0200,
43 /** true NSD from MC */
44 kMCNSD = 0x0400,
45 /** Offline MB triggered */
46 kOffline = 0x0800,
47 /** At least one SPD cluster */
48 kNClusterGt0 = 0x1000,
49 /** V0-AND trigger */
50 kV0AND = 0x2000,
51 /** Satellite event */
52 kSatellite = 0x4000
53 };
54 /**
55 * Bin numbers in trigger histograms
56 */
57 enum {
58 kBinAll=1,
59 kBinInel,
60 kBinInelGt0,
61 kBinNSD,
62 kBinV0AND,
63 kBinA,
64 kBinB,
65 kBinC,
66 kBinE,
67 kBinSatellite,
68 kBinPileUp,
69 kBinMCNSD,
70 kBinOffline,
71 kBinNClusterGt0,
72 kWithTrigger,
73 kWithVertex,
74 kAccepted
75 };
76 /**
77 * Return codes of CheckEvent
78 */
79 enum ECheckStatus {
80 /** Event accepted by cuts */
81 kGoodEvent = 0,
82 /** Event centrality not in range */
83 kWrongCentrality,
84 /** Event trigger isn't in the supplied mask */
85 kWrongTrigger,
86 /** Event is a pile-up event */
87 kIsPileup,
88 /** Event has no interaction point information */
89 kNoVertex,
90 /** Event interaction point is out of range */
91 kWrongVertex
92 };
93 /**
94 * Constructor
95 */
96 AliForwardHeader()
97 : fTriggers(0), fIpZ(fgkInvalidIpZ), fCentrality(-1), fNClusters(0)
98 {}
99
100 /**
101 * @{
102 * @name Setters of data
103 */
104 /**
105 * Clear all data
106 *
107 * @param option Not used
108 */
109 void Clear(Option_t* option="");
110 /**
111 * Set the trigger mask
112 *
113 * @param trg Trigger mask
114 */
115 void SetTriggerMask(UInt_t trg) { fTriggers = trg; } // Set triggers
116 /**
117 * Set bit(s) in trigger mask
118 *
119 * @param bits bit(s) to set
120 */
121 void SetTriggerBits(UInt_t bits) { fTriggers |= bits; } // Set trigger bits
122 /**
123 * Set the z coordinate of the interaction point
124 *
125 * @param ipZ Interaction point z coordinate
126 */
127 void SetIpZ(Float_t ipZ) { fIpZ = ipZ; } // Set Ip's Z coordinate
128 /**
129 * Set the event centrality
130 *
131 * @param c Centrality
132 */
133 void SetCentrality(Float_t c) { fCentrality = c; }
134 /**
135 * Set the number of SPD clusters seen in @f$ |\eta|<1@f$
136 *
137 * @param n Number of SPD clusters
138 */
139 void SetNClusters(UShort_t n) { fNClusters = n; }
140 /* @} */
141
142
143 /**
144 * @{
145 * @name Tests
146 */
147 /**
148 * Check if all bit(s) are set in the trigger mask. Note, this is
149 * an @e and between the bits. If you need an @e or you should use
150 * the member function IsTriggerOrBits
151 *
152 * @param bits Bits to test for
153 *
154 * @return true if all enabled bits in the argument is also set in
155 * the trigger word
156 */
157 Bool_t IsTriggerBits(UInt_t bits) const;
158 /**
159 * Check if any of bit(s) are enabled in the trigger word. This is
160 * an @e or between the selected bits. If you need and @a and you
161 * should use the member function IsTriggerBits;
162 *
163 * @param bits Bits to check for
164 *
165 * @return true if any of the enabled bits in the arguments are also
166 * enabled in the trigger mask
167 */
168 Bool_t IsTriggerOrBits(UInt_t bits) const;
169 /**
170 * Whether we have any trigger bits
171 *
172 * @return true if we have some trigger
173 */
174 Bool_t HasTrigger() const { return fTriggers != 0; } // Check for triggers
175 /**
176 * Check if we have a valid z coordinate of the interaction point
177 *
178 * @return True if we have a valid interaction point z coordinate
179 */
180 Bool_t HasIpZ() const;
181 /**
182 * Check if the z coordinate of the interaction point is within the
183 * given limits. Note that the convention used corresponds to the
184 * convention used in ROOTs TAxis.
185 *
186 * @param low Lower cut (inclusive)
187 * @param high Upper cut (exclusive)
188 *
189 * @return true if @f$ low \ge ipz < high@f$
190 */
191 Bool_t InRange(Float_t low, Float_t high) const;
192 /**
193 * Check if we have a valid centrality
194 *
195 * @return True if the centrality is set
196 */
197 Bool_t HasCentrality() const { return !(fCentrality < 0); }
198 /**
199 * Check if event meets the passses requirements.
200 *
201 * It returns true if @e all of the following is true
202 *
203 * - The trigger is within the bit mask passed.
204 * - The vertex is within the specified limits.
205 * - The centrality is within the specified limits, or if lower
206 * limit is equal to or larger than the upper limit.
207 *
208 * Note, for data with out a centrality estimate (e.g., pp), one
209 * must pass equal centrality cuts, or no data will be accepted. In
210 * other words, for pp data, always pass cMin=0, cMax=0
211 *
212 * If a histogram is passed in the last parameter, then that
213 * histogram is filled with the trigger bits.
214 *
215 * @param triggerMask Trigger mask
216 * @param vzMin Minimum @f$ v_z@f$ (in centimeters)
217 * @param vzMax Maximum @f$ v_z@f$ (in centimeters)
218 * @param cMin Minimum centrality (in percent)
219 * @param cMax Maximum centrality (in percent)
220 * @param hist Histogram to fill
221 * @param status Histogram to fill
222 *
223 *
224 * @return @c true if the event meets the requirements
225 */
226 Bool_t CheckEvent(Int_t triggerMask=kInel,
227 Double_t vzMin=-10, Double_t vzMax=10,
228 UShort_t cMin=0, UShort_t cMax=100,
229 TH1* hist=0,
230 TH1* status=0) const;
231 /* @} */
232
233 /**
234 * @{
235 * @name Getters of data
236 */
237 /**
238 * Get the trigger bits
239 *
240 * @return Trigger bits
241 */
242 UInt_t GetTriggerBits() const { return fTriggers; } // Get triggers
243 /**
244 * Set the z coordinate of the interaction point
245 *
246 * @return Interaction point z coordinate
247 */
248 Float_t GetIpZ() const { return fIpZ; } // Get Ip's Z coordinate
249 /**
250 * Get the event centrality
251 *
252 * @return The event centrality or -1 if not set
253 */
254 Float_t GetCentrality() const { return fCentrality; }
255 /**
256 * Get the number of SPD clusters seen in @f$ |\eta|<1@f$
257 *
258 * @return Number of SPD clusters seen
259 */
260 UShort_t GetNClusters() const { return fNClusters; }
261 /* @} */
262
263 /**
264 * @{
265 * @name Standard TObject member functions
266 */
267 /**
268 * Print content
269 *
270 * @param option Passed verbatim to TH2::Print
271 */
272 void Print(Option_t* option="") const;
273 /**
274 * Get the name of the object
275 *
276 * @return Name of object
277 */
278 const Char_t* GetName() const { return "ForwardHeader"; }
279 /**
280 * browse this object
281 *
282 * @param b Browser
283 */
284 void Browse(TBrowser* b);
285 /**
286 * This is a folder
287 *
288 * @return Always true
289 */
290 Bool_t IsFolder() const { return kTRUE; } // Always true
291 /* @} */
292 /**
293 * @{
294 * @name Utility class functions
295 */
296 /**
297 * Get a string correspondig to the trigger mask
298 *
299 * @param mask Trigger mask
300 *
301 * @return Static string (copy before use)
302 */
303 static const Char_t* GetTriggerString(UInt_t mask);
304 /**
305 * Make a histogram to record triggers in.
306 *
307 * The bins defined by the trigger enumeration in this class. One
308 * can use this enumeration to retrieve the number of triggers for
309 * each class.
310 *
311 * @param name Name of the histogram
312 * @param mask Trigger mask
313 *
314 * @return Newly allocated histogram
315 */
316 static TH1I* MakeTriggerHistogram(const char* name="triggers",
317 Int_t mask=0);
318 /**
319 * Make a histogram to record status in.
320 *
321 * The bins defined by the status enumeration in this class.
322 *
323 * @param name Name of the histogram
324 *
325 * @return Newly allocated histogram
326 */
327 static TH1I* MakeStatusHistogram(const char* name="status");
328 /**
329 * Utility function to make a trigger mask from the passed string.
330 *
331 * The string is a comma or space seperated list of case-insensitive
332 * strings
333 *
334 * - INEL
335 * - INEL>0
336 * - NSD
337 *
338 * @param what Which triggers to put in the mask.
339 *
340 * @return The generated trigger mask.
341 */
342 static UInt_t MakeTriggerMask(const char* what);
343 /* @} */
344protected:
345 /** Trigger bits */
346 UInt_t fTriggers; // Trigger bit mask
347 /** Interaction point @f$z@f$ coordinate */
348 Float_t fIpZ; // Z coordinate of the interaction point
349 /** Centrality */
350 Float_t fCentrality; // Event centrality
351 /** Number of clusters in @f$|\eta|<1@f$ */
352 UShort_t fNClusters; // Number of SPD clusters in |eta|<1
353 /** Invalid value for interaction point @f$z@f$ coordiante */
354 static const Float_t fgkInvalidIpZ; // Invalid IpZ value
355 ClassDef(AliAODForwardHeader,1); // AOD forward header
356};
357
358//____________________________________________________________________
359inline Bool_t
360AliAODForwardHeader::InRange(Float_t low, Float_t high) const
361{
362 return HasIpZ() && fIpZ >= low && fIpZ < high;
363}
364
365//____________________________________________________________________
366inline Bool_t
367AliAODForwardHeader::IsTriggerBits(UInt_t bits) const
368{
369 return HasTrigger() && ((fTriggers & bits) == bits);
370}
371//____________________________________________________________________
372inline Bool_t
373AliAODForwardHeader::IsTriggerOrBits(UInt_t bits) const
374{
375 return HasTrigger() && ((fTriggers & bits) != 0);
376}
377
378
379#endif
380// Local Variables:
381// mode: C++
382// End:
383