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),
50 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
51 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
53 fTriggerClasses.SetOwner(kTRUE);
54 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
55 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
58 //______________________________________________________________________________
59 AliESDRun::AliESDRun(const AliESDRun &esd) :
64 fMagneticField(esd.fMagneticField),
65 fDiamondZ(esd.fDiamondZ),
66 fDiamondSig2Z(esd.fDiamondSig2Z),
67 fPeriodNumber(esd.fPeriodNumber),
68 fRunNumber(esd.fRunNumber),
69 fRecoVersion(esd.fRecoVersion),
71 fTriggerClasses(TObjArray(kNTriggerClasses)),
76 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
77 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
79 for(Int_t i = 0; i < kNTriggerClasses; i++) {
80 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
81 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
84 for(Int_t m=0; m<kNPHOSMatrix; m++){
85 if(esd.fPHOSMatrix[m])
86 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
91 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
92 if(esd.fEMCALMatrix[sm])
93 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
95 fEMCALMatrix[sm]=NULL;
99 //______________________________________________________________________________
100 AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
102 // assigment operator
104 TObject::operator=(esd);
105 fRunNumber=esd.fRunNumber;
106 fPeriodNumber=esd.fPeriodNumber;
107 fRecoVersion=esd.fRecoVersion;
108 fMagneticField=esd.fMagneticField;
109 fDiamondZ=esd.fDiamondZ;
110 fDiamondSig2Z=esd.fDiamondSig2Z;
111 fBeamType = esd.fBeamType;
112 fCurrentL3 = esd.fCurrentL3;
113 fCurrentDip = esd.fCurrentDip;
114 fBeamEnergy = esd.fBeamEnergy;
115 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
116 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
117 fTriggerClasses.Clear();
118 for(Int_t i = 0; i < kNTriggerClasses; i++) {
119 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
120 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
123 fDetInDAQ = esd.fDetInDAQ;
124 fDetInReco = esd.fDetInReco;
126 for(Int_t m=0; m<kNPHOSMatrix; m++){
127 if(esd.fPHOSMatrix[m])
128 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
133 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
134 if(esd.fEMCALMatrix[sm])
135 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
143 void AliESDRun::Copy(TObject &obj) const{
145 // this overwrites the virtual TOBject::Copy()
146 // to allow run time copying without casting
149 if(this==&obj)return;
150 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
151 if(!robj)return; // not an aliesdrun
156 //______________________________________________________________________________
157 AliESDRun::~AliESDRun() {
159 // Delete PHOS position matrices
160 for(Int_t m=0; m<kNPHOSMatrix; m++) {
161 if(fPHOSMatrix[m]) delete fPHOSMatrix[m] ;
162 fPHOSMatrix[m] = NULL;
164 // Delete PHOS position matrices
165 for(Int_t sm=0; sm<kNEMCALMatrix; sm++) {
166 if(fEMCALMatrix[sm]) delete fEMCALMatrix[sm] ;
167 fEMCALMatrix[sm] = NULL;
171 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
172 // set the interaction diamond
173 fDiamondXY[0]=vertex->GetXv();
174 fDiamondXY[1]=vertex->GetYv();
175 fDiamondZ=vertex->GetZv();
177 vertex->GetCovMatrix(cov);
178 fDiamondCovXY[0]=cov[0];
179 fDiamondCovXY[1]=cov[1];
180 fDiamondCovXY[2]=cov[2];
181 fDiamondSig2Z=cov[5];
185 //______________________________________________________________________________
186 void AliESDRun::Print(const Option_t *) const
188 // Print some data members
189 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
190 GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
191 printf("Beam Type: %s, Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":fBeamType.Data(),fBeamEnergy);
192 printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
193 GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
194 printf("Event from reconstruction version %d \n",fRecoVersion);
196 printf("List of active trigger classes: ");
197 for(Int_t i = 0; i < kNTriggerClasses; i++) {
198 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
199 if (str) printf("%s ",str->GetName());
204 void AliESDRun::Reset()
206 // reset data members
215 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
216 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
217 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
220 fDiamondSig2Z=10.*10.;
221 fTriggerClasses.Clear();
226 //______________________________________________________________________________
227 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
229 // Fill the trigger class name
230 // into the corresponding array
231 if (index >= kNTriggerClasses || index < 0) {
232 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
236 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
239 //______________________________________________________________________________
240 const char* AliESDRun::GetTriggerClass(Int_t index) const
242 // Get the trigger class name at
243 // specified position in the trigger mask
244 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
246 return trclass->GetName();
251 //______________________________________________________________________________
252 TString AliESDRun::GetActiveTriggerClasses() const
254 // Construct and return
255 // the list of trigger classes
256 // which are present in the run
258 for(Int_t i = 0; i < kNTriggerClasses; i++) {
259 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
262 trclasses += str->GetName();
270 //______________________________________________________________________________
271 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
273 // Constructs and returns the
274 // list of trigger classes that
275 // have been fired. Uses the trigger
276 // class mask as an argument.
278 for(Int_t i = 0; i < kNTriggerClasses; i++) {
279 if (mask & (1ull << i)) {
280 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
283 trclasses += str->GetName();
292 //______________________________________________________________________________
293 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
295 // Checks if the trigger class
296 // identified by 'name' has been
297 // fired. Uses the trigger class mask.
299 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
300 if (!trclass) return kFALSE;
302 Int_t iclass = fTriggerClasses.IndexOf(trclass);
303 if (iclass < 0) return kFALSE;
305 if (mask & (1ull << iclass))
311 //_____________________________________________________________________________
312 Bool_t AliESDRun::InitMagneticField() const
314 // Create mag field from stored information
316 if (!TestBit(kBInfoStored)) {
317 AliError("No information on currents, cannot create field from run header");
321 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
322 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
323 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
324 AliInfo("ExpertMode!!! Running with the externally locked B field !");
328 AliInfo("Destroying existing B field instance!");
329 delete TGeoGlobalMagField::Instance();
333 AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
334 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
336 TGeoGlobalMagField::Instance()->SetField( fld );
337 TGeoGlobalMagField::Instance()->Lock();
338 AliInfo("Running with the B field constructed out of the Run Header !");
342 AliError("Failed to create a B field map !");