ATLAS Offline Software
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 
7 #include "StoreGate/ReadHandle.h"
9 
12 
13 namespace MuonR4{
15  ATH_CHECK(m_idHelperSvc.retrieve());
16  ATH_CHECK(m_readKey.initialize());
17  ATH_CHECK(m_writeKey.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 }
xAOD::RpcMeasurement_v1
RpcMeasurement_v1: Class storing the geneic.
Definition: RpcMeasurement_v1.h:21
MuonR4::xRpcMeasToRpcTrkPrdCnvAlg::initialize
virtual StatusCode initialize() override
Definition: xRpcMeasToTrkPrdCnvAlg.cxx:14
MuonGM::RpcReadoutElement
An RpcReadoutElement corresponds to a single RPC module; therefore typicaly a barrel muon station con...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/RpcReadoutElement.h:55
MuonR4::xRpcMeasToRpcTrkPrdCnvAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: xRpcMeasToTrkPrdCnvAlg.h:26
Muon::MuonPrepDataCollection::setIdentifier
virtual void setIdentifier(Identifier id)
MuonR4::xRpcMeasToRpcTrkPrdCnvAlg::m_detMgrKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
Definition: xRpcMeasToTrkPrdCnvAlg.h:33
RpcIdHelper
Definition: RpcIdHelper.h:51
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
MuonR4::xRpcMeasToRpcTrkPrdCnvAlg::m_readKey
SG::ReadHandleKey< xAOD::RpcMeasurementContainer > m_readKey
Definition: xRpcMeasToTrkPrdCnvAlg.h:29
ReadCondHandle.h
WriteHandle.h
Handle class for recording to StoreGate.
Muon::MuonPrepDataCollection::identifyHash
virtual IdentifierHash identifyHash() const override final
xRpcMeasToTrkPrdCnvAlg.h
MuonR4::xRpcMeasToRpcTrkPrdCnvAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: xRpcMeasToTrkPrdCnvAlg.cxx:21
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonR4::xRpcMeasToRpcTrkPrdCnvAlg::m_writeKey
SG::WriteHandleKey< Muon::RpcPrepDataContainer > m_writeKey
Definition: xRpcMeasToTrkPrdCnvAlg.h:31
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
RpcReadoutElement.h
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:108
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:51
ReadHandle.h
Handle class for reading from StoreGate.
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
RpcReadoutElement.h
Identifier
Definition: IdentifierFieldParser.cxx:14