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
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 return StatusCode::SUCCESS;
22 }
23 StatusCode xMdtMeasToTrkPrdCnvAlg::execute(const EventContext& ctx) const {
24 // getting both xAOD containers
25 const xAOD::MdtDriftCircleContainer* mdtContainer{nullptr};
26 ATH_CHECK(SG::get(mdtContainer, m_readKey, ctx));
27
28 const MuonGM::MuonDetectorManager* detMgr{nullptr};
29 ATH_CHECK(SG::get(detMgr, m_detMgrKey, ctx));
30
31 std::vector<std::unique_ptr<Muon::MdtPrepDataCollection>> prdCollections{};
32 const MdtIdHelper& idHelper{m_idHelperSvc->mdtIdHelper()};
33 prdCollections.resize(idHelper.module_hash_max());
34 // single drift circles
35 for (const xAOD::MdtDriftCircle* meas : *mdtContainer) {
36 const Identifier measId = meas->identify();
37 const IdentifierHash modHash{m_idHelperSvc->moduleHash(measId)};
38
39 std::unique_ptr<Muon::MdtPrepDataCollection>& coll = prdCollections[modHash];
40 if (!coll) {
41 coll = std::make_unique<Muon::MdtPrepDataCollection>(modHash);
42 coll->setIdentifier(m_idHelperSvc->chamberId(measId));
43 }
44 const MuonGM::MdtReadoutElement* outEle = detMgr->getMdtReadoutElement(measId);
45
46 std::unique_ptr<Muon::MdtPrepData> prd{};
47 std::vector<Identifier> rdo{measId};
48
49 if (meas->numDimensions() == 1) {
50 // covariance matrix manipulation
51 Amg::MatrixX cov(1, 1);
52 (cov)(0,0) = meas->driftRadiusCov();
53 prd = std::make_unique<Muon::MdtPrepData>(measId, meas->driftRadius() * Amg::Vector2D::UnitX(),
54 cov, outEle, meas->tdc(), meas->adc(), meas->status());
55
56 } else {
57 // drift measurement and covariance matrix manipulation
58 const auto* twin = static_cast<const xAOD::MdtTwinDriftCircle*>(meas);
59 Amg::Vector2D hitPos{twin->driftRadius(), twin->posAlongWire()};
60 AmgSymMatrix(2) cov{AmgSymMatrix(2)::Identity()};
61 (cov)(0,0) = twin->driftRadiusCov();
62 (cov)(1,1) = twin->posAlongWireCov();
63
64 prd = std::make_unique<Muon::MdtTwinPrepData>(measId, std::move(hitPos), std::move(cov),
65 outEle, twin->tdc(), twin->adc(),
66 twin->twinTdc(), twin->twinAdc(), twin->status());
67 }
68 prd->setHashAndIndex(coll->identifyHash(), coll->size());
69 coll->push_back(std::move(prd));
70 }
71
73 auto outContainer = std::make_unique<Muon::MdtPrepDataContainer>(idHelper.module_hash_max());
74 for (std::unique_ptr<Muon::MdtPrepDataCollection>& coll : prdCollections){
75 if (!coll) continue;
76 const IdentifierHash hash = coll->identifyHash();
77 ATH_CHECK(outContainer->addCollection(coll.release(), hash));
78 }
79 SG::WriteHandle writeHandle{m_writeKey, ctx};
80 ATH_CHECK(writeHandle.record(std::move(outContainer)));
81
82 return StatusCode::SUCCESS;
83 }
84}
#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 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
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.
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