]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDRun.cxx
coverity warnings 15388 10083 10082 fixed
[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)
d443e5e9 49
d5ebf00e 50{
51 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
a2dedd16 52 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
53 fDiamondCovXY[1]=0.;
f009b5c1 54 fTriggerClasses.SetOwner(kTRUE);
b671618d 55 fMeanBeamInt[0][0]=fMeanBeamInt[0][1]=fMeanBeamInt[1][0]=fMeanBeamInt[1][1]=-1;
8d218603 56 for (Int_t m=0; m<kNPHOSMatrix; m++) fPHOSMatrix[m]=NULL;
428557af 57 for (Int_t sm=0; sm<kNEMCALMatrix; sm++) fEMCALMatrix[sm]=NULL;
d443e5e9 58 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=0.;
d5ebf00e 59}
60
61//______________________________________________________________________________
62AliESDRun::AliESDRun(const AliESDRun &esd) :
63 TObject(esd),
33fe5eb1 64 fCurrentL3(0),
65 fCurrentDip(0),
66 fBeamEnergy(0),
694aad0c 67 fMagneticField(esd.fMagneticField),
1c7554f9 68 fDiamondZ(esd.fDiamondZ),
69 fDiamondSig2Z(esd.fDiamondSig2Z),
d5ebf00e 70 fPeriodNumber(esd.fPeriodNumber),
694aad0c 71 fRunNumber(esd.fRunNumber),
f009b5c1 72 fRecoVersion(esd.fRecoVersion),
33fe5eb1 73 fBeamType(""),
7b649c02 74 fTriggerClasses(TObjArray(kNTriggerClasses)),
75 fDetInDAQ(0),
76 fDetInReco(0)
d5ebf00e 77{
78 // Copy constructor
79 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
80 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
f009b5c1 81
82 for(Int_t i = 0; i < kNTriggerClasses; i++) {
83 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
84 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
85 }
8d218603 86
87 for(Int_t m=0; m<kNPHOSMatrix; m++){
88 if(esd.fPHOSMatrix[m])
89 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
90 else
91 fPHOSMatrix[m]=NULL;
92 }
b671618d 93
94 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
95
428557af 96 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
97 if(esd.fEMCALMatrix[sm])
98 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
99 else
100 fEMCALMatrix[sm]=NULL;
101 }
d443e5e9 102 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
103
d5ebf00e 104}
105
106//______________________________________________________________________________
107AliESDRun& AliESDRun::operator=(const AliESDRun &esd)
108{
109 // assigment operator
110 if(this!=&esd) {
111 TObject::operator=(esd);
112 fRunNumber=esd.fRunNumber;
8d218603 113 fPeriodNumber=esd.fPeriodNumber;
114 fRecoVersion=esd.fRecoVersion;
115 fMagneticField=esd.fMagneticField;
1c7554f9 116 fDiamondZ=esd.fDiamondZ;
117 fDiamondSig2Z=esd.fDiamondSig2Z;
33fe5eb1 118 fBeamType = esd.fBeamType;
119 fCurrentL3 = esd.fCurrentL3;
120 fCurrentDip = esd.fCurrentDip;
121 fBeamEnergy = esd.fBeamEnergy;
8d218603 122 for (Int_t i=0; i<2; i++) fDiamondXY[i]=esd.fDiamondXY[i];
123 for (Int_t i=0; i<3; i++) fDiamondCovXY[i]=esd.fDiamondCovXY[i];
124 fTriggerClasses.Clear();
125 for(Int_t i = 0; i < kNTriggerClasses; i++) {
126 TNamed *str = (TNamed *)((esd.fTriggerClasses).At(i));
127 if (str) fTriggerClasses.AddAt(new TNamed(*str),i);
128 }
129
7b649c02 130 fDetInDAQ = esd.fDetInDAQ;
131 fDetInReco = esd.fDetInReco;
132
b671618d 133 for (int ib=2;ib--;) for (int it=2;it--;) fMeanBeamInt[ib][it] = esd.fMeanBeamInt[ib][it];
134
8d218603 135 for(Int_t m=0; m<kNPHOSMatrix; m++){
136 if(esd.fPHOSMatrix[m])
137 fPHOSMatrix[m]=new TGeoHMatrix(*(esd.fPHOSMatrix[m])) ;
138 else
139 fPHOSMatrix[m]=0;
140 }
428557af 141
142 for(Int_t sm=0; sm<kNEMCALMatrix; sm++){
143 if(esd.fEMCALMatrix[sm])
144 fEMCALMatrix[sm]=new TGeoHMatrix(*(esd.fEMCALMatrix[sm])) ;
145 else
146 fEMCALMatrix[sm]=0;
147 }
d5ebf00e 148 }
d443e5e9 149 for (Int_t i=0; i<kT0spreadSize;i++) fT0spread[i]=esd.fT0spread[i];
d5ebf00e 150 return *this;
151}
152
732a24fe 153void AliESDRun::Copy(TObject &obj) const{
154
155 // this overwrites the virtual TOBject::Copy()
156 // to allow run time copying without casting
157 // in AliESDEvent
158
159 if(this==&obj)return;
160 AliESDRun *robj = dynamic_cast<AliESDRun*>(&obj);
161 if(!robj)return; // not an aliesdrun
162 *robj = *this;
163
164}
165
8d218603 166//______________________________________________________________________________
167AliESDRun::~AliESDRun() {
168 // Destructor
169 // Delete PHOS position matrices
170 for(Int_t m=0; m<kNPHOSMatrix; m++) {
171 if(fPHOSMatrix[m]) delete fPHOSMatrix[m] ;
172 fPHOSMatrix[m] = NULL;
173 }
428557af 174 // Delete PHOS position matrices
175 for(Int_t sm=0; sm<kNEMCALMatrix; sm++) {
176 if(fEMCALMatrix[sm]) delete fEMCALMatrix[sm] ;
177 fEMCALMatrix[sm] = NULL;
178 }
8d218603 179}
180
d5ebf00e 181void AliESDRun::SetDiamond(const AliESDVertex *vertex) {
182 // set the interaction diamond
c7a22819 183 if (vertex) {
184 fDiamondXY[0]=vertex->GetXv();
185 fDiamondXY[1]=vertex->GetYv();
186 fDiamondZ=vertex->GetZv();
187 Double32_t cov[6];
188 vertex->GetCovMatrix(cov);
189 fDiamondCovXY[0]=cov[0];
190 fDiamondCovXY[1]=cov[1];
191 fDiamondCovXY[2]=cov[2];
192 fDiamondSig2Z=cov[5];
193 }
d5ebf00e 194}
195
196
197//______________________________________________________________________________
198void AliESDRun::Print(const Option_t *) const
199{
200 // Print some data members
1c7554f9 201 printf("Mean vertex in RUN %d: X=%.4f Y=%.4f Z=%.4f cm\n",
202 GetRunNumber(),GetDiamondX(),GetDiamondY(),GetDiamondZ());
33fe5eb1 203 printf("Beam Type: %s, Energy: %.1f GeV\n",fBeamType.IsNull() ? "N/A":fBeamType.Data(),fBeamEnergy);
204 printf("Magnetic field in IP= %f T | Currents: L3:%+.1f Dipole:%+.1f %s\n",
205 GetMagneticField(),fCurrentL3,fCurrentDip,TestBit(kUniformBMap) ? "(Uniform)":"");
d5ebf00e 206 printf("Event from reconstruction version %d \n",fRecoVersion);
f009b5c1 207
208 printf("List of active trigger classes: ");
209 for(Int_t i = 0; i < kNTriggerClasses; i++) {
210 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
384e7a60 211 if (str) printf("%s ",str->GetName());
f009b5c1 212 }
b671618d 213 printf("Mean intenstity for interacting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][0],fMeanBeamInt[1][0]);
214 printf("Mean intenstity for non-intecting : beam1:%+.3e beam2:%+.3e\n",fMeanBeamInt[0][1],fMeanBeamInt[1][1]);
f009b5c1 215 printf("\n");
d5ebf00e 216}
217
218void AliESDRun::Reset()
219{
220 // reset data members
221 fRunNumber = 0;
222 fPeriodNumber = 0;
223 fRecoVersion = 0;
224 fMagneticField = 0;
11be4f1c 225 fCurrentL3 = 0;
226 fCurrentDip = 0;
227 fBeamEnergy = 0;
228 fBeamType = "";
5cf76849 229 ResetBit(kBInfoStored|kUniformBMap|kConvSqrtSHalfGeV);
d5ebf00e 230 for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.;
a2dedd16 231 fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.;
232 fDiamondCovXY[1]=0.;
1c7554f9 233 fDiamondZ=0.;
234 fDiamondSig2Z=10.*10.;
f009b5c1 235 fTriggerClasses.Clear();
7b649c02 236 fDetInDAQ = 0;
237 fDetInReco = 0;
f009b5c1 238}
239
240//______________________________________________________________________________
241void AliESDRun::SetTriggerClass(const char*name, Int_t index)
242{
243 // Fill the trigger class name
244 // into the corresponding array
245 if (index >= kNTriggerClasses || index < 0) {
246 AliError(Form("Index (%d) is outside the allowed range (0,49)!",index));
247 return;
248 }
249
250 fTriggerClasses.AddAt(new TNamed(name,NULL),index);
251}
252
253//______________________________________________________________________________
254const char* AliESDRun::GetTriggerClass(Int_t index) const
255{
256 // Get the trigger class name at
257 // specified position in the trigger mask
258 TNamed *trclass = (TNamed *)fTriggerClasses.At(index);
259 if (trclass)
260 return trclass->GetName();
261 else
262 return "";
263}
264
265//______________________________________________________________________________
266TString AliESDRun::GetActiveTriggerClasses() const
267{
268 // Construct and return
269 // the list of trigger classes
270 // which are present in the run
271 TString trclasses;
272 for(Int_t i = 0; i < kNTriggerClasses; i++) {
273 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
274 if (str) {
275 trclasses += " ";
276 trclasses += str->GetName();
277 trclasses += " ";
278 }
279 }
280
281 return trclasses;
282}
283
284//______________________________________________________________________________
285TString AliESDRun::GetFiredTriggerClasses(ULong64_t mask) const
286{
287 // Constructs and returns the
288 // list of trigger classes that
289 // have been fired. Uses the trigger
290 // class mask as an argument.
291 TString trclasses;
292 for(Int_t i = 0; i < kNTriggerClasses; i++) {
a62d86d6 293 if (mask & (1ull << i)) {
f009b5c1 294 TNamed *str = (TNamed *)((fTriggerClasses).At(i));
295 if (str) {
296 trclasses += " ";
297 trclasses += str->GetName();
298 trclasses += " ";
299 }
300 }
301 }
302
303 return trclasses;
d5ebf00e 304}
305
f009b5c1 306//______________________________________________________________________________
307Bool_t AliESDRun::IsTriggerClassFired(ULong64_t mask, const char *name) const
308{
309 // Checks if the trigger class
310 // identified by 'name' has been
311 // fired. Uses the trigger class mask.
312
313 TNamed *trclass = (TNamed *)fTriggerClasses.FindObject(name);
314 if (!trclass) return kFALSE;
315
316 Int_t iclass = fTriggerClasses.IndexOf(trclass);
317 if (iclass < 0) return kFALSE;
318
a62d86d6 319 if (mask & (1ull << iclass))
f009b5c1 320 return kTRUE;
321 else
322 return kFALSE;
323}
33fe5eb1 324
325//_____________________________________________________________________________
326Bool_t AliESDRun::InitMagneticField() const
327{
328 // Create mag field from stored information
329 //
330 if (!TestBit(kBInfoStored)) {
331 AliError("No information on currents, cannot create field from run header");
332 return kFALSE;
333 }
334 //
335 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
336 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
337 AliInfo("ExpertMode!!! Information on magnet currents will be ignored !");
338 AliInfo("ExpertMode!!! Running with the externally locked B field !");
339 return kTRUE;
340 }
341 else {
342 AliInfo("Destroying existing B field instance!");
343 delete TGeoGlobalMagField::Instance();
344 }
345 }
346 //
347 AliMagF* fld = AliMagF::CreateFieldMap(fCurrentL3,fCurrentDip,AliMagF::kConvLHC,
5cf76849 348 TestBit(kUniformBMap), GetBeamEnergy(), GetBeamType());
33fe5eb1 349 if (fld) {
350 TGeoGlobalMagField::Instance()->SetField( fld );
351 TGeoGlobalMagField::Instance()->Lock();
352 AliInfo("Running with the B field constructed out of the Run Header !");
353 return kTRUE;
354 }
355 else {
356 AliError("Failed to create a B field map !");
357 return kFALSE;
358 }
359 //
360}
d443e5e9 361
362//_____________________________________________________________________________
363void AliESDRun::SetT0spread(Int_t i,Float_t t)
364{
365 //
366 // Setting the T0 spread value at index i
367 //
368
369 if ( (i>=0) && (i<kT0spreadSize)) {
370 fT0spread[i]=t;
371 } else {
372 AliError(Form("Index %d out of bound",i));
373 }
374 return;
375}
376
377//_____________________________________________________________________________
378void AliESDRun::SetT0spread(Float_t *t)
379{
380 //
381 // Setting the T0 spread values
382 //
383 if (t == 0x0){
384 AliError(Form("Null pointer passed"));
385 }
386 else{
387 for (Int_t i=0;i<kT0spreadSize;i++) fT0spread[i]=t[i];
388 }
389 return;
390}
391