]>
Commit | Line | Data |
---|---|---|
242b332c | 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 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
6769d914 | 19 | // ALICE Reconstruction parameterization: // |
20 | // // | |
21 | // // | |
22 | // Base Class for Detector reconstruction parameters // | |
23 | // Revision: cvetan.cheshkov@cern.ch 12/06/2008 // | |
24 | // Its structure has been revised and it is interfaced to AliEventInfo. // | |
242b332c | 25 | // // |
26 | /////////////////////////////////////////////////////////////////////////////// | |
27 | ||
5e232cd6 | 28 | #include "TClass.h" |
242b332c | 29 | #include "TObjArray.h" |
57acd2d2 | 30 | #include "TMath.h" |
77ba28ba | 31 | #include "THashTable.h" |
21625b40 | 32 | #include "TString.h" |
33 | #include "TRegexp.h" | |
242b332c | 34 | #include "AliDetectorRecoParam.h" |
35 | ||
6bcbb25b | 36 | #include "AliLog.h" |
242b332c | 37 | #include "AliRecoParam.h" |
48f5e52d | 38 | #include "AliRunInfo.h" |
39 | #include "AliEventInfo.h" | |
5e232cd6 | 40 | #include "AliLog.h" |
242b332c | 41 | |
242b332c | 42 | ClassImp(AliRecoParam) |
43 | ||
2ddda051 | 44 | TString AliRecoParam::fkgEventSpecieName[] = {"Default", "LowMultiplicity", "HighMultiplicity", "Cosmic", "Calib", "Unknown"} ; |
57acd2d2 | 45 | |
6769d914 | 46 | AliRecoParam::AliRecoParam(): |
7e88424f | 47 | TObject(), |
48 | fEventSpecie(kDefault) | |
242b332c | 49 | { |
6769d914 | 50 | // Default constructor |
51 | // ... | |
7e88424f | 52 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) |
53 | fDetRecoParams[iDet] = NULL; | |
54 | for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) { | |
55 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { | |
56 | fDetRecoParamsIndex[iSpecie][iDet] = -1; | |
57 | } | |
58 | } | |
242b332c | 59 | } |
60 | ||
54e51010 | 61 | AliRecoParam::AliRecoParam(const AliRecoParam& par) : |
62 | TObject(), | |
63 | fEventSpecie(par.fEventSpecie) | |
64 | { | |
65 | // copy constructor | |
66 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { | |
54e51010 | 67 | if (par.fDetRecoParams[iDet]) |
68 | fDetRecoParams[iDet] = (TObjArray*)(par.fDetRecoParams[iDet]->Clone()); | |
69 | else | |
70 | fDetRecoParams[iDet] = NULL; | |
71 | } | |
72 | for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) { | |
73 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { | |
74 | fDetRecoParamsIndex[iSpecie][iDet] = par.fDetRecoParamsIndex[iSpecie][iDet]; | |
75 | } | |
76 | } | |
77 | } | |
78 | ||
49ad11d0 | 79 | //_____________________________________________________________________________ |
80 | AliRecoParam& AliRecoParam::operator = (const AliRecoParam& par) | |
81 | { | |
82 | // assignment operator | |
83 | ||
84 | if(&par == this) return *this; | |
85 | ||
86 | this->~AliRecoParam(); | |
87 | new(this) AliRecoParam(par); | |
88 | return *this; | |
89 | } | |
90 | ||
242b332c | 91 | AliRecoParam::~AliRecoParam(){ |
6769d914 | 92 | // Destructor |
93 | // ... | |
94 | // Delete the array with the reco-param objects | |
7e88424f | 95 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { |
96 | if (fDetRecoParams[iDet]){ | |
97 | fDetRecoParams[iDet]->Delete(); | |
98 | delete fDetRecoParams[iDet]; | |
99 | } | |
242b332c | 100 | } |
101 | } | |
102 | ||
57acd2d2 | 103 | Int_t AliRecoParam::AConvert(EventSpecie_t es) |
104 | { | |
105 | //Converts EventSpecie_t into int | |
5e232cd6 | 106 | Int_t rv = -1 ; |
107 | switch (es) { | |
108 | case kDefault: | |
109 | rv = 0 ; | |
110 | break; | |
111 | case kLowMult: | |
112 | rv = 1 ; | |
113 | break; | |
114 | case kHighMult: | |
115 | rv = 2 ; | |
116 | break; | |
117 | case kCosmic: | |
118 | rv = 3 ; | |
119 | break; | |
120 | case kCalib: | |
121 | rv = 4 ; | |
122 | break; | |
123 | default: | |
124 | break; | |
125 | } | |
9d556894 | 126 | |
127 | if (rv < 0) | |
5e232cd6 | 128 | AliFatalClass(Form("Wrong event specie conversion %d", es)) ; |
9d556894 | 129 | |
130 | return rv ; | |
57acd2d2 | 131 | } |
132 | ||
133 | AliRecoParam::EventSpecie_t AliRecoParam::Convert(Int_t ies) | |
134 | { | |
135 | //Converts int into EventSpecie_t | |
5e232cd6 | 136 | AliRecoParam::EventSpecie_t es = kDefault ; |
137 | if ( ies >> 1) | |
57acd2d2 | 138 | es = kLowMult ; |
5e232cd6 | 139 | if ( ies >> 2) |
57acd2d2 | 140 | es = kHighMult ; |
5e232cd6 | 141 | if ( ies >> 3) |
57acd2d2 | 142 | es = kCosmic ; |
5e232cd6 | 143 | if ( ies >> 4) |
144 | es = kCalib ; | |
145 | ||
57acd2d2 | 146 | return es ; |
147 | } | |
148 | ||
5e232cd6 | 149 | AliRecoParam::EventSpecie_t AliRecoParam::ConvertIndex(Int_t index) |
150 | { | |
151 | //Converts index of lists into eventspecie | |
152 | EventSpecie_t es = kDefault ; | |
153 | switch (index) { | |
154 | case 0: | |
155 | es = kDefault ; | |
156 | break; | |
157 | case 1: | |
158 | es = kLowMult ; | |
159 | break; | |
160 | case 2: | |
161 | es = kHighMult ; | |
162 | break; | |
163 | case 3: | |
164 | es = kCosmic ; | |
165 | break; | |
166 | case 4: | |
167 | es = kCalib ; | |
168 | break; | |
169 | default: | |
170 | break; | |
171 | } | |
172 | return es ; | |
173 | } | |
174 | ||
6769d914 | 175 | void AliRecoParam::Print(Option_t *option) const { |
242b332c | 176 | // |
177 | // Print reconstruction setup | |
178 | // | |
7e88424f | 179 | for(Int_t iDet = 0; iDet < kNDetectors; iDet++) { |
180 | if (fDetRecoParams[iDet]){ | |
ac232c75 | 181 | printf("AliDetectorRecoParam objects for detector %d:\n",iDet); |
7e88424f | 182 | Int_t nparam = fDetRecoParams[iDet]->GetEntriesFast(); |
183 | for (Int_t iparam=0; iparam<nparam; iparam++){ | |
184 | AliDetectorRecoParam * param = (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(iparam); | |
185 | if (!param) continue; | |
186 | param->Print(option); | |
187 | } | |
188 | } | |
189 | else { | |
190 | printf("No AliDetectorRecoParam objects specified for detector %d\n",iDet); | |
191 | } | |
242b332c | 192 | } |
193 | } | |
194 | ||
77ba28ba | 195 | void AliRecoParam::SetEventSpecie(const AliRunInfo *runInfo, const AliEventInfo &evInfo, |
21625b40 | 196 | const THashTable *cosmicTriggersList) |
7e88424f | 197 | { |
21625b40 | 198 | // Implemented according to the discussions |
199 | // and meetings with physics and trigger coordination | |
48f5e52d | 200 | |
21625b40 | 201 | fEventSpecie = kDefault; |
48f5e52d | 202 | |
21625b40 | 203 | if (strcmp(runInfo->GetRunType(),"PHYSICS")) { |
204 | // Not a physics run, the event specie is set to kCalib | |
205 | fEventSpecie = kCalib; | |
206 | return; | |
52fc52f0 | 207 | } |
21625b40 | 208 | |
209 | // Special DAQ events considered as calibration events | |
210 | if (evInfo.GetEventType() != 7) { | |
211 | // START_OF_*, END_OF_*, CALIBRATION etc events | |
212 | fEventSpecie = kCalib; | |
213 | return; | |
48f5e52d | 214 | } |
21625b40 | 215 | |
216 | TString lhcState(runInfo->GetLHCState()); | |
217 | TString beamType(runInfo->GetBeamType()); | |
218 | TRegexp reStable("^STABLE[_ ]BEAMS$"); | |
219 | TRegexp reASthg("^A-"); | |
220 | TRegexp reSthgA(".*-A$"); | |
221 | TRegexp repSthg("^[pP]-.*"); | |
222 | TRegexp reSthgp(".*-[pP]$"); | |
223 | ||
224 | if(lhcState.Index(reStable)==0){ | |
de90f40d | 225 | if(beamType.Index(repSthg)==0 || beamType.Index(reSthgp)==0){ |
21625b40 | 226 | // Proton run, the event specie is set to kLowMult |
227 | fEventSpecie = kLowMult; | |
de90f40d | 228 | }else if(beamType.Index(reASthg)==0 || beamType.Index(reSthgA)==0){ |
229 | // Heavy ion run (any beam that is not pp, the event specie is set to kHighMult | |
230 | fEventSpecie = kHighMult; | |
231 | } | |
2b408ca9 | 232 | } |
233 | if(beamType==TString("-")){ | |
21625b40 | 234 | // No beams, we assume cosmic data |
235 | fEventSpecie = kCosmic; | |
48f5e52d | 236 | } |
48f5e52d | 237 | |
238 | // Now we look into the trigger type in order to decide | |
239 | // on the remaining cases (cosmic event within LHC run, | |
3732bec6 | 240 | // calibration, for example TPC laser, triggers within physics run |
48f5e52d | 241 | TString triggerClasses = evInfo.GetTriggerClasses(); |
242 | TObjArray* trClassArray = triggerClasses.Tokenize(" "); | |
243 | Int_t nTrClasses = trClassArray->GetEntriesFast(); | |
244 | Bool_t cosmicTrigger = kFALSE, | |
21625b40 | 245 | calibTrigger = kFALSE, |
246 | otherTrigger = kFALSE; | |
48f5e52d | 247 | for( Int_t i=0; i<nTrClasses; ++i ) { |
21625b40 | 248 | TString trClass = ((TObjString*)trClassArray->At(i))->String(); |
4e0a640f | 249 | |
21625b40 | 250 | if (trClass.BeginsWith("C0L")) { |
251 | // Calibration triggers always start with C0L | |
252 | calibTrigger = kTRUE; | |
253 | continue; | |
254 | } | |
4e0a640f | 255 | |
21625b40 | 256 | if (cosmicTriggersList) { |
257 | if (cosmicTriggersList->FindObject(trClass.Data())) { | |
258 | // Cosmic trigger accorind to the table | |
259 | // provided in OCDB | |
260 | cosmicTrigger = kTRUE; | |
261 | AliDebug(1,Form("Trigger %s identified as cosmic according to the list defined in OCDB.", | |
262 | trClass.Data())); | |
263 | continue; | |
264 | } | |
265 | } | |
266 | else { | |
267 | AliDebug(1,"Cosmic trigger list is not provided, cosmic event specie is effectively disabled!"); | |
4e0a640f | 268 | } |
4e0a640f | 269 | |
21625b40 | 270 | otherTrigger = kTRUE; |
48f5e52d | 271 | } |
3c66dd72 | 272 | delete trClassArray; |
48f5e52d | 273 | |
4e0a640f | 274 | if (calibTrigger) { |
21625b40 | 275 | fEventSpecie = kCalib; |
276 | return; | |
48f5e52d | 277 | } |
4e0a640f | 278 | if (cosmicTrigger && !otherTrigger) { |
21625b40 | 279 | fEventSpecie = kCosmic; |
280 | return; | |
48f5e52d | 281 | } |
48f5e52d | 282 | |
283 | // Here we have to add if we have other cases | |
284 | // and also HLT info if any... | |
7e88424f | 285 | } |
286 | ||
287 | const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const | |
288 | { | |
289 | // Return AliDetectorRecoParam object for a given detector | |
290 | // according to the event specie provided as an argument | |
a00021a7 | 291 | if ( iDet >= kNDetectors) return NULL; |
7e88424f | 292 | if (!fDetRecoParams[iDet]) return NULL; |
293 | if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL; | |
294 | ||
295 | for(Int_t iBit = 0; iBit < kNSpecies; iBit++) { | |
296 | if (fEventSpecie & (1 << iBit)) { | |
297 | if (fDetRecoParamsIndex[iBit][iDet] >= 0) | |
298 | return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[iBit][iDet]); | |
c7a07b9c | 299 | else if (fDetRecoParamsIndex[0][iDet] >= 0) |
7e88424f | 300 | return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]); |
c7a07b9c | 301 | else { |
302 | AliError(Form("no RecoParam set for detector %d", iDet)); | |
303 | return NULL; | |
304 | } | |
7e88424f | 305 | } |
306 | } | |
6bcbb25b | 307 | |
7e88424f | 308 | // Default one |
309 | AliError(Form("Invalid event specie: %d!",fEventSpecie)); | |
c7a07b9c | 310 | if (fDetRecoParamsIndex[0][iDet] >= 0) |
311 | return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]); | |
312 | ||
313 | AliError(Form("no RecoParam set for detector %d", iDet)); | |
314 | return NULL; | |
6bcbb25b | 315 | } |
316 | ||
7e88424f | 317 | void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param) |
318 | { | |
6769d914 | 319 | // Add an instance of reco params object into |
7e88424f | 320 | // the fDetRecoParams for detector iDet |
321 | // Updates the fDetRecoParams index | |
322 | if (!fDetRecoParams[iDet]) fDetRecoParams[iDet] = new TObjArray; | |
323 | fDetRecoParams[iDet]->AddLast(param); | |
324 | Int_t index = fDetRecoParams[iDet]->GetLast(); | |
325 | ||
326 | // Index | |
327 | Int_t specie = param->GetEventSpecie(); | |
328 | for(Int_t iBit = 0; iBit < kNSpecies; iBit++) { | |
329 | if (specie & (1 << iBit)) { | |
330 | fDetRecoParamsIndex[iBit][iDet] = index; | |
331 | } | |
332 | } | |
333 | } | |
334 | ||
335 | Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray) | |
336 | { | |
337 | // Add an array of reconstruction parameter objects | |
338 | // for a given detector | |
339 | // Basic check on the consistency of the array | |
340 | Bool_t defaultFound = kFALSE; | |
4018c387 | 341 | if (!parArray) return defaultFound; |
7e88424f | 342 | for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) { |
343 | AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i); | |
344 | if (!par) continue; | |
345 | if (par->IsDefault()) defaultFound = kTRUE; | |
3d0847a7 | 346 | |
347 | Int_t specie = par->GetEventSpecie(); | |
348 | for(Int_t iBit = 0; iBit < kNSpecies; iBit++) { | |
349 | if (specie & (1 << iBit)) { | |
350 | fDetRecoParamsIndex[iBit][iDet] = i; | |
351 | } | |
352 | } | |
353 | } | |
7e88424f | 354 | |
355 | fDetRecoParams[iDet] = parArray; | |
356 | ||
357 | return defaultFound; | |
242b332c | 358 | } |
48f5e52d | 359 | |
360 | const char* AliRecoParam::PrintEventSpecie() const | |
361 | { | |
362 | // Print the current | |
363 | // event specie | |
364 | switch (fEventSpecie) { | |
365 | case kDefault: | |
57acd2d2 | 366 | return fkgEventSpecieName[0].Data() ; |
48f5e52d | 367 | break; |
368 | case kLowMult: | |
57acd2d2 | 369 | return fkgEventSpecieName[1].Data() ; |
48f5e52d | 370 | break; |
371 | case kHighMult: | |
57acd2d2 | 372 | return fkgEventSpecieName[2].Data() ; |
48f5e52d | 373 | break; |
374 | case kCosmic: | |
57acd2d2 | 375 | return fkgEventSpecieName[3].Data() ; |
48f5e52d | 376 | break; |
377 | case kCalib: | |
57acd2d2 | 378 | return fkgEventSpecieName[4].Data() ; |
48f5e52d | 379 | break; |
380 | default: | |
57acd2d2 | 381 | return fkgEventSpecieName[5].Data() ; |
48f5e52d | 382 | break; |
383 | } | |
384 | } | |
57acd2d2 | 385 | |
386 | const char * AliRecoParam::GetEventSpecieName(EventSpecie_t es) | |
387 | { | |
388 | switch (es) { | |
389 | case kDefault: | |
390 | return fkgEventSpecieName[0].Data() ; | |
391 | break; | |
392 | case kLowMult: | |
393 | return fkgEventSpecieName[1].Data() ; | |
394 | break; | |
395 | case kHighMult: | |
396 | return fkgEventSpecieName[2].Data() ; | |
397 | break; | |
398 | case kCosmic: | |
399 | return fkgEventSpecieName[3].Data() ; | |
400 | break; | |
401 | case kCalib: | |
402 | return fkgEventSpecieName[4].Data() ; | |
403 | break; | |
404 | default: | |
405 | return fkgEventSpecieName[5].Data() ; | |
406 | break; | |
407 | } | |
408 | } | |
409 | ||
410 | const char * AliRecoParam::GetEventSpecieName(Int_t esIndex) | |
411 | { | |
412 | if ( esIndex >= 0 && esIndex < kNSpecies) | |
413 | return fkgEventSpecieName[esIndex].Data() ; | |
414 | else | |
415 | return fkgEventSpecieName[kNSpecies].Data() ; | |
416 | } |