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