]>
Commit | Line | Data |
---|---|---|
1 | /* $Id: AliTriggerAnalysis.cxx 35782 2009-10-22 11:54:31Z jgrosseo $ */ | |
2 | ||
3 | /************************************************************************** | |
4 | * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. * | |
5 | * * | |
6 | * Author: The ALICE Off-line Project. * | |
7 | * Contributors are mentioned in the code where appropriate. * | |
8 | * * | |
9 | * Permission to use, copy, modify and distribute this software and its * | |
10 | * documentation strictly for non-commercial purposes is hereby granted * | |
11 | * without fee, provided that the above copyright notice appears in all * | |
12 | * copies and that both the copyright notice and this permission notice * | |
13 | * appear in the supporting documentation. The authors make no claims * | |
14 | * about the suitability of this software for any purpose. It is * | |
15 | * provided "as is" without express or implied warranty. * | |
16 | **************************************************************************/ | |
17 | ||
18 | //------------------------------------------------------------------------- | |
19 | // Implementation of Class AliTriggerAnalysis | |
20 | // This class provides function to check if events have been triggered based on the data in the ESD | |
21 | // The trigger bits, trigger class inputs and only the data (offline trigger) can be used | |
22 | // Origin: Jan Fiete Grosse-Oetringhaus, CERN | |
23 | //------------------------------------------------------------------------- | |
24 | ||
25 | #include <Riostream.h> | |
26 | #include <TH1F.h> | |
27 | #include <TH2F.h> | |
28 | #include <TList.h> | |
29 | #include <TIterator.h> | |
30 | #include "TParameter.h" | |
31 | #include <TMap.h> | |
32 | #include <TRandom.h> | |
33 | ||
34 | #include <AliTriggerAnalysis.h> | |
35 | ||
36 | #include <AliLog.h> | |
37 | ||
38 | #include <AliESDEvent.h> | |
39 | ||
40 | #include <AliMultiplicity.h> | |
41 | #include <AliESDVZERO.h> | |
42 | #include <AliESDZDC.h> | |
43 | #include <AliESDFMD.h> | |
44 | ||
45 | ClassImp(AliTriggerAnalysis) | |
46 | ||
47 | AliTriggerAnalysis::AliTriggerAnalysis() : | |
48 | fSPDGFOThreshold(2), | |
49 | fSPDGFOEfficiency(0), | |
50 | fV0TimeOffset(0), | |
51 | fV0AdcThr(0), | |
52 | fV0HwAdcThr(2.5), | |
53 | fV0HwWinLow(61.5), | |
54 | fV0HwWinHigh(86.5), | |
55 | fFMDLowCut(0.2), | |
56 | fFMDHitCut(0.5), | |
57 | fHistBitsSPD(0), | |
58 | fHistFiredBitsSPD(0), | |
59 | fHistV0A(0), | |
60 | fHistV0C(0), | |
61 | fHistZDC(0), | |
62 | fHistFMDA(0), | |
63 | fHistFMDC(0), | |
64 | fHistFMDSingle(0), | |
65 | fHistFMDSum(0), | |
66 | fTriggerClasses(0), | |
67 | fMC(kFALSE) | |
68 | { | |
69 | // constructor | |
70 | } | |
71 | ||
72 | AliTriggerAnalysis::~AliTriggerAnalysis() | |
73 | { | |
74 | // destructor | |
75 | ||
76 | if (fHistBitsSPD) | |
77 | { | |
78 | delete fHistBitsSPD; | |
79 | fHistBitsSPD = 0; | |
80 | } | |
81 | ||
82 | if (fHistFiredBitsSPD) | |
83 | { | |
84 | delete fHistFiredBitsSPD; | |
85 | fHistFiredBitsSPD = 0; | |
86 | } | |
87 | ||
88 | if (fHistV0A) | |
89 | { | |
90 | delete fHistV0A; | |
91 | fHistV0A = 0; | |
92 | } | |
93 | ||
94 | if (fHistV0C) | |
95 | { | |
96 | delete fHistV0C; | |
97 | fHistV0C = 0; | |
98 | } | |
99 | ||
100 | if (fHistZDC) | |
101 | { | |
102 | delete fHistZDC; | |
103 | fHistZDC = 0; | |
104 | } | |
105 | ||
106 | if (fHistFMDA) | |
107 | { | |
108 | delete fHistFMDA; | |
109 | fHistFMDA = 0; | |
110 | } | |
111 | ||
112 | if (fHistFMDC) | |
113 | { | |
114 | delete fHistFMDC; | |
115 | fHistFMDC = 0; | |
116 | } | |
117 | ||
118 | if (fHistFMDSingle) | |
119 | { | |
120 | delete fHistFMDSingle; | |
121 | fHistFMDSingle = 0; | |
122 | } | |
123 | ||
124 | if (fHistFMDSum) | |
125 | { | |
126 | delete fHistFMDSum; | |
127 | fHistFMDSum = 0; | |
128 | } | |
129 | ||
130 | if (fTriggerClasses) | |
131 | { | |
132 | fTriggerClasses->DeleteAll(); | |
133 | delete fTriggerClasses; | |
134 | fTriggerClasses = 0; | |
135 | } | |
136 | } | |
137 | ||
138 | void AliTriggerAnalysis::EnableHistograms() | |
139 | { | |
140 | // creates the monitoring histograms | |
141 | ||
142 | // do not add this hists to the directory | |
143 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
144 | TH1::AddDirectory(kFALSE); | |
145 | ||
146 | fHistBitsSPD = new TH2F("fHistBitsSPD", "SPD GFO;number of fired chips (offline);number of fired chips (hardware)", 1202, -1.5, 1200.5, 1202, -1.5, 1200.5); | |
147 | fHistFiredBitsSPD = new TH1F("fHistFiredBitsSPD", "SPD GFO Hardware;chip number;events", 1200, -0.5, 1199.5); | |
148 | fHistV0A = new TH1F("fHistV0A", "V0A;leading time (ns);events", 200, 0, 100); | |
149 | fHistV0C = new TH1F("fHistV0C", "V0C;leading time (ns);events", 200, 0, 100); | |
150 | fHistZDC = new TH1F("fHistZDC", "ZDC;trigger bits;events", 8, -1.5, 6.5); | |
151 | ||
152 | // TODO check limits | |
153 | fHistFMDA = new TH1F("fHistFMDA", "FMDA;combinations above threshold;events", 102, -1.5, 100.5); | |
154 | fHistFMDC = new TH1F("fHistFMDC", "FMDC;combinations above threshold;events", 102, -1.5, 100.5); | |
155 | fHistFMDSingle = new TH1F("fHistFMDSingle", "FMD single;multiplicity value;counts", 1000, 0, 10); | |
156 | fHistFMDSum = new TH1F("fHistFMDSum", "FMD sum;multiplicity value;counts", 1000, 0, 10); | |
157 | ||
158 | fTriggerClasses = new TMap; | |
159 | fTriggerClasses->SetOwner(); | |
160 | ||
161 | TH1::AddDirectory(oldStatus); | |
162 | } | |
163 | ||
164 | //____________________________________________________________________ | |
165 | const char* AliTriggerAnalysis::GetTriggerName(Trigger trigger) | |
166 | { | |
167 | // returns the name of the requested trigger | |
168 | // the returned string will only be valid until the next call to this function [not thread-safe] | |
169 | ||
170 | static TString str; | |
171 | ||
172 | UInt_t triggerNoFlags = (UInt_t) trigger % (UInt_t) kStartOfFlags; | |
173 | ||
174 | switch (triggerNoFlags) | |
175 | { | |
176 | case kAcceptAll : str = "ACCEPT ALL (bypass!)"; break; | |
177 | case kMB1 : str = "MB1"; break; | |
178 | case kMB2 : str = "MB2"; break; | |
179 | case kMB3 : str = "MB3"; break; | |
180 | case kSPDGFO : str = "SPD GFO"; break; | |
181 | case kSPDGFOBits : str = "SPD GFO Bits"; break; | |
182 | case kV0A : str = "V0 A BB"; break; | |
183 | case kV0C : str = "V0 C BB"; break; | |
184 | case kV0OR : str = "V0 OR BB"; break; | |
185 | case kV0AND : str = "V0 AND BB"; break; | |
186 | case kV0ABG : str = "V0 A BG"; break; | |
187 | case kV0CBG : str = "V0 C BG"; break; | |
188 | case kZDC : str = "ZDC"; break; | |
189 | case kZDCA : str = "ZDC A"; break; | |
190 | case kZDCC : str = "ZDC C"; break; | |
191 | case kFMDA : str = "FMD A"; break; | |
192 | case kFMDC : str = "FMD C"; break; | |
193 | case kFPANY : str = "SPD GFO | V0 | ZDC | FMD"; break; | |
194 | case kNSD1 : str = "NSD1"; break; | |
195 | case kMB1Prime: str = "MB1prime"; break; | |
196 | default: str = ""; break; | |
197 | } | |
198 | ||
199 | if (trigger & kOfflineFlag) | |
200 | str += " OFFLINE"; | |
201 | ||
202 | return str; | |
203 | } | |
204 | ||
205 | Bool_t AliTriggerAnalysis::IsTriggerFired(const AliESDEvent* aEsd, Trigger trigger) | |
206 | { | |
207 | // checks if an event has been triggered | |
208 | ||
209 | if (trigger & kOfflineFlag) | |
210 | return IsOfflineTriggerFired(aEsd, trigger); | |
211 | ||
212 | return IsTriggerBitFired(aEsd, trigger); | |
213 | } | |
214 | ||
215 | Bool_t AliTriggerAnalysis::IsTriggerBitFired(const AliESDEvent* aEsd, Trigger trigger) const | |
216 | { | |
217 | // checks if an event is fired using the trigger bits | |
218 | ||
219 | return IsTriggerBitFired(aEsd->GetTriggerMask(), trigger); | |
220 | } | |
221 | ||
222 | Bool_t AliTriggerAnalysis::IsTriggerBitFired(ULong64_t triggerMask, Trigger trigger) const | |
223 | { | |
224 | // checks if an event is fired using the trigger bits | |
225 | // | |
226 | // this function needs the branch TriggerMask in the ESD | |
227 | ||
228 | // definitions from p-p.cfg | |
229 | ULong64_t spdFO = (1 << 14); | |
230 | ULong64_t v0left = (1 << 10); | |
231 | ULong64_t v0right = (1 << 11); | |
232 | ||
233 | switch (trigger) | |
234 | { | |
235 | case kAcceptAll: | |
236 | { | |
237 | return kTRUE; | |
238 | break; | |
239 | } | |
240 | case kMB1: | |
241 | { | |
242 | if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right))) | |
243 | return kTRUE; | |
244 | break; | |
245 | } | |
246 | case kMB2: | |
247 | { | |
248 | if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right))) | |
249 | return kTRUE; | |
250 | break; | |
251 | } | |
252 | case kMB3: | |
253 | { | |
254 | if (triggerMask & spdFO && (triggerMask & v0left) && (triggerMask & v0right)) | |
255 | return kTRUE; | |
256 | break; | |
257 | } | |
258 | case kSPDGFO: | |
259 | { | |
260 | if (triggerMask & spdFO) | |
261 | return kTRUE; | |
262 | break; | |
263 | } | |
264 | default: | |
265 | Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger); | |
266 | break; | |
267 | } | |
268 | ||
269 | return kFALSE; | |
270 | } | |
271 | ||
272 | Bool_t AliTriggerAnalysis::IsTriggerBitFired(const AliESDEvent* aEsd, ULong64_t tclass) const | |
273 | { | |
274 | // Checks if corresponding bit in mask is on | |
275 | ||
276 | ULong64_t trigmask = aEsd->GetTriggerMask(); | |
277 | return (trigmask & (1ull << (tclass-1))); | |
278 | } | |
279 | ||
280 | Bool_t AliTriggerAnalysis::IsOfflineTriggerFired(const AliESDEvent* aEsd, Trigger trigger) | |
281 | { | |
282 | // checks if an event has been triggered "offline" | |
283 | ||
284 | UInt_t triggerNoFlags = (UInt_t) trigger % (UInt_t) kStartOfFlags; | |
285 | ||
286 | switch (triggerNoFlags) | |
287 | { | |
288 | case kAcceptAll: | |
289 | { | |
290 | return kTRUE; | |
291 | break; | |
292 | } | |
293 | case kMB1: | |
294 | { | |
295 | if (SPDGFOTrigger(aEsd, 0) || V0Trigger(aEsd, kASide, kFALSE) == kV0BB || V0Trigger(aEsd, kCSide, kFALSE) == kV0BB) | |
296 | return kTRUE; | |
297 | break; | |
298 | } | |
299 | case kMB2: | |
300 | { | |
301 | if (SPDGFOTrigger(aEsd, 0) && (V0Trigger(aEsd, kASide, kFALSE) == kV0BB || V0Trigger(aEsd, kCSide, kFALSE) == kV0BB)) | |
302 | return kTRUE; | |
303 | break; | |
304 | } | |
305 | case kMB3: | |
306 | { | |
307 | if (SPDGFOTrigger(aEsd, 0) && V0Trigger(aEsd, kASide, kFALSE) == kV0BB && V0Trigger(aEsd, kCSide, kFALSE) == kV0BB) | |
308 | return kTRUE; | |
309 | break; | |
310 | } | |
311 | case kSPDGFO: | |
312 | { | |
313 | if (SPDGFOTrigger(aEsd, 0)) | |
314 | return kTRUE; | |
315 | break; | |
316 | } | |
317 | case kSPDGFOBits: | |
318 | { | |
319 | if (SPDGFOTrigger(aEsd, 1)) | |
320 | return kTRUE; | |
321 | break; | |
322 | } | |
323 | case kV0A: | |
324 | { | |
325 | if (V0Trigger(aEsd, kASide, kFALSE) == kV0BB) | |
326 | return kTRUE; | |
327 | break; | |
328 | } | |
329 | case kV0C: | |
330 | { | |
331 | if (V0Trigger(aEsd, kCSide, kFALSE) == kV0BB) | |
332 | return kTRUE; | |
333 | break; | |
334 | } | |
335 | case kV0OR: | |
336 | { | |
337 | if (V0Trigger(aEsd, kASide, kFALSE) == kV0BB || V0Trigger(aEsd, kCSide, kFALSE) == kV0BB) | |
338 | return kTRUE; | |
339 | break; | |
340 | } | |
341 | case kV0AND: | |
342 | { | |
343 | if (V0Trigger(aEsd, kASide, kFALSE) == kV0BB && V0Trigger(aEsd, kCSide, kFALSE) == kV0BB) | |
344 | return kTRUE; | |
345 | break; | |
346 | } | |
347 | case kV0ABG: | |
348 | { | |
349 | if (V0Trigger(aEsd, kASide, kFALSE) == kV0BG) | |
350 | return kTRUE; | |
351 | break; | |
352 | } | |
353 | case kV0CBG: | |
354 | { | |
355 | if (V0Trigger(aEsd, kCSide, kFALSE) == kV0BG) | |
356 | return kTRUE; | |
357 | break; | |
358 | } | |
359 | case kZDC: | |
360 | { | |
361 | if (ZDCTrigger(aEsd, kASide) || ZDCTrigger(aEsd, kCentralBarrel) || ZDCTrigger(aEsd, kCSide)) | |
362 | return kTRUE; | |
363 | break; | |
364 | } | |
365 | case kZDCA: | |
366 | { | |
367 | if (ZDCTrigger(aEsd, kASide)) | |
368 | return kTRUE; | |
369 | break; | |
370 | } | |
371 | case kZDCC: | |
372 | { | |
373 | if (ZDCTrigger(aEsd, kCSide)) | |
374 | return kTRUE; | |
375 | break; | |
376 | } | |
377 | case kFMDA: | |
378 | { | |
379 | if (FMDTrigger(aEsd, kASide)) | |
380 | return kTRUE; | |
381 | break; | |
382 | } | |
383 | case kFMDC: | |
384 | { | |
385 | if (FMDTrigger(aEsd, kCSide)) | |
386 | return kTRUE; | |
387 | break; | |
388 | } | |
389 | case kFPANY: | |
390 | { | |
391 | if (SPDGFOTrigger(aEsd, 0) || V0Trigger(aEsd, kASide, kFALSE) == kV0BB || V0Trigger(aEsd, kCSide, kFALSE) == kV0BB || ZDCTrigger(aEsd, kASide) || ZDCTrigger(aEsd, kCentralBarrel) || ZDCTrigger(aEsd, kCSide) || FMDTrigger(aEsd, kASide) || FMDTrigger(aEsd, kCSide)) | |
392 | return kTRUE; | |
393 | break; | |
394 | } | |
395 | case kNSD1: | |
396 | { | |
397 | if (SPDFiredChips(aEsd, 0) >= 5 || (V0Trigger(aEsd, kASide, kFALSE) == kV0BB && V0Trigger(aEsd, kCSide, kFALSE) == kV0BB)) | |
398 | return kTRUE; | |
399 | break; | |
400 | } | |
401 | case kMB1Prime: | |
402 | { | |
403 | Int_t count = 0; | |
404 | if (SPDGFOTrigger(aEsd, 0)) | |
405 | count++; | |
406 | if (V0Trigger(aEsd, kASide, kFALSE) == kV0BB) | |
407 | count++; | |
408 | if (V0Trigger(aEsd, kCSide, kFALSE) == kV0BB) | |
409 | count++; | |
410 | ||
411 | if (count >= 2) | |
412 | return kTRUE; | |
413 | ||
414 | break; | |
415 | } | |
416 | default: | |
417 | { | |
418 | AliFatal(Form("Trigger type %d not implemented", triggerNoFlags)); | |
419 | } | |
420 | } | |
421 | ||
422 | return kFALSE; | |
423 | } | |
424 | ||
425 | ||
426 | Bool_t AliTriggerAnalysis::IsTriggerClassFired(const AliESDEvent* aEsd, const Char_t* tclass) const | |
427 | { | |
428 | // tclass is logical function of inputs, e.g. 01 && 02 || 03 && 11 && 21 | |
429 | // = L0 inp 1 && L0 inp 2 || L0 inp 3 && L1 inp 1 && L2 inp 1 | |
430 | // NO brackets in logical function ! | |
431 | // Spaces between operators and inputs. | |
432 | // Not all logical functions are available in CTP= | |
433 | // =any function of first 4 inputs; 'AND' of other inputs, check not done | |
434 | // This method will be replaced/complemened by similar one | |
435 | // which works withh class and inputs names as in CTP cfg file | |
436 | ||
437 | TString TClass(tclass); | |
438 | TObjArray* tcltokens = TClass.Tokenize(" "); | |
439 | Char_t level=((TObjString*)tcltokens->At(0))->String()[0]; | |
440 | UInt_t input=atoi((((TObjString*)tcltokens->At(0))->String()).Remove(0)); | |
441 | Bool_t tcl = IsInputFired(aEsd,level,input); | |
442 | ||
443 | for (Int_t i=1;i<tcltokens->GetEntriesFast();i=i+2) { | |
444 | level=((TObjString*)tcltokens->At(i+1))->String()[0]; | |
445 | input=atoi((((TObjString*)tcltokens->At(i+1))->String()).Remove(0)); | |
446 | Bool_t inpnext = IsInputFired(aEsd,level,input); | |
447 | Char_t op =((TObjString*)tcltokens->At(i))->String()[0]; | |
448 | if (op == '&') tcl=tcl && inpnext; | |
449 | else if (op == '|') tcl =tcl || inpnext; | |
450 | else { | |
451 | AliError(Form("Syntax error in %s", tclass)); | |
452 | tcltokens->Delete(); | |
453 | return kFALSE; | |
454 | } | |
455 | } | |
456 | tcltokens->Delete(); | |
457 | return tcl; | |
458 | } | |
459 | ||
460 | Bool_t AliTriggerAnalysis::IsInputFired(const AliESDEvent* aEsd, Char_t level, UInt_t input) const | |
461 | { | |
462 | // Checks trigger input of any level | |
463 | ||
464 | switch (level) | |
465 | { | |
466 | case '0': return IsL0InputFired(aEsd,input); | |
467 | case '1': return IsL1InputFired(aEsd,input); | |
468 | case '2': return IsL2InputFired(aEsd,input); | |
469 | default: | |
470 | AliError(Form("Wrong level %i",level)); | |
471 | return kFALSE; | |
472 | } | |
473 | } | |
474 | ||
475 | Bool_t AliTriggerAnalysis::IsL0InputFired(const AliESDEvent* aEsd, UInt_t input) const | |
476 | { | |
477 | // Checks if corresponding bit in mask is on | |
478 | ||
479 | UInt_t inpmask = aEsd->GetHeader()->GetL0TriggerInputs(); | |
480 | return (inpmask & (1<<(input-1))); | |
481 | } | |
482 | ||
483 | Bool_t AliTriggerAnalysis::IsL1InputFired(const AliESDEvent* aEsd, UInt_t input) const | |
484 | { | |
485 | // Checks if corresponding bit in mask is on | |
486 | ||
487 | UInt_t inpmask = aEsd->GetHeader()->GetL1TriggerInputs(); | |
488 | return (inpmask & (1<<(input-1))); | |
489 | } | |
490 | ||
491 | Bool_t AliTriggerAnalysis::IsL2InputFired(const AliESDEvent* aEsd, UInt_t input) const | |
492 | { | |
493 | // Checks if corresponding bit in mask is on | |
494 | ||
495 | UInt_t inpmask = aEsd->GetHeader()->GetL2TriggerInputs(); | |
496 | return (inpmask & (1<<(input-1))); | |
497 | } | |
498 | ||
499 | void AliTriggerAnalysis::FillHistograms(const AliESDEvent* aEsd) | |
500 | { | |
501 | // fills the histograms with the info from the ESD | |
502 | ||
503 | fHistBitsSPD->Fill(SPDFiredChips(aEsd, 0), SPDFiredChips(aEsd, 1, kTRUE)); | |
504 | ||
505 | V0Trigger(aEsd, kASide, kFALSE, kTRUE); | |
506 | V0Trigger(aEsd, kCSide, kFALSE, kTRUE); | |
507 | ||
508 | AliESDZDC* zdcData = aEsd->GetESDZDC(); | |
509 | if (zdcData) | |
510 | { | |
511 | UInt_t quality = zdcData->GetESDQuality(); | |
512 | ||
513 | // from Nora's presentation, general first physics meeting 16.10.09 | |
514 | static UInt_t zpc = 0x20; | |
515 | static UInt_t znc = 0x10; | |
516 | static UInt_t zem1 = 0x08; | |
517 | static UInt_t zem2 = 0x04; | |
518 | static UInt_t zpa = 0x02; | |
519 | static UInt_t zna = 0x01; | |
520 | ||
521 | fHistZDC->Fill(1, quality & zna); | |
522 | fHistZDC->Fill(2, quality & zpa); | |
523 | fHistZDC->Fill(3, quality & zem2); | |
524 | fHistZDC->Fill(4, quality & zem1); | |
525 | fHistZDC->Fill(5, quality & znc); | |
526 | fHistZDC->Fill(6, quality & zpc); | |
527 | } | |
528 | else | |
529 | { | |
530 | fHistZDC->Fill(-1); | |
531 | AliError("AliESDZDC not available"); | |
532 | } | |
533 | ||
534 | fHistFMDA->Fill(FMDHitCombinations(aEsd, kASide, kTRUE)); | |
535 | fHistFMDC->Fill(FMDHitCombinations(aEsd, kCSide, kTRUE)); | |
536 | } | |
537 | ||
538 | void AliTriggerAnalysis::FillTriggerClasses(const AliESDEvent* aEsd) | |
539 | { | |
540 | // fills trigger classes map | |
541 | ||
542 | TParameter<Long64_t>* count = dynamic_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(aEsd->GetFiredTriggerClasses().Data())); | |
543 | if (!count) | |
544 | { | |
545 | count = new TParameter<Long64_t>(aEsd->GetFiredTriggerClasses(), 0); | |
546 | fTriggerClasses->Add(new TObjString(aEsd->GetFiredTriggerClasses().Data()), count); | |
547 | } | |
548 | count->SetVal(count->GetVal() + 1); | |
549 | ||
550 | // TODO add first and last orbit number here | |
551 | } | |
552 | ||
553 | Int_t AliTriggerAnalysis::SPDFiredChips(const AliESDEvent* aEsd, Int_t origin, Bool_t fillHists) | |
554 | { | |
555 | // returns the number of fired chips in the SPD | |
556 | // | |
557 | // origin = 0 --> aEsd->GetMultiplicity()->GetNumberOfFiredChips() (filled from clusters) | |
558 | // origin = 1 --> aEsd->GetMultiplicity()->TestFastOrFiredChips() (from hardware bits) | |
559 | ||
560 | const AliMultiplicity* mult = aEsd->GetMultiplicity(); | |
561 | if (!mult) | |
562 | { | |
563 | AliError("AliMultiplicity not available"); | |
564 | return -1; | |
565 | } | |
566 | ||
567 | if (origin == 0) | |
568 | return mult->GetNumberOfFiredChips(0) + mult->GetNumberOfFiredChips(1); | |
569 | ||
570 | if (origin == 1) | |
571 | { | |
572 | Int_t nChips = 0; | |
573 | for (Int_t i=0; i<1200; i++) | |
574 | { | |
575 | if (mult->TestFastOrFiredChips(i) == kTRUE) | |
576 | { | |
577 | // efficiency simulation (if enabled) | |
578 | if (fSPDGFOEfficiency) | |
579 | { | |
580 | if (gRandom->Uniform() > fSPDGFOEfficiency->GetBinContent(i+1)) | |
581 | continue; | |
582 | } | |
583 | ||
584 | nChips++; | |
585 | if (fillHists) | |
586 | fHistFiredBitsSPD->Fill(i); | |
587 | } | |
588 | } | |
589 | return nChips; | |
590 | } | |
591 | ||
592 | return -1; | |
593 | } | |
594 | ||
595 | Bool_t AliTriggerAnalysis::SPDGFOTrigger(const AliESDEvent* aEsd, Int_t origin) | |
596 | { | |
597 | // Returns if the SPD gave a global Fast OR trigger | |
598 | ||
599 | Int_t firedChips = SPDFiredChips(aEsd, origin); | |
600 | ||
601 | if (firedChips >= fSPDGFOThreshold) | |
602 | return kTRUE; | |
603 | return kFALSE; | |
604 | } | |
605 | ||
606 | AliTriggerAnalysis::V0Decision AliTriggerAnalysis::V0Trigger(const AliESDEvent* aEsd, AliceSide side, Bool_t online, Bool_t fillHists) | |
607 | { | |
608 | // Returns the V0 trigger decision in V0A | V0C | |
609 | // | |
610 | // Returns kV0Fake if the calculated average time is in a window where neither BB nor BG is expected. | |
611 | // The rate of such triggers can be used to estimate the background. Note that the rate has to be | |
612 | // rescaled with the size of the windows (numerical values see below in the code) | |
613 | // | |
614 | // argument 'online' is used as a switch between online and offline trigger algorithms | |
615 | // | |
616 | // Based on an algorithm by Cvetan Cheshkov | |
617 | ||
618 | AliESDVZERO* esdV0 = aEsd->GetVZEROData(); | |
619 | if (!esdV0) | |
620 | { | |
621 | AliError("AliESDVZERO not available"); | |
622 | return kV0Invalid; | |
623 | } | |
624 | ||
625 | Int_t begin = -1; | |
626 | Int_t end = -1; | |
627 | ||
628 | if (side == kASide) | |
629 | { | |
630 | begin = 32; | |
631 | end = 64; | |
632 | } | |
633 | else if (side == kCSide) | |
634 | { | |
635 | begin = 0; | |
636 | end = 32; | |
637 | } | |
638 | else | |
639 | return kV0Invalid; | |
640 | ||
641 | Float_t time = 0; | |
642 | Float_t weight = 0; | |
643 | if (fMC) | |
644 | { | |
645 | Int_t runRange; | |
646 | if (aEsd->GetRunNumber() <= 104803) runRange = 0; | |
647 | else if (aEsd->GetRunNumber() <= 104876) runRange = 1; | |
648 | else runRange = 2; | |
649 | ||
650 | Float_t factors[3][64] = { | |
651 | // runs: 104792-104803 | |
652 | {4.6,5.9,6.3,6.0,4.7,5.9,4.9,5.4,4.8,4.1,4.9,4.6,4.5,5.5,5.1,5.8,4.3,4.0,4.0,3.3,3.1,2.9,3.0,5.6,3.3,4.9,3.9,5.3,4.1,4.4,3.9,5.5,5.7,9.5,5.1,5.3,6.6,7.1,8.9,4.4,4.1,5.9,9.0,4.5,4.1,6.0,4.7,7.1,4.2,4.7,3.9,6.3,5.9,4.8,4.7,4.5,4.7,5.4,5.8,5.0,5.1,5.9,5.3,3.6}, | |
653 | // runs: 104841-104876 | |
654 | {4.6,4.8,4.9,4.8,4.3,4.9,4.4,4.5,4.6,5.0,4.7,4.6,4.7,4.6,4.6,5.5,4.7,4.5,4.7,5.0,6.5,7.6,5.3,4.9,5.5,4.8,4.6,4.9,4.5,4.5,4.6,4.9,5.7,9.8,4.9,5.2,7.1,7.1,8.1,4.4,4.0,6.0,8.3,4.6,4.2,5.6,4.6,6.4,4.4,4.7,4.5,6.5,6.0,4.7,4.5,4.4,4.8,5.5,5.9,5.3,5.0,5.7,5.1,3.6}, | |
655 | // runs: 104890-92 | |
656 | {4.7,5.2,4.8,5.0,4.4,5.0,4.4,4.6,4.6,4.5,4.4,4.6,4.5,4.6,4.8,5.5,4.8,4.5,4.4,4.3,5.4,7.7,5.6,5.0,5.4,4.3,4.5,4.8,4.5,4.5,4.6,5.3,5.7,9.6,4.9,5.4,6.1,7.2,8.6,4.4,4.0,5.4,8.8,4.4,4.2,5.8,4.7,6.7,4.3,4.7,4.0,6.1,6.0,4.9,4.8,4.6,4.7,5.2,5.7,5.0,5.0,5.8,5.3,3.6} | |
657 | }; | |
658 | Float_t dA = 77.4 - 11.0; | |
659 | Float_t dC = 77.4 - 2.9; | |
660 | // Time misalignment | |
661 | Float_t timeShift[64] = {0.477957 , 0.0889999 , 0.757669 , 0.205439 , 0.239666 , -0.183705 , 0.442873 , -0.281366 , 0.260976 , 0.788995 , 0.974758 , 0.548532 , 0.495023 , 0.868472 , 0.661167 , 0.358307 , 0.221243 , 0.530179 , 1.26696 , 1.33082 , 1.27086 , 1.77133 , 1.10253 , 0.634806 , 2.14838 , 1.50212 , 1.59253 , 1.66122 , 1.16957 , 1.52056 , 1.47791 , 1.81905 , -1.94123 , -1.29124 , -2.16045 , -1.78939 , -3.11111 , -1.87178 , -1.57671 , -1.70311 , -1.81208 , -1.94475 , -2.53058 , -1.7042 , -2.08109 , -1.84416 , -0.61073 , -1.77145 , 0.16999 , -0.0585339 , 0.00401133 , 0.397726 , 0.851111 , 0.264187 , 0.59573 , -0.158263 , 0.584362 , 1.20835 , 0.927573 , 1.13895 , 0.64648 , 2.18747 , 1.68909 , 0.451194}; | |
662 | Float_t dA2 = 2.8, dC2 = 3.3; | |
663 | ||
664 | if (online) { | |
665 | for (Int_t i = begin; i < end; ++i) { | |
666 | Float_t tempAdc = esdV0->GetAdc(i)/factors[runRange][i]; | |
667 | Float_t tempTime = (i >= 32) ? esdV0->GetTime(i)+dA+timeShift[i]+dA2 : esdV0->GetTime(i)+dC+timeShift[i]+dC2; | |
668 | if (esdV0->GetTime(i) >= 1e-6 && | |
669 | tempTime > fV0HwWinLow && tempTime < fV0HwWinHigh && | |
670 | tempAdc > fV0HwAdcThr) | |
671 | return kV0BB; | |
672 | } | |
673 | return kV0Empty; | |
674 | } | |
675 | else { | |
676 | for (Int_t i = begin; i < end; ++i) { | |
677 | Float_t tempAdc = esdV0->GetAdc(i)/factors[runRange][i]; | |
678 | Float_t tempTime = (i >= 32) ? esdV0->GetTime(i)+dA : esdV0->GetTime(i)+dC; | |
679 | Float_t tempRawTime = (i >= 32) ? esdV0->GetTime(i)+dA+timeShift[i]+dA2 : esdV0->GetTime(i)+dC+timeShift[i]+dC2; | |
680 | if (esdV0->GetTime(i) >= 1e-6 && | |
681 | tempRawTime < 125.0 && | |
682 | tempAdc > fV0AdcThr) { | |
683 | weight += 1.0; | |
684 | time += tempTime; | |
685 | } | |
686 | } | |
687 | } | |
688 | } | |
689 | else { | |
690 | if (online) { | |
691 | for (Int_t i = begin; i < end; ++i) { | |
692 | if (esdV0->GetTime(i) >= 1e-6 && | |
693 | esdV0->GetTime(i) > fV0HwWinLow && esdV0->GetTime(i) < fV0HwWinHigh && | |
694 | esdV0->GetAdc(i) > fV0HwAdcThr) | |
695 | return kV0BB; | |
696 | } | |
697 | return kV0Empty; | |
698 | } | |
699 | else { | |
700 | for (Int_t i = begin; i < end; ++i) { | |
701 | if (esdV0->GetTime(i) > 1e-6 && esdV0->GetAdc(i) > fV0AdcThr) { | |
702 | Float_t correctedTime = V0CorrectLeadingTime(i, esdV0->GetTime(i), esdV0->GetAdc(i)); | |
703 | Float_t timeWeight = V0LeadingTimeWeight(esdV0->GetAdc(i)); | |
704 | time += correctedTime*timeWeight; | |
705 | ||
706 | weight += timeWeight; | |
707 | } | |
708 | } | |
709 | } | |
710 | } | |
711 | ||
712 | if (weight > 0) | |
713 | time /= weight; | |
714 | time += fV0TimeOffset; | |
715 | ||
716 | if (fillHists) | |
717 | { | |
718 | if (side == kASide && fHistV0A) | |
719 | fHistV0A->Fill(time); | |
720 | if (side == kCSide && fHistV0C) | |
721 | fHistV0C->Fill(time); | |
722 | } | |
723 | ||
724 | if (side == kASide) | |
725 | { | |
726 | if (time > 68 && time < 100) | |
727 | return kV0BB; | |
728 | if (time > 54 && time < 57.5) | |
729 | return kV0BG; | |
730 | if (time > 57.5 && time < 68) | |
731 | return kV0Fake; | |
732 | } | |
733 | ||
734 | if (side == kCSide) | |
735 | { | |
736 | if (time > 75.5 && time < 100) | |
737 | return kV0BB; | |
738 | if (time > 69.5 && time < 73) | |
739 | return kV0BG; | |
740 | if (time > 55 && time < 69.5) | |
741 | return kV0Fake; | |
742 | } | |
743 | ||
744 | return kV0Empty; | |
745 | } | |
746 | ||
747 | Float_t AliTriggerAnalysis::V0CorrectLeadingTime(Int_t i, Float_t time, Float_t adc) const | |
748 | { | |
749 | // Correct for slewing and align the channels | |
750 | // | |
751 | // Authors: Cvetan Cheshkov / Raphael Tieulent | |
752 | ||
753 | if (time == 0) return 0; | |
754 | ||
755 | // Time alignment | |
756 | Float_t timeShift[64] = {0.477957 , 0.0889999 , 0.757669 , 0.205439 , 0.239666 , -0.183705 , 0.442873 , -0.281366 , 0.260976 , 0.788995 , 0.974758 , 0.548532 , 0.495023 , 0.868472 , 0.661167 , 0.358307 , 0.221243 , 0.530179 , 1.26696 , 1.33082 , 1.27086 , 1.77133 , 1.10253 , 0.634806 , 2.14838 , 1.50212 , 1.59253 , 1.66122 , 1.16957 , 1.52056 , 1.47791 , 1.81905 , -1.94123 , -1.29124 , -2.16045 , -1.78939 , -3.11111 , -1.87178 , -1.57671 , -1.70311 , -1.81208 , -1.94475 , -2.53058 , -1.7042 , -2.08109 , -1.84416 , -0.61073 , -1.77145 , 0.16999 , -0.0585339 , 0.00401133 , 0.397726 , 0.851111 , 0.264187 , 0.59573 , -0.158263 , 0.584362 , 1.20835 , 0.927573 , 1.13895 , 0.64648 , 2.18747 , 1.68909 , 0.451194}; | |
757 | ||
758 | time -= timeShift[i]; | |
759 | ||
760 | // Slewing correction | |
761 | if (adc == 0) return time; | |
762 | ||
763 | Float_t p1 = 1.57345e1; | |
764 | Float_t p2 =-4.25603e-1; | |
765 | ||
766 | return (time - p1*TMath::Power(adc,p2)); | |
767 | } | |
768 | ||
769 | Float_t AliTriggerAnalysis::V0LeadingTimeWeight(Float_t adc) const | |
770 | { | |
771 | if (adc < 1e-6) return 0; | |
772 | ||
773 | Float_t p1 = 40.211; | |
774 | Float_t p2 =-4.25603e-1; | |
775 | Float_t p3 = 0.5646; | |
776 | ||
777 | return 1./(p1*p1*TMath::Power(adc,2.*(p2-1.))+p3*p3); | |
778 | } | |
779 | ||
780 | Bool_t AliTriggerAnalysis::ZDCTrigger(const AliESDEvent* aEsd, AliceSide side) const | |
781 | { | |
782 | // Returns if ZDC triggered | |
783 | ||
784 | AliESDZDC* zdcData = aEsd->GetESDZDC(); | |
785 | if (!zdcData) | |
786 | { | |
787 | AliError("AliESDZDC not available"); | |
788 | return kFALSE; | |
789 | } | |
790 | ||
791 | UInt_t quality = zdcData->GetESDQuality(); | |
792 | ||
793 | // from Nora's presentation, general first physics meeting 16.10.09 | |
794 | static UInt_t zpc = 0x20; | |
795 | static UInt_t znc = 0x10; | |
796 | static UInt_t zem1 = 0x08; | |
797 | static UInt_t zem2 = 0x04; | |
798 | static UInt_t zpa = 0x02; | |
799 | static UInt_t zna = 0x01; | |
800 | ||
801 | if (side == kASide && ((quality & zpa) || (quality & zna))) | |
802 | return kTRUE; | |
803 | if (side == kCentralBarrel && ((quality & zem1) || (quality & zem2))) | |
804 | return kTRUE; | |
805 | if (side == kCSide && ((quality & zpc) || (quality & znc))) | |
806 | return kTRUE; | |
807 | ||
808 | return kFALSE; | |
809 | } | |
810 | ||
811 | Int_t AliTriggerAnalysis::FMDHitCombinations(const AliESDEvent* aEsd, AliceSide side, Bool_t fillHists) | |
812 | { | |
813 | // returns number of hit combinations agove threshold | |
814 | // | |
815 | // Authors: FMD team, Hans Dalsgaard (code merged from FMD/AliFMDOfflineTrigger) | |
816 | ||
817 | // Workaround for AliESDEvent::GetFMDData is not const! | |
818 | const AliESDFMD* fmdData = (const_cast<AliESDEvent*>(aEsd))->GetFMDData(); | |
819 | if (!fmdData) | |
820 | { | |
821 | AliError("AliESDFMD not available"); | |
822 | return -1; | |
823 | } | |
824 | ||
825 | Int_t detFrom = (side == kASide) ? 1 : 3; | |
826 | Int_t detTo = (side == kASide) ? 2 : 3; | |
827 | ||
828 | Int_t triggers = 0; | |
829 | Float_t totalMult = 0; | |
830 | for (UShort_t det=detFrom;det<=detTo;det++) { | |
831 | Int_t nRings = (det == 1 ? 1 : 2); | |
832 | for (UShort_t ir = 0; ir < nRings; ir++) { | |
833 | Char_t ring = (ir == 0 ? 'I' : 'O'); | |
834 | UShort_t nsec = (ir == 0 ? 20 : 40); | |
835 | UShort_t nstr = (ir == 0 ? 512 : 256); | |
836 | for (UShort_t sec =0; sec < nsec; sec++) { | |
837 | for (UShort_t strip = 0; strip < nstr; strip++) { | |
838 | Float_t mult = fmdData->Multiplicity(det,ring,sec,strip); | |
839 | if (mult == AliESDFMD::kInvalidMult) continue; | |
840 | ||
841 | if (fillHists) | |
842 | fHistFMDSingle->Fill(mult); | |
843 | ||
844 | if (mult > fFMDLowCut) | |
845 | totalMult = totalMult + mult; | |
846 | else | |
847 | { | |
848 | if (totalMult > fFMDHitCut) | |
849 | triggers++; | |
850 | ||
851 | if (fillHists) | |
852 | fHistFMDSum->Fill(totalMult); | |
853 | ||
854 | totalMult = 0; | |
855 | } | |
856 | } | |
857 | } | |
858 | } | |
859 | } | |
860 | ||
861 | return triggers; | |
862 | } | |
863 | ||
864 | Bool_t AliTriggerAnalysis::FMDTrigger(const AliESDEvent* aEsd, AliceSide side) | |
865 | { | |
866 | // Returns if the FMD triggered | |
867 | // | |
868 | // Authors: FMD team, Hans Dalsgaard (code merged from FMD/AliFMDOfflineTrigger) | |
869 | ||
870 | Int_t triggers = FMDHitCombinations(aEsd, side, kFALSE); | |
871 | ||
872 | if (triggers > 0) | |
873 | return kTRUE; | |
874 | ||
875 | return kFALSE; | |
876 | } | |
877 | ||
878 | Long64_t AliTriggerAnalysis::Merge(TCollection* list) | |
879 | { | |
880 | // Merge a list of AliMultiplicityCorrection objects with this (needed for | |
881 | // PROOF). | |
882 | // Returns the number of merged objects (including this). | |
883 | ||
884 | if (!list) | |
885 | return 0; | |
886 | ||
887 | if (list->IsEmpty()) | |
888 | return 1; | |
889 | ||
890 | TIterator* iter = list->MakeIterator(); | |
891 | TObject* obj; | |
892 | ||
893 | // collections of all histograms | |
894 | const Int_t nHists = 9; | |
895 | TList collections[nHists]; | |
896 | ||
897 | Int_t count = 0; | |
898 | while ((obj = iter->Next())) { | |
899 | ||
900 | AliTriggerAnalysis* entry = dynamic_cast<AliTriggerAnalysis*> (obj); | |
901 | if (entry == 0) | |
902 | continue; | |
903 | ||
904 | Int_t n = 0; | |
905 | collections[n++].Add(entry->fHistV0A); | |
906 | collections[n++].Add(entry->fHistV0C); | |
907 | collections[n++].Add(entry->fHistZDC); | |
908 | collections[n++].Add(entry->fHistFMDA); | |
909 | collections[n++].Add(entry->fHistFMDC); | |
910 | collections[n++].Add(entry->fHistFMDSingle); | |
911 | collections[n++].Add(entry->fHistFMDSum); | |
912 | collections[n++].Add(entry->fHistBitsSPD); | |
913 | collections[n++].Add(entry->fHistFiredBitsSPD); | |
914 | ||
915 | // merge fTriggerClasses | |
916 | TIterator* iter2 = entry->fTriggerClasses->MakeIterator(); | |
917 | TObjString* obj = 0; | |
918 | while ((obj = dynamic_cast<TObjString*> (iter2->Next()))) | |
919 | { | |
920 | TParameter<Long64_t>* param2 = dynamic_cast<TParameter<Long64_t>*> (entry->fTriggerClasses->GetValue(obj)); | |
921 | ||
922 | TParameter<Long64_t>* param1 = dynamic_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(obj)); | |
923 | if (param1) | |
924 | { | |
925 | param1->SetVal(param1->GetVal() + param2->GetVal()); | |
926 | } | |
927 | else | |
928 | { | |
929 | param1 = dynamic_cast<TParameter<Long64_t>*> (param2->Clone()); | |
930 | fTriggerClasses->Add(new TObjString(obj->String()), param1); | |
931 | } | |
932 | } | |
933 | ||
934 | delete iter2; | |
935 | ||
936 | count++; | |
937 | } | |
938 | ||
939 | Int_t n = 0; | |
940 | fHistV0A->Merge(&collections[n++]); | |
941 | fHistV0C->Merge(&collections[n++]); | |
942 | fHistZDC->Merge(&collections[n++]); | |
943 | fHistFMDA->Merge(&collections[n++]); | |
944 | fHistFMDC->Merge(&collections[n++]); | |
945 | fHistFMDSingle->Merge(&collections[n++]); | |
946 | fHistFMDSum->Merge(&collections[n++]); | |
947 | fHistBitsSPD->Merge(&collections[n++]); | |
948 | fHistFiredBitsSPD->Merge(&collections[n++]); | |
949 | ||
950 | delete iter; | |
951 | ||
952 | return count+1; | |
953 | } | |
954 | ||
955 | void AliTriggerAnalysis::SaveHistograms() const | |
956 | { | |
957 | // write histograms to current directory | |
958 | ||
959 | if (!fHistBitsSPD) | |
960 | return; | |
961 | ||
962 | fHistBitsSPD->Write(); | |
963 | fHistBitsSPD->ProjectionX(); | |
964 | fHistBitsSPD->ProjectionY(); | |
965 | fHistFiredBitsSPD->Write(); | |
966 | fHistV0A->Write(); | |
967 | fHistV0C->Write(); | |
968 | fHistZDC->Write(); | |
969 | fHistFMDA->Write(); | |
970 | fHistFMDC->Write(); | |
971 | fHistFMDSingle->Write(); | |
972 | fHistFMDSum->Write(); | |
973 | ||
974 | if (fSPDGFOEfficiency) | |
975 | fSPDGFOEfficiency->Write("fSPDGFOEfficiency"); | |
976 | ||
977 | fTriggerClasses->Write("fTriggerClasses", TObject::kSingleKey); | |
978 | } | |
979 | ||
980 | void AliTriggerAnalysis::PrintTriggerClasses() const | |
981 | { | |
982 | // print trigger classes | |
983 | ||
984 | Printf("Trigger Classes:"); | |
985 | ||
986 | Printf("Event count for trigger combinations:"); | |
987 | ||
988 | TMap singleTrigger; | |
989 | singleTrigger.SetOwner(); | |
990 | ||
991 | TIterator* iter = fTriggerClasses->MakeIterator(); | |
992 | TObjString* obj = 0; | |
993 | while ((obj = dynamic_cast<TObjString*> (iter->Next()))) | |
994 | { | |
995 | TParameter<Long64_t>* param = static_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(obj)); | |
996 | ||
997 | Printf(" %s: %ld triggers", obj->String().Data(), param->GetVal()); | |
998 | ||
999 | TObjArray* tokens = obj->String().Tokenize(" "); | |
1000 | for (Int_t i=0; i<tokens->GetEntries(); i++) | |
1001 | { | |
1002 | TParameter<Long64_t>* count = dynamic_cast<TParameter<Long64_t>*> (singleTrigger.GetValue(((TObjString*) tokens->At(i))->String().Data())); | |
1003 | if (!count) | |
1004 | { | |
1005 | count = new TParameter<Long64_t>(((TObjString*) tokens->At(i))->String().Data(), 0); | |
1006 | singleTrigger.Add(new TObjString(((TObjString*) tokens->At(i))->String().Data()), count); | |
1007 | } | |
1008 | count->SetVal(count->GetVal() + param->GetVal()); | |
1009 | } | |
1010 | ||
1011 | delete tokens; | |
1012 | } | |
1013 | delete iter; | |
1014 | ||
1015 | Printf("Event count for single trigger:"); | |
1016 | ||
1017 | iter = singleTrigger.MakeIterator(); | |
1018 | while ((obj = dynamic_cast<TObjString*> (iter->Next()))) | |
1019 | { | |
1020 | TParameter<Long64_t>* param = static_cast<TParameter<Long64_t>*> (singleTrigger.GetValue(obj)); | |
1021 | ||
1022 | Printf(" %s: %ld triggers", obj->String().Data(), param->GetVal()); | |
1023 | } | |
1024 | delete iter; | |
1025 | ||
1026 | singleTrigger.DeleteAll(); | |
1027 | } |