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),
51 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
52 fBeamParticle[0] = fBeamParticle[1] = 0;
53 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
55 fTriggerClasses.SetOwner(kTRUE);
56 fMeanBeamInt[0][0]=fMeanBeamInt[0][1]=fMeanBeamInt[1][0]=fMeanBeamInt[1][1]=-1;
57 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
58 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
59 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=0.;
60 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=0;
61 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=-1;
64 //______________________________________________________________________________
65 AliESDRun::AliESDRun(const AliESDRun &esd) :
70 fMagneticField(esd.fMagneticField),
71 fDiamondZ(esd.fDiamondZ),
72 fDiamondSig2Z(esd.fDiamondSig2Z),
73 fPeriodNumber(esd.fPeriodNumber),
74 fRunNumber(esd.fRunNumber),
75 fRecoVersion(esd.fRecoVersion),
77 fTriggerClasses(TObjArray(kNTriggerClasses)),
82 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
83 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
84 for (Int_t i=0; i<2; i++) fBeamParticle[i] = esd.fBeamParticle[i];
85 for(Int_t i = 0; i < kNTriggerClasses; i++) {
86 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
87 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
90 for(Int_t m=0; m<kNPHOSMatrix; m++){
91 if(esd.fPHOSMatrix[m])
92 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
97 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
99 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
100 if(esd.fEMCALMatrix[sm])
101 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
103 fEMCALMatrix[sm]=NULL;
105 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
106 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
107 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=esd.fVZEROEqFactors[j];
111 //______________________________________________________________________________
112 AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
114 // assigment operator
116 TObject::operator=(esd);
117 fRunNumber=esd.fRunNumber;
118 fPeriodNumber=esd.fPeriodNumber;
119 fRecoVersion=esd.fRecoVersion;
120 fMagneticField=esd.fMagneticField;
121 fDiamondZ=esd.fDiamondZ;
122 fDiamondSig2Z=esd.fDiamondSig2Z;
123 fBeamType = esd.fBeamType;
124 fCurrentL3 = esd.fCurrentL3;
125 fCurrentDip = esd.fCurrentDip;
126 fBeamEnergy = esd.fBeamEnergy;
127 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
128 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
129 for (Int_t i=0; i<2; i++) fBeamParticle[i] = esd.fBeamParticle[i];
130 fTriggerClasses.Clear();
131 for(Int_t i = 0; i < kNTriggerClasses; i++) {
132 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
133 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
136 fDetInDAQ = esd.fDetInDAQ;
137 fDetInReco = esd.fDetInReco;
139 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
141 for(Int_t m=0; m<kNPHOSMatrix; m++){
142 if(esd.fPHOSMatrix[m])
143 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
148 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
149 if(esd.fEMCALMatrix[sm])
150 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
155 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
156 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
157 for (Int_t j=0; j<64; ++j) fVZEROEqFactors[j]=esd.fVZEROEqFactors[j];
161 void AliESDRun::Copy(TObject &obj) const{
163 // this overwrites the virtual TOBject::Copy()
164 // to allow run time copying without casting
167 if(this==&obj)return;
168 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
169 if(!robj)return; // not an aliesdrun
174 //______________________________________________________________________________
175 AliESDRun::~AliESDRun() {
177 // Delete PHOS position matrices
178 for(Int_t m=0; m<kNPHOSMatrix; m++) {
179 if(fPHOSMatrix[m]) delete fPHOSMatrix[m] ;
180 fPHOSMatrix[m] = NULL;
182 // Delete PHOS position matrices
183 for(Int_t sm=0; sm<kNEMCALMatrix; sm++) {
184 if(fEMCALMatrix[sm]) delete fEMCALMatrix[sm] ;
185 fEMCALMatrix[sm] = NULL;
189 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
190 // set the interaction diamond
192 fDiamondXY[0]=vertex->GetXv();
193 fDiamondXY[1]=vertex->GetYv();
194 fDiamondZ=vertex->GetZv();
196 vertex->GetCovMatrix(cov);
197 fDiamondCovXY[0]=cov[0];
198 fDiamondCovXY[1]=cov[1];
199 fDiamondCovXY[2]=cov[2];
200 fDiamondSig2Z=cov[5];
205 //______________________________________________________________________________
206 void AliESDRun::Print(const Option_t *) const
208 // Print some data members
209 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
210 GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
211 printf("Beam Type: %s (%d/%d - %d/%d), Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":GetBeamType(),
212 GetBeamParticleA(0),GetBeamParticleZ(0),GetBeamParticleA(1),GetBeamParticleZ(1),
214 printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
215 GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
216 printf("Event from reconstruction version %d \n",fRecoVersion);
218 printf("List of active trigger classes: ");
219 for(Int_t i = 0; i < kNTriggerClasses; i++) {
220 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
221 if (str) printf("%s ",str->GetName());
223 printf("Mean intenstity for interacting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][0],fMeanBeamInt[1][0]);
224 printf("Mean intenstity for non-intecting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][1],fMeanBeamInt[1][1]);
228 void AliESDRun::Reset()
230 // reset data members
239 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
240 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
241 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
244 fDiamondSig2Z=10.*10.;
245 fTriggerClasses.Clear();
250 //______________________________________________________________________________
251 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
253 // Fill the trigger class name
254 // into the corresponding array
255 if (index >= kNTriggerClasses || index < 0) {
256 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
260 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
263 //______________________________________________________________________________
264 const char* AliESDRun::GetTriggerClass(Int_t index) const
266 // Get the trigger class name at
267 // specified position in the trigger mask
268 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
270 return trclass->GetName();
275 //______________________________________________________________________________
276 TString AliESDRun::GetActiveTriggerClasses() const
278 // Construct and return
279 // the list of trigger classes
280 // which are present in the run
282 for(Int_t i = 0; i < kNTriggerClasses; i++) {
283 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
286 trclasses += str->GetName();
294 //______________________________________________________________________________
295 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
297 // Constructs and returns the
298 // list of trigger classes that
299 // have been fired. Uses the trigger
300 // class mask as an argument.
302 for(Int_t i = 0; i < kNTriggerClasses; i++) {
303 if (mask & (1ull << i)) {
304 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
307 trclasses += str->GetName();
316 //______________________________________________________________________________
317 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
319 // Checks if the trigger class
320 // identified by 'name' has been
321 // fired. Uses the trigger class mask.
323 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
324 if (!trclass) return kFALSE;
326 Int_t iclass = fTriggerClasses.IndexOf(trclass);
327 if (iclass < 0) return kFALSE;
329 if (mask & (1ull << iclass))
335 //_____________________________________________________________________________
336 Bool_t AliESDRun::InitMagneticField() const
338 // Create mag field from stored information
340 if (!TestBit(kBInfoStored)) {
341 AliError("No information on currents, cannot create field from run header");
345 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
346 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
347 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
348 AliInfo("ExpertMode!!! Running with the externally locked B field !");
352 AliInfo("Destroying existing B field instance!");
353 delete TGeoGlobalMagField::Instance();
357 AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
358 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
360 TGeoGlobalMagField::Instance()->SetField( fld );
361 TGeoGlobalMagField::Instance()->Lock();
362 AliInfo("Running with the B field constructed out of the Run Header !");
366 AliError("Failed to create a B field map !");
372 //_____________________________________________________________________________
373 void AliESDRun::SetT0spread(Int_t i,Float_t t)
376 // Setting the T0 spread value at index i
379 if ( (i>=0) && (i<kT0spreadSize)) {
382 AliError(Form("Index %d out of bound",i));
387 //_____________________________________________________________________________
388 void AliESDRun::SetT0spread(Float_t *t)
391 // Setting the T0 spread values
394 AliError(Form("Null pointer passed"));
397 for (Int_t i=0;i<kT0spreadSize;i++) fT0spread[i]=t[i];