ATLAS Offline Software
Loading...
Searching...
No Matches
xMdtMeasToTrkPrdCnvAlg.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
14
15
16namespace{
18 static const SG::Decorator<Link_t> dec_link{"mdtTrkPrdLink"};
19}
20
21namespace MuonR4{
23 ATH_CHECK(m_idHelperSvc.retrieve());
24 ATH_CHECK(m_readKey.initialize());
25 ATH_CHECK(m_writeKey.initialize());
26 ATH_CHECK(m_detMgrKey.initialize());
27 ATH_CHECK(m_linkKey.initialize());
28 return StatusCode::SUCCESS;
29 }
30 StatusCode xMdtMeasToTrkPrdCnvAlg::execute(const EventContext& ctx) const {
31 // getting both xAOD containers
32 const xAOD::MdtDriftCircleContainer* mdtContainer{nullptr};
33 ATH_CHECK(SG::get(mdtContainer, m_readKey, ctx));
34
35 const MuonGM::MuonDetectorManager* detMgr{nullptr};
36 ATH_CHECK(SG::get(detMgr, m_detMgrKey, ctx));
37
38 std::vector<std::unique_ptr<Muon::MdtPrepDataCollection>> prdCollections{};
39 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
40 prdCollections.resize(idHelper.module_hash_max());
41 // single drift circles
42 for (const xAOD::MdtDriftCircle* meas : *mdtContainer) {
43 const Identifier measId = meas->identify();
44 const IdentifierHash modHash{m_idHelperSvc->moduleHash(measId)};
45
46 std::unique_ptr<Muon::MdtPrepDataCollection>& coll = prdCollections[modHash];
47 if (!coll) {
48 coll = std::make_unique<Muon::MdtPrepDataCollection>(modHash);
49 coll->setIdentifier(m_idHelperSvc->chamberId(measId));
50 }
51 const MuonGM::MdtReadoutElement* outEle = detMgr->getMdtReadoutElement(measId);
52
53 std::unique_ptr<Muon::MdtPrepData> prd{};
54 std::vector<Identifier> rdo{measId};
55
56 if (meas->numDimensions() == 1) {
57 // covariance matrix manipulation
58 Amg::MatrixX cov(1, 1);
59 (cov)(0,0) = meas->driftRadiusCov();
60 prd = std::make_unique<Muon::MdtPrepData>(measId, meas->driftRadius() * Amg::Vector2D::UnitX(),
61 cov, outEle, meas->tdc(), meas->adc(), meas->status());
62
63 } else {
64 // drift measurement and covariance matrix manipulation
65 const auto* twin = static_cast<const xAOD::MdtTwinDriftCircle*>(meas);
66 Amg::Vector2D hitPos{twin->driftRadius(), twin->posAlongWire()};
67 AmgSymMatrix(2) cov{AmgSymMatrix(2)::Identity()};
68 (cov)(0,0) = twin->driftRadiusCov();
69 (cov)(1,1) = twin->posAlongWireCov();
70
71 prd = std::make_unique<Muon::MdtTwinPrepData>(measId, std::move(hitPos), std::move(cov),
72 outEle, twin->tdc(), twin->adc(),
73 twin->twinTdc(), twin->twinAdc(), twin->status());
74 }
75 dec_link(*meas) = Link_t{*coll, coll->size()};
76 prd->setHashAndIndex(coll->identifyHash(), coll->size());
77 coll->push_back(std::move(prd));
78 }
79
81 auto outContainer = std::make_unique<Muon::MdtPrepDataContainer>(idHelper.module_hash_max());
82 for (std::unique_ptr<Muon::MdtPrepDataCollection>& coll : prdCollections){
83 if (!coll) {
84 continue;
85 }
86 const IdentifierHash hash = coll->identifyHash();
87 ATH_CHECK(outContainer->addCollection(coll.release(), hash));
88 }
89 SG::WriteHandle writeHandle{m_writeKey, ctx};
90 ATH_CHECK(writeHandle.record(std::move(outContainer)));
91
92 return StatusCode::SUCCESS;
93 }
94}
#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 MdtReadoutElement * getMdtReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
size_type module_hash_max() const
the maximum hash value
SG::ReadHandleKey< xAOD::MdtDriftCircleContainer > m_readKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::WriteHandleKey< Muon::MdtPrepDataContainer > m_writeKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
SG::WriteDecorHandleKey< xAOD::MdtDriftCircleContainer > m_linkKey
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode initialize() override
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
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.
MdtDriftCircle_v1 MdtDriftCircle
MdtTwinDriftCircle_v1 MdtTwinDriftCircle
MdtDriftCircleContainer_v1 MdtDriftCircleContainer