]>
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(""), |
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 | //______________________________________________________________________________ | |
55 | AliESDRun::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 | //______________________________________________________________________________ | |
92 | AliESDRun& 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 | 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 | ||
8d218603 | 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 | } | |
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 | 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()); | |
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 | ||
189 | void AliESDRun::Reset() | |
190 | { | |
191 | // reset data members | |
192 | fRunNumber = 0; | |
193 | fPeriodNumber = 0; | |
194 | fRecoVersion = 0; | |
195 | fMagneticField = 0; | |
11be4f1c | 196 | fCurrentL3 = 0; |
197 | fCurrentDip = 0; | |
198 | fBeamEnergy = 0; | |
199 | fBeamType = ""; | |
200 | ResetBit(kBInfoStored|kUniformBMap); | |
d5ebf00e | 201 | for (Int_t i=0; i<2; i++) fDiamondXY[i]=0.; |
a2dedd16 | 202 | fDiamondCovXY[0]=fDiamondCovXY[2]=3.*3.; |
203 | fDiamondCovXY[1]=0.; | |
f009b5c1 | 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++) { | |
2c736180 | 260 | if (mask & (1 << i)) { |
f009b5c1 | 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; | |
d5ebf00e | 271 | } |
272 | ||
f009b5c1 | 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 | ||
2c736180 | 286 | if (mask & (1 << iclass)) |
f009b5c1 | 287 | return kTRUE; |
288 | else | |
289 | return kFALSE; | |
290 | } | |
33fe5eb1 | 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),fBeamEnergy,fBeamType.Data()); | |
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 | } |