Skip to content
Snippets Groups Projects
Commit 821d6b0f authored by Walter Lampl's avatar Walter Lampl
Browse files

Merge branch 'l0MuonRpc' into 'main'

Adding skeleton of L0 Muon RPC sim

See merge request atlas/athena!77881
parents e32c8d02 9bc4f0e9
No related branches found
No related tags found
No related merge requests found
# 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 )
#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())
/*
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
/*
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
#include "../L0MuonRPCSim.h"
DECLARE_COMPONENT( L0Muon::L0MuonRPCSim )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment