From cc484ed9d999ed8be1d4c0ac9070ea85002a457f Mon Sep 17 00:00:00 2001 From: richterm Date: Fri, 6 Nov 2009 01:22:19 +0000 Subject: [PATCH] Adding common handling for the magnetic field settings tothe component interface Components will use the AliMagF instance in the future. This instance is set up by the framework 1) AliRoot: AliReconstruction, AliSimulation or explicitely in the macro 2) online environment: AliMagF initialized via the GRPManager from the ExternalInterface This change will soon make all private code regarding setup of AliMagF obsolete in the HLT code. Furthermore the SolenoidBz OCDB entry will be removed. --- HLT/BASE/AliHLTMisc.cxx | 14 +++-- HLT/BASE/AliHLTMisc.h | 2 + .../AliHLT_C_Component_WrapperInterface.cxx | 4 +- .../interface/AliHLTExternalInterface.cxx | 21 +++---- HLT/rec/AliHLTMiscImplementation.cxx | 62 ++++++++++--------- HLT/rec/AliHLTMiscImplementation.h | 3 + 6 files changed, 59 insertions(+), 47 deletions(-) diff --git a/HLT/BASE/AliHLTMisc.cxx b/HLT/BASE/AliHLTMisc.cxx index 7e8274daa66..f0298d03fea 100644 --- a/HLT/BASE/AliHLTMisc.cxx +++ b/HLT/BASE/AliHLTMisc.cxx @@ -90,28 +90,34 @@ AliHLTMisc& AliHLTMisc::Instance() int AliHLTMisc::InitCDB(const char* /*cdbpath*/) { - // see header file for function documentation + // default method, functionality is implemented in the child class return -EFAULT; } int AliHLTMisc::SetCDBRunNo(int /*runNo*/) { - // see header file for function documentation + // default method, functionality is implemented in the child class return -EFAULT; } AliCDBEntry* AliHLTMisc::LoadOCDBEntry(const char* /*path*/, int /*runNo*/, int /*version*/, int /*subVersion*/) { - // see header file for function documentation + // default method, functionality is implemented in the child class return NULL; } TObject* AliHLTMisc::ExtractObject(AliCDBEntry* /*entry*/) { - // see header file for function documentation + // default method, functionality is implemented in the child class return NULL; } +int AliHLTMisc::InitMagneticField() const +{ + // default method, functionality is implemented in the child class + return -EFAULT; +} + ostream &operator<<(ostream &out, const AliHLTComponentDataType &dt) { // printout of AliHLTComponentDataType struct diff --git a/HLT/BASE/AliHLTMisc.h b/HLT/BASE/AliHLTMisc.h index d33cef3587b..33006308474 100644 --- a/HLT/BASE/AliHLTMisc.h +++ b/HLT/BASE/AliHLTMisc.h @@ -38,6 +38,8 @@ class AliHLTMisc : public TObject { virtual TObject* ExtractObject(AliCDBEntry* entry); + virtual int InitMagneticField() const; + private: static AliHLTMisc* fgInstance; diff --git a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx index e9b364852a6..20092317e88 100644 --- a/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx +++ b/HLT/BASE/AliHLT_C_Component_WrapperInterface.cxx @@ -30,6 +30,7 @@ using namespace std; #include "AliHLT_C_Component_WrapperInterface.h" #include "AliHLTComponentHandler.h" #include "AliHLTComponent.h" +#include "AliHLTMisc.h" #include static AliHLTComponentHandler *gComponentHandler_C = NULL; @@ -112,7 +113,8 @@ int AliHLT_C_CreateComponent( const char* componentType, void* environParam, int if (!cdbPath) cdbPath = getenv("ALICE_ROOT"); int ret = gComponentHandler_C->CreateComponent( componentType, comp); if (ret>=0 && comp) { - comp->InitCDB(cdbPath, gComponentHandler_C); + AliHLTMisc::Instance().InitCDB(cdbPath); + AliHLTMisc::Instance().SetCDBRunNo(gRunDesc.fRunNo); comp->SetRunDescription(&gRunDesc, gRunType); const AliHLTAnalysisEnvironment* comenv=gComponentHandler_C->GetEnvironment(); ret=comp->Init(comenv, environParam, argc, argv); diff --git a/HLT/BASE/interface/AliHLTExternalInterface.cxx b/HLT/BASE/interface/AliHLTExternalInterface.cxx index 3ae94773ddd..22c69ea5e5f 100644 --- a/HLT/BASE/interface/AliHLTExternalInterface.cxx +++ b/HLT/BASE/interface/AliHLTExternalInterface.cxx @@ -26,6 +26,7 @@ #include "AliHLTComponentHandler.h" #include "AliHLTComponent.h" #include "AliHLTSystem.h" +#include "AliHLTMisc.h" #include #include ///////////////////////////////////////////////////////////////////////////////////// @@ -77,6 +78,13 @@ int AliHLTAnalysisInitSystem( unsigned long version, AliHLTAnalysisEnvironment* strcpy(gRunType, runType); } } + + // the AliRoot dependent code is implemented by the + // AliHLTMiscImplementation class in libHLTrec + AliHLTMisc::Instance().InitCDB(getenv("ALIHLT_HCDBDIR")); + AliHLTMisc::Instance().SetCDBRunNo(gRunDesc.fRunNo); + AliHLTMisc::Instance().InitMagneticField(); + return 0; } @@ -123,22 +131,11 @@ int AliHLTAnalysisCreateComponent( const char* componentType, void* environParam if (!handle) return EINVAL; AliHLTComponent* comp=NULL; - string cdbPath; - const char* envvar = getenv("ALIHLT_HCDBDIR"); - if (envvar) { - cdbPath=envvar; - } else { - envvar = getenv("ALICE_ROOT"); - if (envvar) { - cdbPath=envvar; - cdbPath+="/OCDB"; - } - } + int ret = gComponentHandler->CreateComponent( componentType, comp); if (ret>=0 && comp) { const AliHLTAnalysisEnvironment* comenv=gComponentHandler->GetEnvironment(); comp->SetComponentEnvironment(comenv, environParam); - comp->InitCDB(cdbPath.c_str(), gComponentHandler); if (comenv) { if (description) { comp->SetComponentDescription(description); diff --git a/HLT/rec/AliHLTMiscImplementation.cxx b/HLT/rec/AliHLTMiscImplementation.cxx index 2c7ff71f7dd..44a54ac8176 100644 --- a/HLT/rec/AliHLTMiscImplementation.cxx +++ b/HLT/rec/AliHLTMiscImplementation.cxx @@ -26,6 +26,8 @@ #include "AliCDBManager.h" #include "AliCDBStorage.h" #include "AliCDBEntry.h" +#include "AliGRPManager.h" +#include "TGeoGlobalMagField.h" /** ROOT macro for the implementation of ROOT specific class methods */ ClassImp(AliHLTMiscImplementation); @@ -49,7 +51,14 @@ int AliHLTMiscImplementation::InitCDB(const char* cdbpath) log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); } else { if (cdbpath && cdbpath[0]!=0) { - pCDB->SetDefaultStorage(cdbpath); + TString uri=cdbpath; + if (!uri.BeginsWith("local://") && + !uri.Contains("://")) { + // assume a local path if no uri specifier is found + uri="local://"; + uri+=cdbpath; + } + pCDB->SetDefaultStorage(uri); log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB); } else if (!pCDB->IsDefaultStorageSet()) { const char* cdbUri="local://$ALICE_ROOT/OCDB"; @@ -68,7 +77,7 @@ int AliHLTMiscImplementation::SetCDBRunNo(int runNo) AliCDBManager* pCDB = AliCDBManager::Instance(); AliHLTLogging log; if (!pCDB) { - log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); + log.Logging(kHLTLogError, "SetCDBRunNo", "CDB handling", "Could not get CDB instance"); } else { pCDB->SetRun(runNo); } @@ -94,36 +103,29 @@ TObject* AliHLTMiscImplementation::ExtractObject(AliCDBEntry* entry) return entry->GetObject(); } -int AliHLTMiscInitCDB(const char* cdbpath) +int AliHLTMiscImplementation::InitMagneticField() const { - int iResult=0; - AliCDBManager* pCDB = AliCDBManager::Instance(); - AliHLTLogging log; - if (!pCDB) { - log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); - } else { - if (cdbpath && cdbpath[0]!=0) { - pCDB->SetDefaultStorage(cdbpath); - log.Logging(kHLTLogDebug, "InitCDB", "CDB handling", "CDB instance 0x%x", pCDB); - } else if (!pCDB->IsDefaultStorageSet()) { - const char* cdbUri="local://$ALICE_ROOT/OCDB"; - pCDB->SetDefaultStorage(cdbUri); - pCDB->SetRun(0); - log.Logging(kHLTLogInfo, "InitCDB", "CDB handling", "set default URI: %s", cdbUri); - } + // see header file for function documentation + + // BAD: unit test fails if I call TGeoGlobalMagField::Instance() + // at this point. Something goes wrong in the cleaning of the global + // ROOT onject + /* + if (TGeoGlobalMagField::Instance()->GetField()) { + // everything set, but think about storing the currents for + // a cross-check + return 0; } - return iResult; -} + */ -int AliHLTMiscSetCDBRunNo(int runNo) -{ - int iResult=0; - AliCDBManager* pCDB = AliCDBManager::Instance(); - AliHLTLogging log; - if (!pCDB) { - log.Logging(kHLTLogError, "InitCDB", "CDB handling", "Could not get CDB instance"); - } else { - pCDB->SetRun(runNo); + // The magnetic field is initialized once at the start + // of run. The fields are supposed to be constant througout the + // data taking of one run. The run is aborted if the changes + // exceed a certain limit. + AliGRPManager grpman; + if (grpman.ReadGRPEntry() && grpman.SetMagField()) { + return 0; } - return iResult; + + return -ENOENT; } diff --git a/HLT/rec/AliHLTMiscImplementation.h b/HLT/rec/AliHLTMiscImplementation.h index 9cb1f67a172..a46b10e472c 100644 --- a/HLT/rec/AliHLTMiscImplementation.h +++ b/HLT/rec/AliHLTMiscImplementation.h @@ -28,6 +28,9 @@ class AliHLTMiscImplementation : public AliHLTMisc AliCDBEntry* LoadOCDBEntry(const char* path, int runNo=-1, int version = -1, int subVersion = -1); TObject* ExtractObject(AliCDBEntry* entry); + + int InitMagneticField() const; + private: ClassDef(AliHLTMiscImplementation, 0) -- 2.43.0