1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //-------------------------------------------------------------------------
17 // Implementation of Class AliESDHeader
20 // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
21 //-------------------------------------------------------------------------
23 #include "AliESDHeader.h"
24 #include "AliTriggerScalersESD.h"
25 #include "AliTriggerScalersRecordESD.h"
26 #include "AliTriggerIR.h"
27 #include "AliTriggerConfiguration.h"
30 ClassImp(AliESDHeader)
32 //______________________________________________________________________________
33 AliESDHeader::AliESDHeader() :
41 fEventNumberInFile(0),
48 fTriggerScalersDeltaEvent(),
49 fTriggerScalersDeltaRun(),
50 fTriggerInputsNames(kNTriggerInputs),
54 // default constructor
56 SetName("AliESDHeader");
57 for(Int_t i = 0; i<kNMaxIR ; i++) fIRArray[i] = 0;
58 fTriggerInputsNames.SetOwner(kTRUE);
61 AliESDHeader::~AliESDHeader()
64 for(Int_t i=0;i<kNMaxIR;i++)if(fIRArray[i])delete fIRArray[i];
67 fIRBufferArray.Delete();
71 AliESDHeader::AliESDHeader(const AliESDHeader &header) :
73 fTriggerMask(header.fTriggerMask),
74 fOrbitNumber(header.fOrbitNumber),
75 fTimeStamp(header.fTimeStamp),
76 fEventType(header.fEventType),
77 fEventSpecie(header.fEventSpecie),
78 fPeriodNumber(header.fPeriodNumber),
79 fEventNumberInFile(header.fEventNumberInFile),
80 fBunchCrossNumber(header.fBunchCrossNumber),
81 fTriggerCluster(header.fTriggerCluster),
82 fL0TriggerInputs(header.fL0TriggerInputs),
83 fL1TriggerInputs(header.fL1TriggerInputs),
84 fL2TriggerInputs(header.fL2TriggerInputs),
85 fTriggerScalers(header.fTriggerScalers),
86 fTriggerScalersDeltaEvent(header.fTriggerScalersDeltaEvent),
87 fTriggerScalersDeltaRun(header.fTriggerScalersDeltaRun),
88 fTriggerInputsNames(TObjArray(kNTriggerInputs)),
89 fCTPConfig(header.fCTPConfig),
93 for(Int_t i = 0; i<kNMaxIR ; i++) {
94 if(header.fIRArray[i])fIRArray[i] = new AliTriggerIR(*header.fIRArray[i]);
97 for(Int_t i = 0; i < kNTriggerInputs; i++) {
98 TNamed *str = (TNamed *)((header.fTriggerInputsNames).At(i));
99 if (str) fTriggerInputsNames.AddAt(new TNamed(*str),i);
102 for(Int_t i = 0; i < (header.fIRBufferArray).GetEntries(); ++i) {
103 AliTriggerIR *ir = (AliTriggerIR*)((header.fIRBufferArray).At(i));
104 if (ir) fIRBufferArray.Add(new AliTriggerIR(*ir));
108 AliESDHeader& AliESDHeader::operator=(const AliESDHeader &header)
110 // assigment operator
112 AliVHeader::operator=(header);
113 fTriggerMask = header.fTriggerMask;
114 fOrbitNumber = header.fOrbitNumber;
115 fTimeStamp = header.fTimeStamp;
116 fEventType = header.fEventType;
117 fEventSpecie = header.fEventSpecie;
118 fPeriodNumber = header.fPeriodNumber;
119 fEventNumberInFile = header.fEventNumberInFile;
120 fBunchCrossNumber = header.fBunchCrossNumber;
121 fTriggerCluster = header.fTriggerCluster;
122 fL0TriggerInputs = header.fL0TriggerInputs;
123 fL1TriggerInputs = header.fL1TriggerInputs;
124 fL2TriggerInputs = header.fL2TriggerInputs;
125 fTriggerScalers = header.fTriggerScalers;
126 fTriggerScalersDeltaEvent = header.fTriggerScalersDeltaEvent;
127 fTriggerScalersDeltaRun = header.fTriggerScalersDeltaRun;
129 fCTPConfig = header.fCTPConfig;
131 fTriggerInputsNames.Clear();
132 for(Int_t i = 0; i < kNTriggerInputs; i++) {
133 TNamed *str = (TNamed *)((header.fTriggerInputsNames).At(i));
134 if (str) fTriggerInputsNames.AddAt(new TNamed(*str),i);
136 for(Int_t i = 0; i<kNMaxIR ; i++) {
138 if(header.fIRArray[i])fIRArray[i] = new AliTriggerIR(*header.fIRArray[i]);
142 fIRBufferArray.Delete();
143 for(Int_t i = 0; i < (header.fIRBufferArray).GetEntries(); ++i) {
144 AliTriggerIR *ir = (AliTriggerIR*)((header.fIRBufferArray).At(i));
145 if (ir) fIRBufferArray.Add(new AliTriggerIR(*ir));
151 void AliESDHeader::Copy(TObject &obj) const
153 // this overwrites the virtual TOBject::Copy()
154 // to allow run time copying without casting
157 if(this==&obj)return;
158 AliESDHeader *robj = dynamic_cast<AliESDHeader*>(&obj);
159 if(!robj)return; // not an AliESDHeader
163 //______________________________________________________________________________
164 void AliESDHeader::Reset()
166 // reset all data members
173 fEventNumberInFile = 0;
174 fBunchCrossNumber = 0;
176 fL0TriggerInputs = 0;
177 fL1TriggerInputs = 0;
178 fL2TriggerInputs = 0;
179 fTriggerScalers.Reset();
180 fTriggerScalersDeltaEvent.Reset();
181 fTriggerScalersDeltaRun.Reset();
182 fTriggerInputsNames.Clear();
185 for(Int_t i=0;i<kNMaxIR;i++)if(fIRArray[i]){
190 fIRBufferArray.Delete();
192 //______________________________________________________________________________
193 Bool_t AliESDHeader::AddTriggerIR(const AliTriggerIR* ir)
195 // Add an IR object into the array
196 // of IRs in the ESD header
198 fIRBufferArray.Add(new AliTriggerIR(*ir));
202 //______________________________________________________________________________
203 void AliESDHeader::Print(const Option_t *) const
205 // Print some data members
206 printf("Event # %d in file Bunch crossing # %d Orbit # %d Trigger %lld \n",
207 GetEventNumberInFile(),
208 GetBunchCrossNumber(),
211 printf("List of the active trigger inputs: ");
212 for(Int_t i = 0; i < kNTriggerInputs; i++) {
213 TNamed *str = (TNamed *)((fTriggerInputsNames).At(i));
214 if (str) printf("%s ",str->GetName());
219 //______________________________________________________________________________
220 void AliESDHeader::SetActiveTriggerInputs(const char*name, Int_t index)
222 // Fill the active trigger inputs names
223 // into the corresponding fTriggerInputsNames (TObjArray of TNamed)
224 if (index >= kNTriggerInputs || index < 0) {
225 AliError(Form("Index (%d) is outside the allowed range (0,59)!",index));
229 fTriggerInputsNames.AddAt(new TNamed(name,NULL),index);
231 //______________________________________________________________________________
232 const char* AliESDHeader::GetTriggerInputName(Int_t index, Int_t trglevel) const
234 // Get the trigger input name
235 // at the specified position in the trigger mask and trigger level (0,1,2)
236 TNamed *trginput = 0;
237 if (trglevel == 0) trginput = (TNamed *)fTriggerInputsNames.At(index);
238 if (trglevel == 1) trginput = (TNamed *)fTriggerInputsNames.At(index+24);
239 if (trglevel == 2) trginput = (TNamed *)fTriggerInputsNames.At(index+48);
240 if (trginput) return trginput->GetName();
243 //______________________________________________________________________________
244 TString AliESDHeader::GetActiveTriggerInputs() const
246 // Returns the list with the names of the active trigger inputs
248 for(Int_t i = 0; i < kNTriggerInputs; i++) {
249 TNamed *str = (TNamed *)((fTriggerInputsNames).At(i));
252 trginputs += str->GetName();
259 //______________________________________________________________________________
260 TString AliESDHeader::GetFiredTriggerInputs() const
262 // Returns the list with the names of the fired trigger inputs
264 for(Int_t i = 0; i < kNTriggerInputs; i++) {
265 TNamed *str = (TNamed *)((fTriggerInputsNames.At(i)));
266 if (i < 24 && (fL0TriggerInputs & (1 << i))) {
269 trginputs += str->GetName();
273 if (i >= 24 && i < 48 && (fL1TriggerInputs & (1 << (i-24)))) {
276 trginputs += str->GetName();
280 if (i >= 48 && (fL2TriggerInputs & (1 << (i-48)))) {
283 trginputs += str->GetName();
291 //______________________________________________________________________________
292 Bool_t AliESDHeader::IsTriggerInputFired(const char *name) const
294 // Checks if the trigger input is fired
296 TNamed *trginput = (TNamed *)fTriggerInputsNames.FindObject(name);
297 if (!trginput) return kFALSE;
299 Int_t inputIndex = fTriggerInputsNames.IndexOf(trginput);
300 if (inputIndex < 0) return kFALSE;
302 if (fL0TriggerInputs & (1 << inputIndex)) return kTRUE;
303 else if (fL1TriggerInputs & (1 << (inputIndex-24))) return kTRUE;
304 else if (fL2TriggerInputs & (1 << (inputIndex-48))) return kTRUE;
307 //________________________________________________________________________________
308 Int_t AliESDHeader::GetTriggerIREntries(Int_t int1, Int_t int2, Float_t deltaTime) const
310 // returns number of IR-s within time window deltaTime
311 // all possible combinations of int1 and int2 int1 - zdc bit, int2 v0 bit
313 const AliTriggerIR *IR;
315 Int_t nIR = GetTriggerIREntries();
316 UInt_t orbit1 = GetOrbitNumber();
317 const Double_t ot=0.0889218; //orbit time msec
318 Float_t timediff; // time difference between orbits (msec)
323 for(Int_t i=0;i<nIR;i++){//1
326 UInt_t orbit2 = IR->GetOrbit();
327 timediff = (orbit2<=orbit1) ? (Float_t)((orbit1-orbit2))*ot :
328 (Float_t)((16777215-orbit1+orbit2))*ot;
329 if (timediff>deltaTime) continue; //timediff outside time window
330 if((int1&int2) == -1){ //ignore both bits, just count IR-s within time window
334 // now check if int1, int2 bits are set
335 UInt_t nw = IR->GetNWord();
336 Bool_t *bint1 = IR->GetInt1s();
337 Bool_t *bint2 = IR->GetInt2s();
342 for(UInt_t j=0;j<nw;j++){//2
343 if(bint1[j]) flag1=1; // at least one int1 set
344 if(bint2[j]) flag2=1; // at least one int2 set
345 //printf("IR %d, bint1 %d, bint2 %d\n",i,bint1[j],bint2[j]);
347 // checking combinations
350 if((flag1*int1*flag2*int2)==1){// int1=1 & int2=1
354 if(int1 == -1){// ignore int1
355 if(flag2&int2){// int2=1
359 else if (!flag2&!int2){ //int2=0
365 if(int2 ==-1){//ignore int2
366 if(flag1&int1){//int1=1
370 else if(!flag1&!int1){ //int1=0
376 if((flag1*int1)&!flag2&!int2){// int1=1, int2=0
381 if((int2*flag2)&!int1&!flag1){// int1=0, int2=1
392 //__________________________________________________________________________
393 TObjArray AliESDHeader::GetIRArray(Int_t int1, Int_t int2, Float_t deltaTime) const
396 // returns an array of IR-s within time window deltaTime
397 // all possible combinations of int1 and int2 int1 - zdc bit, int2 v0 bit
399 const AliTriggerIR *IR;
402 Int_t nIR = GetTriggerIREntries();
403 UInt_t orbit1 = GetOrbitNumber();
404 const Double_t ot=0.0889218; //orbit time msec
405 Float_t timediff; // time difference between orbits (msec)
408 for(Int_t i=0;i<nIR;i++){//1
411 UInt_t orbit2 = IR->GetOrbit();
412 timediff = (orbit2<=orbit1) ? (Float_t)((orbit1-orbit2))*ot :
413 (Float_t)((16777215-orbit1+orbit2))*ot;
414 if (timediff>deltaTime) continue; //timediff outside time window
415 if((int1&int2) == -1){ //ignore both bits, just count IR-s within time window
416 arr.Add((AliTriggerIR*)IR); //add this IR
419 // now check if int1, int2 bits are set
420 UInt_t nw = IR->GetNWord();
421 Bool_t *bint1 = IR->GetInt1s();
422 Bool_t *bint2 = IR->GetInt2s();
427 for(UInt_t j=0;j<nw;j++){//2
428 if(bint1[j]) flag1=1; // at least one int1 set
429 if(bint2[j]) flag2=1; // at least one int2 set
431 // checking combinations
433 if((flag1*int1*flag2*int2)==1){// int1=1 & int2=1
434 arr.Add((AliTriggerIR*)IR); //add this IR
437 if(int1 == -1){// ignore int1
438 if(flag2&int2){// int2=1
439 arr.Add((AliTriggerIR*)IR); //add this IR
442 else if (!flag2&!int2){ //int2=0
443 arr.Add((AliTriggerIR*)IR); //add this IR
447 if(int2 ==-1){//ignore int2
448 if(flag1&int1){//int1=1
449 arr.Add((AliTriggerIR*)IR); //add this IR
452 else if(!flag1&!int1){ //int1=0
453 arr.Add((AliTriggerIR*)IR); //add this IR
457 if ((flag1*int1)&!flag2&!int2){// int1=1, int2=0
458 arr.Add((AliTriggerIR*)IR); //add this IR
461 if ((int2*flag2)&!int1&!flag1){// int1=0, int2=1
462 arr.Add((AliTriggerIR*)IR); //add this IR