]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDRun.cxx
Fix for report #60402 Problem with AliHMPIDPreprocessor. The access to the time stamp...
[u/mrichter/AliRoot.git] / STEER / AliESDRun.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15 #include <TNamed.h>
16 #include <TGeoMatrix.h>
17 #include <TGeoGlobalMagField.h>
18
19 #include "AliESDRun.h"
20 #include "AliESDVertex.h"
21 #include "AliLog.h"
22 #include "AliMagF.h"
23
24 //-------------------------------------------------------------------------
25 //                     Implementation Class AliESDRun
26 //   Run by run data
27 //   for the ESD   
28 //   Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch 
29 //-------------------------------------------------------------------------
30
31 ClassImp(AliESDRun)  
32  
33 //______________________________________________________________________________
34 AliESDRun::AliESDRun() :
35   TObject(),
36   fCurrentL3(0),
37   fCurrentDip(0),
38   fBeamEnergy(0),
39   fMagneticField(0),
40   fPeriodNumber(0),
41   fRunNumber(0),
42   fRecoVersion(0),
43   fBeamType(""),
44   fTriggerClasses(kNTriggerClasses)
45 {
46   for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
47   fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
48   fDiamondCovXY[1]=0.;
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;
52 }
53
54 //______________________________________________________________________________
55 AliESDRun::AliESDRun(const AliESDRun &esd) :
56   TObject(esd),
57   fCurrentL3(0),
58   fCurrentDip(0),
59   fBeamEnergy(0),
60   fMagneticField(esd.fMagneticField),
61   fPeriodNumber(esd.fPeriodNumber),
62   fRunNumber(esd.fRunNumber),
63   fRecoVersion(esd.fRecoVersion),
64   fBeamType(""),
65   fTriggerClasses(TObjArray(kNTriggerClasses))
66
67   // Copy constructor
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];
70
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);
74   }
75
76   for(Int_t m=0; m<kNPHOSMatrix; m++){
77     if(esd.fPHOSMatrix[m])
78       fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
79     else
80       fPHOSMatrix[m]=NULL;
81   }
82         
83   for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
84         if(esd.fEMCALMatrix[sm])
85                 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
86         else
87                 fEMCALMatrix[sm]=NULL;
88   }
89 }
90
91 //______________________________________________________________________________
92 AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
93
94   // assigment operator
95   if(this!=&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);
111     }
112
113     for(Int_t m=0; m<kNPHOSMatrix; m++){
114       if(esd.fPHOSMatrix[m])
115         fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
116       else
117         fPHOSMatrix[m]=0;
118     }
119           
120         for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
121           if(esd.fEMCALMatrix[sm])
122                   fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
123           else
124                   fEMCALMatrix[sm]=0;
125         }
126   } 
127   return *this;
128 }
129
130 void AliESDRun::Copy(TObject &obj) const{
131
132   // this overwrites the virtual TOBject::Copy()
133   // to allow run time copying without casting
134   // in AliESDEvent
135
136   if(this==&obj)return;
137   AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
138   if(!robj)return; // not an aliesdrun
139   *robj = *this;
140
141 }
142
143 //______________________________________________________________________________
144 AliESDRun::~AliESDRun() {
145   // Destructor
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;
150   }
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;
155   }
156 }
157
158 void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
159   // set the interaction diamond
160   fDiamondXY[0]=vertex->GetXv();
161   fDiamondXY[1]=vertex->GetYv();
162   Double32_t cov[6];
163   vertex->GetCovMatrix(cov);
164   fDiamondCovXY[0]=cov[0];
165   fDiamondCovXY[1]=cov[1];
166   fDiamondCovXY[2]=cov[2];
167 }
168
169
170 //______________________________________________________________________________
171 void AliESDRun::Print(const Option_t *) const
172 {
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);
180   
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());
185   }
186   printf("\n");
187 }
188
189 void AliESDRun::Reset() 
190 {
191   // reset data members
192   fRunNumber = 0;
193   fPeriodNumber = 0;
194   fRecoVersion = 0;
195   fMagneticField = 0;
196   fCurrentL3 = 0;
197   fCurrentDip = 0;
198   fBeamEnergy = 0;
199   fBeamType = "";
200   ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
201   for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
202   fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
203   fDiamondCovXY[1]=0.;
204   fTriggerClasses.Clear();
205 }
206
207 //______________________________________________________________________________
208 void AliESDRun::SetTriggerClass(const char*name, Int_t index)
209 {
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));
214     return;
215   }
216
217   fTriggerClasses.AddAt(new TNamed(name,NULL),index);
218 }
219
220 //______________________________________________________________________________
221 const char* AliESDRun::GetTriggerClass(Int_t index) const
222 {
223   // Get the trigger class name at
224   // specified position in the trigger mask
225   TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
226   if (trclass)
227     return trclass->GetName();
228   else
229     return "";
230 }
231
232 //______________________________________________________________________________
233 TString AliESDRun::GetActiveTriggerClasses() const
234 {
235   // Construct and return
236   // the list of trigger classes
237   // which are present in the run
238   TString trclasses;
239   for(Int_t i = 0; i < kNTriggerClasses; i++) {
240     TNamed *str = (TNamed *)((fTriggerClasses).At(i));
241     if (str) {
242       trclasses += " ";
243       trclasses += str->GetName();
244       trclasses += " ";
245     }
246   }
247
248   return trclasses;
249 }
250
251 //______________________________________________________________________________
252 TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
253 {
254   // Constructs and returns the
255   // list of trigger classes that
256   // have been fired. Uses the trigger
257   // class mask as an argument.
258   TString trclasses;
259   for(Int_t i = 0; i < kNTriggerClasses; i++) {
260     if (mask & (1ull << i)) {
261       TNamed *str = (TNamed *)((fTriggerClasses).At(i));
262       if (str) {
263         trclasses += " ";
264         trclasses += str->GetName();
265       trclasses += " ";
266       }
267     }
268   }
269
270   return trclasses;
271 }
272
273 //______________________________________________________________________________
274 Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
275 {
276   // Checks if the trigger class
277   // identified by 'name' has been
278   // fired. Uses the trigger class mask.
279
280   TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
281   if (!trclass) return kFALSE;
282
283   Int_t iclass = fTriggerClasses.IndexOf(trclass);
284   if (iclass < 0) return kFALSE;
285
286   if (mask & (1ull << iclass))
287     return kTRUE;
288   else
289     return kFALSE;
290 }
291
292 //_____________________________________________________________________________
293 Bool_t AliESDRun::InitMagneticField() const
294 {
295   // Create mag field from stored information
296   //
297   if (!TestBit(kBInfoStored)) {
298     AliError("No information on currents, cannot create field from run header");
299     return kFALSE;
300   }
301   //
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 !");
306       return kTRUE;
307     }
308     else {
309       AliInfo("Destroying existing B field instance!");
310       delete TGeoGlobalMagField::Instance();
311     }
312   }
313   //
314   AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
315                                          TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
316   if (fld) {
317     TGeoGlobalMagField::Instance()->SetField( fld );
318     TGeoGlobalMagField::Instance()->Lock();
319     AliInfo("Running with the B field constructed out of the Run Header !");
320     return kTRUE;
321   }
322   else {
323     AliError("Failed to create a B field map !");
324     return kFALSE;
325   }
326   //
327 }