ATLAS Offline Software
Loading...
Searching...
No Matches
xTgcMeasToTrkPrdCnvAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9
10namespace{
12 static const SG::Decorator<Link_t> dec_link{"tgcTrkPrdLink"};
13}
14
15namespace MuonR4 {
17 ATH_CHECK(m_idHelperSvc.retrieve());
18 ATH_CHECK(m_readKey.initialize());
19 ATH_CHECK(m_writeKey.initialize());
20 ATH_CHECK(m_detMgrKey.initialize());
21 ATH_CHECK(m_linkKey.initialize());
22 return StatusCode::SUCCESS;
23 }
24
25 StatusCode xTgcMeasToTrkPrdCnvAlg::execute(const EventContext& ctx) const {
26 const MuonGM::MuonDetectorManager* detMgr{};
27 const xAOD::TgcStripContainer* strips{nullptr};
28 ATH_CHECK(SG::get(detMgr, m_detMgrKey, ctx));
29 ATH_CHECK(SG::get(strips, m_readKey, ctx));
30 std::vector<std::unique_ptr<Muon::TgcPrepDataCollection>> prdCollections{};
31 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
32 prdCollections.resize(idHelper.module_hash_max());
33
34 for (const xAOD::TgcStrip* meas : *strips) {
35 const Identifier measId = meas->identify();
36 const IdentifierHash modHash{m_idHelperSvc->moduleHash(measId)};
37
38 std::unique_ptr<Muon::TgcPrepDataCollection>& coll = prdCollections[modHash];
39 if (!coll) {
40 coll = std::make_unique<Muon::TgcPrepDataCollection>(modHash);
41 coll->setIdentifier(m_idHelperSvc->chamberId(measId));
42 }
43 const MuonGM::TgcReadoutElement* outEle = detMgr->getTgcReadoutElement(measId);
44 Amg::Vector2D locPos = meas->localMeasurementPos().block<2,1>(0,0);
45 auto outPrd = std::make_unique<Muon::TgcPrepData>(meas->identify(),
46 outEle->identifyHash(),
47 std::move(locPos),
48 std::vector<Identifier>{meas->identify()},
49 xAOD::toEigen(meas->localCovariance<1>()),
50 outEle,
51 meas->bcBitMap());
52 outPrd->setHashAndIndex(coll->identifyHash(), coll->size());
53 dec_link(*meas) = Link_t{*coll, coll->size()};
54 coll->push_back(std::move(outPrd));
55
56 }
57
58
60 auto outContainer = std::make_unique<Muon::TgcPrepDataContainer>(idHelper.module_hash_max());
61 for (std::unique_ptr<Muon::TgcPrepDataCollection>& coll : prdCollections){
62 if (!coll) continue;
63 const IdentifierHash hash = coll->identifyHash();
64 ATH_CHECK(outContainer->addCollection(coll.release(), hash));
65 }
66 SG::WriteHandle writeHandle{m_writeKey, ctx};
67 ATH_CHECK(writeHandle.record(std::move(outContainer)));
68 return StatusCode::SUCCESS;
69 }
70}
#define ATH_CHECK
Evaluate an expression and check for errors.
ElementLink< xAOD::TruthParticleContainer > Link_t
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 TgcReadoutElement * getTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
IdentifierHash identifyHash() const override final
Returns the IdentifierHash of the MuonStation, i.e.
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
size_type module_hash_max() const
the maximum hash value
SG::WriteDecorHandleKey< xAOD::TgcStripContainer > m_linkKey
SG::ReadHandleKey< xAOD::TgcStripContainer > m_readKey
virtual StatusCode execute(const EventContext &ctx) const override final
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
virtual StatusCode initialize() override final
SG::WriteHandleKey< Muon::TgcPrepDataContainer > m_writeKey
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Eigen::Matrix< double, 2, 1 > Vector2D
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.
TgcStrip_v1 TgcStrip
Definition TgcStripFwd.h:9
TgcStripContainer_v1 TgcStripContainer