ATLAS Offline Software
Loading...
Searching...
No Matches
xRpcMeasToTrkPrdCnvAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9
12
13
14namespace{
16 static const SG::Decorator<Link_t> dec_link{"rpcTrkPrdLink"};
17}
18
19namespace MuonR4{
21 ATH_CHECK(m_idHelperSvc.retrieve());
22 ATH_CHECK(m_readKey.initialize());
23 ATH_CHECK(m_writeKey.initialize());
24 ATH_CHECK(m_detMgrKey.initialize());
25 ATH_CHECK(m_linkKey.initialize());
26 return StatusCode::SUCCESS;
27 }
28 StatusCode xRpcMeasToTrkPrdCnvAlg::execute(const EventContext& ctx) const {
29 const xAOD::RpcMeasurementContainer* measContainer{nullptr};
30 ATH_CHECK(SG::get(measContainer, m_readKey, ctx));
31
32 const MuonGM::MuonDetectorManager* detMgr{nullptr};
33 ATH_CHECK(SG::get(detMgr, m_detMgrKey, ctx));
34
35 std::vector<std::unique_ptr<Muon::RpcPrepDataCollection>> prdCollections{};
36 const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
37 prdCollections.resize(idHelper.module_hash_max());
38 for (const xAOD::RpcMeasurement* meas : *measContainer) {
39 const Identifier measId = meas->identify();
40 const IdentifierHash modHash{m_idHelperSvc->moduleHash(measId)};
41
42 std::unique_ptr<Muon::RpcPrepDataCollection>& coll = prdCollections[modHash];
43 if (!coll) {
44 coll = std::make_unique<Muon::RpcPrepDataCollection>(modHash);
45 coll->setIdentifier(m_idHelperSvc->chamberId(measId));
46 }
47 const MuonGM::RpcReadoutElement* outEle = detMgr->getRpcReadoutElement(measId);
48
49
50 std::unique_ptr<Muon::RpcPrepData> prd{};
51 std::vector<Identifier> rdo{measId};
52
53 if (meas->numDimensions() == 1) {
54 prd = std::make_unique<Muon::RpcPrepData>(measId, coll->identifyHash(),
55 meas->localPosition<1>().x() * Amg::Vector2D::UnitX(),
56 std::move(rdo),
57 AmgSymMatrix(1){meas->localCovariance<1>()(0,0)},
58 outEle, meas->time(), meas->timeOverThreshold(), 0, 0);
59 } else{
60 prd = std::make_unique<Muon::RpcPrepData>(measId, coll->identifyHash(),
61 xAOD::toEigen(meas->localPosition<2>()),
62 std::move(rdo),
63 xAOD::toEigen(meas->localCovariance<2>()),
64 outEle, meas->time(), meas->timeOverThreshold(), 0, 0);
65
66 }
67 prd->setHashAndIndex(coll->identifyHash(), coll->size());
68 dec_link(*meas) = Link_t{*coll, coll->size()};
69 coll->push_back(std::move(prd));
70 }
72 auto outContainer = std::make_unique<Muon::RpcPrepDataContainer>(idHelper.module_hash_max());
73 for (std::unique_ptr<Muon::RpcPrepDataCollection>& coll : prdCollections){
74 if (!coll) {
75 continue;
76 }
77 const IdentifierHash hash = coll->identifyHash();
78 ATH_CHECK(outContainer->addCollection(coll.release(), hash));
79 }
80 SG::WriteHandle writeHandle{m_writeKey, ctx};
81 ATH_CHECK(writeHandle.record(std::move(outContainer)));
82
83 return StatusCode::SUCCESS;
84 }
85}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define AmgSymMatrix(dim)
ElementLink< xAOD::TruthParticleContainer > Link_t
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
This is a "hash" representation of an Identifier.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const RpcReadoutElement * getRpcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
size_type module_hash_max() const
the maximum hash value
SG::ReadHandleKey< xAOD::RpcMeasurementContainer > m_readKey
SG::WriteDecorHandleKey< xAOD::RpcMeasurementContainer > m_linkKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::WriteHandleKey< Muon::RpcPrepDataContainer > m_writeKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
This header ties the generic definitions in this package.
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data, specialized for JaggedVecElt.
Definition AuxElement.h:576
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
RpcMeasurementContainer_v1 RpcMeasurementContainer
RpcMeasurement_v1 RpcMeasurement