]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDRun.cxx
py2ent added.
[u/mrichter/AliRoot.git] / STEER / AliESDRun.cxx
CommitLineData
d5ebf00e 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 **************************************************************************/
f009b5c1 15#include <TNamed.h>
8d218603 16#include <TGeoMatrix.h>
33fe5eb1 17#include <TGeoGlobalMagField.h>
d5ebf00e 18
19#include "AliESDRun.h"
20#include "AliESDVertex.h"
f009b5c1 21#include "AliLog.h"
33fe5eb1 22#include "AliMagF.h"
d5ebf00e 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
31ClassImp(AliESDRun)
32
33//______________________________________________________________________________
34AliESDRun::AliESDRun() :
694aad0c 35 TObject(),
33fe5eb1 36 fCurrentL3(0),
37 fCurrentDip(0),
38 fBeamEnergy(0),
694aad0c 39 fMagneticField(0),
d5ebf00e 40 fPeriodNumber(0),
694aad0c 41 fRunNumber(0),
f009b5c1 42 fRecoVersion(0),
33fe5eb1 43 fBeamType(""),
f009b5c1 44 fTriggerClasses(kNTriggerClasses)
d5ebf00e 45{
46 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
a2dedd16 47 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
48 fDiamondCovXY[1]=0.;
f009b5c1 49 fTriggerClasses.SetOwner(kTRUE);
8d218603 50 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
428557af 51 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
d5ebf00e 52}
53
54//______________________________________________________________________________
55AliESDRun::AliESDRun(const AliESDRun &esd) :
56 TObject(esd),
33fe5eb1 57 fCurrentL3(0),
58 fCurrentDip(0),
59 fBeamEnergy(0),
694aad0c 60 fMagneticField(esd.fMagneticField),
d5ebf00e 61 fPeriodNumber(esd.fPeriodNumber),
694aad0c 62 fRunNumber(esd.fRunNumber),
f009b5c1 63 fRecoVersion(esd.fRecoVersion),
33fe5eb1 64 fBeamType(""),
f009b5c1 65 fTriggerClasses(TObjArray(kNTriggerClasses))
d5ebf00e 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];
f009b5c1 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 }
8d218603 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 }
428557af 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 }
d5ebf00e 89}
90
91//______________________________________________________________________________
92AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
93{
94 // assigment operator
95 if(this!=&esd) {
96 TObject::operator=(esd);
97 fRunNumber=esd.fRunNumber;
8d218603 98 fPeriodNumber=esd.fPeriodNumber;
99 fRecoVersion=esd.fRecoVersion;
100 fMagneticField=esd.fMagneticField;
33fe5eb1 101 fBeamType = esd.fBeamType;
102 fCurrentL3 = esd.fCurrentL3;
103 fCurrentDip = esd.fCurrentDip;
104 fBeamEnergy = esd.fBeamEnergy;
8d218603 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 }
428557af 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 }
d5ebf00e 126 }
127 return *this;
128}
129
732a24fe 130void 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
8d218603 143//______________________________________________________________________________
144AliESDRun::~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 }
428557af 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 }
8d218603 156}
157
d5ebf00e 158void 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//______________________________________________________________________________
171void 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());
33fe5eb1 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)":"");
d5ebf00e 179 printf("Event from reconstruction version %d \n",fRecoVersion);
f009b5c1 180
181 printf("List of active trigger classes: ");
182 for(Int_t i = 0; i < kNTriggerClasses; i++) {
183 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
384e7a60 184 if (str) printf("%s ",str->GetName());
f009b5c1 185 }
186 printf("\n");
d5ebf00e 187}
188
189void AliESDRun::Reset()
190{
191 // reset data members
192 fRunNumber = 0;
193 fPeriodNumber = 0;
194 fRecoVersion = 0;
195 fMagneticField = 0;
196 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
a2dedd16 197 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
198 fDiamondCovXY[1]=0.;
f009b5c1 199 fTriggerClasses.Clear();
200}
201
202//______________________________________________________________________________
203void AliESDRun::SetTriggerClass(const char*name, Int_t index)
204{
205 // Fill the trigger class name
206 // into the corresponding array
207 if (index >= kNTriggerClasses || index < 0) {
208 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
209 return;
210 }
211
212 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
213}
214
215//______________________________________________________________________________
216const char* AliESDRun::GetTriggerClass(Int_t index) const
217{
218 // Get the trigger class name at
219 // specified position in the trigger mask
220 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
221 if (trclass)
222 return trclass->GetName();
223 else
224 return "";
225}
226
227//______________________________________________________________________________
228TString AliESDRun::GetActiveTriggerClasses() const
229{
230 // Construct and return
231 // the list of trigger classes
232 // which are present in the run
233 TString trclasses;
234 for(Int_t i = 0; i < kNTriggerClasses; i++) {
235 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
236 if (str) {
237 trclasses += " ";
238 trclasses += str->GetName();
239 trclasses += " ";
240 }
241 }
242
243 return trclasses;
244}
245
246//______________________________________________________________________________
247TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
248{
249 // Constructs and returns the
250 // list of trigger classes that
251 // have been fired. Uses the trigger
252 // class mask as an argument.
253 TString trclasses;
254 for(Int_t i = 0; i < kNTriggerClasses; i++) {
2c736180 255 if (mask & (1 << i)) {
f009b5c1 256 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
257 if (str) {
258 trclasses += " ";
259 trclasses += str->GetName();
260 trclasses += " ";
261 }
262 }
263 }
264
265 return trclasses;
d5ebf00e 266}
267
f009b5c1 268//______________________________________________________________________________
269Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
270{
271 // Checks if the trigger class
272 // identified by 'name' has been
273 // fired. Uses the trigger class mask.
274
275 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
276 if (!trclass) return kFALSE;
277
278 Int_t iclass = fTriggerClasses.IndexOf(trclass);
279 if (iclass < 0) return kFALSE;
280
2c736180 281 if (mask & (1 << iclass))
f009b5c1 282 return kTRUE;
283 else
284 return kFALSE;
285}
33fe5eb1 286
287//_____________________________________________________________________________
288Bool_t AliESDRun::InitMagneticField() const
289{
290 // Create mag field from stored information
291 //
292 if (!TestBit(kBInfoStored)) {
293 AliError("No information on currents, cannot create field from run header");
294 return kFALSE;
295 }
296 //
297 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
298 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
299 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
300 AliInfo("ExpertMode!!! Running with the externally locked B field !");
301 return kTRUE;
302 }
303 else {
304 AliInfo("Destroying existing B field instance!");
305 delete TGeoGlobalMagField::Instance();
306 }
307 }
308 //
309 AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
310 TestBit(kUniformBMap),fBeamEnergy,fBeamType.Data());
311 if (fld) {
312 TGeoGlobalMagField::Instance()->SetField( fld );
313 TGeoGlobalMagField::Instance()->Lock();
314 AliInfo("Running with the B field constructed out of the Run Header !");
315 return kTRUE;
316 }
317 else {
318 AliError("Failed to create a B field map !");
319 return kFALSE;
320 }
321 //
322}