1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // ALICE Reconstruction parameterization: //
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. //
26 ///////////////////////////////////////////////////////////////////////////////
29 #include "TObjArray.h"
31 #include "THashTable.h"
32 #include "AliDetectorRecoParam.h"
35 #include "AliRecoParam.h"
36 #include "AliRunInfo.h"
37 #include "AliEventInfo.h"
40 ClassImp(AliRecoParam)
42 TString AliRecoParam::fkgEventSpecieName[] = {"Default", "LowMultiplicity", "HighMultiplicity", "Cosmic", "Calibration", "Unknown"} ;
44 AliRecoParam::AliRecoParam():
46 fEventSpecie(kDefault)
48 // Default constructor
50 for(Int_t iDet = 0; iDet < kNDetectors; iDet++)
51 fDetRecoParams[iDet] = NULL;
52 for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) {
53 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
54 fDetRecoParamsIndex[iSpecie][iDet] = -1;
59 AliRecoParam::AliRecoParam(const AliRecoParam& par) :
61 fEventSpecie(par.fEventSpecie)
64 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
65 if (par.fDetRecoParams[iDet])
66 fDetRecoParams[iDet] = (TObjArray*)(par.fDetRecoParams[iDet]->Clone());
68 fDetRecoParams[iDet] = NULL;
70 for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) {
71 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
72 fDetRecoParamsIndex[iSpecie][iDet] = par.fDetRecoParamsIndex[iSpecie][iDet];
77 //_____________________________________________________________________________
78 AliRecoParam& AliRecoParam::operator = (const AliRecoParam& par)
80 // assignment operator
82 if(&par == this) return *this;
84 this->~AliRecoParam();
85 new(this) AliRecoParam(par);
89 AliRecoParam::~AliRecoParam(){
92 // Delete the array with the reco-param objects
93 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
94 if (fDetRecoParams[iDet]){
95 fDetRecoParams[iDet]->Delete();
96 delete fDetRecoParams[iDet];
101 Int_t AliRecoParam::AConvert(EventSpecie_t es)
103 //Converts EventSpecie_t into int
126 AliFatalClass(Form("Wrong event specie conversion %d", es)) ;
131 AliRecoParam::EventSpecie_t AliRecoParam::Convert(Int_t ies)
133 //Converts int into EventSpecie_t
134 AliRecoParam::EventSpecie_t es = kDefault ;
147 AliRecoParam::EventSpecie_t AliRecoParam::ConvertIndex(Int_t index)
149 //Converts index of lists into eventspecie
150 EventSpecie_t es = kDefault ;
173 void AliRecoParam::Print(Option_t *option) const {
175 // Print reconstruction setup
177 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
178 if (fDetRecoParams[iDet]){
179 printf("AliDetectorRecoParam objects for detector %d:\n",iDet);
180 Int_t nparam = fDetRecoParams[iDet]->GetEntriesFast();
181 for (Int_t iparam=0; iparam<nparam; iparam++){
182 AliDetectorRecoParam * param = (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(iparam);
183 if (!param) continue;
184 param->Print(option);
188 printf("No AliDetectorRecoParam objects specified for detector %d\n",iDet);
193 void AliRecoParam::SetEventSpecie(const AliRunInfo *runInfo, const AliEventInfo &evInfo,
194 const THashTable *cosmicTriggersList)
196 // Implemented according to the discussions
197 // and meetings with physics and trigger coordination
199 fEventSpecie = kDefault;
201 if (strcmp(runInfo->GetRunType(),"PHYSICS")) {
202 // Not a physics run, the event specie is set to kCalib
203 fEventSpecie = kCalib;
207 if (strcmp(runInfo->GetLHCState(),"STABLE_BEAMS") == 0) {
208 // In case of stable beams
209 if ((strcmp(runInfo->GetBeamType(),"A-A") == 0) ||
210 (strcmp(runInfo->GetBeamType(),"A-") == 0) ||
211 (strcmp(runInfo->GetBeamType(),"-A") == 0)) {
212 // Heavy ion run (any beam tha is not pp, the event specie is set to kHighMult
213 fEventSpecie = kHighMult;
215 else if ((strcmp(runInfo->GetBeamType(),"p-p") == 0) ||
216 (strcmp(runInfo->GetBeamType(),"p-") == 0) ||
217 (strcmp(runInfo->GetBeamType(),"-p") == 0) ||
218 (strcmp(runInfo->GetBeamType(),"P-P") == 0) ||
219 (strcmp(runInfo->GetBeamType(),"P-") == 0) ||
220 (strcmp(runInfo->GetBeamType(),"-P") == 0)) {
221 // Proton run, the event specie is set to kLowMult
222 fEventSpecie = kLowMult;
224 else if (strcmp(runInfo->GetBeamType(),"-") == 0) {
225 // No beams, we assume cosmic data
226 fEventSpecie = kCosmic;
228 else if (strcmp(runInfo->GetBeamType(),"UNKNOWN") == 0) {
229 // No LHC beam information is available, we the default
231 fEventSpecie = kDefault;
234 // Now we look into the trigger type in order to decide
235 // on the remaining cases (cosmic event within LHC run,
236 // calibration, for example TPC laser, triggers within physics run,
237 // special DAQ events considered as calibration etc...)
238 if (evInfo.GetEventType() != 7) {
239 // START_OF_*, END_OF_*, CALIBRATION etc events
240 fEventSpecie = kCalib;
244 TString triggerClasses = evInfo.GetTriggerClasses();
245 TObjArray* trClassArray = triggerClasses.Tokenize(" ");
246 Int_t nTrClasses = trClassArray->GetEntriesFast();
247 Bool_t cosmicTrigger = kFALSE,
248 calibTrigger = kFALSE,
249 otherTrigger = kFALSE;
250 for( Int_t i=0; i<nTrClasses; ++i ) {
251 TString trClass = ((TObjString*)trClassArray->At(i))->String();
253 if (trClass.BeginsWith("C0L")) {
254 // Calibration triggers always start with C0L
255 calibTrigger = kTRUE;
259 if (cosmicTriggersList) {
260 if (cosmicTriggersList->FindObject(trClass.Data())) {
261 // Cosmic trigger accorind to the table
263 cosmicTrigger = kTRUE;
264 AliDebug(1,Form("Trigger %s identified as cosmic according to the list defined in OCDB.",
269 AliDebug(1,"Cosmic trigger list is not provided, cosmic event specie is effectively disabled!");
272 otherTrigger = kTRUE;
276 fEventSpecie = kCalib;
279 if (cosmicTrigger && !otherTrigger) {
280 fEventSpecie = kCosmic;
284 // Here we have to add if we have other cases
285 // and also HLT info if any...
289 const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const
291 // Return AliDetectorRecoParam object for a given detector
292 // according to the event specie provided as an argument
293 if ( iDet >= kNDetectors) return NULL;
294 if (!fDetRecoParams[iDet]) return NULL;
295 if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL;
297 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
298 if (fEventSpecie & (1 << iBit)) {
299 if (fDetRecoParamsIndex[iBit][iDet] >= 0)
300 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[iBit][iDet]);
302 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
307 AliError(Form("Invalid event specie: %d!",fEventSpecie));
308 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
311 void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
313 // Add an instance of reco params object into
314 // the fDetRecoParams for detector iDet
315 // Updates the fDetRecoParams index
316 if (!fDetRecoParams[iDet]) fDetRecoParams[iDet] = new TObjArray;
317 fDetRecoParams[iDet]->AddLast(param);
318 Int_t index = fDetRecoParams[iDet]->GetLast();
321 Int_t specie = param->GetEventSpecie();
322 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
323 if (specie & (1 << iBit)) {
324 fDetRecoParamsIndex[iBit][iDet] = index;
329 Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray)
331 // Add an array of reconstruction parameter objects
332 // for a given detector
333 // Basic check on the consistency of the array
334 Bool_t defaultFound = kFALSE;
335 for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) {
336 AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i);
338 if (par->IsDefault()) defaultFound = kTRUE;
340 Int_t specie = par->GetEventSpecie();
341 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
342 if (specie & (1 << iBit)) {
343 fDetRecoParamsIndex[iBit][iDet] = i;
348 fDetRecoParams[iDet] = parArray;
353 const char* AliRecoParam::PrintEventSpecie() const
357 switch (fEventSpecie) {
359 return fkgEventSpecieName[0].Data() ;
362 return fkgEventSpecieName[1].Data() ;
365 return fkgEventSpecieName[2].Data() ;
368 return fkgEventSpecieName[3].Data() ;
371 return fkgEventSpecieName[4].Data() ;
374 return fkgEventSpecieName[5].Data() ;
379 const char * AliRecoParam::GetEventSpecieName(EventSpecie_t es)
383 return fkgEventSpecieName[0].Data() ;
386 return fkgEventSpecieName[1].Data() ;
389 return fkgEventSpecieName[2].Data() ;
392 return fkgEventSpecieName[3].Data() ;
395 return fkgEventSpecieName[4].Data() ;
398 return fkgEventSpecieName[5].Data() ;
403 const char * AliRecoParam::GetEventSpecieName(Int_t esIndex)
405 if ( esIndex >= 0 && esIndex < kNSpecies)
406 return fkgEventSpecieName[esIndex].Data() ;
408 return fkgEventSpecieName[kNSpecies].Data() ;