ATLAS Offline Software
xRpcMeasToTrkPrdCnvAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 {
23  ATH_CHECK(readHandle.isPresent());
24 
26  ATH_CHECK(detMgr.isValid());
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 : *readHandle) {
32  const MuonGMR4::RpcReadoutElement* reEle = meas->readoutElement();
33  const Identifier measId = reEle->measurementId(meas->measurementHash());
34 
35  std::unique_ptr<Muon::RpcPrepDataCollection>& coll = prdCollections[m_idHelperSvc->moduleHash(measId)];
36  if (!coll) {
37  coll = std::make_unique<Muon::RpcPrepDataCollection>(m_idHelperSvc->moduleHash(measId));
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  coll->push_back(std::move(prd));
61  }
63  auto outContainer = std::make_unique<Muon::RpcPrepDataContainer>(idHelper.module_hash_max());
64  for (std::unique_ptr<Muon::RpcPrepDataCollection>& coll : prdCollections){
65  if (!coll) continue;
66  const IdentifierHash hash = coll->identifyHash();
67  ATH_CHECK(outContainer->addCollection(coll.release(), hash));
68  }
70  ATH_CHECK(writeHandle.record(std::move(outContainer)));
71 
72  return StatusCode::SUCCESS;
73  }
74 }
xAOD::RpcMeasurement_v1
RpcMeasurement_v1: Class storing the geneic.
Definition: RpcMeasurement_v1.h:21
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
MuonR4::xRpcMeasToRpcTrkPrdCnvAlg::initialize
virtual StatusCode initialize() override
Definition: xRpcMeasToTrkPrdCnvAlg.cxx:14
MuonGMR4::RpcReadoutElement::measurementId
Identifier measurementId(const IdentifierHash &measHash) const override final
Converts the measurement hash back to the full Identifier.
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)
MuonGMR4::RpcReadoutElement
Definition: MuonPhaseII/MuonDetDescr/MuonReadoutGeometryR4/MuonReadoutGeometryR4/RpcReadoutElement.h:17
MuonR4::xRpcMeasToRpcTrkPrdCnvAlg::m_detMgrKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
Definition: xRpcMeasToTrkPrdCnvAlg.h:33
RpcIdHelper
Definition: RpcIdHelper.h:51
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
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::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:76
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
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
MuonR4::AmgSymMatrix
const AmgSymMatrix(2) &SpacePoint
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:150
RpcReadoutElement.h
Identifier
Definition: IdentifierFieldParser.cxx:14