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