for p-A and A-p the event specie is set to high multiplicity
[u/mrichter/AliRoot.git] / STEER / 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"
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 42ClassImp(AliRecoParam)
43
2ddda051 44TString AliRecoParam::fkgEventSpecieName[] = {"Default", "LowMultiplicity", "HighMultiplicity", "Cosmic", "Calib", "Unknown"} ;
57acd2d2 45
6769d914 46AliRecoParam::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 61AliRecoParam::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//_____________________________________________________________________________
80AliRecoParam& 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 91AliRecoParam::~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 103Int_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
133AliRecoParam::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 149AliRecoParam::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 175void 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 195void 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){
225 if(beamType.Index(reASthg)==0 || beamType.Index(reSthgA)==0){
226 // Heavy ion run (any beam that is not pp, the event specie is set to kHighMult
227 fEventSpecie = kHighMult;
228 }else if(beamType.Index(repSthg)==0 || beamType.Index(reSthgp)==0){
229 // Proton run, the event specie is set to kLowMult
230 fEventSpecie = kLowMult;
231 }
232 }else if(beamType==TString("-")){
233 // No beams, we assume cosmic data
234 fEventSpecie = kCosmic;
48f5e52d 235 }
48f5e52d 236
237 // Now we look into the trigger type in order to decide
238 // on the remaining cases (cosmic event within LHC run,
3732bec6 239 // calibration, for example TPC laser, triggers within physics run
48f5e52d 240 TString triggerClasses = evInfo.GetTriggerClasses();
241 TObjArray* trClassArray = triggerClasses.Tokenize(" ");
242 Int_t nTrClasses = trClassArray->GetEntriesFast();
243 Bool_t cosmicTrigger = kFALSE,
21625b40 244 calibTrigger = kFALSE,
245 otherTrigger = kFALSE;
48f5e52d 246 for( Int_t i=0; i<nTrClasses; ++i ) {
21625b40 247 TString trClass = ((TObjString*)trClassArray->At(i))->String();
4e0a640f 248
21625b40 249 if (trClass.BeginsWith("C0L")) {
250 // Calibration triggers always start with C0L
251 calibTrigger = kTRUE;
252 continue;
253 }
4e0a640f 254
21625b40 255 if (cosmicTriggersList) {
256 if (cosmicTriggersList->FindObject(trClass.Data())) {
257 // Cosmic trigger accorind to the table
258 // provided in OCDB
259 cosmicTrigger = kTRUE;
260 AliDebug(1,Form("Trigger %s identified as cosmic according to the list defined in OCDB.",
261 trClass.Data()));
262 continue;
263 }
264 }
265 else {
266 AliDebug(1,"Cosmic trigger list is not provided, cosmic event specie is effectively disabled!");
4e0a640f 267 }
4e0a640f 268
21625b40 269 otherTrigger = kTRUE;
48f5e52d 270 }
3c66dd72 271 delete trClassArray;
48f5e52d 272
4e0a640f 273 if (calibTrigger) {
21625b40 274 fEventSpecie = kCalib;
275 return;
48f5e52d 276 }
4e0a640f 277 if (cosmicTrigger && !otherTrigger) {
21625b40 278 fEventSpecie = kCosmic;
279 return;
48f5e52d 280 }
48f5e52d 281
282 // Here we have to add if we have other cases
283 // and also HLT info if any...
7e88424f 284}
285
286const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const
287{
288 // Return AliDetectorRecoParam object for a given detector
289 // according to the event specie provided as an argument
a00021a7 290 if ( iDet >= kNDetectors) return NULL;
7e88424f 291 if (!fDetRecoParams[iDet]) return NULL;
292 if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL;
293
294 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
295 if (fEventSpecie & (1 << iBit)) {
296 if (fDetRecoParamsIndex[iBit][iDet] >= 0)
297 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[iBit][iDet]);
c7a07b9c 298 else if (fDetRecoParamsIndex[0][iDet] >= 0)
7e88424f 299 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
c7a07b9c 300 else {
301 AliError(Form("no RecoParam set for detector %d", iDet));
302 return NULL;
303 }
7e88424f 304 }
305 }
6bcbb25b 306
7e88424f 307 // Default one
308 AliError(Form("Invalid event specie: %d!",fEventSpecie));
c7a07b9c 309 if (fDetRecoParamsIndex[0][iDet] >= 0)
310 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
311
312 AliError(Form("no RecoParam set for detector %d", iDet));
313 return NULL;
6bcbb25b 314}
315
7e88424f 316void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
317{
6769d914 318 // Add an instance of reco params object into
7e88424f 319 // the fDetRecoParams for detector iDet
320 // Updates the fDetRecoParams index
321 if (!fDetRecoParams[iDet]) fDetRecoParams[iDet] = new TObjArray;
322 fDetRecoParams[iDet]->AddLast(param);
323 Int_t index = fDetRecoParams[iDet]->GetLast();
324
325 // Index
326 Int_t specie = param->GetEventSpecie();
327 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
328 if (specie & (1 << iBit)) {
329 fDetRecoParamsIndex[iBit][iDet] = index;
330 }
331 }
332}
333
334Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray)
335{
336 // Add an array of reconstruction parameter objects
337 // for a given detector
338 // Basic check on the consistency of the array
339 Bool_t defaultFound = kFALSE;
4018c387 340 if (!parArray) return defaultFound;
7e88424f 341 for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) {
342 AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i);
343 if (!par) continue;
344 if (par->IsDefault()) defaultFound = kTRUE;
3d0847a7 345
346 Int_t specie = par->GetEventSpecie();
347 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
348 if (specie & (1 << iBit)) {
349 fDetRecoParamsIndex[iBit][iDet] = i;
350 }
351 }
352 }
7e88424f 353
354 fDetRecoParams[iDet] = parArray;
355
356 return defaultFound;
242b332c 357}
48f5e52d 358
359const char* AliRecoParam::PrintEventSpecie() const
360{
361 // Print the current
362 // event specie
363 switch (fEventSpecie) {
364 case kDefault:
57acd2d2 365 return fkgEventSpecieName[0].Data() ;
48f5e52d 366 break;
367 case kLowMult:
57acd2d2 368 return fkgEventSpecieName[1].Data() ;
48f5e52d 369 break;
370 case kHighMult:
57acd2d2 371 return fkgEventSpecieName[2].Data() ;
48f5e52d 372 break;
373 case kCosmic:
57acd2d2 374 return fkgEventSpecieName[3].Data() ;
48f5e52d 375 break;
376 case kCalib:
57acd2d2 377 return fkgEventSpecieName[4].Data() ;
48f5e52d 378 break;
379 default:
57acd2d2 380 return fkgEventSpecieName[5].Data() ;
48f5e52d 381 break;
382 }
383}
57acd2d2 384
385const char * AliRecoParam::GetEventSpecieName(EventSpecie_t es)
386{
387 switch (es) {
388 case kDefault:
389 return fkgEventSpecieName[0].Data() ;
390 break;
391 case kLowMult:
392 return fkgEventSpecieName[1].Data() ;
393 break;
394 case kHighMult:
395 return fkgEventSpecieName[2].Data() ;
396 break;
397 case kCosmic:
398 return fkgEventSpecieName[3].Data() ;
399 break;
400 case kCalib:
401 return fkgEventSpecieName[4].Data() ;
402 break;
403 default:
404 return fkgEventSpecieName[5].Data() ;
405 break;
406 }
407}
408
409const char * AliRecoParam::GetEventSpecieName(Int_t esIndex)
410{
411 if ( esIndex >= 0 && esIndex < kNSpecies)
412 return fkgEventSpecieName[esIndex].Data() ;
413 else
414 return fkgEventSpecieName[kNSpecies].Data() ;
415}