///////////////////////////////////////////////////////////////////////////////
// //
-// ALICE Reconstruction parameterization:
-//
-//
-// Retrieving paramaters:
-// 0. Read the parameters from database
-// 1. Using the ConfigRecoParam.C script (example : $ALICE_ROOT/macros)
-// 2. Register additional parametes (AliRecoParam::Instance()->RegisterRecoParam(tpcRecoParam);
-//
-//
-// Using the reconstruction parameters
-// AliRecoParam::Instance()->GetRecoParam(detType, eventType) //
-// detType:
-// 1. Detectors - ITS, TPC, TRD, TOF ...
-// 2. Process - V0, Kink, ESDcuts
-
+// ALICE Reconstruction parameterization: //
+// //
+// //
+// Base Class for Detector reconstruction parameters //
+// Revision: cvetan.cheshkov@cern.ch 12/06/2008 //
+// Its structure has been revised and it is interfaced to AliEventInfo. //
// //
///////////////////////////////////////////////////////////////////////////////
+#include "TClass.h"
#include "TObjArray.h"
+#include "TMath.h"
+#include "THashTable.h"
#include "AliDetectorRecoParam.h"
+#include "AliLog.h"
#include "AliRecoParam.h"
-
+#include "AliRunInfo.h"
+#include "AliEventInfo.h"
+#include "AliLog.h"
ClassImp(AliRecoParam)
+TString AliRecoParam::fkgEventSpecieName[] = {"Default", "LowMultiplicity", "HighMultiplicity", "Cosmic", "Calib", "Unknown"} ;
-AliRecoParam* AliRecoParam::fgInstance = 0x0;
+AliRecoParam::AliRecoParam():
+ TObject(),
+ fEventSpecie(kDefault)
+{
+ // Default constructor
+ // ...
+ for(Int_t iDet = 0; iDet < kNDetectors; iDet++)
+ fDetRecoParams[iDet] = NULL;
+ for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) {
+ for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+ fDetRecoParamsIndex[iSpecie][iDet] = -1;
+ }
+ }
+}
+AliRecoParam::AliRecoParam(const AliRecoParam& par) :
+ TObject(),
+ fEventSpecie(par.fEventSpecie)
+{
+ // copy constructor
+ for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+ if (par.fDetRecoParams[iDet])
+ fDetRecoParams[iDet] = (TObjArray*)(par.fDetRecoParams[iDet]->Clone());
+ else
+ fDetRecoParams[iDet] = NULL;
+ }
+ for(Int_t iSpecie = 0; iSpecie < kNSpecies; iSpecie++) {
+ for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+ fDetRecoParamsIndex[iSpecie][iDet] = par.fDetRecoParamsIndex[iSpecie][iDet];
+ }
+ }
+}
//_____________________________________________________________________________
-AliRecoParam* AliRecoParam::Instance()
+AliRecoParam& AliRecoParam::operator = (const AliRecoParam& par)
{
- //
- // returns AliRecoParam instance (singleton)
- //
- if (!fgInstance) {
- fgInstance = new AliRecoParam();
+ // assignment operator
+
+ if(&par == this) return *this;
+
+ this->~AliRecoParam();
+ new(this) AliRecoParam(par);
+ return *this;
+}
+
+AliRecoParam::~AliRecoParam(){
+ // Destructor
+ // ...
+ // Delete the array with the reco-param objects
+ for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+ if (fDetRecoParams[iDet]){
+ fDetRecoParams[iDet]->Delete();
+ delete fDetRecoParams[iDet];
+ }
}
-
- return fgInstance;
}
+Int_t AliRecoParam::AConvert(EventSpecie_t es)
+{
+ //Converts EventSpecie_t into int
+ Int_t rv = -1 ;
+ switch (es) {
+ case kDefault:
+ rv = 0 ;
+ break;
+ case kLowMult:
+ rv = 1 ;
+ break;
+ case kHighMult:
+ rv = 2 ;
+ break;
+ case kCosmic:
+ rv = 3 ;
+ break;
+ case kCalib:
+ rv = 4 ;
+ break;
+ default:
+ break;
+ }
+ if (rv < 0)
+ AliFatalClass(Form("Wrong event specie conversion %d", es)) ;
-AliRecoParam::AliRecoParam():
- TNamed("ALICE","ALICE"),
- fRecoParamArray(0)
+ return rv ;
+}
+
+AliRecoParam::EventSpecie_t AliRecoParam::Convert(Int_t ies)
{
- //
- //
- //
+ //Converts int into EventSpecie_t
+ AliRecoParam::EventSpecie_t es = kDefault ;
+ if ( ies >> 1)
+ es = kLowMult ;
+ if ( ies >> 2)
+ es = kHighMult ;
+ if ( ies >> 3)
+ es = kCosmic ;
+ if ( ies >> 4)
+ es = kCalib ;
+
+ return es ;
}
-AliRecoParam::~AliRecoParam(){
- //
- //
- //
- if (fRecoParamArray){
- fRecoParamArray->Delete();
- delete fRecoParamArray;
+AliRecoParam::EventSpecie_t AliRecoParam::ConvertIndex(Int_t index)
+{
+ //Converts index of lists into eventspecie
+ EventSpecie_t es = kDefault ;
+ switch (index) {
+ case 0:
+ es = kDefault ;
+ break;
+ case 1:
+ es = kLowMult ;
+ break;
+ case 2:
+ es = kHighMult ;
+ break;
+ case 3:
+ es = kCosmic ;
+ break;
+ case 4:
+ es = kCalib ;
+ break;
+ default:
+ break;
}
+ return es ;
}
-void AliRecoParam::Print(Option_t *option) const{
+void AliRecoParam::Print(Option_t *option) const {
//
// Print reconstruction setup
//
- printf("AliRecoParam\n");
- if (!fRecoParamArray) return;
- Int_t nparam = fRecoParamArray->GetEntriesFast();
- for (Int_t iparam=0; iparam<nparam; iparam++){
- AliDetectorRecoParam * param = (AliDetectorRecoParam *)fRecoParamArray->At(iparam);
- if (!param) continue;
- param->Print(option);
+ for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
+ if (fDetRecoParams[iDet]){
+ printf("AliDetectorRecoParam objects for detector %d:\n",iDet);
+ Int_t nparam = fDetRecoParams[iDet]->GetEntriesFast();
+ for (Int_t iparam=0; iparam<nparam; iparam++){
+ AliDetectorRecoParam * param = (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(iparam);
+ if (!param) continue;
+ param->Print(option);
+ }
+ }
+ else {
+ printf("No AliDetectorRecoParam objects specified for detector %d\n",iDet);
+ }
}
}
-void AliRecoParam::RegisterRecoParam(AliDetectorRecoParam* param){
- //
- //
- //
- if (!fRecoParamArray) fRecoParamArray = new TObjArray;
- fRecoParamArray->AddLast(param);
+void AliRecoParam::SetEventSpecie(const AliRunInfo *runInfo, const AliEventInfo &evInfo,
+ const THashTable *cosmicTriggersList)
+{
+ // Implemented according to the discussions
+ // and meetings with physics and trigger coordination
+
+ fEventSpecie = kDefault;
+
+ if (strcmp(runInfo->GetRunType(),"PHYSICS")) {
+ // Not a physics run, the event specie is set to kCalib
+ fEventSpecie = kCalib;
+ return;
+ }
+
+ // Special DAQ events considered as calibration events
+ if (evInfo.GetEventType() != 7) {
+ // START_OF_*, END_OF_*, CALIBRATION etc events
+ fEventSpecie = kCalib;
+ return;
+ }
+
+ if ((strcmp(runInfo->GetLHCState(),"STABLE_BEAMS") == 0) &&
+ ((strcmp(runInfo->GetBeamType(),"A-A") == 0) ||
+ (strcmp(runInfo->GetBeamType(),"A-") == 0) ||
+ (strcmp(runInfo->GetBeamType(),"-A") == 0))) {
+ // Heavy ion run (any beam that is not pp, the event specie is set to kHighMult
+ fEventSpecie = kHighMult;
+ }
+ else if ((strcmp(runInfo->GetLHCState(),"STABLE_BEAMS") == 0) &&
+ ((strcmp(runInfo->GetBeamType(),"p-p") == 0) ||
+ (strcmp(runInfo->GetBeamType(),"p-") == 0) ||
+ (strcmp(runInfo->GetBeamType(),"-p") == 0) ||
+ (strcmp(runInfo->GetBeamType(),"P-P") == 0) ||
+ (strcmp(runInfo->GetBeamType(),"P-") == 0) ||
+ (strcmp(runInfo->GetBeamType(),"-P") == 0))) {
+ // Proton run, the event specie is set to kLowMult
+ fEventSpecie = kLowMult;
+ }
+ else if (strcmp(runInfo->GetBeamType(),"-") == 0) {
+ // No beams, we assume cosmic data
+ fEventSpecie = kCosmic;
+ }
+
+ // Now we look into the trigger type in order to decide
+ // on the remaining cases (cosmic event within LHC run,
+ // calibration, for example TPC laser, triggers within physics run
+ TString triggerClasses = evInfo.GetTriggerClasses();
+ TObjArray* trClassArray = triggerClasses.Tokenize(" ");
+ Int_t nTrClasses = trClassArray->GetEntriesFast();
+ Bool_t cosmicTrigger = kFALSE,
+ calibTrigger = kFALSE,
+ otherTrigger = kFALSE;
+ for( Int_t i=0; i<nTrClasses; ++i ) {
+ TString trClass = ((TObjString*)trClassArray->At(i))->String();
+
+ if (trClass.BeginsWith("C0L")) {
+ // Calibration triggers always start with C0L
+ calibTrigger = kTRUE;
+ continue;
+ }
+
+ if (cosmicTriggersList) {
+ if (cosmicTriggersList->FindObject(trClass.Data())) {
+ // Cosmic trigger accorind to the table
+ // provided in OCDB
+ cosmicTrigger = kTRUE;
+ AliDebug(1,Form("Trigger %s identified as cosmic according to the list defined in OCDB.",
+ trClass.Data()));
+ continue;
+ }
+ }
+ else {
+ AliDebug(1,"Cosmic trigger list is not provided, cosmic event specie is effectively disabled!");
+ }
+
+ otherTrigger = kTRUE;
+ }
+
+ if (calibTrigger) {
+ fEventSpecie = kCalib;
+ return;
+ }
+ if (cosmicTrigger && !otherTrigger) {
+ fEventSpecie = kCosmic;
+ return;
+ }
+
+ // Here we have to add if we have other cases
+ // and also HLT info if any...
}
-TObjArray * AliRecoParam::GetRecoParam(const char * detType, Int_t */*eventType*/){
- //
- // Get the list of Reconstruction parameters for given detector
- // and event type
- //
- if (!fRecoParamArray) return 0;
- TObjArray * array = 0;
- Int_t nparam = fRecoParamArray->GetEntriesFast();
- for (Int_t iparam=0;iparam<nparam; iparam++){
- AliDetectorRecoParam * param = (AliDetectorRecoParam *)fRecoParamArray->At(iparam);
- if (!param) continue;
- TString str(param->GetName());
- if (!str.Contains(detType)) continue;
- if (!array) array = new TObjArray;
- array->AddLast(param);
+const AliDetectorRecoParam *AliRecoParam::GetDetRecoParam(Int_t iDet) const
+{
+ // Return AliDetectorRecoParam object for a given detector
+ // according to the event specie provided as an argument
+ if ( iDet >= kNDetectors) return NULL;
+ if (!fDetRecoParams[iDet]) return NULL;
+ if (fDetRecoParams[iDet]->GetEntries() == 0) return NULL;
+
+ for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
+ if (fEventSpecie & (1 << iBit)) {
+ if (fDetRecoParamsIndex[iBit][iDet] >= 0)
+ return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[iBit][iDet]);
+ else
+ return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
+ }
+ }
+
+ // Default one
+ AliError(Form("Invalid event specie: %d!",fEventSpecie));
+ return (AliDetectorRecoParam *)fDetRecoParams[iDet]->At(fDetRecoParamsIndex[0][iDet]);
+}
+
+void AliRecoParam::AddDetRecoParam(Int_t iDet, AliDetectorRecoParam* param)
+{
+ // Add an instance of reco params object into
+ // the fDetRecoParams for detector iDet
+ // Updates the fDetRecoParams index
+ if (!fDetRecoParams[iDet]) fDetRecoParams[iDet] = new TObjArray;
+ fDetRecoParams[iDet]->AddLast(param);
+ Int_t index = fDetRecoParams[iDet]->GetLast();
+
+ // Index
+ Int_t specie = param->GetEventSpecie();
+ for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
+ if (specie & (1 << iBit)) {
+ fDetRecoParamsIndex[iBit][iDet] = index;
+ }
+ }
+}
+
+Bool_t AliRecoParam::AddDetRecoParamArray(Int_t iDet, TObjArray* parArray)
+{
+ // Add an array of reconstruction parameter objects
+ // for a given detector
+ // Basic check on the consistency of the array
+ Bool_t defaultFound = kFALSE;
+ for(Int_t i = 0; i < parArray->GetEntriesFast(); i++) {
+ AliDetectorRecoParam *par = (AliDetectorRecoParam*)parArray->At(i);
+ if (!par) continue;
+ if (par->IsDefault()) defaultFound = kTRUE;
+
+ Int_t specie = par->GetEventSpecie();
+ for(Int_t iBit = 0; iBit < kNSpecies; iBit++) {
+ if (specie & (1 << iBit)) {
+ fDetRecoParamsIndex[iBit][iDet] = i;
+ }
+ }
+ }
+
+ fDetRecoParams[iDet] = parArray;
+
+ return defaultFound;
+}
+
+const char* AliRecoParam::PrintEventSpecie() const
+{
+ // Print the current
+ // event specie
+ switch (fEventSpecie) {
+ case kDefault:
+ return fkgEventSpecieName[0].Data() ;
+ break;
+ case kLowMult:
+ return fkgEventSpecieName[1].Data() ;
+ break;
+ case kHighMult:
+ return fkgEventSpecieName[2].Data() ;
+ break;
+ case kCosmic:
+ return fkgEventSpecieName[3].Data() ;
+ break;
+ case kCalib:
+ return fkgEventSpecieName[4].Data() ;
+ break;
+ default:
+ return fkgEventSpecieName[5].Data() ;
+ break;
}
- return array;
}
+const char * AliRecoParam::GetEventSpecieName(EventSpecie_t es)
+{
+ switch (es) {
+ case kDefault:
+ return fkgEventSpecieName[0].Data() ;
+ break;
+ case kLowMult:
+ return fkgEventSpecieName[1].Data() ;
+ break;
+ case kHighMult:
+ return fkgEventSpecieName[2].Data() ;
+ break;
+ case kCosmic:
+ return fkgEventSpecieName[3].Data() ;
+ break;
+ case kCalib:
+ return fkgEventSpecieName[4].Data() ;
+ break;
+ default:
+ return fkgEventSpecieName[5].Data() ;
+ break;
+ }
+}
+const char * AliRecoParam::GetEventSpecieName(Int_t esIndex)
+{
+ if ( esIndex >= 0 && esIndex < kNSpecies)
+ return fkgEventSpecieName[esIndex].Data() ;
+ else
+ return fkgEventSpecieName[kNSpecies].Data() ;
+}