From 3d279f86c71f52872665daa0342fab6e12b77003 Mon Sep 17 00:00:00 2001 From: Stefano Rosati <stefano.rosati@cern.ch> Date: Mon, 17 Feb 2025 17:48:03 +0100 Subject: [PATCH 1/2] adding skeleton of L0 Muon RPC sim --- .../TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt | 16 +++++ .../L0MuonS1RPC/python/L0MuonS1RPCConfig.py | 62 +++++++++++++++++++ .../Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx | 50 +++++++++++++++ .../Muon/L0MuonS1RPC/src/L0MuonRPCSim.h | 40 ++++++++++++ .../src/components/L0MuonS1RPC_entries.cxx | 2 + 5 files changed, 170 insertions(+) create mode 100644 Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt create mode 100644 Trigger/TrigT1/Muon/L0MuonS1RPC/python/L0MuonS1RPCConfig.py create mode 100644 Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx create mode 100644 Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h create mode 100644 Trigger/TrigT1/Muon/L0MuonS1RPC/src/components/L0MuonS1RPC_entries.cxx diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt b/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt new file mode 100644 index 000000000000..a1f2fd575ce0 --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration + +atlas_subdir ( L0MuonS1RPC ) + +find_package( CLHEP ) + +atlas_add_component (L0MuonS1RPC + src/*.cxx src/components/*.cxx + INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} + LINK_LIBRARIES AnaAlgorithmLib AthenaKernel xAODMuonRDO MuonDigitContainer xAODTrigger AthenaMonitoringKernelLib + PRIVATE_LINK_LIBRARIES ${CLHEP_LIBRARIES} ) + + +atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} --extend-extensions=ATL901 ) + + diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/python/L0MuonS1RPCConfig.py b/Trigger/TrigT1/Muon/L0MuonS1RPC/python/L0MuonS1RPCConfig.py new file mode 100644 index 000000000000..0a174df88a69 --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/python/L0MuonS1RPCConfig.py @@ -0,0 +1,62 @@ +#Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration +from AthenaConfiguration.ComponentFactory import CompFactory +from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator + +from AthenaCommon.Logging import logging +_log = logging.getLogger(__name__) + +def L0MuonRPCSimCfg(flags, name = "L0MuonRPCSim", **kwargs): + + result = ComponentAccumulator() + + alg = CompFactory.L0Muon.L0MuonRPCSim(name = name, + **kwargs) + + from AthenaMonitoringKernel.GenericMonitoringTool import GenericMonitoringTool + monTool = GenericMonitoringTool(flags, 'MonTool') + monTool.HistPath = 'L0MuonRPCSim' + monTool.defineHistogram('track_input_eta', path='EXPERT', type='TH1F', title=';#eta_{#mu}^{truth};Muons', xbins=50, xmin=-3, xmax=3) + + alg.MonTool = monTool + + histSvc = CompFactory.THistSvc(Output=["EXPERT DATAFILE='" + name + ".root' OPT='RECREATE'"]) + + result.addEventAlgo(alg) + result.addService(histSvc) + return result + + +if __name__ == "__main__": + + from AthenaConfiguration.TestDefaults import defaultTestFiles + from AthenaConfiguration.AllConfigFlags import initConfigFlags + from AthenaCommon.Constants import DEBUG + flags = initConfigFlags() + flags.Input.Files = defaultTestFiles.AOD_RUN3_MC + flags.Exec.MaxEvents = 20 + flags.Common.MsgSuppression = False + flags.lock() + + # create basic infrastructure + from AthenaConfiguration.MainServicesConfig import MainServicesCfg + acc = MainServicesCfg(flags) + + from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg + acc.merge(PoolReadCfg(flags)) + + # example simulation alg + simAlg = L0MuonRPCSimCfg(flags, + name = "L0MuonRPCSim", + OutputLevel = DEBUG) + acc.merge(simAlg) + + # below is validation + acc.printConfig(withDetails=True, summariseProps=True) + + # run the job + status = acc.run() + + # report the execution status (0 ok, else error) + import sys + sys.exit(not status.isSuccess()) + diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx new file mode 100644 index 000000000000..6c4930e46f7d --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx @@ -0,0 +1,50 @@ +/* + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration +*/ + +#include "L0MuonRPCSim.h" + +#include "xAODTrigger/MuonRoIAuxContainer.h" + +namespace L0Muon { + +L0MuonRPCSim::L0MuonRPCSim(const std::string& name, ISvcLocator* pSvcLocator) +: AthReentrantAlgorithm(name, pSvcLocator) {} + + +L0MuonRPCSim::~L0MuonRPCSim() {} + + +StatusCode L0MuonRPCSim::initialize() { + ATH_MSG_INFO("Initializing " << name() << "..."); + + ATH_CHECK(m_keyRpcRdo.initialize()); + ATH_CHECK(m_keyRpcDigit.initialize()); + + return StatusCode::SUCCESS; +} + + +StatusCode L0MuonRPCSim::finalize() { + ATH_MSG_INFO ("Finalizing " << name() << "..."); + return StatusCode::SUCCESS; +} + + +StatusCode L0MuonRPCSim::execute(const EventContext& ctx) const { + ATH_MSG_DEBUG ("Executing " << name() << "..."); + + SG::ReadHandle<xAOD::NRPCRDOContainer> rpcRdo_handle(m_keyRpcRdo,ctx); + const xAOD::NRPCRDOContainer* inputRDO = rpcRdo_handle.cptr(); + if ( not inputRDO ) { + ATH_MSG_FATAL("Unable to retrieve input RPC RDO container: " << m_keyRpcRdo.key()); + return StatusCode::FAILURE; + } + + ATH_MSG_INFO("Number of RPC RDO: " << inputRDO->size()); + + return StatusCode::SUCCESS; +} + + +} // end of namespace diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h new file mode 100644 index 000000000000..47b45ee5301e --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration +*/ +#ifndef L0MUONRPCSIM_H +#define L0MUONRPCSIM_H + +#include "AthenaBaseComps/AthReentrantAlgorithm.h" +#include "AthenaMonitoringKernel/Monitored.h" +#include "AthenaKernel/IAthRNGSvc.h" + +#include "StoreGate/ReadHandleKey.h" +#include "xAODMuonRDO/NRPCRDOContainer.h" +#include "MuonDigitContainer/RpcDigitContainer.h" + +namespace L0Muon { + +class L0MuonRPCSim: public ::AthReentrantAlgorithm { + public: + L0MuonRPCSim(const std::string& name, ISvcLocator* pSvcLocator); + virtual ~L0MuonRPCSim(); + + virtual StatusCode initialize() override; + virtual StatusCode execute(const EventContext& ctx) const override; + virtual StatusCode finalize() override; + + private: + + /// RPC Digit container + SG::ReadHandleKey<RpcDigitContainer> m_keyRpcDigit{this,"InputDigit","RpcDigitContainer","Location of input RpcDigitContainer"}; + /// RPC Rdo + SG::ReadHandleKey<xAOD::NRPCRDOContainer> m_keyRpcRdo{this,"NrpcRdoKey","NRPCRDO","Location of input RpcRDO"}; + + ToolHandle<GenericMonitoringTool> m_monTool{this, "MonTool", "", "Monitoring Tool"}; + +}; + +} // end of namespace + +#endif // L0MUONRPCSIM_H + diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/src/components/L0MuonS1RPC_entries.cxx b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/components/L0MuonS1RPC_entries.cxx new file mode 100644 index 000000000000..e8893fcd15ac --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/components/L0MuonS1RPC_entries.cxx @@ -0,0 +1,2 @@ +#include "../L0MuonRPCSim.h" +DECLARE_COMPONENT( L0Muon::L0MuonRPCSim ) -- GitLab From 73228b482721b4ef1df4439e3ea3a75d7850424e Mon Sep 17 00:00:00 2001 From: Stefano Rosati <stefano.rosati@cern.ch> Date: Thu, 20 Feb 2025 17:59:55 +0100 Subject: [PATCH 2/2] updating main alg --- .../TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt | 1 + .../Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx | 28 ++++++++++++++++++- .../Muon/L0MuonS1RPC/src/L0MuonRPCSim.h | 9 ++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt b/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt index a1f2fd575ce0..07aed5bff4fe 100644 --- a/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt @@ -8,6 +8,7 @@ atlas_add_component (L0MuonS1RPC src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CLHEP_INCLUDE_DIRS} LINK_LIBRARIES AnaAlgorithmLib AthenaKernel xAODMuonRDO MuonDigitContainer xAODTrigger AthenaMonitoringKernelLib + MuonCablingData xAODTrigger PRIVATE_LINK_LIBRARIES ${CLHEP_LIBRARIES} ) diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx index 6c4930e46f7d..09558c8c4327 100644 --- a/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx @@ -20,6 +20,13 @@ StatusCode L0MuonRPCSim::initialize() { ATH_CHECK(m_keyRpcRdo.initialize()); ATH_CHECK(m_keyRpcDigit.initialize()); + ATH_CHECK(m_cablingKey.initialize()); + + /// container of output RoIs + ATH_CHECK(m_outputMuonRoIKey.initialize()); + + /// retrieve the monitoring tool + if (!m_monTool.empty()) ATH_CHECK(m_monTool.retrieve()); return StatusCode::SUCCESS; } @@ -40,9 +47,28 @@ StatusCode L0MuonRPCSim::execute(const EventContext& ctx) const { ATH_MSG_FATAL("Unable to retrieve input RPC RDO container: " << m_keyRpcRdo.key()); return StatusCode::FAILURE; } + ATH_MSG_DEBUG("Number of RPC RDO: " << inputRDO->size()); + + SG::ReadCondHandle cablingMap{m_cablingKey, ctx}; + ATH_CHECK(cablingMap.isValid()); + + /// monitor RDO quantities + if ( !m_monTool.empty() ) { + + auto n_of_RDO = Monitored::Scalar<unsigned int>("n_of_RDO",inputRDO->size()); + + } + + + /// output RoIs container + SG::WriteHandle<xAOD::MuonRoIContainer> outputRoI_handle(m_outputMuonRoIKey, ctx); + ATH_CHECK(outputRoI_handle.record(std::make_unique<xAOD::MuonRoIContainer>(), std::make_unique<xAOD::MuonRoIAuxContainer>())); + auto outputRoIs = outputRoI_handle.ptr(); - ATH_MSG_INFO("Number of RPC RDO: " << inputRDO->size()); + /// Create an RoI + outputRoIs->push_back(std::make_unique<xAOD::MuonRoI>()); + return StatusCode::SUCCESS; } diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h index 47b45ee5301e..7df9c4ef2792 100644 --- a/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h @@ -10,7 +10,9 @@ #include "StoreGate/ReadHandleKey.h" #include "xAODMuonRDO/NRPCRDOContainer.h" +#include "xAODTrigger/MuonRoIContainer.h" #include "MuonDigitContainer/RpcDigitContainer.h" +#include "MuonCablingData/RpcCablingMap.h" namespace L0Muon { @@ -29,7 +31,14 @@ class L0MuonRPCSim: public ::AthReentrantAlgorithm { SG::ReadHandleKey<RpcDigitContainer> m_keyRpcDigit{this,"InputDigit","RpcDigitContainer","Location of input RpcDigitContainer"}; /// RPC Rdo SG::ReadHandleKey<xAOD::NRPCRDOContainer> m_keyRpcRdo{this,"NrpcRdoKey","NRPCRDO","Location of input RpcRDO"}; + /// Output RoIs + SG::WriteHandleKey<xAOD::MuonRoIContainer> m_outputMuonRoIKey{this, "L0MuonBarrelKey", "L0MuonBarrelRoI", + "key for LVL0 Muon RoIs in the barrel" }; + + /// NRPC cabling map + SG::ReadCondHandleKey<Muon::RpcCablingMap> m_cablingKey{this, "CablingKey", "MuonNRPC_CablingMap","Key of MuonNRPC_CablingMap"}; + ToolHandle<GenericMonitoringTool> m_monTool{this, "MonTool", "", "Monitoring Tool"}; }; -- GitLab