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
8namespace MuonR4 {
10 ATH_CHECK(m_idHelperSvc.retrieve());
11 ATH_CHECK(m_readKey.initialize());
12 ATH_CHECK(m_writeKey.initialize());
13 ATH_CHECK(m_detMgrKey.initialize());
14 return StatusCode::SUCCESS;
15 }
16
17 StatusCode xTgcMeasToTrkPrdCnvAlg::execute(const EventContext& ctx) const {
18 const MuonGM::MuonDetectorManager* detMgr{};
19 const xAOD::TgcStripContainer* strips{nullptr};
20 ATH_CHECK(SG::get(detMgr, m_detMgrKey, ctx));
21 ATH_CHECK(SG::get(strips, m_readKey, ctx));
22 std::vector<std::unique_ptr<Muon::TgcPrepDataCollection>> prdCollections{};
23 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
24 prdCollections.resize(idHelper.module_hash_max());
25
26 for (const xAOD::TgcStrip* meas : *strips) {
27 const Identifier measId = meas->identify();
28 const IdentifierHash modHash{m_idHelperSvc->moduleHash(measId)};
29
30 std::unique_ptr<Muon::TgcPrepDataCollection>& coll = prdCollections[modHash];
31 if (!coll) {
32 coll = std::make_unique<Muon::TgcPrepDataCollection>(modHash);
33 coll->setIdentifier(m_idHelperSvc->chamberId(measId));
34 }
35 const MuonGM::TgcReadoutElement* outEle = detMgr->getTgcReadoutElement(measId);
36 Amg::Vector2D locPos = meas->localMeasurementPos().block<2,1>(0,0);
37 auto outPrd = std::make_unique<Muon::TgcPrepData>(meas->identify(),
38 outEle->identifyHash(),
39 std::move(locPos),
40 std::vector<Identifier>{meas->identify()},
41 xAOD::toEigen(meas->localCovariance<1>()),
42 outEle,
43 meas->bcBitMap());
44 outPrd->setHashAndIndex(coll->identifyHash(), coll->size());
45 coll->push_back(std::move(outPrd));
46
47 }
48
49
51 auto outContainer = std::make_unique<Muon::TgcPrepDataContainer>(idHelper.module_hash_max());
52 for (std::unique_ptr<Muon::TgcPrepDataCollection>& coll : prdCollections){
53 if (!coll) continue;
54 const IdentifierHash hash = coll->identifyHash();
55 ATH_CHECK(outContainer->addCollection(coll.release(), hash));
56 }
57 SG::WriteHandle writeHandle{m_writeKey, ctx};
58 ATH_CHECK(writeHandle.record(std::move(outContainer)));
59 return StatusCode::SUCCESS;
60 }
61}
#define ATH_CHECK
Evaluate an expression and check for errors.
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::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.
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