]>
Commit | Line | Data |
---|---|---|
d5ebf00e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | //------------------------------------------------------------------------- | |
17 | // Implementation of Class AliESDHeader | |
18 | // Header data | |
19 | // for the ESD | |
20 | // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch | |
21 | //------------------------------------------------------------------------- | |
22 | ||
23 | #include "AliESDHeader.h" | |
bf1f98c4 | 24 | #include "AliTriggerScalersESD.h" |
25 | #include "AliTriggerScalersRecordESD.h" | |
8258ca76 | 26 | #include "AliTriggerIR.h" |
5aef203e | 27 | #include "AliTriggerConfiguration.h" |
b7b66e38 | 28 | #include "AliLog.h" |
d5ebf00e | 29 | |
30 | ClassImp(AliESDHeader) | |
31 | ||
32 | //______________________________________________________________________________ | |
33 | AliESDHeader::AliESDHeader() : | |
9ae2e5e6 | 34 | AliVHeader(), |
d5ebf00e | 35 | fTriggerMask(0), |
da3314d6 | 36 | fTriggerMaskNext50(0), |
d5ebf00e | 37 | fOrbitNumber(0), |
38 | fTimeStamp(0), | |
39 | fEventType(0), | |
fd2e2210 | 40 | fEventSpecie(0), |
4f036e6e | 41 | fPeriodNumber(0), |
d5ebf00e | 42 | fEventNumberInFile(0), |
43 | fBunchCrossNumber(0), | |
53eef471 | 44 | fTriggerCluster(0), |
45 | fL0TriggerInputs(0), | |
46 | fL1TriggerInputs(0), | |
bf1f98c4 | 47 | fL2TriggerInputs(0), |
6ef9caeb | 48 | fTriggerScalers(), |
d789992f | 49 | fTriggerScalersDeltaEvent(), |
50 | fTriggerScalersDeltaRun(), | |
51 | fTriggerInputsNames(kNTriggerInputs), | |
96bf4ffc | 52 | fCTPConfig(NULL), |
4ccebdba | 53 | fIRBufferArray(), |
54 | fIRInt2InteractionsMap(0), | |
55 | fIRInt1InteractionsMap(0) | |
d5ebf00e | 56 | { |
9ae2e5e6 | 57 | // default constructor |
58 | ||
59 | SetName("AliESDHeader"); | |
c47cda51 | 60 | for(Int_t i = 0; i<kNMaxIR ; i++) fIRArray[i] = 0; |
6ef9caeb | 61 | fTriggerInputsNames.SetOwner(kTRUE); |
9ae2e5e6 | 62 | } |
d789992f | 63 | |
9ae2e5e6 | 64 | AliESDHeader::~AliESDHeader() |
65 | { | |
66 | // destructor | |
c47cda51 | 67 | for(Int_t i=0;i<kNMaxIR;i++)if(fIRArray[i])delete fIRArray[i]; |
d789992f | 68 | delete fCTPConfig; |
96bf4ffc | 69 | |
70 | fIRBufferArray.Delete(); | |
d5ebf00e | 71 | } |
72 | ||
73 | ||
74 | AliESDHeader::AliESDHeader(const AliESDHeader &header) : | |
9ae2e5e6 | 75 | AliVHeader(header), |
d5ebf00e | 76 | fTriggerMask(header.fTriggerMask), |
da3314d6 | 77 | fTriggerMaskNext50(header.fTriggerMaskNext50), |
d5ebf00e | 78 | fOrbitNumber(header.fOrbitNumber), |
79 | fTimeStamp(header.fTimeStamp), | |
80 | fEventType(header.fEventType), | |
fd2e2210 | 81 | fEventSpecie(header.fEventSpecie), |
4f036e6e | 82 | fPeriodNumber(header.fPeriodNumber), |
d5ebf00e | 83 | fEventNumberInFile(header.fEventNumberInFile), |
84 | fBunchCrossNumber(header.fBunchCrossNumber), | |
53eef471 | 85 | fTriggerCluster(header.fTriggerCluster), |
86 | fL0TriggerInputs(header.fL0TriggerInputs), | |
87 | fL1TriggerInputs(header.fL1TriggerInputs), | |
bf1f98c4 | 88 | fL2TriggerInputs(header.fL2TriggerInputs), |
6ef9caeb | 89 | fTriggerScalers(header.fTriggerScalers), |
d789992f | 90 | fTriggerScalersDeltaEvent(header.fTriggerScalersDeltaEvent), |
91 | fTriggerScalersDeltaRun(header.fTriggerScalersDeltaRun), | |
92 | fTriggerInputsNames(TObjArray(kNTriggerInputs)), | |
96bf4ffc | 93 | fCTPConfig(header.fCTPConfig), |
4ccebdba | 94 | fIRBufferArray(), |
95 | fIRInt2InteractionsMap(header.fIRInt2InteractionsMap), | |
96 | fIRInt1InteractionsMap(header.fIRInt1InteractionsMap) | |
d5ebf00e | 97 | { |
98 | // copy constructor | |
c47cda51 | 99 | for(Int_t i = 0; i<kNMaxIR ; i++) { |
100 | if(header.fIRArray[i])fIRArray[i] = new AliTriggerIR(*header.fIRArray[i]); | |
101 | else fIRArray[i]=0; | |
102 | } | |
6ef9caeb | 103 | for(Int_t i = 0; i < kNTriggerInputs; i++) { |
104 | TNamed *str = (TNamed *)((header.fTriggerInputsNames).At(i)); | |
105 | if (str) fTriggerInputsNames.AddAt(new TNamed(*str),i); | |
106 | } | |
96bf4ffc | 107 | |
108 | for(Int_t i = 0; i < (header.fIRBufferArray).GetEntries(); ++i) { | |
109 | AliTriggerIR *ir = (AliTriggerIR*)((header.fIRBufferArray).At(i)); | |
110 | if (ir) fIRBufferArray.Add(new AliTriggerIR(*ir)); | |
111 | } | |
d5ebf00e | 112 | } |
113 | ||
114 | AliESDHeader& AliESDHeader::operator=(const AliESDHeader &header) | |
115 | { | |
116 | // assigment operator | |
117 | if(this!=&header) { | |
9ae2e5e6 | 118 | AliVHeader::operator=(header); |
d5ebf00e | 119 | fTriggerMask = header.fTriggerMask; |
da3314d6 | 120 | fTriggerMaskNext50 = header.fTriggerMaskNext50; |
d5ebf00e | 121 | fOrbitNumber = header.fOrbitNumber; |
122 | fTimeStamp = header.fTimeStamp; | |
123 | fEventType = header.fEventType; | |
fd2e2210 | 124 | fEventSpecie = header.fEventSpecie; |
4f036e6e | 125 | fPeriodNumber = header.fPeriodNumber; |
d5ebf00e | 126 | fEventNumberInFile = header.fEventNumberInFile; |
127 | fBunchCrossNumber = header.fBunchCrossNumber; | |
128 | fTriggerCluster = header.fTriggerCluster; | |
53eef471 | 129 | fL0TriggerInputs = header.fL0TriggerInputs; |
130 | fL1TriggerInputs = header.fL1TriggerInputs; | |
131 | fL2TriggerInputs = header.fL2TriggerInputs; | |
bf1f98c4 | 132 | fTriggerScalers = header.fTriggerScalers; |
d789992f | 133 | fTriggerScalersDeltaEvent = header.fTriggerScalersDeltaEvent; |
134 | fTriggerScalersDeltaRun = header.fTriggerScalersDeltaRun; | |
4ccebdba | 135 | fIRInt2InteractionsMap = header.fIRInt2InteractionsMap; |
136 | fIRInt1InteractionsMap = header.fIRInt1InteractionsMap; | |
137 | ||
481acdb5 | 138 | delete fCTPConfig; |
d789992f | 139 | fCTPConfig = header.fCTPConfig; |
140 | ||
6ef9caeb | 141 | fTriggerInputsNames.Clear(); |
142 | for(Int_t i = 0; i < kNTriggerInputs; i++) { | |
143 | TNamed *str = (TNamed *)((header.fTriggerInputsNames).At(i)); | |
144 | if (str) fTriggerInputsNames.AddAt(new TNamed(*str),i); | |
145 | } | |
c47cda51 | 146 | for(Int_t i = 0; i<kNMaxIR ; i++) { |
481acdb5 | 147 | delete fIRArray[i]; |
c47cda51 | 148 | if(header.fIRArray[i])fIRArray[i] = new AliTriggerIR(*header.fIRArray[i]); |
149 | else fIRArray[i]=0; | |
150 | } | |
96bf4ffc | 151 | |
152 | fIRBufferArray.Delete(); | |
153 | for(Int_t i = 0; i < (header.fIRBufferArray).GetEntries(); ++i) { | |
154 | AliTriggerIR *ir = (AliTriggerIR*)((header.fIRBufferArray).At(i)); | |
155 | if (ir) fIRBufferArray.Add(new AliTriggerIR(*ir)); | |
156 | } | |
d789992f | 157 | } |
d5ebf00e | 158 | return *this; |
159 | } | |
160 | ||
bf1f98c4 | 161 | void AliESDHeader::Copy(TObject &obj) const |
162 | { | |
732a24fe | 163 | // this overwrites the virtual TOBject::Copy() |
164 | // to allow run time copying without casting | |
165 | // in AliESDEvent | |
166 | ||
167 | if(this==&obj)return; | |
168 | AliESDHeader *robj = dynamic_cast<AliESDHeader*>(&obj); | |
169 | if(!robj)return; // not an AliESDHeader | |
170 | *robj = *this; | |
171 | ||
172 | } | |
d5ebf00e | 173 | //______________________________________________________________________________ |
174 | void AliESDHeader::Reset() | |
175 | { | |
176 | // reset all data members | |
177 | fTriggerMask = 0; | |
da3314d6 | 178 | fTriggerMaskNext50 = 0; |
d5ebf00e | 179 | fOrbitNumber = 0; |
180 | fTimeStamp = 0; | |
181 | fEventType = 0; | |
fd2e2210 | 182 | fEventSpecie = 0; |
4f036e6e | 183 | fPeriodNumber = 0; |
d5ebf00e | 184 | fEventNumberInFile = 0; |
185 | fBunchCrossNumber = 0; | |
186 | fTriggerCluster = 0; | |
53eef471 | 187 | fL0TriggerInputs = 0; |
188 | fL1TriggerInputs = 0; | |
189 | fL2TriggerInputs = 0; | |
bf1f98c4 | 190 | fTriggerScalers.Reset(); |
d789992f | 191 | fTriggerScalersDeltaEvent.Reset(); |
192 | fTriggerScalersDeltaRun.Reset(); | |
6ef9caeb | 193 | fTriggerInputsNames.Clear(); |
4ccebdba | 194 | |
195 | fIRInt2InteractionsMap.ResetAllBits(); | |
196 | fIRInt1InteractionsMap.ResetAllBits(); | |
197 | ||
d789992f | 198 | delete fCTPConfig; |
199 | fCTPConfig = 0; | |
c47cda51 | 200 | for(Int_t i=0;i<kNMaxIR;i++)if(fIRArray[i]){ |
201 | delete fIRArray[i]; | |
202 | fIRArray[i]=0; | |
203 | } | |
96bf4ffc | 204 | |
205 | fIRBufferArray.Delete(); | |
d5ebf00e | 206 | } |
76a7c65b | 207 | //______________________________________________________________________________ |
c47cda51 | 208 | Bool_t AliESDHeader::AddTriggerIR(const AliTriggerIR* ir) |
76a7c65b | 209 | { |
96bf4ffc | 210 | // Add an IR object into the array |
211 | // of IRs in the ESD header | |
212 | ||
213 | fIRBufferArray.Add(new AliTriggerIR(*ir)); | |
214 | ||
215 | return kTRUE; | |
76a7c65b | 216 | } |
d5ebf00e | 217 | //______________________________________________________________________________ |
218 | void AliESDHeader::Print(const Option_t *) const | |
219 | { | |
220 | // Print some data members | |
35a702f0 | 221 | printf("Event # %d in file Bunch crossing # %d Orbit # %d Trigger %lld %lld\n", |
d5ebf00e | 222 | GetEventNumberInFile(), |
223 | GetBunchCrossNumber(), | |
224 | GetOrbitNumber(), | |
35a702f0 | 225 | GetTriggerMask(), |
226 | GetTriggerMaskNext50()); | |
6ef9caeb | 227 | printf("List of the active trigger inputs: "); |
228 | for(Int_t i = 0; i < kNTriggerInputs; i++) { | |
229 | TNamed *str = (TNamed *)((fTriggerInputsNames).At(i)); | |
4cbef9fb | 230 | if (str) printf("%i %s ",i,str->GetName()); |
6ef9caeb | 231 | } |
232 | printf("\n"); | |
233 | } | |
234 | ||
6ef9caeb | 235 | //______________________________________________________________________________ |
236 | void AliESDHeader::SetActiveTriggerInputs(const char*name, Int_t index) | |
237 | { | |
238 | // Fill the active trigger inputs names | |
239 | // into the corresponding fTriggerInputsNames (TObjArray of TNamed) | |
240 | if (index >= kNTriggerInputs || index < 0) { | |
241 | AliError(Form("Index (%d) is outside the allowed range (0,59)!",index)); | |
242 | return; | |
243 | } | |
244 | ||
245 | fTriggerInputsNames.AddAt(new TNamed(name,NULL),index); | |
246 | } | |
247 | //______________________________________________________________________________ | |
248 | const char* AliESDHeader::GetTriggerInputName(Int_t index, Int_t trglevel) const | |
249 | { | |
250 | // Get the trigger input name | |
251 | // at the specified position in the trigger mask and trigger level (0,1,2) | |
252 | TNamed *trginput = 0; | |
253 | if (trglevel == 0) trginput = (TNamed *)fTriggerInputsNames.At(index); | |
254 | if (trglevel == 1) trginput = (TNamed *)fTriggerInputsNames.At(index+24); | |
255 | if (trglevel == 2) trginput = (TNamed *)fTriggerInputsNames.At(index+48); | |
256 | if (trginput) return trginput->GetName(); | |
257 | else return ""; | |
d5ebf00e | 258 | } |
6ef9caeb | 259 | //______________________________________________________________________________ |
260 | TString AliESDHeader::GetActiveTriggerInputs() const | |
261 | { | |
262 | // Returns the list with the names of the active trigger inputs | |
263 | TString trginputs; | |
264 | for(Int_t i = 0; i < kNTriggerInputs; i++) { | |
265 | TNamed *str = (TNamed *)((fTriggerInputsNames).At(i)); | |
266 | if (str) { | |
267 | trginputs += " "; | |
268 | trginputs += str->GetName(); | |
269 | trginputs += " "; | |
270 | } | |
271 | } | |
272 | ||
273 | return trginputs; | |
274 | } | |
275 | //______________________________________________________________________________ | |
276 | TString AliESDHeader::GetFiredTriggerInputs() const | |
277 | { | |
278 | // Returns the list with the names of the fired trigger inputs | |
279 | TString trginputs; | |
280 | for(Int_t i = 0; i < kNTriggerInputs; i++) { | |
281 | TNamed *str = (TNamed *)((fTriggerInputsNames.At(i))); | |
797592ea | 282 | if (i < 24 && (fL0TriggerInputs & (1ul << i))) { |
6ef9caeb | 283 | if (str) { |
284 | trginputs += " "; | |
285 | trginputs += str->GetName(); | |
286 | trginputs += " "; | |
287 | } | |
288 | } | |
797592ea | 289 | if (i >= 24 && i < 48 && (fL1TriggerInputs & (1ul << (i-24)))) { |
6ef9caeb | 290 | if (str) { |
291 | trginputs += " "; | |
292 | trginputs += str->GetName(); | |
293 | trginputs += " "; | |
294 | } | |
295 | } | |
797592ea | 296 | if (i >= 48 && (fL2TriggerInputs & (1u << (i-48)))) { |
6ef9caeb | 297 | if (str) { |
298 | trginputs += " "; | |
299 | trginputs += str->GetName(); | |
300 | trginputs += " "; | |
301 | } | |
302 | } | |
d5ebf00e | 303 | |
6ef9caeb | 304 | } |
305 | return trginputs; | |
306 | } | |
307 | //______________________________________________________________________________ | |
308 | Bool_t AliESDHeader::IsTriggerInputFired(const char *name) const | |
309 | { | |
310 | // Checks if the trigger input is fired | |
311 | ||
312 | TNamed *trginput = (TNamed *)fTriggerInputsNames.FindObject(name); | |
313 | if (!trginput) return kFALSE; | |
314 | ||
315 | Int_t inputIndex = fTriggerInputsNames.IndexOf(trginput); | |
316 | if (inputIndex < 0) return kFALSE; | |
317 | ||
797592ea | 318 | if (fL0TriggerInputs & (1lu << inputIndex)) return kTRUE; |
319 | else if (fL1TriggerInputs & (1lu << (inputIndex-24))) return kTRUE; | |
320 | else if (fL2TriggerInputs & (1u << (inputIndex-48))) return kTRUE; | |
6ef9caeb | 321 | else return kFALSE; |
322 | } | |
d01710c6 | 323 | //________________________________________________________________________________ |
324 | Int_t AliESDHeader::GetTriggerIREntries(Int_t int1, Int_t int2, Float_t deltaTime) const | |
325 | { | |
326 | // returns number of IR-s within time window deltaTime | |
327 | // all possible combinations of int1 and int2 int1 - zdc bit, int2 v0 bit | |
328 | // | |
329 | const AliTriggerIR *IR; | |
330 | // triggered event | |
331 | Int_t nIR = GetTriggerIREntries(); | |
332 | UInt_t orbit1 = GetOrbitNumber(); | |
333 | const Double_t ot=0.0889218; //orbit time msec | |
334 | Float_t timediff; // time difference between orbits (msec) | |
335 | // | |
336 | Int_t nofIR; | |
337 | nofIR=0; | |
338 | // loop over IR-s | |
339 | for(Int_t i=0;i<nIR;i++){//1 | |
340 | IR=GetTriggerIR(i); | |
341 | // | |
342 | UInt_t orbit2 = IR->GetOrbit(); | |
343 | timediff = (orbit2<=orbit1) ? (Float_t)((orbit1-orbit2))*ot : | |
344 | (Float_t)((16777215-orbit1+orbit2))*ot; | |
345 | if (timediff>deltaTime) continue; //timediff outside time window | |
346 | if((int1&int2) == -1){ //ignore both bits, just count IR-s within time window | |
347 | nofIR++; | |
348 | continue; | |
349 | } | |
350 | // now check if int1, int2 bits are set | |
351 | UInt_t nw = IR->GetNWord(); | |
352 | Bool_t *bint1 = IR->GetInt1s(); | |
353 | Bool_t *bint2 = IR->GetInt2s(); | |
354 | // | |
355 | Int_t flag1,flag2; | |
356 | flag1=0; | |
357 | flag2=0; | |
358 | for(UInt_t j=0;j<nw;j++){//2 | |
359 | if(bint1[j]) flag1=1; // at least one int1 set | |
360 | if(bint2[j]) flag2=1; // at least one int2 set | |
361 | //printf("IR %d, bint1 %d, bint2 %d\n",i,bint1[j],bint2[j]); | |
362 | }//2 | |
363 | // checking combinations | |
364 | // | |
365 | ||
366 | if((flag1*int1*flag2*int2)==1){// int1=1 & int2=1 | |
367 | nofIR++; | |
368 | continue; | |
369 | } | |
370 | if(int1 == -1){// ignore int1 | |
371 | if(flag2&int2){// int2=1 | |
372 | nofIR++; | |
373 | continue; | |
374 | } | |
375 | else if (!flag2&!int2){ //int2=0 | |
376 | nofIR++; | |
377 | continue; | |
378 | } | |
379 | } | |
380 | ||
381 | if(int2 ==-1){//ignore int2 | |
382 | if(flag1&int1){//int1=1 | |
383 | nofIR++; | |
384 | continue; | |
385 | } | |
386 | else if(!flag1&!int1){ //int1=0 | |
387 | nofIR++; | |
388 | continue; | |
389 | } | |
390 | } | |
391 | ||
392 | if((flag1*int1)&!flag2&!int2){// int1=1, int2=0 | |
393 | nofIR++; | |
394 | continue; | |
395 | } | |
396 | ||
397 | if((int2*flag2)&!int1&!flag1){// int1=0, int2=1 | |
398 | nofIR++; | |
399 | continue; | |
400 | } | |
401 | ||
402 | ||
403 | ||
404 | }//1 | |
405 | ||
406 | return nofIR; | |
407 | } | |
408 | //__________________________________________________________________________ | |
409 | TObjArray AliESDHeader::GetIRArray(Int_t int1, Int_t int2, Float_t deltaTime) const | |
410 | { | |
411 | // | |
412 | // returns an array of IR-s within time window deltaTime | |
413 | // all possible combinations of int1 and int2 int1 - zdc bit, int2 v0 bit | |
414 | // | |
415 | const AliTriggerIR *IR; | |
416 | TObjArray arr; | |
417 | // triggered event | |
418 | Int_t nIR = GetTriggerIREntries(); | |
419 | UInt_t orbit1 = GetOrbitNumber(); | |
420 | const Double_t ot=0.0889218; //orbit time msec | |
421 | Float_t timediff; // time difference between orbits (msec) | |
422 | // | |
423 | // loop over IR-s | |
424 | for(Int_t i=0;i<nIR;i++){//1 | |
425 | IR=GetTriggerIR(i); | |
426 | // | |
427 | UInt_t orbit2 = IR->GetOrbit(); | |
428 | timediff = (orbit2<=orbit1) ? (Float_t)((orbit1-orbit2))*ot : | |
429 | (Float_t)((16777215-orbit1+orbit2))*ot; | |
430 | if (timediff>deltaTime) continue; //timediff outside time window | |
431 | if((int1&int2) == -1){ //ignore both bits, just count IR-s within time window | |
432 | arr.Add((AliTriggerIR*)IR); //add this IR | |
433 | continue; | |
434 | } | |
435 | // now check if int1, int2 bits are set | |
436 | UInt_t nw = IR->GetNWord(); | |
437 | Bool_t *bint1 = IR->GetInt1s(); | |
438 | Bool_t *bint2 = IR->GetInt2s(); | |
439 | // | |
440 | Int_t flag1,flag2; | |
441 | flag1=0; | |
442 | flag2=0; | |
443 | for(UInt_t j=0;j<nw;j++){//2 | |
444 | if(bint1[j]) flag1=1; // at least one int1 set | |
445 | if(bint2[j]) flag2=1; // at least one int2 set | |
446 | }//2 | |
447 | // checking combinations | |
448 | // | |
449 | if((flag1*int1*flag2*int2)==1){// int1=1 & int2=1 | |
450 | arr.Add((AliTriggerIR*)IR); //add this IR | |
451 | continue; | |
452 | } | |
453 | if(int1 == -1){// ignore int1 | |
454 | if(flag2&int2){// int2=1 | |
455 | arr.Add((AliTriggerIR*)IR); //add this IR | |
456 | continue; | |
457 | } | |
458 | else if (!flag2&!int2){ //int2=0 | |
459 | arr.Add((AliTriggerIR*)IR); //add this IR | |
460 | continue; | |
461 | } | |
462 | } | |
463 | if(int2 ==-1){//ignore int2 | |
464 | if(flag1&int1){//int1=1 | |
465 | arr.Add((AliTriggerIR*)IR); //add this IR | |
466 | continue; | |
467 | } | |
468 | else if(!flag1&!int1){ //int1=0 | |
469 | arr.Add((AliTriggerIR*)IR); //add this IR | |
470 | continue; | |
471 | } | |
472 | } | |
473 | if ((flag1*int1)&!flag2&!int2){// int1=1, int2=0 | |
474 | arr.Add((AliTriggerIR*)IR); //add this IR | |
475 | continue; | |
476 | } | |
477 | if ((int2*flag2)&!int1&!flag1){// int1=0, int2=1 | |
478 | arr.Add((AliTriggerIR*)IR); //add this IR | |
479 | continue; | |
480 | } | |
481 | ||
482 | }//1 | |
483 | ||
484 | return arr; | |
485 | } | |
4ccebdba | 486 | |
487 | //__________________________________________________________________________ | |
299994c6 | 488 | void AliESDHeader::SetIRInteractionMap() const |
4ccebdba | 489 | { |
490 | // | |
491 | // Function to compute the map of interations | |
492 | // within 0TVX (int2) or V0A&V0C (int1) and the Event Id | |
493 | // Note, the zero value is excluded | |
494 | // | |
495 | const AliTriggerIR *ir[5] = {GetTriggerIR(0),GetTriggerIR(1),GetTriggerIR(2),GetTriggerIR(3),GetTriggerIR(4)}; | |
496 | ||
497 | Long64_t orb = (Long64_t)GetOrbitNumber(); | |
498 | Long64_t bc = (Long64_t)GetBunchCrossNumber(); | |
499 | ||
500 | Long64_t evId = orb*3564 + bc; | |
501 | ||
502 | for(Int_t i = 0; i < 5; ++i) { | |
503 | if (ir[i] == NULL || ir[i]->GetNWord() == 0) continue; | |
504 | Long64_t irOrb = (Long64_t)ir[i]->GetOrbit(); | |
505 | Bool_t* int2 = ir[i]->GetInt2s(); | |
506 | Bool_t* int1 = ir[i]->GetInt1s(); | |
507 | UShort_t* bcs = ir[i]->GetBCs(); | |
508 | for(UInt_t nW = 0; nW < ir[i]->GetNWord(); ++nW) { | |
509 | Long64_t intId = irOrb*3564 + (Long64_t)bcs[nW]; | |
510 | if (int2[nW] == kTRUE) { | |
511 | Int_t item = (intId-evId); | |
512 | Int_t bin = FindIRIntInteractionsBXMap(item); | |
513 | if(bin>=0) { | |
514 | fIRInt2InteractionsMap.SetBitNumber(bin,kTRUE); | |
515 | } | |
516 | } | |
517 | if (int1[nW] == kTRUE) { | |
518 | Int_t item = (intId-evId); | |
519 | Int_t bin = FindIRIntInteractionsBXMap(item); | |
520 | if(bin>=0) { | |
521 | fIRInt1InteractionsMap.SetBitNumber(bin,kTRUE); | |
522 | } | |
523 | } | |
524 | } | |
525 | } | |
526 | ||
527 | fIRInt2InteractionsMap.Compact(); | |
528 | fIRInt1InteractionsMap.Compact(); | |
529 | } | |
530 | ||
531 | //__________________________________________________________________________ | |
299994c6 | 532 | Int_t AliESDHeader::FindIRIntInteractionsBXMap(Int_t difference) const |
4ccebdba | 533 | { |
534 | // | |
535 | // The mapping is of 181 bits, from -90 to +90 | |
536 | // | |
537 | Int_t bin=-1; | |
538 | ||
539 | if(difference<-90 || difference>90) return bin; | |
540 | else { bin = 90 + difference; } | |
541 | ||
542 | return bin; | |
543 | } | |
544 | ||
545 | //__________________________________________________________________________ | |
299994c6 | 546 | Int_t AliESDHeader::GetIRInt2ClosestInteractionMap() const |
4ccebdba | 547 | { |
548 | // | |
549 | // Calculation of the closest interaction | |
550 | // | |
551 | SetIRInteractionMap(); | |
552 | ||
553 | Int_t firstNegative=100; | |
554 | for(Int_t item=-1; item>=-90; item--) { | |
555 | Int_t bin = FindIRIntInteractionsBXMap(item); | |
556 | Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin); | |
557 | if(isFired) { | |
558 | firstNegative = item; | |
559 | break; | |
560 | } | |
561 | } | |
562 | Int_t firstPositive=100; | |
563 | for(Int_t item=1; item<=90; item++) { | |
564 | Int_t bin = FindIRIntInteractionsBXMap(item); | |
565 | Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin); | |
566 | if(isFired) { | |
567 | firstPositive = item; | |
568 | break; | |
e89fc1d8 | 569 | } |
570 | } | |
571 | ||
572 | Int_t closest = firstPositive < TMath::Abs(firstNegative) ? firstPositive : TMath::Abs(firstNegative); | |
573 | if(firstPositive==100 && firstNegative==100) closest=0; | |
574 | return closest; | |
575 | } | |
576 | ||
577 | //__________________________________________________________________________ | |
299994c6 | 578 | Int_t AliESDHeader::GetIRInt1ClosestInteractionMap(Int_t gap) const |
e89fc1d8 | 579 | { |
580 | // | |
581 | // Calculation of the closest interaction | |
582 | // In case of VZERO (Int1) one has to introduce a gap | |
583 | // in order to avoid false positivies from after-pulses | |
584 | ||
585 | SetIRInteractionMap(); | |
586 | ||
587 | Int_t firstNegative=100; | |
588 | for(Int_t item=-1; item>=-90; item--) { | |
589 | Int_t bin = FindIRIntInteractionsBXMap(item); | |
590 | Bool_t isFired = fIRInt1InteractionsMap.TestBitNumber(bin); | |
591 | if(isFired) { | |
592 | firstNegative = item; | |
593 | break; | |
594 | } | |
595 | } | |
596 | Int_t firstPositive=100; | |
597 | for(Int_t item=1+gap; item<=90; item++) { | |
598 | Int_t bin = FindIRIntInteractionsBXMap(item); | |
599 | Bool_t isFired = fIRInt1InteractionsMap.TestBitNumber(bin); | |
600 | if(isFired) { | |
601 | firstPositive = item; | |
602 | break; | |
4ccebdba | 603 | } |
604 | } | |
605 | ||
606 | Int_t closest = firstPositive < TMath::Abs(firstNegative) ? firstPositive : TMath::Abs(firstNegative); | |
607 | if(firstPositive==100 && firstNegative==100) closest=0; | |
608 | return closest; | |
609 | } | |
610 | ||
611 | //__________________________________________________________________________ | |
299994c6 | 612 | Int_t AliESDHeader::GetIRInt2LastInteractionMap() const |
4ccebdba | 613 | { |
614 | // | |
615 | // Calculation of the last interaction | |
616 | // | |
617 | SetIRInteractionMap(); | |
618 | ||
619 | Int_t lastNegative=0; | |
620 | for(Int_t item=-90; item<=-1; item++) { | |
621 | Int_t bin = FindIRIntInteractionsBXMap(item); | |
622 | Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin); | |
623 | if(isFired) { | |
624 | lastNegative = item; | |
625 | break; | |
626 | } | |
627 | } | |
628 | Int_t lastPositive=0; | |
629 | for(Int_t item=90; item>=1; item--) { | |
630 | Int_t bin = FindIRIntInteractionsBXMap(item); | |
631 | Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin); | |
632 | if(isFired) { | |
633 | lastPositive = item; | |
634 | break; | |
635 | } | |
636 | } | |
637 | ||
638 | Int_t last = lastPositive > TMath::Abs(lastNegative) ? lastPositive : TMath::Abs(lastNegative); | |
639 | return last; | |
640 | } |