Firward declaration of AliTriggerConfiguration is enough
[u/mrichter/AliRoot.git] / STEER / AliESDHeader.cxx
CommitLineData
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"
b7b66e38 27#include "AliLog.h"
d5ebf00e 28
29ClassImp(AliESDHeader)
30
31//______________________________________________________________________________
32AliESDHeader::AliESDHeader() :
9ae2e5e6 33 AliVHeader(),
d5ebf00e 34 fTriggerMask(0),
35 fOrbitNumber(0),
36 fTimeStamp(0),
37 fEventType(0),
fd2e2210 38 fEventSpecie(0),
4f036e6e 39 fPeriodNumber(0),
d5ebf00e 40 fEventNumberInFile(0),
41 fBunchCrossNumber(0),
53eef471 42 fTriggerCluster(0),
43 fL0TriggerInputs(0),
44 fL1TriggerInputs(0),
bf1f98c4 45 fL2TriggerInputs(0),
6ef9caeb 46 fTriggerScalers(),
d789992f 47 fTriggerScalersDeltaEvent(),
48 fTriggerScalersDeltaRun(),
49 fTriggerInputsNames(kNTriggerInputs),
50 fCTPConfig(NULL)
d5ebf00e 51{
9ae2e5e6 52 // default constructor
53
54 SetName("AliESDHeader");
c47cda51 55 for(Int_t i = 0; i<kNMaxIR ; i++) fIRArray[i] = 0;
6ef9caeb 56 fTriggerInputsNames.SetOwner(kTRUE);
9ae2e5e6 57}
d789992f 58
9ae2e5e6 59AliESDHeader::~AliESDHeader()
60{
61 // destructor
c47cda51 62 for(Int_t i=0;i<kNMaxIR;i++)if(fIRArray[i])delete fIRArray[i];
d789992f 63 delete fCTPConfig;
d5ebf00e 64}
65
66
67AliESDHeader::AliESDHeader(const AliESDHeader &header) :
9ae2e5e6 68 AliVHeader(header),
d5ebf00e 69 fTriggerMask(header.fTriggerMask),
70 fOrbitNumber(header.fOrbitNumber),
71 fTimeStamp(header.fTimeStamp),
72 fEventType(header.fEventType),
fd2e2210 73 fEventSpecie(header.fEventSpecie),
4f036e6e 74 fPeriodNumber(header.fPeriodNumber),
d5ebf00e 75 fEventNumberInFile(header.fEventNumberInFile),
76 fBunchCrossNumber(header.fBunchCrossNumber),
53eef471 77 fTriggerCluster(header.fTriggerCluster),
78 fL0TriggerInputs(header.fL0TriggerInputs),
79 fL1TriggerInputs(header.fL1TriggerInputs),
bf1f98c4 80 fL2TriggerInputs(header.fL2TriggerInputs),
6ef9caeb 81 fTriggerScalers(header.fTriggerScalers),
d789992f 82 fTriggerScalersDeltaEvent(header.fTriggerScalersDeltaEvent),
83 fTriggerScalersDeltaRun(header.fTriggerScalersDeltaRun),
84 fTriggerInputsNames(TObjArray(kNTriggerInputs)),
85 fCTPConfig(header.fCTPConfig)
d5ebf00e 86{
87 // copy constructor
9ae2e5e6 88 SetName(header.fName);
89 SetTitle(header.fTitle);
c47cda51 90 for(Int_t i = 0; i<kNMaxIR ; i++) {
91 if(header.fIRArray[i])fIRArray[i] = new AliTriggerIR(*header.fIRArray[i]);
92 else fIRArray[i]=0;
93 }
6ef9caeb 94 for(Int_t i = 0; i < kNTriggerInputs; i++) {
95 TNamed *str = (TNamed *)((header.fTriggerInputsNames).At(i));
96 if (str) fTriggerInputsNames.AddAt(new TNamed(*str),i);
97 }
d5ebf00e 98}
99
100AliESDHeader& AliESDHeader::operator=(const AliESDHeader &header)
101{
102 // assigment operator
103 if(this!=&header) {
9ae2e5e6 104 AliVHeader::operator=(header);
d5ebf00e 105 fTriggerMask = header.fTriggerMask;
106 fOrbitNumber = header.fOrbitNumber;
107 fTimeStamp = header.fTimeStamp;
108 fEventType = header.fEventType;
fd2e2210 109 fEventSpecie = header.fEventSpecie;
4f036e6e 110 fPeriodNumber = header.fPeriodNumber;
d5ebf00e 111 fEventNumberInFile = header.fEventNumberInFile;
112 fBunchCrossNumber = header.fBunchCrossNumber;
113 fTriggerCluster = header.fTriggerCluster;
53eef471 114 fL0TriggerInputs = header.fL0TriggerInputs;
115 fL1TriggerInputs = header.fL1TriggerInputs;
116 fL2TriggerInputs = header.fL2TriggerInputs;
bf1f98c4 117 fTriggerScalers = header.fTriggerScalers;
d789992f 118 fTriggerScalersDeltaEvent = header.fTriggerScalersDeltaEvent;
119 fTriggerScalersDeltaRun = header.fTriggerScalersDeltaRun;
120 fCTPConfig = header.fCTPConfig;
121
6ef9caeb 122 fTriggerInputsNames.Clear();
123 for(Int_t i = 0; i < kNTriggerInputs; i++) {
124 TNamed *str = (TNamed *)((header.fTriggerInputsNames).At(i));
125 if (str) fTriggerInputsNames.AddAt(new TNamed(*str),i);
126 }
c47cda51 127 for(Int_t i = 0; i<kNMaxIR ; i++) {
128 if(header.fIRArray[i])fIRArray[i] = new AliTriggerIR(*header.fIRArray[i]);
129 else fIRArray[i]=0;
130 }
4f036e6e 131 SetName(header.fName);
132 SetTitle(header.fTitle);
d789992f 133 }
d5ebf00e 134 return *this;
135}
136
bf1f98c4 137void AliESDHeader::Copy(TObject &obj) const
138{
732a24fe 139 // this overwrites the virtual TOBject::Copy()
140 // to allow run time copying without casting
141 // in AliESDEvent
142
143 if(this==&obj)return;
144 AliESDHeader *robj = dynamic_cast<AliESDHeader*>(&obj);
145 if(!robj)return; // not an AliESDHeader
146 *robj = *this;
147
148}
d5ebf00e 149//______________________________________________________________________________
150void AliESDHeader::Reset()
151{
152 // reset all data members
153 fTriggerMask = 0;
154 fOrbitNumber = 0;
155 fTimeStamp = 0;
156 fEventType = 0;
fd2e2210 157 fEventSpecie = 0;
4f036e6e 158 fPeriodNumber = 0;
d5ebf00e 159 fEventNumberInFile = 0;
160 fBunchCrossNumber = 0;
161 fTriggerCluster = 0;
53eef471 162 fL0TriggerInputs = 0;
163 fL1TriggerInputs = 0;
164 fL2TriggerInputs = 0;
bf1f98c4 165 fTriggerScalers.Reset();
d789992f 166 fTriggerScalersDeltaEvent.Reset();
167 fTriggerScalersDeltaRun.Reset();
6ef9caeb 168 fTriggerInputsNames.Clear();
d789992f 169 delete fCTPConfig;
170 fCTPConfig = 0;
c47cda51 171 for(Int_t i=0;i<kNMaxIR;i++)if(fIRArray[i]){
172 delete fIRArray[i];
173 fIRArray[i]=0;
174 }
d5ebf00e 175}
76a7c65b 176//______________________________________________________________________________
c47cda51 177Bool_t AliESDHeader::AddTriggerIR(const AliTriggerIR* ir)
76a7c65b 178{
179 // Adds trigger interaction record to array
c47cda51 180 for(Int_t i=0;i<kNMaxIR;i++){
b7b66e38 181 if(!fIRArray[i]){
8b44b965 182 fIRArray[i]=new AliTriggerIR(*ir);
b7b66e38 183 return 0;
184 }
c47cda51 185 }
b7b66e38 186 //AliErrorClass("Attempt to add # of IRs > kNMaxIR \n");
c47cda51 187 return 1;
76a7c65b 188}
d5ebf00e 189//______________________________________________________________________________
190void AliESDHeader::Print(const Option_t *) const
191{
192 // Print some data members
193 printf("Event # %d in file Bunch crossing # %d Orbit # %d Trigger %lld \n",
194 GetEventNumberInFile(),
195 GetBunchCrossNumber(),
196 GetOrbitNumber(),
197 GetTriggerMask());
6ef9caeb 198 printf("List of the active trigger inputs: ");
199 for(Int_t i = 0; i < kNTriggerInputs; i++) {
200 TNamed *str = (TNamed *)((fTriggerInputsNames).At(i));
201 if (str) printf("%s ",str->GetName());
202 }
203 printf("\n");
204}
205
6ef9caeb 206//______________________________________________________________________________
207void AliESDHeader::SetActiveTriggerInputs(const char*name, Int_t index)
208{
209 // Fill the active trigger inputs names
210 // into the corresponding fTriggerInputsNames (TObjArray of TNamed)
211 if (index >= kNTriggerInputs || index < 0) {
212 AliError(Form("Index (%d) is outside the allowed range (0,59)!",index));
213 return;
214 }
215
216 fTriggerInputsNames.AddAt(new TNamed(name,NULL),index);
217}
218//______________________________________________________________________________
219const char* AliESDHeader::GetTriggerInputName(Int_t index, Int_t trglevel) const
220{
221 // Get the trigger input name
222 // at the specified position in the trigger mask and trigger level (0,1,2)
223 TNamed *trginput = 0;
224 if (trglevel == 0) trginput = (TNamed *)fTriggerInputsNames.At(index);
225 if (trglevel == 1) trginput = (TNamed *)fTriggerInputsNames.At(index+24);
226 if (trglevel == 2) trginput = (TNamed *)fTriggerInputsNames.At(index+48);
227 if (trginput) return trginput->GetName();
228 else return "";
d5ebf00e 229}
6ef9caeb 230//______________________________________________________________________________
231TString AliESDHeader::GetActiveTriggerInputs() const
232{
233 // Returns the list with the names of the active trigger inputs
234 TString trginputs;
235 for(Int_t i = 0; i < kNTriggerInputs; i++) {
236 TNamed *str = (TNamed *)((fTriggerInputsNames).At(i));
237 if (str) {
238 trginputs += " ";
239 trginputs += str->GetName();
240 trginputs += " ";
241 }
242 }
243
244 return trginputs;
245}
246//______________________________________________________________________________
247TString AliESDHeader::GetFiredTriggerInputs() const
248{
249 // Returns the list with the names of the fired trigger inputs
250 TString trginputs;
251 for(Int_t i = 0; i < kNTriggerInputs; i++) {
252 TNamed *str = (TNamed *)((fTriggerInputsNames.At(i)));
253 if (i < 24 && (fL0TriggerInputs & (1 << i))) {
254 if (str) {
255 trginputs += " ";
256 trginputs += str->GetName();
257 trginputs += " ";
258 }
259 }
d999f2e6 260 if (i >= 24 && i < 48 && (fL1TriggerInputs & (1 << (i-24)))) {
6ef9caeb 261 if (str) {
262 trginputs += " ";
263 trginputs += str->GetName();
264 trginputs += " ";
265 }
266 }
d999f2e6 267 if (i >= 48 && (fL2TriggerInputs & (1 << (i-48)))) {
6ef9caeb 268 if (str) {
269 trginputs += " ";
270 trginputs += str->GetName();
271 trginputs += " ";
272 }
273 }
d5ebf00e 274
6ef9caeb 275 }
276 return trginputs;
277}
278//______________________________________________________________________________
279Bool_t AliESDHeader::IsTriggerInputFired(const char *name) const
280{
281 // Checks if the trigger input is fired
282
283 TNamed *trginput = (TNamed *)fTriggerInputsNames.FindObject(name);
284 if (!trginput) return kFALSE;
285
286 Int_t inputIndex = fTriggerInputsNames.IndexOf(trginput);
287 if (inputIndex < 0) return kFALSE;
288
289 if (fL0TriggerInputs & (1 << inputIndex)) return kTRUE;
290 else if (fL1TriggerInputs & (1 << (inputIndex-24))) return kTRUE;
291 else if (fL2TriggerInputs & (1 << (inputIndex-48))) return kTRUE;
292 else return kFALSE;
293}