]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/SPECTRA/PiKaPr/TOF/pPb502/task/AliAnalysisEvent.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGLF / SPECTRA / PiKaPr / TOF / pPb502 / task / AliAnalysisEvent.cxx
CommitLineData
59e49925 1#include "AliAnalysisEvent.h"
2#include "AliVEvent.h"
3
4ClassImp(AliAnalysisEvent)
5
6//___________________________________________________________
7
8Bool_t AliAnalysisEvent::fgInitCorrections = kFALSE;
9
10const Char_t *AliAnalysisEvent::fgTimeZeroTOFCentCorrFormula = "[0]+[1]*x+[2]*x*x";
11
12Double_t AliAnalysisEvent::fgTimeZeroTOFCentCorrParams[3] = {
13 -14.9262, 0.0212941, 0.000960528
14};
15
16TF1 *AliAnalysisEvent::fgTimeZeroTOFCentCorrFunc = NULL;
17
18//___________________________________________________________
19
20AliTOFPIDResponse AliAnalysisEvent::fgTOFResponse;
21
22Float_t AliAnalysisEvent::fgVertexZ_cuts[2] = {-10., 10.}; /* min,max */
23Float_t AliAnalysisEvent::fgTimeZeroT0_AND_params[2] = {0., 1000.}; /* mean,sigma */
24Float_t AliAnalysisEvent::fgTimeZeroT0_A_params[2] = {0., 1000.}; /* mean,sigma */
25Float_t AliAnalysisEvent::fgTimeZeroT0_C_params[2] = {0., 1000.}; /* mean,sigma */
26Float_t AliAnalysisEvent::fgTimeZeroT0_ACdiff_params[2] = {0., 1000.}; /* mean,sigma */
27Float_t AliAnalysisEvent::fgTimeZero_TOFT0diff_params[2] = {0., 1000.}; /* mean,sigma */
28
29const Char_t *AliAnalysisEvent::fgkCentralityEstimatorName[AliAnalysisEvent::kNCentralityEstimators] = {
30 "V0M",
31 "V0A",
32 "V0C",
33 "TRK",
34 "TKL",
35 "CL1",
36 "ZNA"
37};
38
39Float_t AliAnalysisEvent::fgTimeZeroSpread = 196.7;
40Float_t AliAnalysisEvent::fgTimeZeroT0_AND_sigma = 3.87264325235363032e+01;
41Float_t AliAnalysisEvent::fgTimeZeroT0_A_sigma = 8.27180042372880706e+01;
42Float_t AliAnalysisEvent::fgTimeZeroT0_C_sigma = 9.73209262235003933e+01;
43
44//___________________________________________________________
45
46AliAnalysisEvent::AliAnalysisEvent() :
47 TObject(),
48 fIsCollisionCandidate(kFALSE),
49 fIsEventSelected(0),
50 fIsPileupFromSPD(kFALSE),
51 fHasVertex(kFALSE),
52 fVertexZ(0.),
53 fCentralityQuality(0),
54 fCentralityPercentile(),
55 fReferenceMultiplicity(0),
56 fMCMultiplicity(0),
57 fTimeZeroTOF(),
58 fTimeZeroTOFSigma(),
59 fTimeZeroT0(),
60 fMCTimeZero(0.)
61{
62 /*
63 * default constructor
64 */
65
66 /* init corrections */
67 if (!fgInitCorrections) {
68
69 /*** TIME-ZERO TOF CENTRALITY CORRECTION ***/
70 fgTimeZeroTOFCentCorrFunc = new TF1("fTimeZeroTOFCentCorrFunc", fgTimeZeroTOFCentCorrFormula, 0., 100.);
71 for (Int_t iparam = 0; iparam < 3; iparam++)
72 fgTimeZeroTOFCentCorrFunc->SetParameter(iparam, fgTimeZeroTOFCentCorrParams[iparam]);
73
74 /* set init flag */
75 fgInitCorrections = kTRUE;
76 }
77
78 /* reset */
79 Reset();
80}
81
82//___________________________________________________________
83
84AliAnalysisEvent::AliAnalysisEvent(const AliAnalysisEvent &source) :
85 TObject(source),
86 fIsCollisionCandidate(source.fIsCollisionCandidate),
87 fIsEventSelected(source.fIsEventSelected),
88 fIsPileupFromSPD(source.fIsPileupFromSPD),
89 fHasVertex(source.fHasVertex),
90 fVertexZ(source.fVertexZ),
91 fCentralityQuality(source.fCentralityQuality),
92 fCentralityPercentile(),
93 fReferenceMultiplicity(source.fReferenceMultiplicity),
94 fMCMultiplicity(source.fMCMultiplicity),
95 fTimeZeroTOF(),
96 fTimeZeroTOFSigma(),
97 fTimeZeroT0(),
98 fMCTimeZero(source.fMCTimeZero)
99{
100 /*
101 * copy constructor
102 */
103
104 for (Int_t i = 0; i < kNCentralityEstimators; i++)
105 fCentralityPercentile[i] = source.fCentralityPercentile[i];
106 for (Int_t i = 0; i < 10; i++) {
107 fTimeZeroTOF[i] = source.fTimeZeroTOF[i];
108 fTimeZeroTOFSigma[i] = source.fTimeZeroTOFSigma[i];
109 }
110 for (Int_t i = 0; i < 3; i++)
111 fTimeZeroT0[i] = source.fTimeZeroT0[i];
112
113}
114
115//___________________________________________________________
116
117AliAnalysisEvent &
118AliAnalysisEvent::operator=(const AliAnalysisEvent &source)
119{
120 /*
121 * operator=
122 */
123
124 if (&source == this) return *this;
125 TObject::operator=(source);
126
127 fIsCollisionCandidate = source.fIsCollisionCandidate;
128 fIsEventSelected = source.fIsEventSelected;
129 fIsPileupFromSPD = source.fIsPileupFromSPD;
130 fHasVertex = source.fHasVertex;
131 fVertexZ = source.fVertexZ;
132 fCentralityQuality = source.fCentralityQuality;
133 fReferenceMultiplicity = source.fReferenceMultiplicity;
134 fMCMultiplicity = source.fMCMultiplicity;
135 for (Int_t i = 0; i < kNCentralityEstimators; i++)
136 fCentralityPercentile[i] = source.fCentralityPercentile[i];
137 for (Int_t i = 0; i < 10; i++) {
138 fTimeZeroTOF[i] = source.fTimeZeroTOF[i];
139 fTimeZeroTOFSigma[i] = source.fTimeZeroTOFSigma[i];
140 }
141 for (Int_t i = 0; i < 3; i++)
142 fTimeZeroT0[i] = source.fTimeZeroT0[i];
143 fMCTimeZero = source.fMCTimeZero;
144
145 return *this;
146}
147
148//___________________________________________________________
149
150AliAnalysisEvent::~AliAnalysisEvent()
151{
152 /*
153 * default destructor
154 */
155
156}
157
158//___________________________________________________________
159
160void
161AliAnalysisEvent::Reset()
162{
163 /*
164 * reset
165 */
166
167 fIsCollisionCandidate = kFALSE;
168 fIsEventSelected = 0;
169 fIsPileupFromSPD = kFALSE;
170 fHasVertex = 0.;
171 fVertexZ = 0.;
172 fCentralityQuality = 0;
173 fReferenceMultiplicity = 0;
174 fMCMultiplicity = 0;
175 for (Int_t i = 0; i < kNCentralityEstimators; i++)
176 fCentralityPercentile[i] = 0.;
177 for (Int_t i = 0; i < 10; i++) {
178 fTimeZeroTOF[i] = 0.;
179 fTimeZeroTOFSigma[i] = 0.;
180 }
181 for (Int_t i = 0; i < 3; i++)
182 fTimeZeroT0[i] = 0.;
183 fMCTimeZero = 0.;
184}
185
186//___________________________________________________________
187
188Bool_t
189AliAnalysisEvent::CheckLimits(Float_t value, Float_t *params, Float_t nSigma) const
190{
191 /*
192 * check limits
193 */
194
195 Float_t min = params[0] - nSigma * params[1];
196 Float_t max = params[0] + nSigma * params[1];
197 if (value < min || value > max) return kFALSE;
198 return kTRUE;
199}
200
201//___________________________________________________________
202
203Bool_t
204AliAnalysisEvent::AcceptEvent(Int_t type) const
205{
206 /*
207 * accept event proton-proton
208 */
209
210 if (!fIsCollisionCandidate) return kFALSE;
211 if (!AcceptVertex()) return kFALSE;
212 if (fCentralityQuality != 0) return kFALSE;
213 if (!(fIsEventSelected & AliVEvent::kINT7)) return kFALSE;
214
215 if (type > 0) {
216 if (fIsPileupFromSPD) return kFALSE;
217 if (!(fIsEventSelected & AliVEvent::kMB)) return kFALSE;
218 };
219
220
221 return kTRUE;
222}
223
224//___________________________________________________________
225
226Bool_t
227AliAnalysisEvent::AcceptVertex() const
228{
229 /*
230 * accept vertex
231 */
232
233 if (!HasVertex()) return kFALSE;
234 if (fVertexZ < fgVertexZ_cuts[0] || fVertexZ > fgVertexZ_cuts[1]) return kFALSE;
235 return kTRUE;
236}
237
238//___________________________________________________________
239
240Bool_t
241AliAnalysisEvent::HasTimeZeroT0_AND() const
242{
243 /*
244 * has time-zero T0-AND
245 */
246
247 /* check T0-AND */
248 if (!CheckLimits(fTimeZeroT0[0], fgTimeZeroT0_AND_params)) return kFALSE;
249 /* check T0-A */
250 if (!CheckLimits(fTimeZeroT0[1], fgTimeZeroT0_A_params)) return kFALSE;
251 /* check T0-C */
252 if (!CheckLimits(fTimeZeroT0[2], fgTimeZeroT0_C_params)) return kFALSE;
253 /* check A-C difference */
254 if (!CheckLimits(fTimeZeroT0[1] - fTimeZeroT0[2], fgTimeZeroT0_ACdiff_params)) return kFALSE;
255 /* ok */
256 return kTRUE;
257}
258
259//___________________________________________________________
260
261Bool_t
262AliAnalysisEvent::HasTimeZeroT0_XOR() const
263{
264 /*
265 * has time-zero T0-XOR
266 */
267
268 /* check T0-A only */
269 if (CheckLimits(fTimeZeroT0[1], fgTimeZeroT0_A_params) &&
270 !CheckLimits(fTimeZeroT0[2], fgTimeZeroT0_C_params)) return kTRUE;
271 /* check T0-C only */
272 if (!CheckLimits(fTimeZeroT0[1], fgTimeZeroT0_A_params) &&
273 CheckLimits(fTimeZeroT0[2], fgTimeZeroT0_C_params)) return kTRUE;
274 return kFALSE;
275}
276
277//___________________________________________________________
278
279Bool_t
280AliAnalysisEvent::HasTimeZeroT0_OR() const
281{
282 /*
283 * has time-zero T0-OR
284 */
285
286 if (HasTimeZeroT0_AND() || HasTimeZeroT0_XOR()) return kTRUE;
287 return kFALSE;
288}
289
290//___________________________________________________________
291
292Bool_t
293AliAnalysisEvent::HasTimeZeroTOF(Float_t momentum) const
294{
295 /*
296 * has time-zero TOF
297 */
298
299 Int_t momBin = fgTOFResponse.GetMomBin(momentum);
300 if (fTimeZeroTOF[momBin] == 0.) return kFALSE;
301 return kTRUE;
302}
303
304//___________________________________________________________
305
306Bool_t
307AliAnalysisEvent::HasTimeZeroBest(Float_t momentum) const
308{
309 /*
310 * has time-zero best
311 */
312
313 if (HasTimeZeroT0_OR() || HasTimeZeroTOF(momentum)) return kTRUE;
314 return kFALSE;
315}
316
317//___________________________________________________________
318
319Bool_t
320AliAnalysisEvent::HasTimeZeroSafe(Float_t momentum) const
321{
322 /*
323 * has time-zero safe
324 */
325
326 if (!HasTimeZeroT0_AND() || !HasTimeZeroTOF(momentum)) return kFALSE;
327 Float_t tzeroTOF = GetTimeZeroTOF(momentum);
328 Float_t tzeroT0 = GetTimeZeroT0_AND();
329 Float_t diff = tzeroTOF - tzeroT0;
330 if (!CheckLimits(diff, fgTimeZero_TOFT0diff_params)) return kFALSE;
331 return kTRUE;
332}
333
334//___________________________________________________________
335
336Float_t
337AliAnalysisEvent::GetTimeZeroT0_AND() const
338{
339 /*
340 * get time-zero T0-AND
341 */
342
343 return fTimeZeroT0[0] - fgTimeZeroT0_AND_params[0];
344}
345
346//___________________________________________________________
347
348Float_t
349AliAnalysisEvent::GetTimeZeroT0Sigma_AND() const
350{
351 /*
352 * get time-zero T0-AND sigma
353 */
354
355 return fgTimeZeroT0_AND_sigma;
356}
357
358//___________________________________________________________
359
360Float_t
361AliAnalysisEvent::GetTimeZeroT0_XOR() const
362{
363 /*
364 * get time-zero T0-XOR
365 */
366
367 if (CheckLimits(fTimeZeroT0[1], fgTimeZeroT0_A_params) &&
368 !CheckLimits(fTimeZeroT0[2], fgTimeZeroT0_C_params)) return fTimeZeroT0[1] - fgTimeZeroT0_A_params[0];
369 if (!CheckLimits(fTimeZeroT0[1], fgTimeZeroT0_A_params) &&
370 CheckLimits(fTimeZeroT0[2], fgTimeZeroT0_C_params)) return fTimeZeroT0[2] - fgTimeZeroT0_C_params[0];
371 return 0.;
372}
373
374//___________________________________________________________
375
376Float_t
377AliAnalysisEvent::GetTimeZeroT0Sigma_XOR() const
378{
379 /*
380 * get time-zero T0-XOR sigma
381 */
382
383 if (CheckLimits(fTimeZeroT0[1], fgTimeZeroT0_A_params) &&
384 !CheckLimits(fTimeZeroT0[2], fgTimeZeroT0_C_params)) return fgTimeZeroT0_A_sigma;
385 if (!CheckLimits(fTimeZeroT0[1], fgTimeZeroT0_A_params) &&
386 CheckLimits(fTimeZeroT0[2], fgTimeZeroT0_C_params)) return fgTimeZeroT0_C_sigma;
387 return 0.;
388}
389
390//___________________________________________________________
391
392Float_t
393AliAnalysisEvent::GetTimeZeroT0_OR() const
394{
395 /*
396 * get time-zero T0-OR
397 */
398
399 if (HasTimeZeroT0_AND()) return GetTimeZeroT0_AND();
400 if (HasTimeZeroT0_XOR()) return GetTimeZeroT0_XOR();
401 return 0.;
402}
403
404//___________________________________________________________
405
406Float_t
407AliAnalysisEvent::GetTimeZeroT0Sigma_OR() const
408{
409 /*
410 * get time-zero T0-OR sigma
411 */
412
413 if (HasTimeZeroT0_AND()) return GetTimeZeroT0Sigma_AND();
414 if (HasTimeZeroT0_XOR()) return GetTimeZeroT0Sigma_XOR();
415 return 0.;
416}
417
418//___________________________________________________________
419
420Float_t
421AliAnalysisEvent::GetTimeZeroTOF(Float_t momentum) const
422{
423 /*
424 * get time-zero TOF
425 */
426
427 Int_t momBin = fgTOFResponse.GetMomBin(momentum);
428 return fTimeZeroTOF[momBin];
429}
430
431//___________________________________________________________
432
433Float_t
434AliAnalysisEvent::GetTimeZeroTOFSigma(Float_t momentum) const
435{
436 /*
437 * get time-zero TOF sigma
438 */
439
440 Int_t momBin = fgTOFResponse.GetMomBin(momentum);
441 return fTimeZeroTOFSigma[momBin];
442}
443
444//___________________________________________________________
445
446Float_t
447AliAnalysisEvent::GetTimeZeroBest(Float_t momentum) const
448{
449 /*
450 * get time-zero best
451 */
452
453 if (HasTimeZeroTOF(momentum)) return GetTimeZeroTOF(momentum);
454 if (HasTimeZeroT0_OR()) return GetTimeZeroT0_OR();
455 return 0.;
456}
457
458//___________________________________________________________
459
460Float_t
461AliAnalysisEvent::GetTimeZeroBestSigma(Float_t momentum) const
462{
463 /*
464 * get time-zero best sigma
465 */
466
467 if (HasTimeZeroTOF(momentum)) return GetTimeZeroTOFSigma(momentum);
468 if (HasTimeZeroT0_OR()) return GetTimeZeroT0Sigma_OR();
469 return fgTimeZeroSpread;
470}
471
472//___________________________________________________________
473
474Float_t
475AliAnalysisEvent::GetTimeZeroSafe(Float_t momentum) const
476{
477 /*
478 * get time-zero safe
479 */
480
481 return GetTimeZeroTOF(momentum);
482}
483
484//___________________________________________________________
485
486Float_t
487AliAnalysisEvent::GetTimeZeroSafeSigma(Float_t momentum) const
488{
489 /*
490 * get time-zero safe sigma
491 */
492
493 return GetTimeZeroTOFSigma(momentum);
494}
495
496//___________________________________________________________
497
498void
499AliAnalysisEvent::ApplyTimeZeroTOFCorrection()
500{
501 /*
502 * apply timezero TOF correction
503 */
504
505 for (Int_t imom = 0; imom < 10; imom++)
506 fTimeZeroTOF[imom] += GetTimeZeroTOFCorrection();
507
508}