ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::RpcRdoToRpcPrepDataTool Class Reference

#include <RpcRdoToRpcPrepDataTool.h>

Inheritance diagram for MuonR4::RpcRdoToRpcPrepDataTool:
Collaboration diagram for MuonR4::RpcRdoToRpcPrepDataTool:

Public Member Functions

 ~RpcRdoToRpcPrepDataTool ()=default
StatusCode initialize () override final
StatusCode decode (const EventContext &ctx, const std::vector< IdentifierHash > &idVect) const override final
StatusCode decode (const EventContext &ctx, const std::vector< uint32_t > &robIds) const override final
StatusCode provideEmptyContainer (const EventContext &ctx) const override final
 Method to create the empty containers.. Only used for seeded decoding.

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::ReadHandleKey< xAOD::NRPCRDOContainerm_rdoKey {this, "RpcRdoContainer", "NRPCRDO"}
SG::ReadCondHandleKey< Muon::RpcCablingMapm_cablingKey
SG::WriteHandleKey< xAOD::RpcStripContainerm_writeKey
SG::WriteHandleKey< xAOD::RpcStrip2DContainerm_writeKeyBI
const MuonGMR4::MuonDetectorManagerm_detMgr {nullptr}
Gaudi::Property< bool > m_decode2DStrips {this, "decode2DStrips", true}
Gaudi::Property< double > m_propagationVelocity
Gaudi::Property< double > m_stripTimeResolution

Detailed Description

Definition at line 24 of file RpcRdoToRpcPrepDataTool.h.

Constructor & Destructor Documentation

◆ ~RpcRdoToRpcPrepDataTool()

MuonR4::RpcRdoToRpcPrepDataTool::~RpcRdoToRpcPrepDataTool ( )
default

Member Function Documentation

◆ decode() [1/2]

StatusCode MuonR4::RpcRdoToRpcPrepDataTool::decode ( const EventContext & ctx,
const std::vector< IdentifierHash > & idVect ) const
finaloverride

TODO: Do we need to apply a time of flight correction here?

Next step convert the RDOs into prepdata objects

Hash is overwritten by the setMeasValues method

Hash is overwritten by the setMeasValues method

Definition at line 26 of file RpcRdoToRpcPrepDataTool.cxx.

27 {
28
29
30 const xAOD::NRPCRDOContainer* rdoContainer{nullptr};
31 ATH_CHECK(SG::get(rdoContainer, m_rdoKey, ctx));
32
33 const Muon::RpcCablingMap* cablingMap{nullptr};
34 ATH_CHECK(SG::get(cablingMap, m_cablingKey, ctx));
35
36 const std::unordered_set<IdentifierHash> hashToSelect(idVect.begin(), idVect.end());
37 using RdoPairs = std::array<const xAOD::NRPCRDO*, 2>;
38 std::map<Identifier, RdoPairs, Muon::IdentifierByDetElSorter> sortedRdos{Muon::IdentifierByDetElSorter{m_idHelperSvc.get()}};
39 for (const xAOD::NRPCRDO* rdo : *rdoContainer){
40 /* cabling data conversion */
41 Muon::RpcCablingData cabling{};
42 cabling.subDetector = rdo->subdetector();
43 cabling.boardSector = rdo->boardsector();
44 cabling.board = rdo->board();
45 cabling.channelId = rdo->channel();
46
47
48 if (!cablingMap->getOfflineId(cabling, msgStream())){
49 return StatusCode::FAILURE;
50 }
51 Identifier offId{};
52 if (!cablingMap->convert(cabling, offId)){
53 ATH_MSG_FATAL("Cabling conversion failed "<<cabling);
54 return StatusCode::FAILURE;
55 }
56 if (hashToSelect.size() && !hashToSelect.count(m_idHelperSvc->moduleHash(offId))) {
57 ATH_MSG_VERBOSE("Skip "<<m_idHelperSvc->toString(offId)<<" due to ROI selection ");
58 continue;
59 }
61 const bool stripSide = cabling.stripSide();
62 sortedRdos[offId][stripSide] = rdo;
63 }
64
65 SG::WriteHandle stripHandle{m_writeKey, ctx};
66 ATH_CHECK(stripHandle.record(std::make_unique<xAOD::RpcStripContainer>(),
67 std::make_unique<xAOD::RpcStripAuxContainer>()));
68
69 SG::WriteHandle<xAOD::RpcStrip2DContainer> strip2DHandle{};
70 if (!m_writeKeyBI.empty()) {
71 strip2DHandle = SG::WriteHandle{m_writeKeyBI, ctx};
72 ATH_CHECK(strip2DHandle.record(std::make_unique<xAOD::RpcStrip2DContainer>(),
73 std::make_unique<xAOD::RpcStrip2DAuxContainer>()));
74
75 }
76
77 const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
78
79 auto setMeasValues = [&idHelper,this](xAOD::RpcMeasurement* outputMeas,
80 const xAOD::NRPCRDO* rdo,
81 const Identifier& offId){
82
83 const MuonGMR4::RpcReadoutElement* reElement = m_detMgr->getRpcReadoutElement(offId);
84 outputMeas->setIdentifierHash(m_idHelperSvc->detElementHash(offId));
85 outputMeas->setReadoutElement(reElement);
86 outputMeas->setIdentifier(offId.get_compact());
87 outputMeas->setDoubletPhi(idHelper.doubletPhi(offId));
88 outputMeas->setGasGap(idHelper.gasGap(offId));
89 outputMeas->setStripNumber(idHelper.channel(offId));
90 outputMeas->setTimeOverThreshold(rdo->timeoverthr());
92 outputMeas->setTime(rdo->time());
93 outputMeas->setTimeCovariance(std::pow(m_stripTimeResolution,2));
94 };
95
97 using CheckVector2D = MuonGMR4::StripDesign::CheckVector2D;
98 for (const auto& [offId, rdoPairs] : sortedRdos) {
99 const MuonGMR4::RpcReadoutElement* reElement = m_detMgr->getRpcReadoutElement(offId);
100 const IdentifierHash measHash = reElement->measurementHash(offId);
101
102 const MuonGMR4::StripDesign& design{reElement->sensorLayout(measHash)->design(idHelper.measuresPhi(offId))};
103
104 CheckVector2D stripPos = design.center(idHelper.channel(offId));
105 if (!stripPos) {
106 ATH_MSG_WARNING("Failed to fetch a valid stripPosition for "<<m_idHelperSvc->toString(offId));
107 continue;
108 }
109 const double stripLocX = (*stripPos).x();
110 const double stripCovX = std::pow(design.stripPitch(), 2) / std::sqrt(12.);
111
112 if (m_decode2DStrips && rdoPairs[0] && rdoPairs[1]) {
113 xAOD::RpcStrip2D* measurement = strip2DHandle->push_back(std::make_unique<xAOD::RpcStrip2D>());
114
115 xAOD::MeasVector<2> lPos{xAOD::MeasVector<2>::Zero()};
116 xAOD::MeasMatrix<2> lCov{xAOD::MeasMatrix<2>::Identity()};
117
118 lPos[0] = stripLocX;
119 lPos[1] = 0.5*m_propagationVelocity *(rdoPairs[0]->time() - rdoPairs[1]->time());
120 lCov(0,0) = stripCovX;
121 lCov(1,1) = M_SQRT1_2 * m_propagationVelocity* m_stripTimeResolution;
123 measurement->setMeasurement<2>(0, lPos, lCov);
124 // CheckVector2D stripPos
125 setMeasValues(measurement, rdoPairs[0], offId);
126 ATH_MSG_VERBOSE("Measurement "<<m_idHelperSvc->toString(offId)<<" "<<lPos.x()<<", "<<lPos.y());
127 continue;
128 }
129
130 xAOD::RpcStrip* strip = stripHandle->push_back(std::make_unique<xAOD::RpcStrip>());
131 xAOD::MeasVector<1> lPos{xAOD::MeasVector<1>::Zero()};
132 xAOD::MeasMatrix<1> lCov{xAOD::MeasMatrix<1>::Identity()};
133 lPos[0] = stripLocX;
134 lCov(0,0) = stripCovX;
135
136 strip->setMeasuresPhi(idHelper.measuresPhi(offId));
138 strip->setMeasurement<1>(0, lPos, lCov);
139 setMeasValues(strip, rdoPairs[0] ? rdoPairs[0] : rdoPairs[1], offId);
140 }
141 return StatusCode::SUCCESS;
142
143 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
value_type get_compact() const
Get the compact id.
IdentifierHash measurementHash(const Identifier &measId) const override final
Constructs the identifier hash from the full measurement Identifier.
const StripLayerPtr & sensorLayout(const IdentifierHash &measHash) const
Access to the StripLayer associated to a given measurement Hash.
CheckVector2D center(int stripNumb) const
Returns the bisector of the strip (Global numbering scheme)
std::optional< Amg::Vector2D > CheckVector2D
Definition StripDesign.h:82
double stripPitch() const
Distance between two adjacent strips.
SG::ReadHandleKey< xAOD::NRPCRDOContainer > m_rdoKey
Gaudi::Property< double > m_propagationVelocity
SG::ReadCondHandleKey< Muon::RpcCablingMap > m_cablingKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::WriteHandleKey< xAOD::RpcStripContainer > m_writeKey
SG::WriteHandleKey< xAOD::RpcStrip2DContainer > m_writeKeyBI
Gaudi::Property< double > m_stripTimeResolution
const MuonGMR4::MuonDetectorManager * m_detMgr
int gasGap(const Identifier &id) const override
get the hashes
int channel(const Identifier &id) const override
int doubletPhi(const Identifier &id) const
bool measuresPhi(const Identifier &id) const override
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
time(flags, cells_name, *args, **kw)
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
RpcStrip_v1 RpcStrip
Definition RpcStripFwd.h:12
RpcStrip2D_v1 RpcStrip2D
Eigen::Matrix< float, N, N > MeasMatrix
NRPCRDO_v1 NRPCRDO
Define the version of the NRPC RDO class.
Definition NRPCRDO.h:13
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
NRPCRDOContainer_v1 NRPCRDOContainer
Define the version of the NRPC RDO container.
RpcMeasurement_v1 RpcMeasurement

◆ decode() [2/2]

StatusCode MuonR4::RpcRdoToRpcPrepDataTool::decode ( const EventContext & ctx,
const std::vector< uint32_t > & robIds ) const
finaloverride

Definition at line 144 of file RpcRdoToRpcPrepDataTool.cxx.

145 {
146 const Muon::RpcCablingMap* cablingMap{nullptr};
147 ATH_CHECK(SG::get(cablingMap, m_cablingKey, ctx));
148 return decode(ctx, cablingMap->getChamberHashVec(robIds, msgStream()));
149 }
StatusCode decode(const EventContext &ctx, const std::vector< IdentifierHash > &idVect) const override final

◆ initialize()

StatusCode MuonR4::RpcRdoToRpcPrepDataTool::initialize ( )
finaloverride

Definition at line 16 of file RpcRdoToRpcPrepDataTool.cxx.

16 {
17 ATH_CHECK(m_idHelperSvc.retrieve());
18 ATH_CHECK(m_rdoKey.initialize());
19 ATH_CHECK(m_cablingKey.initialize());
21 ATH_CHECK(m_writeKey.initialize());
23 return StatusCode::SUCCESS;
24 }
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ provideEmptyContainer()

StatusCode MuonR4::RpcRdoToRpcPrepDataTool::provideEmptyContainer ( const EventContext & ctx) const
finaloverride

Method to create the empty containers.. Only used for seeded decoding.

Definition at line 150 of file RpcRdoToRpcPrepDataTool.cxx.

150 {
151 SG::WriteHandle stripHandle{m_writeKey, ctx};
152 ATH_CHECK(stripHandle.record(std::make_unique<xAOD::RpcStripContainer>(),
153 std::make_unique<xAOD::RpcStripAuxContainer>()));
154
155 if (!m_writeKeyBI.empty()) {
156 SG::WriteHandle strip2DHandle{m_writeKeyBI, ctx};
157 ATH_CHECK(strip2DHandle.record(std::make_unique<xAOD::RpcStrip2DContainer>(),
158 std::make_unique<xAOD::RpcStrip2DAuxContainer>()));
159
160 }
161 return StatusCode::SUCCESS;
162 }

Member Data Documentation

◆ m_cablingKey

SG::ReadCondHandleKey<Muon::RpcCablingMap> MuonR4::RpcRdoToRpcPrepDataTool::m_cablingKey
private
Initial value:
{this, "CablingKey", "MuonNRPC_CablingMap",
"Key of MuonNRPC_CablingMap"}

Definition at line 47 of file RpcRdoToRpcPrepDataTool.h.

47 {this, "CablingKey", "MuonNRPC_CablingMap",
48 "Key of MuonNRPC_CablingMap"};

◆ m_decode2DStrips

Gaudi::Property<bool> MuonR4::RpcRdoToRpcPrepDataTool::m_decode2DStrips {this, "decode2DStrips", true}
private

Definition at line 60 of file RpcRdoToRpcPrepDataTool.h.

60{this, "decode2DStrips", true};

◆ m_detMgr

const MuonGMR4::MuonDetectorManager* MuonR4::RpcRdoToRpcPrepDataTool::m_detMgr {nullptr}
private

Definition at line 57 of file RpcRdoToRpcPrepDataTool.h.

57{nullptr};

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonR4::RpcRdoToRpcPrepDataTool::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 43 of file RpcRdoToRpcPrepDataTool.h.

43{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_propagationVelocity

Gaudi::Property<double> MuonR4::RpcRdoToRpcPrepDataTool::m_propagationVelocity
private
Initial value:
{this, "propSpeed", 0.5 * Gaudi::Units::c_light,
"Propagation speed of the signal inside the strip"}

Definition at line 62 of file RpcRdoToRpcPrepDataTool.h.

62 {this, "propSpeed", 0.5 * Gaudi::Units::c_light,
63 "Propagation speed of the signal inside the strip"}; // in mm/ns

◆ m_rdoKey

SG::ReadHandleKey<xAOD::NRPCRDOContainer> MuonR4::RpcRdoToRpcPrepDataTool::m_rdoKey {this, "RpcRdoContainer", "NRPCRDO"}
private

Definition at line 45 of file RpcRdoToRpcPrepDataTool.h.

45{this, "RpcRdoContainer", "NRPCRDO"};

◆ m_stripTimeResolution

Gaudi::Property<double> MuonR4::RpcRdoToRpcPrepDataTool::m_stripTimeResolution
private
Initial value:
{this, "timeResolution", 0.6 * Gaudi::Units::nanosecond,
"Estimated time resolution of the strip readout"}

Definition at line 65 of file RpcRdoToRpcPrepDataTool.h.

65 {this, "timeResolution", 0.6 * Gaudi::Units::nanosecond,
66 "Estimated time resolution of the strip readout"};

◆ m_writeKey

SG::WriteHandleKey<xAOD::RpcStripContainer> MuonR4::RpcRdoToRpcPrepDataTool::m_writeKey
private
Initial value:
{this, "OutputContainer", "xRpcStrips",
"Output container"}

Definition at line 51 of file RpcRdoToRpcPrepDataTool.h.

51 {this, "OutputContainer", "xRpcStrips",
52 "Output container"};

◆ m_writeKeyBI

SG::WriteHandleKey<xAOD::RpcStrip2DContainer> MuonR4::RpcRdoToRpcPrepDataTool::m_writeKeyBI
private
Initial value:
{this, "OutputContainerBI", "xRpcBILStrips",
"Output container of the 2D BIL rpc strips"}

Definition at line 54 of file RpcRdoToRpcPrepDataTool.h.

54 {this, "OutputContainerBI", "xRpcBILStrips",
55 "Output container of the 2D BIL rpc strips"};

The documentation for this class was generated from the following files: