diff --git a/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt b/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..07aed5bff4fec873566cb75bfc0a37767f006231 --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/CMakeLists.txt @@ -0,0 +1,17 @@ +# 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 + MuonCablingData xAODTrigger + 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 0000000000000000000000000000000000000000..0a174df88a694ad12a497fb7c90411dbd4f53ad3 --- /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 0000000000000000000000000000000000000000..09558c8c4327f48e163d1ab5c2f52bdaf383695c --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.cxx @@ -0,0 +1,76 @@ +/* + 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()); + 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; +} + + +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_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(); + + /// Create an RoI + outputRoIs->push_back(std::make_unique<xAOD::MuonRoI>()); + + + 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 0000000000000000000000000000000000000000..7df9c4ef2792b6c784b5501278c3225fcd080d2c --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/L0MuonRPCSim.h @@ -0,0 +1,49 @@ +/* + 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 "xAODTrigger/MuonRoIContainer.h" +#include "MuonDigitContainer/RpcDigitContainer.h" +#include "MuonCablingData/RpcCablingMap.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"}; + /// 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"}; + +}; + +} // 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 0000000000000000000000000000000000000000..e8893fcd15acccd1f3d678c94f52f39cc7f77bcb --- /dev/null +++ b/Trigger/TrigT1/Muon/L0MuonS1RPC/src/components/L0MuonS1RPC_entries.cxx @@ -0,0 +1,2 @@ +#include "../L0MuonRPCSim.h" +DECLARE_COMPONENT( L0Muon::L0MuonRPCSim )