]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/ESD/AliESDRun.cxx
Update timestamp for new data points simulation
[u/mrichter/AliRoot.git] / STEER / ESD / AliESDRun.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 **************************************************************************/
f009b5c1 15#include <TNamed.h>
8d218603 16#include <TGeoMatrix.h>
33fe5eb1 17#include <TGeoGlobalMagField.h>
d5ebf00e 18
19#include "AliESDRun.h"
20#include "AliESDVertex.h"
f009b5c1 21#include "AliLog.h"
33fe5eb1 22#include "AliMagF.h"
d5ebf00e 23
24//-------------------------------------------------------------------------
25// Implementation Class AliESDRun
26// Run by run data
27// for the ESD
28// Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
29//-------------------------------------------------------------------------
30
31ClassImp(AliESDRun)
32
33//______________________________________________________________________________
34AliESDRun::AliESDRun() :
694aad0c 35 TObject(),
33fe5eb1 36 fCurrentL3(0),
37 fCurrentDip(0),
38 fBeamEnergy(0),
694aad0c 39 fMagneticField(0),
1c7554f9 40 fDiamondZ(0),
41 fDiamondSig2Z(0),
d5ebf00e 42 fPeriodNumber(0),
694aad0c 43 fRunNumber(0),
f009b5c1 44 fRecoVersion(0),
33fe5eb1 45 fBeamType(""),
7b649c02 46 fTriggerClasses(kNTriggerClasses),
47 fDetInDAQ(0),
5d8eaff6 48 fDetInReco(0)
d5ebf00e 49{
5d8eaff6 50 //
51 // default ctor
52 //
d5ebf00e 53 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
91460b26 54 fBeamParticle[0] = fBeamParticle[1] = 0;
a2dedd16 55 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
56 fDiamondCovXY[1]=0.;
f009b5c1 57 fTriggerClasses.SetOwner(kTRUE);
b671618d 58 fMeanBeamInt[0][0]=fMeanBeamInt[0][1]=fMeanBeamInt[1][0]=fMeanBeamInt[1][1]=-1;
8d218603 59 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
428557af 60 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
d443e5e9 61 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=0.;
e2456048 62 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=0;
1dc767cf 63 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=-1;
d5ebf00e 64}
65
66//______________________________________________________________________________
67AliESDRun::AliESDRun(const AliESDRun &esd) :
68 TObject(esd),
33fe5eb1 69 fCurrentL3(0),
70 fCurrentDip(0),
71 fBeamEnergy(0),
694aad0c 72 fMagneticField(esd.fMagneticField),
1c7554f9 73 fDiamondZ(esd.fDiamondZ),
74 fDiamondSig2Z(esd.fDiamondSig2Z),
d5ebf00e 75 fPeriodNumber(esd.fPeriodNumber),
694aad0c 76 fRunNumber(esd.fRunNumber),
f009b5c1 77 fRecoVersion(esd.fRecoVersion),
33fe5eb1 78 fBeamType(""),
7b649c02 79 fTriggerClasses(TObjArray(kNTriggerClasses)),
80 fDetInDAQ(0),
81 fDetInReco(0)
d5ebf00e 82{
5d8eaff6 83 //
d5ebf00e 84 // Copy constructor
5d8eaff6 85 //
d5ebf00e 86 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
87 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
91460b26 88 for (Int_t i=0; i<2; i++) fBeamParticle[i] = esd.fBeamParticle[i];
f009b5c1 89 for(Int_t i = 0; i < kNTriggerClasses; i++) {
90 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
91 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
92 }
8d218603 93
94 for(Int_t m=0; m<kNPHOSMatrix; m++){
95 if(esd.fPHOSMatrix[m])
96 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
97 else
98 fPHOSMatrix[m]=NULL;
99 }
b671618d 100
101 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
102
428557af 103 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
104 if(esd.fEMCALMatrix[sm])
105 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
106 else
107 fEMCALMatrix[sm]=NULL;
108 }
d443e5e9 109 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
e2456048 110 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
1dc767cf 111 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=esd.fVZEROEqFactors[j];
d443e5e9 112
d5ebf00e 113}
114
115//______________________________________________________________________________
116AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
117{
118 // assigment operator
119 if(this!=&esd) {
120 TObject::operator=(esd);
121 fRunNumber=esd.fRunNumber;
8d218603 122 fPeriodNumber=esd.fPeriodNumber;
123 fRecoVersion=esd.fRecoVersion;
124 fMagneticField=esd.fMagneticField;
1c7554f9 125 fDiamondZ=esd.fDiamondZ;
126 fDiamondSig2Z=esd.fDiamondSig2Z;
33fe5eb1 127 fBeamType = esd.fBeamType;
128 fCurrentL3 = esd.fCurrentL3;
129 fCurrentDip = esd.fCurrentDip;
130 fBeamEnergy = esd.fBeamEnergy;
8d218603 131 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
132 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
91460b26 133 for (Int_t i=0; i<2; i++) fBeamParticle[i] = esd.fBeamParticle[i];
8d218603 134 fTriggerClasses.Clear();
135 for(Int_t i = 0; i < kNTriggerClasses; i++) {
136 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
137 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
138 }
139
7b649c02 140 fDetInDAQ = esd.fDetInDAQ;
141 fDetInReco = esd.fDetInReco;
142
b671618d 143 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
144
8d218603 145 for(Int_t m=0; m<kNPHOSMatrix; m++){
481acdb5 146 delete fPHOSMatrix[m];
8d218603 147 if(esd.fPHOSMatrix[m])
148 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
149 else
150 fPHOSMatrix[m]=0;
151 }
428557af 152
481acdb5 153 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
154 delete fEMCALMatrix[sm];
155 if(esd.fEMCALMatrix[sm])
156 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
157 else
158 fEMCALMatrix[sm]=0;
159 }
d5ebf00e 160 }
d443e5e9 161 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
e2456048 162 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
1dc767cf 163 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=esd.fVZEROEqFactors[j];
d5ebf00e 164 return *this;
165}
166
732a24fe 167void AliESDRun::Copy(TObject &obj) const{
168
169 // this overwrites the virtual TOBject::Copy()
170 // to allow run time copying without casting
171 // in AliESDEvent
172
173 if(this==&obj)return;
174 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
175 if(!robj)return; // not an aliesdrun
176 *robj = *this;
177
178}
179
8d218603 180//______________________________________________________________________________
181AliESDRun::~AliESDRun() {
182 // Destructor
183 // Delete PHOS position matrices
184 for(Int_t m=0; m<kNPHOSMatrix; m++) {
185 if(fPHOSMatrix[m]) delete fPHOSMatrix[m] ;
186 fPHOSMatrix[m] = NULL;
187 }
428557af 188 // Delete PHOS position matrices
189 for(Int_t sm=0; sm<kNEMCALMatrix; sm++) {
190 if(fEMCALMatrix[sm]) delete fEMCALMatrix[sm] ;
191 fEMCALMatrix[sm] = NULL;
192 }
8d218603 193}
194
d5ebf00e 195void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
196 // set the interaction diamond
c7a22819 197 if (vertex) {
e690d4d0 198 fDiamondXY[0]=vertex->GetX();
199 fDiamondXY[1]=vertex->GetY();
200 fDiamondZ=vertex->GetZ();
c7a22819 201 Double32_t cov[6];
202 vertex->GetCovMatrix(cov);
203 fDiamondCovXY[0]=cov[0];
204 fDiamondCovXY[1]=cov[1];
205 fDiamondCovXY[2]=cov[2];
206 fDiamondSig2Z=cov[5];
207 }
d5ebf00e 208}
209
210
211//______________________________________________________________________________
212void AliESDRun::Print(const Option_t *) const
213{
214 // Print some data members
1c7554f9 215 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
216 GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
91460b26 217 printf("Beam Type: %s (%d/%d - %d/%d), Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":GetBeamType(),
218 GetBeamParticleA(0),GetBeamParticleZ(0),GetBeamParticleA(1),GetBeamParticleZ(1),
219 fBeamEnergy);
33fe5eb1 220 printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
221 GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
d5ebf00e 222 printf("Event from reconstruction version %d \n",fRecoVersion);
f009b5c1 223
224 printf("List of active trigger classes: ");
225 for(Int_t i = 0; i < kNTriggerClasses; i++) {
226 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
384e7a60 227 if (str) printf("%s ",str->GetName());
f009b5c1 228 }
b671618d 229 printf("Mean intenstity for interacting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][0],fMeanBeamInt[1][0]);
230 printf("Mean intenstity for non-intecting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][1],fMeanBeamInt[1][1]);
f009b5c1 231 printf("\n");
d5ebf00e 232}
233
234void AliESDRun::Reset()
235{
236 // reset data members
237 fRunNumber = 0;
238 fPeriodNumber = 0;
239 fRecoVersion = 0;
240 fMagneticField = 0;
11be4f1c 241 fCurrentL3 = 0;
242 fCurrentDip = 0;
243 fBeamEnergy = 0;
244 fBeamType = "";
5cf76849 245 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
d5ebf00e 246 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
a2dedd16 247 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
248 fDiamondCovXY[1]=0.;
1c7554f9 249 fDiamondZ=0.;
250 fDiamondSig2Z=10.*10.;
f009b5c1 251 fTriggerClasses.Clear();
7b649c02 252 fDetInDAQ = 0;
253 fDetInReco = 0;
f009b5c1 254}
255
256//______________________________________________________________________________
35a702f0 257void AliESDRun::SetTriggerClass(const char* name, Int_t index)
f009b5c1 258{
259 // Fill the trigger class name
260 // into the corresponding array
261 if (index >= kNTriggerClasses || index < 0) {
262 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
263 return;
264 }
265
266 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
267}
268
269//______________________________________________________________________________
270const char* AliESDRun::GetTriggerClass(Int_t index) const
271{
272 // Get the trigger class name at
273 // specified position in the trigger mask
274 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
275 if (trclass)
276 return trclass->GetName();
277 else
278 return "";
279}
280
281//______________________________________________________________________________
282TString AliESDRun::GetActiveTriggerClasses() const
283{
284 // Construct and return
285 // the list of trigger classes
286 // which are present in the run
287 TString trclasses;
288 for(Int_t i = 0; i < kNTriggerClasses; i++) {
289 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
290 if (str) {
291 trclasses += " ";
292 trclasses += str->GetName();
293 trclasses += " ";
294 }
295 }
296
297 return trclasses;
298}
299
300//______________________________________________________________________________
301TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
302{
303 // Constructs and returns the
304 // list of trigger classes that
305 // have been fired. Uses the trigger
306 // class mask as an argument.
35a702f0 307 // Works for first50
f009b5c1 308 TString trclasses;
35a702f0 309 for(Int_t i = 0; i < kNTriggerClasses/2; i++) {
a62d86d6 310 if (mask & (1ull << i)) {
f009b5c1 311 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
312 if (str) {
313 trclasses += " ";
314 trclasses += str->GetName();
315 trclasses += " ";
316 }
317 }
318 }
319
320 return trclasses;
d5ebf00e 321}
35a702f0 322//______________________________________________________________________________
323TString AliESDRun::GetFiredTriggerClassesNext50(ULong64_t mask) const
324{
325 // Constructs and returns the
326 // list of trigger classes that
327 // have been fired. Uses the trigger
328 // class mask as an argument.
329 // Works for next50 classes
330 TString trclasses;
331 for(Int_t i = 0; i < kNTriggerClasses/2; i++) {
332 if (mask & (1ull << i)) {
333 TNamed *str = (TNamed *)((fTriggerClasses).At(i+50));
334 if (str) {
335 trclasses += " ";
336 trclasses += str->GetName();
337 trclasses += " ";
338 }
339 }
340 }
341 return trclasses;
342}
6848e3be 343//______________________________________________________________________________
344TString AliESDRun::GetFiredTriggerClasses(ULong64_t masklow,ULong64_t maskhigh) const
345{
346 // Contruct and returns list of trigger classes for 100 classes
347 TString trclasseslow;
348 trclasseslow = GetFiredTriggerClasses(masklow);
349 TString trclasseshigh;
35a702f0 350 trclasseshigh = GetFiredTriggerClassesNext50(maskhigh);
6848e3be 351 TString trclasses;
352 trclasses = trclasseslow+trclasseshigh;
353 return trclasses;
354}
f009b5c1 355//______________________________________________________________________________
35a702f0 356void AliESDRun::PrintAllTriggerClasses() const
357{
358 TString trclasses;
359 for(Int_t i = 0; i < kNTriggerClasses; i++) {
360 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
361 if (str) {
362 printf("%03i:",i+1);
363 printf("%s ",str->GetName());
364 }else{
365 //printf("NO ");
366 }
367 }
368 printf("\n");
369}
370//______________________________________________________________________________
f009b5c1 371Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
372{
373 // Checks if the trigger class
374 // identified by 'name' has been
375 // fired. Uses the trigger class mask.
376
377 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
378 if (!trclass) return kFALSE;
379
380 Int_t iclass = fTriggerClasses.IndexOf(trclass);
381 if (iclass < 0) return kFALSE;
382
a62d86d6 383 if (mask & (1ull << iclass))
f009b5c1 384 return kTRUE;
385 else
386 return kFALSE;
387}
6848e3be 388//______________________________________________________________________________
389Bool_t AliESDRun::IsTriggerClassFired(ULong64_t masklow, ULong64_t maskhigh,const char *name) const
390{
391 return (IsTriggerClassFired(masklow,name) || IsTriggerClassFired(maskhigh,name));
392}
33fe5eb1 393//_____________________________________________________________________________
394Bool_t AliESDRun::InitMagneticField() const
395{
396 // Create mag field from stored information
397 //
398 if (!TestBit(kBInfoStored)) {
399 AliError("No information on currents, cannot create field from run header");
400 return kFALSE;
401 }
402 //
127be208 403 AliMagF* fld = (AliMagF*) TGeoGlobalMagField::Instance()->GetField();
404 if (fld) {
405 if (TGeoGlobalMagField::Instance()->IsLocked()) {
406 if (fld->TestBit(AliMagF::kOverrideGRP)) {
407 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
408 AliInfo("ExpertMode!!! Running with the externally locked B field !");
409 return kTRUE;
410 }
33fe5eb1 411 }
127be208 412 AliInfo("Destroying existing B field instance!");
413 delete TGeoGlobalMagField::Instance();
33fe5eb1 414 }
415 //
127be208 416 fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
417 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
33fe5eb1 418 if (fld) {
419 TGeoGlobalMagField::Instance()->SetField( fld );
420 TGeoGlobalMagField::Instance()->Lock();
421 AliInfo("Running with the B field constructed out of the Run Header !");
422 return kTRUE;
423 }
424 else {
425 AliError("Failed to create a B field map !");
426 return kFALSE;
427 }
428 //
429}
d443e5e9 430
431//_____________________________________________________________________________
432void AliESDRun::SetT0spread(Int_t i,Float_t t)
433{
434 //
435 // Setting the T0 spread value at index i
436 //
437
438 if ( (i>=0) && (i<kT0spreadSize)) {
439 fT0spread[i]=t;
440 } else {
441 AliError(Form("Index %d out of bound",i));
442 }
443 return;
444}
445
446//_____________________________________________________________________________
447void AliESDRun::SetT0spread(Float_t *t)
448{
449 //
450 // Setting the T0 spread values
451 //
452 if (t == 0x0){
453 AliError(Form("Null pointer passed"));
454 }
455 else{
456 for (Int_t i=0;i<kT0spreadSize;i++) fT0spread[i]=t[i];
457 }
458 return;
459}
460