]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDRun.cxx
AliReconstruction will store in the AliESDRun the average intensities
[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),
1c7554f9 40 fDiamondZ(0),
41 fDiamondSig2Z(0),
d5ebf00e 42 fPeriodNumber(0),
694aad0c 43 fRunNumber(0),
f009b5c1 44 fRecoVersion(0),
33fe5eb1 45 fBeamType(""),
7b649c02 46 fTriggerClasses(kNTriggerClasses),
47 fDetInDAQ(0),
48 fDetInReco(0)
d5ebf00e 49{
50 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
a2dedd16 51 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
52 fDiamondCovXY[1]=0.;
f009b5c1 53 fTriggerClasses.SetOwner(kTRUE);
8d218603 54 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
428557af 55 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
d5ebf00e 56}
57
58//______________________________________________________________________________
59AliESDRun::AliESDRun(const AliESDRun &esd) :
60 TObject(esd),
33fe5eb1 61 fCurrentL3(0),
62 fCurrentDip(0),
63 fBeamEnergy(0),
694aad0c 64 fMagneticField(esd.fMagneticField),
1c7554f9 65 fDiamondZ(esd.fDiamondZ),
66 fDiamondSig2Z(esd.fDiamondSig2Z),
d5ebf00e 67 fPeriodNumber(esd.fPeriodNumber),
694aad0c 68 fRunNumber(esd.fRunNumber),
f009b5c1 69 fRecoVersion(esd.fRecoVersion),
33fe5eb1 70 fBeamType(""),
7b649c02 71 fTriggerClasses(TObjArray(kNTriggerClasses)),
72 fDetInDAQ(0),
73 fDetInReco(0)
d5ebf00e 74{
75 // Copy constructor
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];
f009b5c1 78
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);
82 }
8d218603 83
84 for(Int_t m=0; m<kNPHOSMatrix; m++){
85 if(esd.fPHOSMatrix[m])
86 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
87 else
88 fPHOSMatrix[m]=NULL;
89 }
428557af 90
91 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
92 if(esd.fEMCALMatrix[sm])
93 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
94 else
95 fEMCALMatrix[sm]=NULL;
96 }
d5ebf00e 97}
98
99//______________________________________________________________________________
100AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
101{
102 // assigment operator
103 if(this!=&esd) {
104 TObject::operator=(esd);
105 fRunNumber=esd.fRunNumber;
8d218603 106 fPeriodNumber=esd.fPeriodNumber;
107 fRecoVersion=esd.fRecoVersion;
108 fMagneticField=esd.fMagneticField;
1c7554f9 109 fDiamondZ=esd.fDiamondZ;
110 fDiamondSig2Z=esd.fDiamondSig2Z;
33fe5eb1 111 fBeamType = esd.fBeamType;
112 fCurrentL3 = esd.fCurrentL3;
113 fCurrentDip = esd.fCurrentDip;
114 fBeamEnergy = esd.fBeamEnergy;
8d218603 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);
121 }
122
7b649c02 123 fDetInDAQ = esd.fDetInDAQ;
124 fDetInReco = esd.fDetInReco;
125
8d218603 126 for(Int_t m=0; m<kNPHOSMatrix; m++){
127 if(esd.fPHOSMatrix[m])
128 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
129 else
130 fPHOSMatrix[m]=0;
131 }
428557af 132
133 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
134 if(esd.fEMCALMatrix[sm])
135 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
136 else
137 fEMCALMatrix[sm]=0;
138 }
d5ebf00e 139 }
140 return *this;
141}
142
732a24fe 143void AliESDRun::Copy(TObject &obj) const{
144
145 // this overwrites the virtual TOBject::Copy()
146 // to allow run time copying without casting
147 // in AliESDEvent
148
149 if(this==&obj)return;
150 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
151 if(!robj)return; // not an aliesdrun
152 *robj = *this;
153
154}
155
8d218603 156//______________________________________________________________________________
157AliESDRun::~AliESDRun() {
158 // Destructor
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;
163 }
428557af 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;
168 }
8d218603 169}
170
d5ebf00e 171void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
172 // set the interaction diamond
173 fDiamondXY[0]=vertex->GetXv();
174 fDiamondXY[1]=vertex->GetYv();
1c7554f9 175 fDiamondZ=vertex->GetZv();
d5ebf00e 176 Double32_t cov[6];
177 vertex->GetCovMatrix(cov);
178 fDiamondCovXY[0]=cov[0];
179 fDiamondCovXY[1]=cov[1];
180 fDiamondCovXY[2]=cov[2];
1c7554f9 181 fDiamondSig2Z=cov[5];
d5ebf00e 182}
183
184
185//______________________________________________________________________________
186void AliESDRun::Print(const Option_t *) const
187{
188 // Print some data members
1c7554f9 189 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
190 GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
33fe5eb1 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)":"");
d5ebf00e 194 printf("Event from reconstruction version %d \n",fRecoVersion);
f009b5c1 195
196 printf("List of active trigger classes: ");
197 for(Int_t i = 0; i < kNTriggerClasses; i++) {
198 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
384e7a60 199 if (str) printf("%s ",str->GetName());
f009b5c1 200 }
201 printf("\n");
d5ebf00e 202}
203
204void AliESDRun::Reset()
205{
206 // reset data members
207 fRunNumber = 0;
208 fPeriodNumber = 0;
209 fRecoVersion = 0;
210 fMagneticField = 0;
11be4f1c 211 fCurrentL3 = 0;
212 fCurrentDip = 0;
213 fBeamEnergy = 0;
214 fBeamType = "";
5cf76849 215 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
d5ebf00e 216 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
a2dedd16 217 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
218 fDiamondCovXY[1]=0.;
1c7554f9 219 fDiamondZ=0.;
220 fDiamondSig2Z=10.*10.;
f009b5c1 221 fTriggerClasses.Clear();
7b649c02 222 fDetInDAQ = 0;
223 fDetInReco = 0;
f009b5c1 224}
225
226//______________________________________________________________________________
227void AliESDRun::SetTriggerClass(const char*name, Int_t index)
228{
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));
233 return;
234 }
235
236 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
237}
238
239//______________________________________________________________________________
240const char* AliESDRun::GetTriggerClass(Int_t index) const
241{
242 // Get the trigger class name at
243 // specified position in the trigger mask
244 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
245 if (trclass)
246 return trclass->GetName();
247 else
248 return "";
249}
250
251//______________________________________________________________________________
252TString AliESDRun::GetActiveTriggerClasses() const
253{
254 // Construct and return
255 // the list of trigger classes
256 // which are present in the run
257 TString trclasses;
258 for(Int_t i = 0; i < kNTriggerClasses; i++) {
259 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
260 if (str) {
261 trclasses += " ";
262 trclasses += str->GetName();
263 trclasses += " ";
264 }
265 }
266
267 return trclasses;
268}
269
270//______________________________________________________________________________
271TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
272{
273 // Constructs and returns the
274 // list of trigger classes that
275 // have been fired. Uses the trigger
276 // class mask as an argument.
277 TString trclasses;
278 for(Int_t i = 0; i < kNTriggerClasses; i++) {
a62d86d6 279 if (mask & (1ull << i)) {
f009b5c1 280 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
281 if (str) {
282 trclasses += " ";
283 trclasses += str->GetName();
284 trclasses += " ";
285 }
286 }
287 }
288
289 return trclasses;
d5ebf00e 290}
291
f009b5c1 292//______________________________________________________________________________
293Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
294{
295 // Checks if the trigger class
296 // identified by 'name' has been
297 // fired. Uses the trigger class mask.
298
299 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
300 if (!trclass) return kFALSE;
301
302 Int_t iclass = fTriggerClasses.IndexOf(trclass);
303 if (iclass < 0) return kFALSE;
304
a62d86d6 305 if (mask & (1ull << iclass))
f009b5c1 306 return kTRUE;
307 else
308 return kFALSE;
309}
33fe5eb1 310
311//_____________________________________________________________________________
312Bool_t AliESDRun::InitMagneticField() const
313{
314 // Create mag field from stored information
315 //
316 if (!TestBit(kBInfoStored)) {
317 AliError("No information on currents, cannot create field from run header");
318 return kFALSE;
319 }
320 //
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 !");
325 return kTRUE;
326 }
327 else {
328 AliInfo("Destroying existing B field instance!");
329 delete TGeoGlobalMagField::Instance();
330 }
331 }
332 //
333 AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
5cf76849 334 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
33fe5eb1 335 if (fld) {
336 TGeoGlobalMagField::Instance()->SetField( fld );
337 TGeoGlobalMagField::Instance()->Lock();
338 AliInfo("Running with the B field constructed out of the Run Header !");
339 return kTRUE;
340 }
341 else {
342 AliError("Failed to create a B field map !");
343 return kFALSE;
344 }
345 //
346}