diff --git a/Reconstruction/RecJobTransforms/share/skeleton.RDOtoRDOtrigger.py b/Reconstruction/RecJobTransforms/share/skeleton.RDOtoRDOtrigger.py index 3e3b0129a26ccf7419e2a779468b32cb7adf11ba..5c5134ebc38c702599dc8dc5d95e4d962d4642ab 100644 --- a/Reconstruction/RecJobTransforms/share/skeleton.RDOtoRDOtrigger.py +++ b/Reconstruction/RecJobTransforms/share/skeleton.RDOtoRDOtrigger.py @@ -123,6 +123,18 @@ if TriggerFlags.doMT(): topSequence += Lvl1SimulationSequence(None) recoLog.info( "Configuring HLT (MT)" ) + # this configuration of the HLTConfigSvc is only temporary + if not hasattr(svcMgr, 'HLTConfigSvc'): + from TrigConfigSvc.TrigConfigSvcConfig import HLTConfigSvc + svcMgr += HLTConfigSvc() + if TriggerFlags.readHLTconfigFromXML(): + hltJsonFile = TriggerFlags.inputHLTconfigFile().replace(".xml",".json").replace("HLTconfig", "HLTmenu") + else: + hltJsonFile = TriggerFlags.outputHLTconfigFile().replace(".xml",".json").replace("HLTconfig", "HLTmenu") + svcMgr.HLTConfigSvc.InputType = "file" + svcMgr.HLTConfigSvc.JsonFileName = hltJsonFile + recoLog.info("Configured HLTConfigSvc with InputType='file' and JsonFileName=%s" % hltJsonFile) + from L1Decoder.L1DecoderConfig import L1Decoder topSequence += L1Decoder() diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/CMakeLists.txt b/Trigger/TrigConfiguration/TrigConfigSvc/CMakeLists.txt index cc77edf4c9d2a16936d34e93cbb60a77ce5d9695..2e5891f9e55e912f4b88f7994b5d84abc2c5ba32 100644 --- a/Trigger/TrigConfiguration/TrigConfigSvc/CMakeLists.txt +++ b/Trigger/TrigConfiguration/TrigConfigSvc/CMakeLists.txt @@ -10,6 +10,8 @@ atlas_depends_on_subdirs( PUBLIC Control/AthenaBaseComps Control/StoreGate GaudiKernel + Trigger/TrigConfiguration/TrigConfIO + Trigger/TrigConfiguration/TrigConfData Trigger/TrigConfiguration/TrigConfHLTData Trigger/TrigConfiguration/TrigConfInterfaces Trigger/TrigConfiguration/TrigConfL1Data @@ -41,7 +43,7 @@ atlas_add_library( TrigConfigSvcLib PUBLIC_HEADERS TrigConfigSvc PRIVATE_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${COOL_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES AthenaBaseComps AthenaKernel GaudiKernel StoreGateLib TrigConfHLTData TrigConfInterfaces TrigConfL1Data - PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${COOL_LIBRARIES} ${ROOT_LIBRARIES} AthAnalysisBaseCompsLib AthenaMonitoringLib AthenaPoolUtilities EventInfo IOVDbDataModel L1TopoConfig PathResolver TrigConfBase TrigConfStorage nlohmann_json::nlohmann_json ) + PRIVATE_LINK_LIBRARIES ${Boost_LIBRARIES} ${COOL_LIBRARIES} ${ROOT_LIBRARIES} AthAnalysisBaseCompsLib AthenaMonitoringLib AthenaPoolUtilities EventInfo IOVDbDataModel L1TopoConfig PathResolver TrigConfBase TrigConfStorage TrigConfData TrigConfIOLib nlohmann_json::nlohmann_json ) atlas_add_component( TrigConfigSvc src/components/*.cxx diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/TrigConfigSvc/HLTConfigSvc.h b/Trigger/TrigConfiguration/TrigConfigSvc/TrigConfigSvc/HLTConfigSvc.h index 8ca7b5cdda25adceebf4f741096b883ca7aee0f2..6367b2ff84e03ffeba6bf3ce2f2620d522d12845 100644 --- a/Trigger/TrigConfiguration/TrigConfigSvc/TrigConfigSvc/HLTConfigSvc.h +++ b/Trigger/TrigConfiguration/TrigConfigSvc/TrigConfigSvc/HLTConfigSvc.h @@ -63,6 +63,15 @@ namespace TrigConf { void setL2LowerChainCounter(const CTPConfig*); private: + + StatusCode writeConfigToDetectorStore(); + + // jobProperties + Gaudi::Property< std::string > m_inputType { this, "InputType", "file", "file (json file), db (Trigger DB), cool (keys from cool, content from Trigger DB), none (no menu)" }; + Gaudi::Property< std::string > m_hltFileName { this, "JsonFileName", "HLTMenu.json", "file name of HLT json file, needed if InputType is file" }; + Gaudi::Property< std::string > m_dbConnection { this, "TriggerDB", "TRIGGERDB", "DB connection alias, needed if InputType is db" }; + Gaudi::Property< unsigned int > m_smk { this, "SMK", 0, "DB smk, needed if InputType is db" }; + StatusCode assignPrescalesToChains(uint lumiblock ); StatusCode bookHistograms(); diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/TrigConfigSvc/LVL1ConfigSvc.h b/Trigger/TrigConfiguration/TrigConfigSvc/TrigConfigSvc/LVL1ConfigSvc.h index 24b11fb2e5bc3885b422581d8e37983bf383b6c1..18ed5f3e7a5e85fdc0d7b075cc8c55420af3be28 100644 --- a/Trigger/TrigConfiguration/TrigConfigSvc/TrigConfigSvc/LVL1ConfigSvc.h +++ b/Trigger/TrigConfiguration/TrigConfigSvc/TrigConfigSvc/LVL1ConfigSvc.h @@ -42,6 +42,14 @@ namespace TrigConf { uint32_t lvl1PrescaleKey() const { return m_prescaleSetID; } private: + + StatusCode writeConfigToDetectorStore(); + + // jobProperties + Gaudi::Property< std::string > m_inputType { this, "InputType", "file", "file (json file), db (Trigger DB), cool (keys from cool, content from Trigger DB), none (no menu)" }; + Gaudi::Property< std::string > m_l1FileName { this, "JsonFileName", "L1Menu.json", "file name of L1 json file, needed if InputType is file" }; + Gaudi::Property< std::string > m_dbConnection { this, "TriggerDB", "TRIGGERDB", "DB connection alias, needed if InputType is db" }; + Gaudi::Property< unsigned int > m_smk { this, "SMK", 0, "DB smk, needed if InputType is db" }; ::StoreGateSvc* m_detectorStore; diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/src/HLTConfigSvc.cxx b/Trigger/TrigConfiguration/TrigConfigSvc/src/HLTConfigSvc.cxx index a9b3eae903f941b1867ac5764008e027e10f7a7e..dd85c68d12ef423e413121ea2943319dda59ad13 100644 --- a/Trigger/TrigConfiguration/TrigConfigSvc/src/HLTConfigSvc.cxx +++ b/Trigger/TrigConfiguration/TrigConfigSvc/src/HLTConfigSvc.cxx @@ -25,6 +25,8 @@ #include "TH2I.h" // Local includes: +#include "TrigConfIO/JsonFileLoader.h" +#include "TrigConfData/HLTMenu.h" #include "TrigConfBase/TrigDBConnectionConfig.h" #include "TrigConfStorage/StorageMgr.h" #include "TrigConfStorage/IStorageMgr.h" @@ -78,6 +80,35 @@ HLTConfigSvc::~HLTConfigSvc() {} +StatusCode +HLTConfigSvc::writeConfigToDetectorStore() { + + // load the json file into TrigConf::HLTMenu + TrigConf::JsonFileLoader fileLoader; + fileLoader.setLevel(TrigConf::MSGTC::WARNING); + + TrigConf::HLTMenu * hltmenu = new TrigConf::HLTMenu; + + if( m_inputType == "file" ) { + if( fileLoader.loadFile( m_hltFileName, *hltmenu ).isSuccess() ) { + ATH_MSG_INFO( "Loaded HLT menu file " << m_hltFileName.value() ); + } else { + ATH_MSG_WARNING( "Failed loading HLT menu file " << m_hltFileName.value()); + return StatusCode::RECOVERABLE; + } + } + + ServiceHandle<StoreGateSvc> detStore( "StoreGateSvc/DetectorStore", name() ); + + ATH_CHECK( detStore.retrieve() ); + if( detStore->record(hltmenu,"HLTTriggerMenu").isSuccess() ) { + ATH_MSG_INFO( "Recorded HLT menu with key 'HLTTriggerMenu' in the detector store" ); + } + + return StatusCode::SUCCESS; +} + + // Suppress warnings for two functions of this class marked as deprecated. #ifdef __GNUC__ #pragma GCC diagnostic push @@ -115,7 +146,12 @@ HLTConfigSvc::sequences() const { StatusCode HLTConfigSvc::initialize() { - CHECK(ConfigSvcBase::initialize()); + ATH_CHECK(ConfigSvcBase::initialize()); + + StatusCode sc = writeConfigToDetectorStore(); + if( !sc.isSuccess() ) { + ATH_MSG_INFO( "This previous WARNING message is being ignored in the current transition phase. Once we rely entirely on the new menu providing mechanism, this will become a reason to abort."); + } ////////////////////////////////////////////////////////////// // BEGIN RUN-3 TESTING BLOCK - THIS SHOULD BE TEMPORARY diff --git a/Trigger/TrigConfiguration/TrigConfigSvc/src/LVL1ConfigSvc.cxx b/Trigger/TrigConfiguration/TrigConfigSvc/src/LVL1ConfigSvc.cxx index b9f413131646ab8b8275bf88195c0adc3ff209b3..b97049274cdc1af2e9ac734511d96da8488c74a6 100644 --- a/Trigger/TrigConfiguration/TrigConfigSvc/src/LVL1ConfigSvc.cxx +++ b/Trigger/TrigConfiguration/TrigConfigSvc/src/LVL1ConfigSvc.cxx @@ -20,7 +20,8 @@ #include "TrigConfigSvc/Verifyer.h" // Trigger database interface includes: - +#include "TrigConfIO/JsonFileLoader.h" +#include "TrigConfData/L1Menu.h" #include "TrigConfL1Data/DeadTime.h" #include "TrigConfL1Data/CTPConfig.h" #include "TrigConfL1Data/CTPConfigOnline.h" @@ -68,10 +69,45 @@ LVL1ConfigSvc::~LVL1ConfigSvc() {} +StatusCode +LVL1ConfigSvc::writeConfigToDetectorStore() { + + // load the json file into TrigConf::L1Menu + TrigConf::JsonFileLoader fileLoader; + fileLoader.setLevel(TrigConf::MSGTC::WARNING); + + TrigConf::L1Menu * l1menu = new TrigConf::L1Menu; + + if( m_inputType == "file" ) { + if( fileLoader.loadFile( m_l1FileName, *l1menu ).isSuccess() ) { + ATH_MSG_INFO( "Loaded L1 menu file " << m_l1FileName.value() ); + } else { + ATH_MSG_WARNING( "Failed loading L1 menu file " << m_l1FileName.value()); + return StatusCode::RECOVERABLE; + } + } + + ServiceHandle<StoreGateSvc> detStore( "StoreGateSvc/DetectorStore", name() ); + + ATH_CHECK( detStore.retrieve() ); + if( detStore->record(l1menu,"L1TriggerMenu").isSuccess() ) { + ATH_MSG_INFO( "Recorded L1 menu with key 'L1TriggerMenu' in the detector store" ); + } + + return StatusCode::SUCCESS; +} + + + StatusCode LVL1ConfigSvc::initialize() { CHECK(ConfigSvcBase::initialize()); + + StatusCode sc = writeConfigToDetectorStore(); + if( !sc.isSuccess() ) { + ATH_MSG_INFO( "This previous WARNING message is being ignored in the current transition phase. Once we rely entirely on the new menu providing mechanism, this will become a reason to abort."); + } // could be that this is needed when running from DB CHECK(setProperties()); diff --git a/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.cxx b/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.cxx index 49b5b05aa28942dd261d99f9b7ef97607f32e1af..e55258d884db56988bb4a085b3e3aebd120b7759 100755 --- a/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.cxx +++ b/Trigger/TrigT1/TrigT1CTP/src/CTPSimulation.cxx @@ -924,9 +924,6 @@ LVL1CTP::CTPSimulation::execute() { ATH_MSG_ERROR ( "No L1 menu provided, can't run"); return StatusCode::FAILURE; } - ATH_MSG_DEBUG( "execute: new style cond alg provides menu " << l1menu->name() - << " with " << l1menu->size() << " items and " - << l1menu->thresholds().size() << " thresholds"); } unsigned int ctpVersion = ( m_ctpVersion != 0 ? m_ctpVersion : m_configSvc->ctpConfig()->ctpVersion() ); diff --git a/Trigger/TrigValidation/TrigUpgradeTest/share/testHLT_MT.py b/Trigger/TrigValidation/TrigUpgradeTest/share/testHLT_MT.py index 4d8264c3f248620f3f3b3b220a18427a9dd1724d..2ce3cf621c1e4c90414d9d043f7b6cca06088a8a 100644 --- a/Trigger/TrigValidation/TrigUpgradeTest/share/testHLT_MT.py +++ b/Trigger/TrigValidation/TrigUpgradeTest/share/testHLT_MT.py @@ -374,6 +374,10 @@ TriggerFlags.outputLVL1configFile = None from TrigConfigSvc.TrigConfigSvcConfig import LVL1ConfigSvc, findFileInXMLPATH svcMgr += LVL1ConfigSvc() svcMgr.LVL1ConfigSvc.XMLMenuFile = findFileInXMLPATH(TriggerFlags.inputLVL1configFile()) +svcMgr.LVL1ConfigSvc.InputType = "file" +l1JsonFile = TriggerFlags.inputLVL1configFile().replace(".xml",".json") +svcMgr.LVL1ConfigSvc.JsonFileName = l1JsonFile +log.info("Configured LVL1ConfigSvc with InputType='file' and JsonFileName=%s" % l1JsonFile) if opt.doL1Sim: from TriggerJobOpts.Lvl1SimulationConfig import Lvl1SimulationSequence diff --git a/Trigger/TriggerCommon/TriggerJobOpts/python/Lvl1SimulationConfig.py b/Trigger/TriggerCommon/TriggerJobOpts/python/Lvl1SimulationConfig.py index db3c79dc46544c4c5ff2405e2e04801d2a2d9f2d..67dca94d4ba3b0eb2a774fac4e7a6cf2a2afcb1e 100644 --- a/Trigger/TriggerCommon/TriggerJobOpts/python/Lvl1SimulationConfig.py +++ b/Trigger/TriggerCommon/TriggerJobOpts/python/Lvl1SimulationConfig.py @@ -14,16 +14,24 @@ def Lvl1SimulationSequence( flags = None ): # L1ConfigSvc CA has to be imported and merged # at the end the sequence added to the CA # + from AthenaCommon.Logging import logging + log = logging.getLogger('TriggerJobOpts.Lvl1Simulation') + from AthenaCommon.CFElements import seqAND from AthenaCommon.AppMgr import ServiceMgr as svcMgr from AthenaCommon.AlgSequence import AthSequencer from TriggerJobOpts.TriggerFlags import TriggerFlags + # this configuration of the LVL1ConfigSvc is only temporary TriggerFlags.readLVL1configFromXML = True TriggerFlags.outputLVL1configFile = None from TrigConfigSvc.TrigConfigSvcConfig import LVL1ConfigSvc, findFileInXMLPATH svcMgr += LVL1ConfigSvc() svcMgr.LVL1ConfigSvc.XMLMenuFile = findFileInXMLPATH(TriggerFlags.inputLVL1configFile()) + svcMgr.LVL1ConfigSvc.InputType = "file" + l1JsonFile = TriggerFlags.inputLVL1configFile().replace(".xml",".json") + svcMgr.LVL1ConfigSvc.JsonFileName = l1JsonFile + log.info("Configured LVL1ConfigSvc with InputType='file' and JsonFileName=%s", l1JsonFile) # L1 menu provider Run 3 from TrigConfIO.TrigConfCondSetup import setupMenuProvider