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() :
44 fTriggerClasses(kNTriggerClasses)
46 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
47 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
49 fTriggerClasses.SetOwner(kTRUE);
50 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
51 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
54 //______________________________________________________________________________
55 AliESDRun::AliESDRun(const AliESDRun &esd) :
60 fMagneticField(esd.fMagneticField),
61 fPeriodNumber(esd.fPeriodNumber),
62 fRunNumber(esd.fRunNumber),
63 fRecoVersion(esd.fRecoVersion),
65 fTriggerClasses(TObjArray(kNTriggerClasses))
68 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
69 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
71 for(Int_t i = 0; i < kNTriggerClasses; i++) {
72 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
73 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
76 for(Int_t m=0; m<kNPHOSMatrix; m++){
77 if(esd.fPHOSMatrix[m])
78 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
83 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
84 if(esd.fEMCALMatrix[sm])
85 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
87 fEMCALMatrix[sm]=NULL;
91 //______________________________________________________________________________
92 AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
96 TObject::operator=(esd);
97 fRunNumber=esd.fRunNumber;
98 fPeriodNumber=esd.fPeriodNumber;
99 fRecoVersion=esd.fRecoVersion;
100 fMagneticField=esd.fMagneticField;
101 fBeamType = esd.fBeamType;
102 fCurrentL3 = esd.fCurrentL3;
103 fCurrentDip = esd.fCurrentDip;
104 fBeamEnergy = esd.fBeamEnergy;
105 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
106 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
107 fTriggerClasses.Clear();
108 for(Int_t i = 0; i < kNTriggerClasses; i++) {
109 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
110 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
113 for(Int_t m=0; m<kNPHOSMatrix; m++){
114 if(esd.fPHOSMatrix[m])
115 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
120 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
121 if(esd.fEMCALMatrix[sm])
122 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
130 void AliESDRun::Copy(TObject &obj) const{
132 // this overwrites the virtual TOBject::Copy()
133 // to allow run time copying without casting
136 if(this==&obj)return;
137 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
138 if(!robj)return; // not an aliesdrun
143 //______________________________________________________________________________
144 AliESDRun::~AliESDRun() {
146 // Delete PHOS position matrices
147 for(Int_t m=0; m<kNPHOSMatrix; m++) {
148 if(fPHOSMatrix[m]) delete fPHOSMatrix[m] ;
149 fPHOSMatrix[m] = NULL;
151 // Delete PHOS position matrices
152 for(Int_t sm=0; sm<kNEMCALMatrix; sm++) {
153 if(fEMCALMatrix[sm]) delete fEMCALMatrix[sm] ;
154 fEMCALMatrix[sm] = NULL;
158 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
159 // set the interaction diamond
160 fDiamondXY[0]=vertex->GetXv();
161 fDiamondXY[1]=vertex->GetYv();
163 vertex->GetCovMatrix(cov);
164 fDiamondCovXY[0]=cov[0];
165 fDiamondCovXY[1]=cov[1];
166 fDiamondCovXY[2]=cov[2];
170 //______________________________________________________________________________
171 void AliESDRun::Print(const Option_t *) const
173 // Print some data members
174 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f cm\n",
175 GetRunNumber(),GetDiamondX(),GetDiamondY());
176 printf("Beam Type: %s, Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":fBeamType.Data(),fBeamEnergy);
177 printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
178 GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
179 printf("Event from reconstruction version %d \n",fRecoVersion);
181 printf("List of active trigger classes: ");
182 for(Int_t i = 0; i < kNTriggerClasses; i++) {
183 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
184 if (str) printf("%s ",str->GetName());
189 void AliESDRun::Reset()
191 // reset data members
200 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
201 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
202 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
204 fTriggerClasses.Clear();
207 //______________________________________________________________________________
208 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
210 // Fill the trigger class name
211 // into the corresponding array
212 if (index >= kNTriggerClasses || index < 0) {
213 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
217 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
220 //______________________________________________________________________________
221 const char* AliESDRun::GetTriggerClass(Int_t index) const
223 // Get the trigger class name at
224 // specified position in the trigger mask
225 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
227 return trclass->GetName();
232 //______________________________________________________________________________
233 TString AliESDRun::GetActiveTriggerClasses() const
235 // Construct and return
236 // the list of trigger classes
237 // which are present in the run
239 for(Int_t i = 0; i < kNTriggerClasses; i++) {
240 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
243 trclasses += str->GetName();
251 //______________________________________________________________________________
252 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
254 // Constructs and returns the
255 // list of trigger classes that
256 // have been fired. Uses the trigger
257 // class mask as an argument.
259 for(Int_t i = 0; i < kNTriggerClasses; i++) {
260 if (mask & (1ull << i)) {
261 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
264 trclasses += str->GetName();
273 //______________________________________________________________________________
274 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
276 // Checks if the trigger class
277 // identified by 'name' has been
278 // fired. Uses the trigger class mask.
280 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
281 if (!trclass) return kFALSE;
283 Int_t iclass = fTriggerClasses.IndexOf(trclass);
284 if (iclass < 0) return kFALSE;
286 if (mask & (1ull << iclass))
292 //_____________________________________________________________________________
293 Bool_t AliESDRun::InitMagneticField() const
295 // Create mag field from stored information
297 if (!TestBit(kBInfoStored)) {
298 AliError("No information on currents, cannot create field from run header");
302 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
303 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
304 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
305 AliInfo("ExpertMode!!! Running with the externally locked B field !");
309 AliInfo("Destroying existing B field instance!");
310 delete TGeoGlobalMagField::Instance();
314 AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
315 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
317 TGeoGlobalMagField::Instance()->SetField( fld );
318 TGeoGlobalMagField::Instance()->Lock();
319 AliInfo("Running with the B field constructed out of the Run Header !");
323 AliError("Failed to create a B field map !");