Commit 2fc99a35 authored by Joerg Stelzer's avatar Joerg Stelzer
Browse files

Add menu writing at initialize to L1 and HLT configuration service

Also fix the problem with the CTPSimulation, reported in ATR-20331
parent abd106b2
......@@ -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()
......
......@@ -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
......
......@@ -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();
......
......@@ -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;
......
......@@ -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
......
......@@ -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());
......
......@@ -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() );
......
......@@ -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
......
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment