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"
34 #include "AliDetectorRecoParam.h"
37 #include "AliRecoParam.h"
38 #include "AliRunInfo.h"
39 #include "AliEventInfo.h"
42 ClassImp(AliRecoParam)
44 TString AliRecoParam::fkgEventSpecieName[] = {"Default", "LowMultiplicity", "HighMultiplicity", "Cosmic", "Calib", "Unknown"} ;
46 AliRecoParam::AliRecoParam():
48 fEventSpecie(kDefault)
50 // Default constructor
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;
61 AliRecoParam::AliRecoParam(const AliRecoParam& par) :
63 fEventSpecie(par.fEventSpecie)
66 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
67 if (par.fDetRecoParams[iDet])
68 fDetRecoParams[iDet] = (TObjArray*)(par.fDetRecoParams[iDet]->Clone());
70 fDetRecoParams[iDet] = NULL;
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];
79 //_____________________________________________________________________________
80 AliRecoParam& AliRecoParam::operator = (const AliRecoParam& par)
82 // assignment operator
84 if(&par == this) return *this;
86 this->~AliRecoParam();
87 new(this) AliRecoParam(par);
91 AliRecoParam::~AliRecoParam(){
94 // Delete the array with the reco-param objects
95 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
96 if (fDetRecoParams[iDet]){
97 fDetRecoParams[iDet]->Delete();
98 delete fDetRecoParams[iDet];
103 Int_t AliRecoParam::AConvert(EventSpecie_t es)
105 //Converts EventSpecie_t into int
128 AliFatalClass(Form("Wrong event specie conversion %d", es)) ;
133 AliRecoParam::EventSpecie_t AliRecoParam::Convert(Int_t ies)
135 //Converts int into EventSpecie_t
136 AliRecoParam::EventSpecie_t es = kDefault ;
149 AliRecoParam::EventSpecie_t AliRecoParam::ConvertIndex(Int_t index)
151 //Converts index of lists into eventspecie
152 EventSpecie_t es = kDefault ;
175 void AliRecoParam::Print(Option_t *option) const {
177 // Print reconstruction setup
179 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
180 if (fDetRecoParams[iDet]){
181 printf("AliDetectorRecoParam objects for detector %d:\n",iDet);
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);
190 printf("No AliDetectorRecoParam objects specified for detector %d\n",iDet);
195 void AliRecoParam::SetEventSpecie(const AliRunInfo *runInfo, const AliEventInfo &evInfo,
196 const THashTable *cosmicTriggersList)
198 // Implemented according to the discussions
199 // and meetings with physics and trigger coordination
201 fEventSpecie = kDefault;
203 if (strcmp(runInfo->GetRunType(),"PHYSICS")) {
204 // Not a physics run, the event specie is set to kCalib
205 fEventSpecie = kCalib;
209 // Special DAQ events considered as calibration events
210 if (evInfo.GetEventType() != 7) {
211 // START_OF_*, END_OF_*, CALIBRATION etc events
212 fEventSpecie = kCalib;
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]$");
224 if(lhcState.Index(reStable)==0){
225 if(beamType.Index(repSthg)==0 || beamType.Index(reSthgp)==0){
226 // Proton run, the event specie is set to kLowMult
227 fEventSpecie = kLowMult;
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;
233 if(beamType==TString("-")){
234 // No beams, we assume cosmic data
235 fEventSpecie = kCosmic;
238 // Now we look into the trigger type in order to decide
239 // on the remaining cases (cosmic event within LHC run,
240 // calibration, for example TPC laser, triggers within physics run
241 TString triggerClasses = evInfo.GetTriggerClasses();
242 TObjArray* trClassArray = triggerClasses.Tokenize(" ");
243 Int_t nTrClasses = trClassArray->GetEntriesFast();
244 Bool_t cosmicTrigger = kFALSE,
245 calibTrigger = kFALSE,
246 otherTrigger = kFALSE;
247 for( Int_t i=0; i<nTrClasses; ++i ) {
248 TString trClass = ((TObjString*)trClassArray->At(i))->String();
250 if (trClass.BeginsWith("C0L")) {
251 // Calibration triggers always start with C0L
252 calibTrigger = kTRUE;
256 if (cosmicTriggersList) {
257 if (cosmicTriggersList->FindObject(trClass.Data())) {
258 // Cosmic trigger accorind to the table
260 cosmicTrigger = kTRUE;
261 AliDebug(1,Form("Trigger %s identified as cosmic according to the list defined in OCDB.",
267 AliDebug(1,"Cosmic trigger list is not provided, cosmic event specie is effectively disabled!");
270 otherTrigger = kTRUE;
275 fEventSpecie = kCalib;
278 if (cosmicTrigger && !otherTrigger) {
279 fEventSpecie = kCosmic;
283 // Here we have to add if we have other cases
284 // and also HLT info if any...
287 const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const
289 // Return AliDetectorRecoParam object for a given detector
290 // according to the event specie provided as an argument
291 if ( iDet >= kNDetectors) return NULL;
292 if (!fDetRecoParams[iDet]) return NULL;
293 if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL;
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]);
299 else if (fDetRecoParamsIndex[0][iDet] >= 0)
300 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
302 AliError(Form("no RecoParam set for detector %d", iDet));
309 AliError(Form("Invalid event specie: %d!",fEventSpecie));
310 if (fDetRecoParamsIndex[0][iDet] >= 0)
311 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
313 AliError(Form("no RecoParam set for detector %d", iDet));
317 void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
319 // Add an instance of reco params object into
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();
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;
335 Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray)
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;
341 if (!parArray) return defaultFound;
342 for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) {
343 AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i);
345 if (par->IsDefault()) defaultFound = kTRUE;
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;
355 fDetRecoParams[iDet] = parArray;
360 const char* AliRecoParam::PrintEventSpecie() const
364 switch (fEventSpecie) {
366 return fkgEventSpecieName[0].Data() ;
369 return fkgEventSpecieName[1].Data() ;
372 return fkgEventSpecieName[2].Data() ;
375 return fkgEventSpecieName[3].Data() ;
378 return fkgEventSpecieName[4].Data() ;
381 return fkgEventSpecieName[5].Data() ;
386 const char * AliRecoParam::GetEventSpecieName(EventSpecie_t es)
390 return fkgEventSpecieName[0].Data() ;
393 return fkgEventSpecieName[1].Data() ;
396 return fkgEventSpecieName[2].Data() ;
399 return fkgEventSpecieName[3].Data() ;
402 return fkgEventSpecieName[4].Data() ;
405 return fkgEventSpecieName[5].Data() ;
410 const char * AliRecoParam::GetEventSpecieName(Int_t esIndex)
412 if ( esIndex >= 0 && esIndex < kNSpecies)
413 return fkgEventSpecieName[esIndex].Data() ;
415 return fkgEventSpecieName[kNSpecies].Data() ;