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