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 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
54 fTriggerClasses.SetOwner(kTRUE);
55 fMeanBeamInt[0][0]=fMeanBeamInt[0][1]=fMeanBeamInt[1][0]=fMeanBeamInt[1][1]=-1;
56 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
57 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
58 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=0.;
59 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=0;
62 //______________________________________________________________________________
63 AliESDRun::AliESDRun(const AliESDRun &esd) :
68 fMagneticField(esd.fMagneticField),
69 fDiamondZ(esd.fDiamondZ),
70 fDiamondSig2Z(esd.fDiamondSig2Z),
71 fPeriodNumber(esd.fPeriodNumber),
72 fRunNumber(esd.fRunNumber),
73 fRecoVersion(esd.fRecoVersion),
75 fTriggerClasses(TObjArray(kNTriggerClasses)),
80 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
81 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
83 for(Int_t i = 0; i < kNTriggerClasses; i++) {
84 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
85 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
88 for(Int_t m=0; m<kNPHOSMatrix; m++){
89 if(esd.fPHOSMatrix[m])
90 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
95 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
97 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
98 if(esd.fEMCALMatrix[sm])
99 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
101 fEMCALMatrix[sm]=NULL;
103 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
104 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
108 //______________________________________________________________________________
109 AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
111 // assigment operator
113 TObject::operator=(esd);
114 fRunNumber=esd.fRunNumber;
115 fPeriodNumber=esd.fPeriodNumber;
116 fRecoVersion=esd.fRecoVersion;
117 fMagneticField=esd.fMagneticField;
118 fDiamondZ=esd.fDiamondZ;
119 fDiamondSig2Z=esd.fDiamondSig2Z;
120 fBeamType = esd.fBeamType;
121 fCurrentL3 = esd.fCurrentL3;
122 fCurrentDip = esd.fCurrentDip;
123 fBeamEnergy = esd.fBeamEnergy;
124 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
125 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
126 fTriggerClasses.Clear();
127 for(Int_t i = 0; i < kNTriggerClasses; i++) {
128 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
129 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
132 fDetInDAQ = esd.fDetInDAQ;
133 fDetInReco = esd.fDetInReco;
135 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
137 for(Int_t m=0; m<kNPHOSMatrix; m++){
138 if(esd.fPHOSMatrix[m])
139 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
144 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
145 if(esd.fEMCALMatrix[sm])
146 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
151 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
152 for (Int_t it=0; it<8; it++) fCaloTriggerType[it]=esd.fCaloTriggerType[it];
156 void AliESDRun::Copy(TObject &obj) const{
158 // this overwrites the virtual TOBject::Copy()
159 // to allow run time copying without casting
162 if(this==&obj)return;
163 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
164 if(!robj)return; // not an aliesdrun
169 //______________________________________________________________________________
170 AliESDRun::~AliESDRun() {
172 // Delete PHOS position matrices
173 for(Int_t m=0; m<kNPHOSMatrix; m++) {
174 if(fPHOSMatrix[m]) delete fPHOSMatrix[m] ;
175 fPHOSMatrix[m] = NULL;
177 // Delete PHOS position matrices
178 for(Int_t sm=0; sm<kNEMCALMatrix; sm++) {
179 if(fEMCALMatrix[sm]) delete fEMCALMatrix[sm] ;
180 fEMCALMatrix[sm] = NULL;
184 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
185 // set the interaction diamond
187 fDiamondXY[0]=vertex->GetXv();
188 fDiamondXY[1]=vertex->GetYv();
189 fDiamondZ=vertex->GetZv();
191 vertex->GetCovMatrix(cov);
192 fDiamondCovXY[0]=cov[0];
193 fDiamondCovXY[1]=cov[1];
194 fDiamondCovXY[2]=cov[2];
195 fDiamondSig2Z=cov[5];
200 //______________________________________________________________________________
201 void AliESDRun::Print(const Option_t *) const
203 // Print some data members
204 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
205 GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
206 printf("Beam Type: %s, Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":fBeamType.Data(),fBeamEnergy);
207 printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
208 GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
209 printf("Event from reconstruction version %d \n",fRecoVersion);
211 printf("List of active trigger classes: ");
212 for(Int_t i = 0; i < kNTriggerClasses; i++) {
213 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
214 if (str) printf("%s ",str->GetName());
216 printf("Mean intenstity for interacting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][0],fMeanBeamInt[1][0]);
217 printf("Mean intenstity for non-intecting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][1],fMeanBeamInt[1][1]);
221 void AliESDRun::Reset()
223 // reset data members
232 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
233 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
234 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
237 fDiamondSig2Z=10.*10.;
238 fTriggerClasses.Clear();
243 //______________________________________________________________________________
244 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
246 // Fill the trigger class name
247 // into the corresponding array
248 if (index >= kNTriggerClasses || index < 0) {
249 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
253 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
256 //______________________________________________________________________________
257 const char* AliESDRun::GetTriggerClass(Int_t index) const
259 // Get the trigger class name at
260 // specified position in the trigger mask
261 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
263 return trclass->GetName();
268 //______________________________________________________________________________
269 TString AliESDRun::GetActiveTriggerClasses() const
271 // Construct and return
272 // the list of trigger classes
273 // which are present in the run
275 for(Int_t i = 0; i < kNTriggerClasses; i++) {
276 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
279 trclasses += str->GetName();
287 //______________________________________________________________________________
288 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
290 // Constructs and returns the
291 // list of trigger classes that
292 // have been fired. Uses the trigger
293 // class mask as an argument.
295 for(Int_t i = 0; i < kNTriggerClasses; i++) {
296 if (mask & (1ull << i)) {
297 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
300 trclasses += str->GetName();
309 //______________________________________________________________________________
310 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
312 // Checks if the trigger class
313 // identified by 'name' has been
314 // fired. Uses the trigger class mask.
316 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
317 if (!trclass) return kFALSE;
319 Int_t iclass = fTriggerClasses.IndexOf(trclass);
320 if (iclass < 0) return kFALSE;
322 if (mask & (1ull << iclass))
328 //_____________________________________________________________________________
329 Bool_t AliESDRun::InitMagneticField() const
331 // Create mag field from stored information
333 if (!TestBit(kBInfoStored)) {
334 AliError("No information on currents, cannot create field from run header");
338 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
339 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
340 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
341 AliInfo("ExpertMode!!! Running with the externally locked B field !");
345 AliInfo("Destroying existing B field instance!");
346 delete TGeoGlobalMagField::Instance();
350 AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
351 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
353 TGeoGlobalMagField::Instance()->SetField( fld );
354 TGeoGlobalMagField::Instance()->Lock();
355 AliInfo("Running with the B field constructed out of the Run Header !");
359 AliError("Failed to create a B field map !");
365 //_____________________________________________________________________________
366 void AliESDRun::SetT0spread(Int_t i,Float_t t)
369 // Setting the T0 spread value at index i
372 if ( (i>=0) && (i<kT0spreadSize)) {
375 AliError(Form("Index %d out of bound",i));
380 //_____________________________________________________________________________
381 void AliESDRun::SetT0spread(Float_t *t)
384 // Setting the T0 spread values
387 AliError(Form("Null pointer passed"));
390 for (Int_t i=0;i<kT0spreadSize;i++) fT0spread[i]=t[i];