]>
Commit | Line | Data |
---|---|---|
70fdd197 | 1 | /* $Id: AliTriggerAnalysis.cxx 35782 2009-10-22 11:54:31Z jgrosseo $ */ |
ff8c4f30 | 2 | |
7a11141c | 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 | //------------------------------------------------------------------------- | |
70fdd197 | 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 | |
7a11141c | 22 | // Origin: Jan Fiete Grosse-Oetringhaus, CERN |
23 | //------------------------------------------------------------------------- | |
24 | ||
70fdd197 | 25 | #include <Riostream.h> |
907972ff | 26 | #include <TH1F.h> |
90dc86e9 | 27 | #include <TH2F.h> |
907972ff | 28 | #include <TList.h> |
29 | #include <TIterator.h> | |
c01a136b | 30 | #include "TParameter.h" |
31 | #include <TMap.h> | |
907972ff | 32 | |
70fdd197 | 33 | #include <AliTriggerAnalysis.h> |
ff8c4f30 | 34 | |
35 | #include <AliLog.h> | |
36 | ||
37 | #include <AliESDEvent.h> | |
38 | ||
39 | #include <AliMultiplicity.h> | |
40 | #include <AliESDVZERO.h> | |
c8d3e441 | 41 | #include <AliESDZDC.h> |
7a11141c | 42 | #include <AliESDFMD.h> |
ff8c4f30 | 43 | |
70fdd197 | 44 | ClassImp(AliTriggerAnalysis) |
ff8c4f30 | 45 | |
70fdd197 | 46 | AliTriggerAnalysis::AliTriggerAnalysis() : |
90dc86e9 | 47 | fSPDGFOThreshold(2), |
61899827 | 48 | fV0TimeOffset(0), |
90dc86e9 | 49 | fFMDLowCut(0.2), |
50 | fFMDHitCut(0.5), | |
90dc86e9 | 51 | fHistBitsSPD(0), |
c2fff146 | 52 | fHistFiredBitsSPD(0), |
907972ff | 53 | fHistV0A(0), |
61899827 | 54 | fHistV0C(0), |
907972ff | 55 | fHistZDC(0), |
56 | fHistFMDA(0), | |
57 | fHistFMDC(0), | |
58 | fHistFMDSingle(0), | |
c01a136b | 59 | fHistFMDSum(0), |
60 | fTriggerClasses(0) | |
ff8c4f30 | 61 | { |
61899827 | 62 | // constructor |
63 | } | |
64 | ||
65 | AliTriggerAnalysis::~AliTriggerAnalysis() | |
66 | { | |
67 | // destructor | |
68 | ||
69 | if (fHistBitsSPD) | |
70 | { | |
71 | delete fHistBitsSPD; | |
72 | fHistBitsSPD = 0; | |
73 | } | |
74 | ||
75 | if (fHistFiredBitsSPD) | |
76 | { | |
77 | delete fHistFiredBitsSPD; | |
78 | fHistFiredBitsSPD = 0; | |
79 | } | |
80 | ||
81 | if (fHistV0A) | |
82 | { | |
83 | delete fHistV0A; | |
84 | fHistV0A = 0; | |
85 | } | |
86 | ||
87 | if (fHistV0C) | |
88 | { | |
89 | delete fHistV0C; | |
90 | fHistV0C = 0; | |
91 | } | |
92 | ||
93 | if (fHistZDC) | |
94 | { | |
95 | delete fHistZDC; | |
96 | fHistZDC = 0; | |
97 | } | |
98 | ||
99 | if (fHistFMDA) | |
100 | { | |
101 | delete fHistFMDA; | |
102 | fHistFMDA = 0; | |
103 | } | |
104 | ||
105 | if (fHistFMDC) | |
106 | { | |
107 | delete fHistFMDC; | |
108 | fHistFMDC = 0; | |
109 | } | |
110 | ||
111 | if (fHistFMDSingle) | |
112 | { | |
113 | delete fHistFMDSingle; | |
114 | fHistFMDSingle = 0; | |
115 | } | |
116 | ||
117 | if (fHistFMDSum) | |
118 | { | |
119 | delete fHistFMDSum; | |
120 | fHistFMDSum = 0; | |
121 | } | |
122 | ||
123 | if (fTriggerClasses) | |
124 | { | |
125 | delete fTriggerClasses; | |
126 | fTriggerClasses = 0; | |
127 | } | |
ff8c4f30 | 128 | } |
129 | ||
70fdd197 | 130 | void AliTriggerAnalysis::EnableHistograms() |
907972ff | 131 | { |
132 | // creates the monitoring histograms | |
133 | ||
296dd262 | 134 | // do not add this hists to the directory |
135 | Bool_t oldStatus = TH1::AddDirectoryStatus(); | |
136 | TH1::AddDirectory(kFALSE); | |
137 | ||
90dc86e9 | 138 | 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); |
c01a136b | 139 | fHistFiredBitsSPD = new TH1F("fHistFiredBitsSPD", "SPD GFO Hardware;chip number;events", 1200, -0.5, 1199.5); |
140 | fHistV0A = new TH1F("fHistV0A", "V0A;leading time (ns);events", 200, 0, 100); | |
141 | fHistV0C = new TH1F("fHistV0C", "V0C;leading time (ns);events", 200, 0, 100); | |
907972ff | 142 | fHistZDC = new TH1F("fHistZDC", "ZDC;trigger bits;events", 8, -1.5, 6.5); |
143 | ||
144 | // TODO check limits | |
145 | fHistFMDA = new TH1F("fHistFMDA", "FMDA;combinations above threshold;events", 102, -1.5, 100.5); | |
146 | fHistFMDC = new TH1F("fHistFMDC", "FMDC;combinations above threshold;events", 102, -1.5, 100.5); | |
147 | fHistFMDSingle = new TH1F("fHistFMDSingle", "FMD single;multiplicity value;counts", 1000, 0, 10); | |
148 | fHistFMDSum = new TH1F("fHistFMDSum", "FMD sum;multiplicity value;counts", 1000, 0, 10); | |
c01a136b | 149 | |
150 | fTriggerClasses = new TMap; | |
61899827 | 151 | fTriggerClasses->SetOwner(); |
296dd262 | 152 | |
153 | TH1::AddDirectory(oldStatus); | |
907972ff | 154 | } |
155 | ||
70fdd197 | 156 | //____________________________________________________________________ |
157 | const char* AliTriggerAnalysis::GetTriggerName(Trigger trigger) | |
158 | { | |
159 | // returns the name of the requested trigger | |
160 | // the returned string will only be valid until the next call to this function [not thread-safe] | |
161 | ||
162 | static TString str; | |
163 | ||
164 | UInt_t triggerNoFlags = (UInt_t) trigger % (UInt_t) kStartOfFlags; | |
165 | ||
166 | switch (triggerNoFlags) | |
167 | { | |
168 | case kAcceptAll : str = "ACCEPT ALL (bypass!)"; break; | |
169 | case kMB1 : str = "MB1"; break; | |
170 | case kMB2 : str = "MB2"; break; | |
171 | case kMB3 : str = "MB3"; break; | |
172 | case kSPDGFO : str = "SPD GFO"; break; | |
c2fff146 | 173 | case kSPDGFOBits : str = "SPD GFO Bits"; break; |
61899827 | 174 | case kV0A : str = "V0 A BB"; break; |
175 | case kV0C : str = "V0 C BB"; break; | |
176 | case kV0ABG : str = "V0 A BG"; break; | |
177 | case kV0CBG : str = "V0 C BG"; break; | |
70fdd197 | 178 | case kZDC : str = "ZDC"; break; |
179 | case kZDCA : str = "ZDC A"; break; | |
180 | case kZDCC : str = "ZDC C"; break; | |
181 | case kFMDA : str = "FMD A"; break; | |
182 | case kFMDC : str = "FMD C"; break; | |
183 | case kFPANY : str = "SPD GFO | V0 | ZDC | FMD"; break; | |
184 | default: str = ""; break; | |
185 | } | |
186 | ||
187 | if (trigger & kOfflineFlag) | |
188 | str += " OFFLINE"; | |
189 | ||
190 | return str; | |
191 | } | |
192 | ||
61899827 | 193 | Bool_t AliTriggerAnalysis::IsTriggerFired(const AliESDEvent* aEsd, Trigger trigger) |
70fdd197 | 194 | { |
195 | // checks if an event has been triggered | |
196 | ||
197 | if (trigger & kOfflineFlag) | |
198 | return IsOfflineTriggerFired(aEsd, trigger); | |
199 | ||
200 | return IsTriggerBitFired(aEsd, trigger); | |
201 | } | |
202 | ||
203 | Bool_t AliTriggerAnalysis::IsTriggerBitFired(const AliESDEvent* aEsd, Trigger trigger) const | |
204 | { | |
205 | // checks if an event is fired using the trigger bits | |
206 | ||
207 | return IsTriggerBitFired(aEsd->GetTriggerMask(), trigger); | |
208 | } | |
209 | ||
210 | Bool_t AliTriggerAnalysis::IsTriggerBitFired(ULong64_t triggerMask, Trigger trigger) const | |
211 | { | |
212 | // checks if an event is fired using the trigger bits | |
213 | // | |
214 | // this function needs the branch TriggerMask in the ESD | |
215 | ||
216 | // definitions from p-p.cfg | |
217 | ULong64_t spdFO = (1 << 14); | |
218 | ULong64_t v0left = (1 << 10); | |
219 | ULong64_t v0right = (1 << 11); | |
220 | ||
221 | switch (trigger) | |
222 | { | |
223 | case kAcceptAll: | |
224 | { | |
225 | return kTRUE; | |
226 | break; | |
227 | } | |
228 | case kMB1: | |
229 | { | |
230 | if (triggerMask & spdFO || ((triggerMask & v0left) || (triggerMask & v0right))) | |
231 | return kTRUE; | |
232 | break; | |
233 | } | |
234 | case kMB2: | |
235 | { | |
236 | if (triggerMask & spdFO && ((triggerMask & v0left) || (triggerMask & v0right))) | |
237 | return kTRUE; | |
238 | break; | |
239 | } | |
240 | case kMB3: | |
241 | { | |
242 | if (triggerMask & spdFO && (triggerMask & v0left) && (triggerMask & v0right)) | |
243 | return kTRUE; | |
244 | break; | |
245 | } | |
246 | case kSPDGFO: | |
247 | { | |
248 | if (triggerMask & spdFO) | |
249 | return kTRUE; | |
250 | break; | |
251 | } | |
252 | default: | |
253 | Printf("IsEventTriggered: ERROR: Trigger type %d not implemented in this method", (Int_t) trigger); | |
254 | break; | |
255 | } | |
256 | ||
257 | return kFALSE; | |
258 | } | |
259 | ||
260 | Bool_t AliTriggerAnalysis::IsTriggerBitFired(const AliESDEvent* aEsd, ULong64_t tclass) const | |
261 | { | |
262 | // Checks if corresponding bit in mask is on | |
263 | ||
264 | ULong64_t trigmask = aEsd->GetTriggerMask(); | |
265 | return (trigmask & (1ull << (tclass-1))); | |
266 | } | |
267 | ||
61899827 | 268 | Bool_t AliTriggerAnalysis::IsOfflineTriggerFired(const AliESDEvent* aEsd, Trigger trigger) |
ff8c4f30 | 269 | { |
270 | // checks if an event has been triggered "offline" | |
271 | ||
70fdd197 | 272 | UInt_t triggerNoFlags = (UInt_t) trigger % (UInt_t) kStartOfFlags; |
ff8c4f30 | 273 | |
274 | switch (triggerNoFlags) | |
275 | { | |
70fdd197 | 276 | case kAcceptAll: |
ff8c4f30 | 277 | { |
278 | return kTRUE; | |
279 | break; | |
280 | } | |
70fdd197 | 281 | case kMB1: |
ff8c4f30 | 282 | { |
c01a136b | 283 | if (SPDGFOTrigger(aEsd, 0) || V0Trigger(aEsd, kASide) == kV0BB || V0Trigger(aEsd, kCSide) == kV0BB) |
ff8c4f30 | 284 | return kTRUE; |
285 | break; | |
286 | } | |
70fdd197 | 287 | case kMB2: |
ff8c4f30 | 288 | { |
c01a136b | 289 | if (SPDGFOTrigger(aEsd, 0) && (V0Trigger(aEsd, kASide) == kV0BB || V0Trigger(aEsd, kCSide) == kV0BB)) |
ff8c4f30 | 290 | return kTRUE; |
291 | break; | |
292 | } | |
70fdd197 | 293 | case kMB3: |
ff8c4f30 | 294 | { |
c01a136b | 295 | if (SPDGFOTrigger(aEsd, 0) && V0Trigger(aEsd, kASide) == kV0BB && V0Trigger(aEsd, kCSide) == kV0BB) |
ff8c4f30 | 296 | return kTRUE; |
297 | break; | |
298 | } | |
70fdd197 | 299 | case kSPDGFO: |
ff8c4f30 | 300 | { |
c2fff146 | 301 | if (SPDGFOTrigger(aEsd, 0)) |
302 | return kTRUE; | |
303 | break; | |
304 | } | |
305 | case kSPDGFOBits: | |
306 | { | |
307 | if (SPDGFOTrigger(aEsd, 1)) | |
ff8c4f30 | 308 | return kTRUE; |
309 | break; | |
310 | } | |
70fdd197 | 311 | case kV0A: |
ff8c4f30 | 312 | { |
c01a136b | 313 | if (V0Trigger(aEsd, kASide) == kV0BB) |
ff8c4f30 | 314 | return kTRUE; |
315 | break; | |
316 | } | |
70fdd197 | 317 | case kV0C: |
ff8c4f30 | 318 | { |
c01a136b | 319 | if (V0Trigger(aEsd, kCSide) == kV0BB) |
ff8c4f30 | 320 | return kTRUE; |
321 | break; | |
322 | } | |
61899827 | 323 | case kV0ABG: |
324 | { | |
325 | if (V0Trigger(aEsd, kASide) == kV0BG) | |
326 | return kTRUE; | |
327 | break; | |
328 | } | |
329 | case kV0CBG: | |
330 | { | |
331 | if (V0Trigger(aEsd, kCSide) == kV0BG) | |
332 | return kTRUE; | |
333 | break; | |
334 | } | |
70fdd197 | 335 | case kZDC: |
c8d3e441 | 336 | { |
337 | if (ZDCTrigger(aEsd, kASide) || ZDCTrigger(aEsd, kCentralBarrel) || ZDCTrigger(aEsd, kCSide)) | |
338 | return kTRUE; | |
339 | break; | |
340 | } | |
70fdd197 | 341 | case kZDCA: |
ff8c4f30 | 342 | { |
343 | if (ZDCTrigger(aEsd, kASide)) | |
344 | return kTRUE; | |
345 | break; | |
346 | } | |
70fdd197 | 347 | case kZDCC: |
ff8c4f30 | 348 | { |
349 | if (ZDCTrigger(aEsd, kCSide)) | |
350 | return kTRUE; | |
351 | break; | |
352 | } | |
70fdd197 | 353 | case kFMDA: |
7a11141c | 354 | { |
355 | if (FMDTrigger(aEsd, kASide)) | |
356 | return kTRUE; | |
357 | break; | |
358 | } | |
70fdd197 | 359 | case kFMDC: |
7a11141c | 360 | { |
361 | if (FMDTrigger(aEsd, kCSide)) | |
362 | return kTRUE; | |
363 | break; | |
364 | } | |
70fdd197 | 365 | case kFPANY: |
ff8c4f30 | 366 | { |
c01a136b | 367 | if (SPDGFOTrigger(aEsd, 0) || V0Trigger(aEsd, kASide) == kV0BB || V0Trigger(aEsd, kCSide) == kV0BB || ZDCTrigger(aEsd, kASide) || ZDCTrigger(aEsd, kCentralBarrel) || ZDCTrigger(aEsd, kCSide) || FMDTrigger(aEsd, kASide) || FMDTrigger(aEsd, kCSide)) |
ff8c4f30 | 368 | return kTRUE; |
369 | break; | |
370 | } | |
371 | default: | |
372 | { | |
373 | AliFatal(Form("Trigger type %d not implemented", triggerNoFlags)); | |
374 | } | |
375 | } | |
376 | ||
377 | return kFALSE; | |
378 | } | |
379 | ||
70fdd197 | 380 | |
381 | Bool_t AliTriggerAnalysis::IsTriggerClassFired(const AliESDEvent* aEsd, const Char_t* tclass) const | |
382 | { | |
383 | // tclass is logical function of inputs, e.g. 01 && 02 || 03 && 11 && 21 | |
384 | // = L0 inp 1 && L0 inp 2 || L0 inp 3 && L1 inp 1 && L2 inp 1 | |
385 | // NO brackets in logical function ! | |
386 | // Spaces between operators and inputs. | |
387 | // Not all logical functions are available in CTP= | |
388 | // =any function of first 4 inputs; 'AND' of other inputs, check not done | |
389 | // This method will be replaced/complemened by similar one | |
390 | // which works withh class and inputs names as in CTP cfg file | |
391 | ||
392 | TString TClass(tclass); | |
393 | TObjArray* tcltokens = TClass.Tokenize(" "); | |
394 | Char_t level=((TObjString*)tcltokens->At(0))->String()[0]; | |
395 | UInt_t input=atoi((((TObjString*)tcltokens->At(0))->String()).Remove(0)); | |
396 | Bool_t tcl = IsInputFired(aEsd,level,input); | |
397 | ||
398 | for (Int_t i=1;i<tcltokens->GetEntriesFast();i=i+2) { | |
399 | level=((TObjString*)tcltokens->At(i+1))->String()[0]; | |
400 | input=atoi((((TObjString*)tcltokens->At(i+1))->String()).Remove(0)); | |
401 | Bool_t inpnext = IsInputFired(aEsd,level,input); | |
402 | Char_t op =((TObjString*)tcltokens->At(i))->String()[0]; | |
403 | if (op == '&') tcl=tcl && inpnext; | |
404 | else if (op == '|') tcl =tcl || inpnext; | |
405 | else { | |
406 | AliError(Form("Syntax error in %s", tclass)); | |
407 | tcltokens->Delete(); | |
408 | return kFALSE; | |
409 | } | |
410 | } | |
411 | tcltokens->Delete(); | |
412 | return tcl; | |
413 | } | |
414 | ||
415 | Bool_t AliTriggerAnalysis::IsInputFired(const AliESDEvent* aEsd, Char_t level, UInt_t input) const | |
416 | { | |
417 | // Checks trigger input of any level | |
418 | ||
419 | switch (level) | |
420 | { | |
421 | case '0': return IsL0InputFired(aEsd,input); | |
422 | case '1': return IsL1InputFired(aEsd,input); | |
423 | case '2': return IsL2InputFired(aEsd,input); | |
424 | default: | |
425 | AliError(Form("Wrong level %i",level)); | |
426 | return kFALSE; | |
427 | } | |
428 | } | |
429 | ||
430 | Bool_t AliTriggerAnalysis::IsL0InputFired(const AliESDEvent* aEsd, UInt_t input) const | |
431 | { | |
432 | // Checks if corresponding bit in mask is on | |
433 | ||
434 | UInt_t inpmask = aEsd->GetHeader()->GetL0TriggerInputs(); | |
435 | return (inpmask & (1<<(input-1))); | |
436 | } | |
437 | ||
438 | Bool_t AliTriggerAnalysis::IsL1InputFired(const AliESDEvent* aEsd, UInt_t input) const | |
439 | { | |
440 | // Checks if corresponding bit in mask is on | |
441 | ||
442 | UInt_t inpmask = aEsd->GetHeader()->GetL1TriggerInputs(); | |
443 | return (inpmask & (1<<(input-1))); | |
444 | } | |
445 | ||
446 | Bool_t AliTriggerAnalysis::IsL2InputFired(const AliESDEvent* aEsd, UInt_t input) const | |
447 | { | |
448 | // Checks if corresponding bit in mask is on | |
449 | ||
450 | UInt_t inpmask = aEsd->GetHeader()->GetL2TriggerInputs(); | |
451 | return (inpmask & (1<<(input-1))); | |
452 | } | |
453 | ||
454 | void AliTriggerAnalysis::FillHistograms(const AliESDEvent* aEsd) | |
ff8c4f30 | 455 | { |
907972ff | 456 | // fills the histograms with the info from the ESD |
457 | ||
c2fff146 | 458 | fHistBitsSPD->Fill(SPDFiredChips(aEsd, 0), SPDFiredChips(aEsd, 1, kTRUE)); |
907972ff | 459 | |
c01a136b | 460 | V0Trigger(aEsd, kASide, kTRUE); |
461 | V0Trigger(aEsd, kCSide, kTRUE); | |
907972ff | 462 | |
463 | AliESDZDC* zdcData = aEsd->GetESDZDC(); | |
464 | if (zdcData) | |
465 | { | |
466 | UInt_t quality = zdcData->GetESDQuality(); | |
467 | ||
468 | // from Nora's presentation, general first physics meeting 16.10.09 | |
469 | static UInt_t zpc = 0x20; | |
470 | static UInt_t znc = 0x10; | |
471 | static UInt_t zem1 = 0x08; | |
472 | static UInt_t zem2 = 0x04; | |
473 | static UInt_t zpa = 0x02; | |
474 | static UInt_t zna = 0x01; | |
475 | ||
476 | fHistZDC->Fill(1, quality & zna); | |
477 | fHistZDC->Fill(2, quality & zpa); | |
478 | fHistZDC->Fill(3, quality & zem2); | |
479 | fHistZDC->Fill(4, quality & zem1); | |
480 | fHistZDC->Fill(5, quality & znc); | |
481 | fHistZDC->Fill(6, quality & zpc); | |
482 | } | |
483 | else | |
484 | { | |
485 | fHistZDC->Fill(-1); | |
486 | AliError("AliESDZDC not available"); | |
487 | } | |
488 | ||
489 | fHistFMDA->Fill(FMDHitCombinations(aEsd, kASide, kTRUE)); | |
490 | fHistFMDC->Fill(FMDHitCombinations(aEsd, kCSide, kTRUE)); | |
491 | } | |
c01a136b | 492 | |
493 | void AliTriggerAnalysis::FillTriggerClasses(const AliESDEvent* aEsd) | |
494 | { | |
495 | // fills trigger classes map | |
496 | ||
497 | TParameter<Long64_t>* count = dynamic_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(aEsd->GetFiredTriggerClasses().Data())); | |
498 | if (!count) | |
499 | { | |
500 | count = new TParameter<Long64_t>(aEsd->GetFiredTriggerClasses(), 0); | |
501 | fTriggerClasses->Add(new TObjString(aEsd->GetFiredTriggerClasses().Data()), count); | |
502 | } | |
503 | count->SetVal(count->GetVal() + 1); | |
504 | ||
505 | // TODO add first and last orbit number here | |
506 | } | |
907972ff | 507 | |
61899827 | 508 | Int_t AliTriggerAnalysis::SPDFiredChips(const AliESDEvent* aEsd, Int_t origin, Bool_t fillHists) |
907972ff | 509 | { |
510 | // returns the number of fired chips in the SPD | |
90dc86e9 | 511 | // |
512 | // origin = 0 --> aEsd->GetMultiplicity()->GetNumberOfFiredChips() (filled from clusters) | |
513 | // origin = 1 --> aEsd->GetMultiplicity()->TestFastOrFiredChips() (from hardware bits) | |
ff8c4f30 | 514 | |
ff8c4f30 | 515 | const AliMultiplicity* mult = aEsd->GetMultiplicity(); |
516 | if (!mult) | |
517 | { | |
518 | AliError("AliMultiplicity not available"); | |
907972ff | 519 | return -1; |
ff8c4f30 | 520 | } |
90dc86e9 | 521 | |
522 | if (origin == 0) | |
523 | return mult->GetNumberOfFiredChips(0) + mult->GetNumberOfFiredChips(1); | |
524 | ||
525 | if (origin == 1) | |
526 | { | |
527 | Int_t nChips = 0; | |
528 | for (Int_t i=0; i<1200; i++) | |
529 | if (mult->TestFastOrFiredChips(i) == kTRUE) | |
c2fff146 | 530 | { |
90dc86e9 | 531 | nChips++; |
61899827 | 532 | if (fillHists) |
c2fff146 | 533 | fHistFiredBitsSPD->Fill(i); |
534 | } | |
90dc86e9 | 535 | return nChips; |
536 | } | |
537 | ||
538 | return -1; | |
907972ff | 539 | } |
540 | ||
61899827 | 541 | Bool_t AliTriggerAnalysis::SPDGFOTrigger(const AliESDEvent* aEsd, Int_t origin) |
907972ff | 542 | { |
543 | // Returns if the SPD gave a global Fast OR trigger | |
544 | ||
c2fff146 | 545 | Int_t firedChips = SPDFiredChips(aEsd, origin); |
ff8c4f30 | 546 | |
547 | if (firedChips >= fSPDGFOThreshold) | |
548 | return kTRUE; | |
549 | return kFALSE; | |
550 | } | |
551 | ||
61899827 | 552 | AliTriggerAnalysis::V0Decision AliTriggerAnalysis::V0Trigger(const AliESDEvent* aEsd, AliceSide side, Bool_t fillHists) |
ff8c4f30 | 553 | { |
c01a136b | 554 | // Returns the V0 trigger decision in V0A | V0C |
555 | // | |
556 | // Based on algorithm by Cvetan Cheshkov | |
ff8c4f30 | 557 | |
c01a136b | 558 | AliESDVZERO* esdV0 = aEsd->GetVZEROData(); |
559 | if (!esdV0) | |
ff8c4f30 | 560 | { |
561 | AliError("AliESDVZERO not available"); | |
c01a136b | 562 | return kV0Invalid; |
ff8c4f30 | 563 | } |
564 | ||
c01a136b | 565 | Int_t begin = -1; |
566 | Int_t end = -1; | |
567 | ||
568 | if (side == kASide) | |
ff8c4f30 | 569 | { |
c01a136b | 570 | begin = 32; |
571 | end = 64; | |
572 | } | |
573 | else if (side == kCSide) | |
574 | { | |
575 | begin = 0; | |
576 | end = 32; | |
ff8c4f30 | 577 | } |
c01a136b | 578 | else |
579 | return kV0Invalid; | |
ff8c4f30 | 580 | |
c01a136b | 581 | Float_t time = 0; |
582 | Int_t ntime = 0; | |
583 | for (Int_t i = begin; i < end; ++i) { | |
61899827 | 584 | if (esdV0->GetTime(i) > 1e-6 && esdV0->GetAdc(i) > 6.0) { |
c01a136b | 585 | Float_t correctedTime = V0CorrectLeadingTime(i, esdV0->GetTime(i), esdV0->GetAdc(i)); |
586 | ||
587 | time += correctedTime; | |
61899827 | 588 | time += fV0TimeOffset; |
589 | ||
c01a136b | 590 | ntime++; |
591 | } | |
592 | } | |
907972ff | 593 | |
c01a136b | 594 | if (ntime > 0) |
595 | time /= ntime; | |
596 | ||
597 | if (fillHists) | |
598 | { | |
599 | if (side == kASide && fHistV0A) | |
600 | fHistV0A->Fill(time); | |
601 | if (side == kCSide && fHistV0C) | |
602 | fHistV0C->Fill(time); | |
603 | } | |
907972ff | 604 | |
c01a136b | 605 | if (side == kASide) |
606 | { | |
607 | if (time > 48 && time < 62) | |
608 | return kV0BB; | |
609 | if (time > 26 && time < 33) | |
610 | return kV0BG; | |
611 | } | |
907972ff | 612 | |
c01a136b | 613 | if (side == kCSide) |
614 | { | |
615 | if (time > 49 && time < 60) | |
616 | return kV0BB; | |
617 | if (time > 43 && time < 48.5) | |
618 | return kV0BG; | |
619 | } | |
620 | ||
621 | return kV0Empty; | |
622 | } | |
623 | ||
624 | Float_t AliTriggerAnalysis::V0CorrectLeadingTime(Int_t i, Float_t time, Float_t adc) const | |
625 | { | |
626 | // Correct for slewing and align the channels | |
627 | // | |
628 | // Author: Cvetan Cheshkov | |
629 | ||
630 | if (time == 0) return 0; | |
631 | ||
632 | // Time offsets between channels | |
633 | Float_t timeShift[64] = {30.2914 , 30.0019 , 30.7429 , 30.1997 , 30.1511 , 29.6437 , 30.0609 , 29.5452 , 30.1437 , 30.745 , 30.7537 , 30.446 , 30.2771 , 30.838 , 30.3748 , 30.0635 , 30.1786 , 30.282 , 31.0992 , 30.7491 , 30.624 , 30.9268 , 30.6585 , 30.4895 , 31.5815 , 31.3871 , 31.2032 , 31.5778 , 31.0838 , 31.2259 , 31.2122 , 31.5989 , 28.3792 , 28.8325 , 27.8719 , 28.3475 , 26.9925 , 27.9300 , 28.4223 , 28.4996 , 28.2934 , 28.1281 , 27.209 , 28.5327 , 28.1181 , 28.0888 , 29.5111 , 28.6601 , 29.7705 , 29.6531 , 30.3373 , 30.2345 , 30.5935 , 29.8164 , 30.2235 , 29.6505 , 30.1225 , 31.2045 , 30.8399 , 30.6789 , 30.2784 , 31.7028 , 31.4239 , 30.1814}; | |
634 | time -= timeShift[i]; | |
635 | ||
636 | // Slewing correction | |
637 | if (adc == 0) return time; | |
638 | ||
639 | time += 30.; | |
640 | if (adc > 300.) adc = 300.; | |
641 | if (adc > 70.) { | |
642 | return (time - | |
643 | 2.93028e+01 + | |
644 | adc*1.25188e-02 - | |
645 | adc*adc*2.68348e-05); | |
646 | } | |
647 | else { | |
648 | return (time - | |
649 | 3.52314e+01 + | |
650 | adc*5.99289e-01 - | |
651 | adc*adc*2.74668e-02 + | |
652 | adc*adc*adc*6.61224e-04 - | |
653 | adc*adc*adc*adc*7.77105e-06 + | |
654 | adc*adc*adc*adc*adc*3.51229e-08); | |
655 | } | |
ff8c4f30 | 656 | } |
657 | ||
70fdd197 | 658 | Bool_t AliTriggerAnalysis::ZDCTrigger(const AliESDEvent* aEsd, AliceSide side) const |
ff8c4f30 | 659 | { |
660 | // Returns if ZDC triggered | |
661 | ||
c8d3e441 | 662 | AliESDZDC* zdcData = aEsd->GetESDZDC(); |
663 | if (!zdcData) | |
664 | { | |
665 | AliError("AliESDZDC not available"); | |
666 | return kFALSE; | |
667 | } | |
668 | ||
669 | UInt_t quality = zdcData->GetESDQuality(); | |
670 | ||
671 | // from Nora's presentation, general first physics meeting 16.10.09 | |
672 | static UInt_t zpc = 0x20; | |
673 | static UInt_t znc = 0x10; | |
674 | static UInt_t zem1 = 0x08; | |
675 | static UInt_t zem2 = 0x04; | |
676 | static UInt_t zpa = 0x02; | |
677 | static UInt_t zna = 0x01; | |
678 | ||
679 | if (side == kASide && ((quality & zpa) || (quality & zna))) | |
680 | return kTRUE; | |
681 | if (side == kCentralBarrel && ((quality & zem1) || (quality & zem2))) | |
682 | return kTRUE; | |
683 | if (side == kCSide && ((quality & zpc) || (quality & znc))) | |
684 | return kTRUE; | |
ff8c4f30 | 685 | |
686 | return kFALSE; | |
687 | } | |
688 | ||
61899827 | 689 | Int_t AliTriggerAnalysis::FMDHitCombinations(const AliESDEvent* aEsd, AliceSide side, Bool_t fillHists) |
ff8c4f30 | 690 | { |
907972ff | 691 | // returns number of hit combinations agove threshold |
7a11141c | 692 | // |
693 | // Authors: FMD team, Hans Dalsgaard (code merged from FMD/AliFMDOfflineTrigger) | |
ff8c4f30 | 694 | |
7a11141c | 695 | // Workaround for AliESDEvent::GetFMDData is not const! |
696 | const AliESDFMD* fmdData = (const_cast<AliESDEvent*>(aEsd))->GetFMDData(); | |
697 | if (!fmdData) | |
698 | { | |
699 | AliError("AliESDFMD not available"); | |
907972ff | 700 | return -1; |
7a11141c | 701 | } |
702 | ||
703 | Int_t detFrom = (side == kASide) ? 1 : 3; | |
704 | Int_t detTo = (side == kASide) ? 2 : 3; | |
705 | ||
907972ff | 706 | Int_t triggers = 0; |
7a11141c | 707 | Float_t totalMult = 0; |
708 | for (UShort_t det=detFrom;det<=detTo;det++) { | |
709 | Int_t nRings = (det == 1 ? 1 : 2); | |
710 | for (UShort_t ir = 0; ir < nRings; ir++) { | |
711 | Char_t ring = (ir == 0 ? 'I' : 'O'); | |
712 | UShort_t nsec = (ir == 0 ? 20 : 40); | |
713 | UShort_t nstr = (ir == 0 ? 512 : 256); | |
039db886 | 714 | for (UShort_t sec =0; sec < nsec; sec++) { |
715 | for (UShort_t strip = 0; strip < nstr; strip++) { | |
716 | Float_t mult = fmdData->Multiplicity(det,ring,sec,strip); | |
717 | if (mult == AliESDFMD::kInvalidMult) continue; | |
718 | ||
61899827 | 719 | if (fillHists) |
907972ff | 720 | fHistFMDSingle->Fill(mult); |
721 | ||
039db886 | 722 | if (mult > fFMDLowCut) |
723 | totalMult = totalMult + mult; | |
724 | else | |
907972ff | 725 | { |
726 | if (totalMult > fFMDHitCut) | |
727 | triggers++; | |
728 | ||
61899827 | 729 | if (fillHists) |
907972ff | 730 | fHistFMDSum->Fill(totalMult); |
731 | ||
732 | totalMult = 0; | |
733 | } | |
039db886 | 734 | } |
7a11141c | 735 | } |
736 | } | |
737 | } | |
907972ff | 738 | |
739 | return triggers; | |
740 | } | |
741 | ||
61899827 | 742 | Bool_t AliTriggerAnalysis::FMDTrigger(const AliESDEvent* aEsd, AliceSide side) |
907972ff | 743 | { |
744 | // Returns if the FMD triggered | |
745 | // | |
746 | // Authors: FMD team, Hans Dalsgaard (code merged from FMD/AliFMDOfflineTrigger) | |
747 | ||
748 | Int_t triggers = FMDHitCombinations(aEsd, side, kFALSE); | |
749 | ||
750 | if (triggers > 0) | |
751 | return kTRUE; | |
752 | ||
ff8c4f30 | 753 | return kFALSE; |
754 | } | |
907972ff | 755 | |
70fdd197 | 756 | Long64_t AliTriggerAnalysis::Merge(TCollection* list) |
907972ff | 757 | { |
758 | // Merge a list of AliMultiplicityCorrection objects with this (needed for | |
759 | // PROOF). | |
760 | // Returns the number of merged objects (including this). | |
761 | ||
762 | if (!list) | |
763 | return 0; | |
764 | ||
765 | if (list->IsEmpty()) | |
766 | return 1; | |
767 | ||
768 | TIterator* iter = list->MakeIterator(); | |
769 | TObject* obj; | |
770 | ||
771 | // collections of all histograms | |
c01a136b | 772 | const Int_t nHists = 9; |
907972ff | 773 | TList collections[nHists]; |
774 | ||
775 | Int_t count = 0; | |
776 | while ((obj = iter->Next())) { | |
777 | ||
70fdd197 | 778 | AliTriggerAnalysis* entry = dynamic_cast<AliTriggerAnalysis*> (obj); |
907972ff | 779 | if (entry == 0) |
780 | continue; | |
781 | ||
c01a136b | 782 | Int_t n = 0; |
783 | collections[n++].Add(entry->fHistV0A); | |
784 | collections[n++].Add(entry->fHistV0C); | |
785 | collections[n++].Add(entry->fHistZDC); | |
786 | collections[n++].Add(entry->fHistFMDA); | |
787 | collections[n++].Add(entry->fHistFMDC); | |
788 | collections[n++].Add(entry->fHistFMDSingle); | |
789 | collections[n++].Add(entry->fHistFMDSum); | |
790 | collections[n++].Add(entry->fHistBitsSPD); | |
791 | collections[n++].Add(entry->fHistFiredBitsSPD); | |
792 | ||
793 | // merge fTriggerClasses | |
794 | TIterator* iter2 = entry->fTriggerClasses->MakeIterator(); | |
795 | TObjString* obj = 0; | |
796 | while ((obj = dynamic_cast<TObjString*> (iter2->Next()))) | |
797 | { | |
798 | TParameter<Long64_t>* param2 = dynamic_cast<TParameter<Long64_t>*> (entry->fTriggerClasses->GetValue(obj)); | |
799 | ||
800 | TParameter<Long64_t>* param1 = dynamic_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(obj)); | |
801 | if (param1) | |
802 | { | |
803 | param1->SetVal(param1->GetVal() + param2->GetVal()); | |
804 | } | |
805 | else | |
806 | { | |
807 | param1 = dynamic_cast<TParameter<Long64_t>*> (param2->Clone()); | |
808 | fTriggerClasses->Add(new TObjString(obj->String()), param1); | |
809 | } | |
810 | } | |
811 | ||
812 | delete iter2; | |
813 | ||
907972ff | 814 | count++; |
815 | } | |
816 | ||
c01a136b | 817 | Int_t n = 0; |
818 | fHistV0A->Merge(&collections[n++]); | |
819 | fHistV0C->Merge(&collections[n++]); | |
820 | fHistZDC->Merge(&collections[n++]); | |
821 | fHistFMDA->Merge(&collections[n++]); | |
822 | fHistFMDC->Merge(&collections[n++]); | |
823 | fHistFMDSingle->Merge(&collections[n++]); | |
824 | fHistFMDSum->Merge(&collections[n++]); | |
825 | fHistBitsSPD->Merge(&collections[n++]); | |
826 | fHistFiredBitsSPD->Merge(&collections[n++]); | |
827 | ||
907972ff | 828 | delete iter; |
829 | ||
830 | return count+1; | |
831 | } | |
832 | ||
61899827 | 833 | void AliTriggerAnalysis::SaveHistograms() const |
907972ff | 834 | { |
835 | // write histograms to current directory | |
836 | ||
c01a136b | 837 | if (!fHistBitsSPD) |
907972ff | 838 | return; |
839 | ||
90dc86e9 | 840 | fHistBitsSPD->Write(); |
61899827 | 841 | fHistBitsSPD->ProjectionX(); |
842 | fHistBitsSPD->ProjectionY(); | |
c2fff146 | 843 | fHistFiredBitsSPD->Write(); |
907972ff | 844 | fHistV0A->Write(); |
845 | fHistV0C->Write(); | |
846 | fHistZDC->Write(); | |
847 | fHistFMDA->Write(); | |
848 | fHistFMDC->Write(); | |
849 | fHistFMDSingle->Write(); | |
850 | fHistFMDSum->Write(); | |
c01a136b | 851 | |
852 | fTriggerClasses->Write("fTriggerClasses", TObject::kSingleKey); | |
853 | } | |
854 | ||
855 | void AliTriggerAnalysis::PrintTriggerClasses() const | |
856 | { | |
857 | // print trigger classes | |
858 | ||
859 | Printf("Trigger Classes:"); | |
860 | ||
861 | TIterator* iter = fTriggerClasses->MakeIterator(); | |
862 | TObjString* obj = 0; | |
863 | while ((obj = dynamic_cast<TObjString*> (iter->Next()))) | |
864 | { | |
865 | TParameter<Long64_t>* param = dynamic_cast<TParameter<Long64_t>*> (fTriggerClasses->GetValue(obj)); | |
866 | ||
867 | Printf("%s: %ld triggers", obj->String().Data(), param->GetVal()); | |
868 | } | |
907972ff | 869 | } |