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 #include <TGeoMatrix.h>
17 #include <TGeoGlobalMagField.h>
19 #include "AliESDRun.h"
20 #include "AliESDVertex.h"
24 //-------------------------------------------------------------------------
25 // Implementation Class AliESDRun
28 // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch
29 //-------------------------------------------------------------------------
33 //______________________________________________________________________________
34 AliESDRun::AliESDRun() :
46 fTriggerClasses(kNTriggerClasses),
53 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
54 fBeamParticle[0] = fBeamParticle[1] = 0;
55 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
57 fTriggerClasses.SetOwner(kTRUE);
58 fMeanBeamInt[0][0]=fMeanBeamInt[0][1]=fMeanBeamInt[1][0]=fMeanBeamInt[1][1]=-1;
59 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
60 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
61 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=0.;
62 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=0;
63 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=-1;
66 //______________________________________________________________________________
67 AliESDRun::AliESDRun(const AliESDRun &esd) :
72 fMagneticField(esd.fMagneticField),
73 fDiamondZ(esd.fDiamondZ),
74 fDiamondSig2Z(esd.fDiamondSig2Z),
75 fPeriodNumber(esd.fPeriodNumber),
76 fRunNumber(esd.fRunNumber),
77 fRecoVersion(esd.fRecoVersion),
79 fTriggerClasses(TObjArray(kNTriggerClasses)),
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];
88 for (Int_t i=0; i<2; i++) fBeamParticle[i] = esd.fBeamParticle[i];
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);
94 for(Int_t m=0; m<kNPHOSMatrix; m++){
95 if(esd.fPHOSMatrix[m])
96 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
101 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
103 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
104 if(esd.fEMCALMatrix[sm])
105 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
107 fEMCALMatrix[sm]=NULL;
109 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
110 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
111 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=esd.fVZEROEqFactors[j];
115 //______________________________________________________________________________
116 AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
118 // assigment operator
120 TObject::operator=(esd);
121 fRunNumber=esd.fRunNumber;
122 fPeriodNumber=esd.fPeriodNumber;
123 fRecoVersion=esd.fRecoVersion;
124 fMagneticField=esd.fMagneticField;
125 fDiamondZ=esd.fDiamondZ;
126 fDiamondSig2Z=esd.fDiamondSig2Z;
127 fBeamType = esd.fBeamType;
128 fCurrentL3 = esd.fCurrentL3;
129 fCurrentDip = esd.fCurrentDip;
130 fBeamEnergy = esd.fBeamEnergy;
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];
133 for (Int_t i=0; i<2; i++) fBeamParticle[i] = esd.fBeamParticle[i];
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);
140 fDetInDAQ = esd.fDetInDAQ;
141 fDetInReco = esd.fDetInReco;
143 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
145 for(Int_t m=0; m<kNPHOSMatrix; m++){
146 delete fPHOSMatrix[m];
147 if(esd.fPHOSMatrix[m])
148 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
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])) ;
161 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
162 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
163 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=esd.fVZEROEqFactors[j];
167 void AliESDRun::Copy(TObject &obj) const{
169 // this overwrites the virtual TOBject::Copy()
170 // to allow run time copying without casting
173 if(this==&obj)return;
174 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
175 if(!robj)return; // not an aliesdrun
180 //______________________________________________________________________________
181 AliESDRun::~AliESDRun() {
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;
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;
195 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
196 // set the interaction diamond
198 fDiamondXY[0]=vertex->GetX();
199 fDiamondXY[1]=vertex->GetY();
200 fDiamondZ=vertex->GetZ();
202 vertex->GetCovMatrix(cov);
203 fDiamondCovXY[0]=cov[0];
204 fDiamondCovXY[1]=cov[1];
205 fDiamondCovXY[2]=cov[2];
206 fDiamondSig2Z=cov[5];
211 //______________________________________________________________________________
212 void AliESDRun::Print(const Option_t *) const
214 // Print some data members
215 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
216 GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
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),
220 printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
221 GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
222 printf("Event from reconstruction version %d \n",fRecoVersion);
224 printf("List of active trigger classes: ");
225 for(Int_t i = 0; i < kNTriggerClasses; i++) {
226 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
227 if (str) printf("%s ",str->GetName());
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]);
234 void AliESDRun::Reset()
236 // reset data members
245 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
246 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
247 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
250 fDiamondSig2Z=10.*10.;
251 fTriggerClasses.Clear();
256 //______________________________________________________________________________
257 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
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));
266 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
269 //______________________________________________________________________________
270 const char* AliESDRun::GetTriggerClass(Int_t index) const
272 // Get the trigger class name at
273 // specified position in the trigger mask
274 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
276 return trclass->GetName();
281 //______________________________________________________________________________
282 TString AliESDRun::GetActiveTriggerClasses() const
284 // Construct and return
285 // the list of trigger classes
286 // which are present in the run
288 for(Int_t i = 0; i < kNTriggerClasses; i++) {
289 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
292 trclasses += str->GetName();
300 //______________________________________________________________________________
301 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
303 // Constructs and returns the
304 // list of trigger classes that
305 // have been fired. Uses the trigger
306 // class mask as an argument.
307 // Works both for first50 and next50 classes
309 for(Int_t i = 0; i < kNTriggerClasses; i++) {
310 if (mask & (1ull << i)) {
311 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
314 trclasses += str->GetName();
323 //______________________________________________________________________________
324 TString AliESDRun::GetFiredTriggerClasses(ULong64_t masklow,ULong64_t maskhigh) const
326 // Contruct and returns list of trigger classes for 100 classes
327 TString trclasseslow;
328 trclasseslow = GetFiredTriggerClasses(masklow);
329 TString trclasseshigh;
330 trclasseshigh = GetFiredTriggerClasses(maskhigh);
332 trclasses = trclasseslow+trclasseshigh;
335 //______________________________________________________________________________
336 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
338 // Checks if the trigger class
339 // identified by 'name' has been
340 // fired. Uses the trigger class mask.
342 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
343 if (!trclass) return kFALSE;
345 Int_t iclass = fTriggerClasses.IndexOf(trclass);
346 if (iclass < 0) return kFALSE;
348 if (mask & (1ull << iclass))
353 //______________________________________________________________________________
354 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t masklow, ULong64_t maskhigh,const char *name) const
356 return (IsTriggerClassFired(masklow,name) || IsTriggerClassFired(maskhigh,name));
358 //_____________________________________________________________________________
359 Bool_t AliESDRun::InitMagneticField() const
361 // Create mag field from stored information
363 if (!TestBit(kBInfoStored)) {
364 AliError("No information on currents, cannot create field from run header");
368 AliMagF* fld = (AliMagF*) TGeoGlobalMagField::Instance()->GetField();
370 if (TGeoGlobalMagField::Instance()->IsLocked()) {
371 if (fld->TestBit(AliMagF::kOverrideGRP)) {
372 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
373 AliInfo("ExpertMode!!! Running with the externally locked B field !");
377 AliInfo("Destroying existing B field instance!");
378 delete TGeoGlobalMagField::Instance();
381 fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
382 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
384 TGeoGlobalMagField::Instance()->SetField( fld );
385 TGeoGlobalMagField::Instance()->Lock();
386 AliInfo("Running with the B field constructed out of the Run Header !");
390 AliError("Failed to create a B field map !");
396 //_____________________________________________________________________________
397 void AliESDRun::SetT0spread(Int_t i,Float_t t)
400 // Setting the T0 spread value at index i
403 if ( (i>=0) && (i<kT0spreadSize)) {
406 AliError(Form("Index %d out of bound",i));
411 //_____________________________________________________________________________
412 void AliESDRun::SetT0spread(Float_t *t)
415 // Setting the T0 spread values
418 AliError(Form("Null pointer passed"));
421 for (Int_t i=0;i<kT0spreadSize;i++) fT0spread[i]=t[i];