ATLAS Offline Software
Loading...
Searching...
No Matches
xRpcMeasToTrkPrdCnvAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
9
12
13namespace MuonR4{
15 ATH_CHECK(m_idHelperSvc.retrieve());
16 ATH_CHECK(m_readKey.initialize());
17 ATH_CHECK(m_writeKey.initialize());
18 ATH_CHECK(m_detMgrKey.initialize());
19 return StatusCode::SUCCESS;
20 }
21 StatusCode xRpcMeasToRpcTrkPrdCnvAlg::execute(const EventContext& ctx) const {
22 const xAOD::RpcMeasurementContainer* measContainer{nullptr};
23 ATH_CHECK(SG::get(measContainer, m_readKey, ctx));
24
25 const MuonGM::MuonDetectorManager* detMgr{nullptr};
26 ATH_CHECK(SG::get(detMgr, m_detMgrKey, ctx));
27
28 std::vector<std::unique_ptr<Muon::RpcPrepDataCollection>> prdCollections{};
29 const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
30 prdCollections.resize(idHelper.module_hash_max());
31 for (const xAOD::RpcMeasurement* meas : *measContainer) {
32 const Identifier measId = meas->identify();
33 const IdentifierHash modHash{m_idHelperSvc->moduleHash(measId)};
34
35 std::unique_ptr<Muon::RpcPrepDataCollection>& coll = prdCollections[modHash];
36 if (!coll) {
37 coll = std::make_unique<Muon::RpcPrepDataCollection>(modHash);
38 coll->setIdentifier(m_idHelperSvc->chamberId(measId));
39 }
40 const MuonGM::RpcReadoutElement* outEle = detMgr->getRpcReadoutElement(measId);
41
42
43 std::unique_ptr<Muon::RpcPrepData> prd{};
44 std::vector<Identifier> rdo{measId};
45
46 if (meas->numDimensions() == 1) {
47 prd = std::make_unique<Muon::RpcPrepData>(measId, coll->identifyHash(),
48 meas->localPosition<1>().x() * Amg::Vector2D::UnitX(),
49 std::move(rdo),
50 AmgSymMatrix(1){meas->localCovariance<1>()(0,0)},
51 outEle, meas->time(), meas->timeOverThreshold(), 0, 0);
52 } else{
53 prd = std::make_unique<Muon::RpcPrepData>(measId, coll->identifyHash(),
54 xAOD::toEigen(meas->localPosition<2>()),
55 std::move(rdo),
56 xAOD::toEigen(meas->localCovariance<2>()),
57 outEle, meas->time(), meas->timeOverThreshold(), 0, 0);
58
59 }
60 prd->setHashAndIndex(coll->identifyHash(), coll->size());
61 coll->push_back(std::move(prd));
62 }
64 auto outContainer = std::make_unique<Muon::RpcPrepDataContainer>(idHelper.module_hash_max());
65 for (std::unique_ptr<Muon::RpcPrepDataCollection>& coll : prdCollections){
66 if (!coll) continue;
67 const IdentifierHash hash = coll->identifyHash();
68 ATH_CHECK(outContainer->addCollection(coll.release(), hash));
69 }
70 SG::WriteHandle writeHandle{m_writeKey, ctx};
71 ATH_CHECK(writeHandle.record(std::move(outContainer)));
72
73 return StatusCode::SUCCESS;
74 }
75}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define AmgSymMatrix(dim)
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
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::WriteHandleKey< Muon::RpcPrepDataContainer > m_writeKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadHandleKey< xAOD::RpcMeasurementContainer > m_readKey
virtual StatusCode initialize() override
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
This header ties the generic definitions in this package.
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