From 5699c0e6d2215ded7344052f555e049b32a73900 Mon Sep 17 00:00:00 2001 From: ivana Date: Wed, 17 Oct 2007 13:01:32 +0000 Subject: [PATCH 1/1] Protection against not accessible input OCDB (Laurent) --- MUON/TestMUONPreprocessor.C | 62 +++++++++++++++++++++++++++---------- MUON/TestMUONPreprocessor.h | 2 +- MUON/mapping/AliMpCDB.cxx | 24 ++++++++++---- 3 files changed, 65 insertions(+), 23 deletions(-) diff --git a/MUON/TestMUONPreprocessor.C b/MUON/TestMUONPreprocessor.C index fb5f2b1025c..55c33023163 100644 --- a/MUON/TestMUONPreprocessor.C +++ b/MUON/TestMUONPreprocessor.C @@ -28,6 +28,13 @@ /// b) select run type, using shuttle->AddInputRunParameter() (the run type /// dictates which task is really performed by the MUONPreprocessor /// +/// You must load relevant libraries (besides normal MUON ones) before +/// compiling this macro : +/// +/// gSystem->Load("$ALICE_ROOT/SHUTTLE/TestShuttle/libTestShuttle"); +/// gSystem->Load("libMUONshuttle.so"); +/// +/// /// For more information on usage, please see READMEshuttle. /// // By Laurent Aphecetche, SUBATECH Nantes @@ -35,10 +42,12 @@ #include "TestMUONPreprocessor.h" #include "AliMUONTrackerPreprocessor.h" -#include "AliMUONHVNamer.h" + +#include "AliLog.h" #include "AliMpExMap.h" #include "AliMpHelper.h" +#include "AliMpHVNamer.h" #include "AliMpCDB.h" #include "AliCDBManager.h" @@ -66,29 +75,30 @@ void TestMUONPreprocessor(Int_t runNumber=80, const char* runType="PEDESTAL_RUN" // PHYSICS -> HV // GMS - // load library - gSystem->Load("../SHUTTLE/TestShuttle/libTestShuttle.so"); - gSystem->Load("libMUONshuttle.so"); - // create AliTestShuttle instance // The parameters are run, startTime, endTime AliTestShuttle* shuttle = new AliTestShuttle(runNumber, 0, 1); - - AliTestShuttle::SetMainCDB("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"); + const char* inputCDB = "local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB"; + + AliTestShuttle::SetMainCDB(inputCDB); AliTestShuttle::SetMainRefStorage("local://$ALICE_ROOT/SHUTTLE/TestShuttle/TestReference"); + // Create DCS HV aliases + TMap* dcsAliasMap = CreateDCSAliasMap(inputCDB); + + if ( dcsAliasMap ) + { + // now give the alias map to the shuttle + shuttle->SetDCSInput(dcsAliasMap); + } + + printf("Test Shuttle temp dir: %s\n", AliShuttleInterface::GetShuttleTempDir()); printf("Test Shuttle log dir: %s\n", AliShuttleInterface::GetShuttleLogDir()); printf("Test OCDB storage Uri: %s\n", AliShuttleInterface::GetMainCDB().Data()); printf("Test Reference storage Uri: %s\n", AliShuttleInterface::GetMainRefStorage().Data()); - // Create DCS HV aliases - TMap* dcsAliasMap = CreateDCSAliasMap(); - - // now give the alias map to the shuttle - shuttle->SetDCSInput(dcsAliasMap); - // The shuttle can process files that originate from DCS, DAQ and HLT. // To test it, we provide some local files and locations where these would be found when // the online machinery would be there. @@ -127,7 +137,7 @@ void TestMUONPreprocessor(Int_t runNumber=80, const char* runType="PEDESTAL_RUN" shuttle->Process(); } -TMap* CreateDCSAliasMap() +TMap* CreateDCSAliasMap(const char* inputCDB) { /// Creates a DCS structure for MUON Tracker HV /// @@ -138,15 +148,35 @@ TMap* CreateDCSAliasMap() /// is a TObjArray of AliDCSValue /// An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue + Bool_t undefStorage(kFALSE); + + AliCDBManager* man = AliCDBManager::Instance(); + if (!man->IsDefaultStorageSet()) + { + undefStorage = kTRUE; + man->SetDefaultStorage(inputCDB); + } + // Load mapping - AliMpCDB::LoadDDLStore(); + Bool_t ok = AliMpCDB::LoadDDLStore(); + + if (undefStorage) + { + man->UnsetDefaultStorage(); + } + + if (!ok) + { + AliErrorGeneral("CreateDCSAliasMap","Could not load DDLStore from OCDB"); + return 0x0; + } TMap* aliasMap = new TMap; aliasMap->SetOwner(kTRUE); TRandom random(0); - AliMUONHVNamer hvNamer; + AliMpHVNamer hvNamer; TObjArray* aliases = hvNamer.GenerateAliases(); diff --git a/MUON/TestMUONPreprocessor.h b/MUON/TestMUONPreprocessor.h index 82335ba7620..20eb546ab08 100644 --- a/MUON/TestMUONPreprocessor.h +++ b/MUON/TestMUONPreprocessor.h @@ -3,6 +3,6 @@ class TMap; -TMap* CreateDCSAliasMap(); +TMap* CreateDCSAliasMap(const char* inputCDB); #endif diff --git a/MUON/mapping/AliMpCDB.cxx b/MUON/mapping/AliMpCDB.cxx index 47c4557f253..99557082ca8 100644 --- a/MUON/mapping/AliMpCDB.cxx +++ b/MUON/mapping/AliMpCDB.cxx @@ -68,10 +68,16 @@ Bool_t AliMpCDB::LoadMpSegmentation(Bool_t warn) cdbManager->SetRun(run); } - AliCDBEntry* cdbEntry - = cdbManager->Get("MUON/Calib/Mapping", run); + AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/Mapping", run); - return (AliMpSegmentation*)cdbEntry->GetObject() != 0x0; + if ( cdbEntry ) + { + return (AliMpSegmentation*)cdbEntry->GetObject() != 0x0; + } + else + { + return kFALSE; + } } //______________________________________________________________________________ @@ -104,10 +110,16 @@ Bool_t AliMpCDB::LoadDDLStore(Bool_t warn) cdbManager->SetRun(run); } - AliCDBEntry* cdbEntry - = cdbManager->Get("MUON/Calib/DDLStore", run); + AliCDBEntry* cdbEntry = cdbManager->Get("MUON/Calib/DDLStore", run); - return (AliMpDDLStore*)cdbEntry->GetObject() != 0x0; + if ( cdbEntry ) + { + return (AliMpDDLStore*)cdbEntry->GetObject() != 0x0; + } + else + { + return kFALSE; + } } //______________________________________________________________________________ -- 2.39.3