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 ///////////////////////////////////////////////////////////////////////////////
28 #include "TObjArray.h"
30 #include "AliDetectorRecoParam.h"
33 #include "AliRecoParam.h"
34 #include "AliRunInfo.h"
35 #include "AliEventInfo.h"
37 ClassImp(AliRecoParam)
39 TString AliRecoParam::fkgEventSpecieName[] = {"Default", "LowMultiplicity", "HighMultiplicity", "Cosmic", "Calibration", "Unknown"} ;
41 AliRecoParam::AliRecoParam():
43 fEventSpecie(kDefault)
45 // Default constructor
47 for(Int_t iDet = 0; iDet < kNDetectors; iDet++)
48 fDetRecoParams[iDet] = NULL;
49 for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) {
50 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
51 fDetRecoParamsIndex[iSpecie][iDet] = -1;
56 AliRecoParam::AliRecoParam(const AliRecoParam& par) :
58 fEventSpecie(par.fEventSpecie)
61 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
62 if (par.fDetRecoParams[iDet])
63 fDetRecoParams[iDet] = (TObjArray*)(par.fDetRecoParams[iDet]->Clone());
65 fDetRecoParams[iDet] = NULL;
67 for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) {
68 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
69 fDetRecoParamsIndex[iSpecie][iDet] = par.fDetRecoParamsIndex[iSpecie][iDet];
74 //_____________________________________________________________________________
75 AliRecoParam& AliRecoParam::operator = (const AliRecoParam& par)
77 // assignment operator
79 if(&par == this) return *this;
81 this->~AliRecoParam();
82 new(this) AliRecoParam(par);
86 AliRecoParam::~AliRecoParam(){
89 // Delete the array with the reco-param objects
90 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
91 if (fDetRecoParams[iDet]){
92 fDetRecoParams[iDet]->Delete();
93 delete fDetRecoParams[iDet];
98 Int_t AliRecoParam::AConvert(EventSpecie_t es)
100 //Converts EventSpecie_t into int
101 return static_cast<Int_t>(TMath::Log2(es)) ;
105 AliRecoParam::EventSpecie_t AliRecoParam::Convert(Int_t ies)
107 //Converts int into EventSpecie_t
108 AliRecoParam::EventSpecie_t es = AliRecoParam::kDefault ;
110 Int_t i = (Int_t)TMath::Power(2, ies) ;
112 if ( i == AliRecoParam::kLowMult)
114 else if ( i == AliRecoParam::kHighMult)
116 else if ( i == AliRecoParam::kCosmic)
118 else if ( i == AliRecoParam::kCalib)
124 void AliRecoParam::Print(Option_t *option) const {
126 // Print reconstruction setup
128 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
129 if (fDetRecoParams[iDet]){
130 printf("AliDetectorRecoParam objects for detector %d:\n",iDet);
131 Int_t nparam = fDetRecoParams[iDet]->GetEntriesFast();
132 for (Int_t iparam=0; iparam<nparam; iparam++){
133 AliDetectorRecoParam * param = (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(iparam);
134 if (!param) continue;
135 param->Print(option);
139 printf("No AliDetectorRecoParam objects specified for detector %d\n",iDet);
144 void AliRecoParam::SetEventSpecie(const AliRunInfo *runInfo, const AliEventInfo &evInfo)
147 // Here we return always kDefault!!
149 fEventSpecie = kDefault;
151 if (strcmp(runInfo->GetRunType(),"PHYSICS")) {
152 // Not a physics run, the event specie is set to kCalib
153 fEventSpecie = kCalib;
157 if (strcmp(runInfo->GetLHCState(),"STABLE_BEAMS") == 0) {
158 // In case of stable beams
159 // if ((strcmp(runInfo->GetBeamType(),"A-A") == 0) ||
160 // (strcmp(runInfo->GetBeamType(),"A-") == 0) ||
161 // (strcmp(runInfo->GetBeamType(),"-A") == 0)) {
162 // Heavy ion run (any beam tha is not pp, the event specie is set to kHighMult
163 fEventSpecie = kHighMult;
166 if ((strcmp(runInfo->GetBeamType(),"p-p") == 0) ||
167 (strcmp(runInfo->GetBeamType(),"p-") == 0) ||
168 (strcmp(runInfo->GetBeamType(),"-p") == 0) ||
169 (strcmp(runInfo->GetBeamType(),"P-P") == 0) ||
170 (strcmp(runInfo->GetBeamType(),"P-") == 0) ||
171 (strcmp(runInfo->GetBeamType(),"-P") == 0)) {
172 // Proton run, the event specie is set to kLowMult
173 fEventSpecie = kLowMult;
175 else if (strcmp(runInfo->GetBeamType(),"-") == 0) {
176 // No beams, we assume cosmic data
177 fEventSpecie = kCosmic;
179 else if (strcmp(runInfo->GetBeamType(),"UNKNOWN") == 0) {
180 // No LHC beam information is available, we the default
182 fEventSpecie = kDefault;
185 // Now we look into the trigger type in order to decide
186 // on the remaining cases (cosmic event within LHC run,
187 // high-mult event based on high-mult SPD trigger
188 // within p-p run, laser triggers within physics run,
189 // special DAQ events considered as calibration etc...)
190 if (evInfo.GetEventType() != 7) {
191 // START_OF_*, END_OF_*, CALIBRATION etc events
192 fEventSpecie = kCalib;
195 TString triggerClasses = evInfo.GetTriggerClasses();
196 TObjArray* trClassArray = triggerClasses.Tokenize(" ");
197 Int_t nTrClasses = trClassArray->GetEntriesFast();
198 Bool_t cosmicTrigger = kFALSE,
199 laserTrigger = kFALSE,
200 highMultTrigger = kFALSE,
201 otherTrigger = kFALSE;
202 for( Int_t i=0; i<nTrClasses; ++i ) {
203 TString trClass = ((TObjString*)trClassArray->At(i))->String();
204 if (trClass.BeginsWith("C0A") ||
205 trClass.BeginsWith("C0SC") ||
206 trClass.BeginsWith("C0OC")) {
207 // ACORDE/SPD/TOF cosmic trigger, so we have cosmic event
208 // not always true, but we don't have a better idea...
209 cosmicTrigger = kTRUE;
211 else if (trClass.BeginsWith("C0LSR")) {
213 laserTrigger = kTRUE;
215 else if (trClass.BeginsWith("C0SH")) {
216 // High-multiplicity SPD trugger
217 // Have to add other high-mult triggers here...
218 highMultTrigger = kTRUE;
221 otherTrigger = kTRUE;
226 fEventSpecie = kCalib;
229 if (cosmicTrigger && !highMultTrigger && !otherTrigger) {
230 fEventSpecie = kCosmic;
233 if (highMultTrigger) {
234 fEventSpecie = kHighMult;
238 // Here we have to add if we have other cases
239 // and also HLT info if any...
243 const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const
245 // Return AliDetectorRecoParam object for a given detector
246 // according to the event specie provided as an argument
247 if ( iDet >= kNDetectors) return NULL;
248 if (!fDetRecoParams[iDet]) return NULL;
249 if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL;
251 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
252 if (fEventSpecie & (1 << iBit)) {
253 if (fDetRecoParamsIndex[iBit][iDet] >= 0)
254 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[iBit][iDet]);
256 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
261 AliError(Form("Invalid event specie: %d!",fEventSpecie));
262 return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
265 void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
267 // Add an instance of reco params object into
268 // the fDetRecoParams for detector iDet
269 // Updates the fDetRecoParams index
270 if (!fDetRecoParams[iDet]) fDetRecoParams[iDet] = new TObjArray;
271 fDetRecoParams[iDet]->AddLast(param);
272 Int_t index = fDetRecoParams[iDet]->GetLast();
275 Int_t specie = param->GetEventSpecie();
276 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
277 if (specie & (1 << iBit)) {
278 fDetRecoParamsIndex[iBit][iDet] = index;
283 Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray)
285 // Add an array of reconstruction parameter objects
286 // for a given detector
287 // Basic check on the consistency of the array
288 Bool_t defaultFound = kFALSE;
289 for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) {
290 AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i);
292 if (par->IsDefault()) defaultFound = kTRUE;
294 Int_t specie = par->GetEventSpecie();
295 for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
296 if (specie & (1 << iBit)) {
297 fDetRecoParamsIndex[iBit][iDet] = i;
302 fDetRecoParams[iDet] = parArray;
307 const char* AliRecoParam::PrintEventSpecie() const
311 switch (fEventSpecie) {
313 return fkgEventSpecieName[0].Data() ;
316 return fkgEventSpecieName[1].Data() ;
319 return fkgEventSpecieName[2].Data() ;
322 return fkgEventSpecieName[3].Data() ;
325 return fkgEventSpecieName[4].Data() ;
328 return fkgEventSpecieName[5].Data() ;
333 const char * AliRecoParam::GetEventSpecieName(EventSpecie_t es)
337 return fkgEventSpecieName[0].Data() ;
340 return fkgEventSpecieName[1].Data() ;
343 return fkgEventSpecieName[2].Data() ;
346 return fkgEventSpecieName[3].Data() ;
349 return fkgEventSpecieName[4].Data() ;
352 return fkgEventSpecieName[5].Data() ;
357 const char * AliRecoParam::GetEventSpecieName(Int_t esIndex)
359 if ( esIndex >= 0 && esIndex < kNSpecies)
360 return fkgEventSpecieName[esIndex].Data() ;
362 return fkgEventSpecieName[kNSpecies].Data() ;