ATLAS Offline Software
Loading...
Searching...
No Matches
PRDxAODConvertorAlg.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
13
14
21
22 ATH_CHECK(m_mdtxAODKey.initialize(!m_mdtPrepRawDataKey.empty()));
23 ATH_CHECK(m_rpcxAODKey.initialize(!m_rpcPrepRawDataKey.empty()));
24 ATH_CHECK(m_tgcxAODKey.initialize(!m_tgcPrepRawDataKey.empty()));
25 ATH_CHECK(m_mmxAODKey.initialize(!m_mmPrepRawDataKey.empty()));
28 ATH_CHECK(m_stgcPadxAODKey.initialize(!m_stgcPrepRawDataKey.empty()));
29
30 ATH_CHECK(m_idHelperSvc.retrieve());
31
32 return StatusCode::SUCCESS;
33}
34
49
50// I *think* it's possible to not need to pass OUTTYPEAUX, but construct it from OUTTYPE.
51template <class INTYPE, class OUTTYPE, class OUTTYPEAUX>
53 const SG::WriteHandleKey<OUTTYPE> &outKey,
54 const EventContext& ctx) const {
55 if(inKey.empty()) {
56 ATH_MSG_VERBOSE("No key configured to convert "<<typeid(INTYPE).name()<<" into xAOD objects. Skipping.");
57 return StatusCode::SUCCESS;
58 }
59
60 SG::ReadHandle<INTYPE> handle(inKey, ctx);
61
62 ATH_MSG_VERBOSE("Trying to load " << handle.key());
63 ATH_CHECK(handle.isValid());
64 ATH_MSG_VERBOSE("Which has " << handle->numberOfCollections()
65 << " collections: ");
66
67 SG::WriteHandle<OUTTYPE> outputContainer(outKey, ctx);
68 ATH_CHECK( outputContainer.record (std::make_unique<OUTTYPE>(),
69 std::make_unique<OUTTYPEAUX>()) );
70 ATH_MSG_DEBUG( "Recorded xAOD container with key: " << outputContainer.key() );
71
72 for (const auto *coll : *handle) {
73 for (const auto * prd : *coll) {
74 auto * xprd = new typename OUTTYPE::base_value_type();
75 outputContainer->push_back(xprd);
76 if (!fillxPRD(*prd, *xprd)) {
77 outputContainer->pop_back();
78 }
79 }
80 }
81
82 return StatusCode::SUCCESS;
83}
84
85// Keeping this in since it seems to compile with gcc13 and not 11 and I want to understand why.
86// template<class PRD, class xPRD> void Muon::PRDxAODConvertorAlg::fillxPRD(
87// const PRD& prd, xPRD& xprd) const {
88// static_assert(false, "FillxPRD requires explicit specialization.");
89// }
90
92 xAOD::MdtDriftCircle& xprd) const {
93 const MdtIdHelper& id_helper{m_idHelperSvc->mdtIdHelper()};
94
95 const Identifier prdId{prd.identify()};
97
98 xAOD::MeasVector<1> localPosition(prd.localPosition().x());
99 xAOD::MeasMatrix<1> localCovariance{};
100 localCovariance(0, 0) = prd.localCovariance()(0, 0);
101 xprd.setMeasurement(m_idHelperSvc->detElementHash(prdId), localPosition, localCovariance);
102
103 xprd.setTdc(prd.tdc());
104 xprd.setAdc(prd.adc());
105 xprd.setTube(id_helper.tube(prd.identify()));
106 xprd.setLayer(id_helper.tubeLayer(prd.identify()));
107 xprd.setStatus(prd.status());
108 // TODO tubePosInStation - but this needs ReadoutElement?
109 return true;
110}
111
113 xAOD::RpcStrip& xprd) const {
114
115 const RpcIdHelper& idHelper{m_idHelperSvc->rpcIdHelper()};
116 const Identifier prdId{prd.identify()};
118
119 xprd.setStripNumber(idHelper.strip(prdId));
120 xprd.setGasGap(idHelper.gasGap(prdId));
121 xprd.setMeasuresPhi(idHelper.measuresPhi(prdId));
122 xprd.setDoubletPhi(idHelper.doubletPhi(prdId));
123
124 xAOD::MeasVector<1> localPosition(prd.localPosition().x());
126 localCovariance(0, 0) = prd.localCovariance()(0, 0);
127 xprd.setMeasurement(m_idHelperSvc->detElementHash(prdId), localPosition, localCovariance);
128
129 xprd.setTime(prd.time());
130 xprd.setTriggerInfo(prd.triggerInfo());
133 return true;
134}
135
137 xAOD::TgcStrip& xprd) const {
138
139 const TgcIdHelper& idHelper{m_idHelperSvc->tgcIdHelper()};
140 const Identifier prdId{prd.identify()};
142 xprd.setMeasuresPhi(idHelper.measuresPhi(prdId));
143 xprd.setGasGap(idHelper.gasGap(prdId));
144 xprd.setChannelNumber(idHelper.channel(prdId));
145 xAOD::MeasVector<1> localPosition(prd.localPosition().x());
147 localCovariance(0, 0) = prd.localCovariance()(0, 0);
148 xprd.setMeasurement(m_idHelperSvc->detElementHash(prdId), localPosition, localCovariance);
149
150 xprd.setBcBitMap(prd.getBcBitMap());
151 return true;
152}
153
155 xAOD::MMCluster& xprd) const {
156
157 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
158 const Identifier prdId{prd.identify()};
160 xprd.setGasGap(idHelper.gasGap(prdId));
161 xprd.setChannelNumber(idHelper.channel(prdId));
162 xAOD::MeasVector<1> localPosition(prd.localPosition().x());
164 localCovariance(0, 0) = prd.localCovariance()(0, 0);
165 xprd.setMeasurement(m_idHelperSvc->detElementHash(prdId), localPosition, localCovariance);
166
167 xprd.setTime(prd.time());
168 xprd.setCharge(prd.charge());
169 xprd.setDriftDist(prd.driftDist());
170 xprd.setAngle(prd.angle());
171 xprd.setChiSqProb(prd.chisqProb());
172
176 xprd.setStripCharges(prd.stripCharges());
177 xprd.setStripTimes(prd.stripTimes());
178 xprd.setStripNumbers(prd.stripNumbers());
179 return true;
180}
181
183 xAOD::sTgcStripCluster& xprd) const {
184
185 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
186 const Identifier prdId = prd.identify();
187 if (idHelper.channelType(prdId) != sTgcIdHelper::Strip) return false;
189 xAOD::MeasVector<1> localPosition(prd.localPosition().x());
191 localCovariance(0, 0) = prd.localCovariance()(0, 0);
192 xprd.setChannelNumber(idHelper.channel(prdId));
193 xprd.setGasGap(idHelper.gasGap(prdId));
194 xprd.setMeasurement(prd.collectionHash(), localPosition, localCovariance);
195 xprd.setTime(prd.time());
196 xprd.setCharge(prd.charge());
197 xprd.setAuthor(prd.author());
198 xprd.setQuality(prd.quality());
199 xprd.setStripCharges(prd.stripCharges());
200 xprd.setStripNumbers(prd.stripNumbers());
201 xprd.setStripTimes(prd.stripTimes());
202 return true;
203}
204
206 xAOD::sTgcWireHit& xprd) const {
207 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
208 const Identifier prdId = prd.identify();
209 if (idHelper.channelType(prdId) != sTgcIdHelper::Wire) return false;
211 xAOD::MeasVector<1> localPosition(prd.localPosition().x());
213 localCovariance(0, 0) = prd.localCovariance()(0, 0);
214 xprd.setChannelNumber(idHelper.channel(prdId));
215 xprd.setGasGap(idHelper.gasGap(prdId));
216 xprd.setMeasurement(prd.collectionHash(), localPosition, localCovariance);
217 xprd.setTime(prd.time());
218 xprd.setCharge(prd.charge());
219 xprd.setAuthor(prd.author());
220 return true;
221}
223 xAOD::sTgcPadHit& xprd) const {
224 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
225 const Identifier prdId = prd.identify();
226 if (idHelper.channelType(prdId) != sTgcIdHelper::Pad) return false;
230 localCovariance(0, 0) = prd.localCovariance()(0, 0);
231 // localCovariance(1, 1) = prd.localCovariance()(1, 1);
232 xprd.setChannelNumber(idHelper.channel(prdId));
233 xprd.setGasGap(idHelper.gasGap(prdId));
234 xprd.setMeasurement(prd.collectionHash(), localPosition, localCovariance);
235 xprd.setTime(prd.time());
236 xprd.setCharge(prd.charge());
237 xprd.setAuthor(prd.author());
238 return true;
239}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
int tube(const Identifier &id) const
int tubeLayer(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
Class to represent MM measurements.
Definition MMPrepData.h:22
const std::vector< AmgVector(2)> & stripDriftErrors() const
returns the list of drift distances
Definition MMPrepData.h:267
const std::vector< uint16_t > & stripNumbers() const
returns the list of strip numbers
Definition MMPrepData.h:247
const std::vector< short int > & stripTimes() const
returns the list of times
Definition MMPrepData.h:252
float angle() const
Returns the microTPC angle.
Definition MMPrepData.h:237
float driftDist() const
Returns the Drift Distance.
Definition MMPrepData.h:232
short int time() const
Returns the time (in ns)
Definition MMPrepData.h:222
const std::vector< float > & stripDriftDist() const
returns the list of drift distances
Definition MMPrepData.h:262
const std::vector< int > & stripCharges() const
returns the list of charges
Definition MMPrepData.h:257
int charge() const
Returns the AD.
Definition MMPrepData.h:227
float chisqProb() const
Returns the microTPC chisq Prob.
Definition MMPrepData.h:242
Class to represent measurements from the Monitored Drift Tubes.
Definition MdtPrepData.h:33
int adc() const
Returns the ADC (typically range is 0 to 250)
MdtDriftCircleStatus status() const
Returns the status of the measurement.
int tdc() const
Returns the TDC (typically range is 0 to 2500).
virtual IdentifierHash collectionHash() const
Returns the IdentifierHash corresponding to the PRD collection in the PRD container.
SG::ReadHandleKey< Muon::RpcPrepDataContainer > m_rpcPrepRawDataKey
SG::WriteHandleKey< xAOD::sTgcPadContainer > m_stgcPadxAODKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
SG::ReadHandleKey< Muon::TgcPrepDataContainer > m_tgcPrepRawDataKey
SG::WriteHandleKey< xAOD::sTgcWireContainer > m_stgcWirexAODKey
SG::ReadHandleKey< Muon::MdtPrepDataContainer > m_mdtPrepRawDataKey
SG::ReadHandleKey< Muon::sTgcPrepDataContainer > m_stgcPrepRawDataKey
SG::WriteHandleKey< xAOD::MdtDriftCircleContainer > m_mdtxAODKey
bool fillxPRD(const PRD &prd, xPRD &xprd) const
SG::ReadHandleKey< Muon::MMPrepDataContainer > m_mmPrepRawDataKey
virtual StatusCode initialize() override
SG::WriteHandleKey< xAOD::TgcStripContainer > m_tgcxAODKey
virtual StatusCode execute(const EventContext &ctx) const override
StatusCode getAndFillContainer(const SG::ReadHandleKey< INTYPE > &inKey, const SG::WriteHandleKey< OUTTYPE > &outKey, const EventContext &) const
SG::WriteHandleKey< xAOD::sTgcStripContainer > m_stgcStripxAODKey
SG::WriteHandleKey< xAOD::MMClusterContainer > m_mmxAODKey
SG::WriteHandleKey< xAOD::RpcStripContainer > m_rpcxAODKey
Class to represent RPC measurements.
Definition RpcPrepData.h:35
float timeOverThreshold() const
Returns the time over threshold.
int triggerInfo() const
Returns the trigger coincidence - usually false, unless ijk>5 or highpt&&ijk==0.
int ambiguityFlag() const
Returns the number of ambiguities associated with this RpcPrepData.
float time() const
Returns the time.
Class to represent TGC measurements.
Definition TgcPrepData.h:32
uint16_t getBcBitMap() const
Returns the bcBitMap of this PRD bit2 for Previous BC, bit1 for Current BC, bit0 for Next BC.
Class to represent sTgc measurements.
Quality quality() const
int charge() const
Returns the bcBitMap of this PRD bit2 for Previous BC, bit1 for Current BC, bit0 for Next BC.
Author author() const
const std::vector< uint16_t > & stripNumbers() const
returns the list of strip numbers
short int time() const
const std::vector< int > & stripCharges() const
returns the list of charges
const std::vector< short int > & stripTimes() const
returns the list of times
int gasGap(const Identifier &id) const override
get the hashes
int doubletPhi(const Identifier &id) const
int strip(const Identifier &id) const
bool measuresPhi(const Identifier &id) const override
Property holding a SG store/key/clid from which a ReadHandle is made.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
bool empty() const
Test if the key is blank.
Property holding a SG store/key/clid from which a WriteHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
bool measuresPhi(const Identifier &id) const override
const Amg::Vector2D & localPosition() const
return the local position reference
Identifier identify() const
return the identifier
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
int channelType(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
void setDriftDist(float value)
Sets the drift distance.
void setStripDriftDist(const std::vector< float > &stripDriftDist)
void setStripDriftErrors(const std::vector< DriftCov_t > &stripDriftErrors)
void setStripNumbers(const std::vector< uint16_t > &stripNumbers)
void setStripCharges(const std::vector< int > &stripCharges)
void setChiSqProb(float value)
Sets the microTPC chisq probability.
void setTime(uint16_t value)
Sets the TDC counts.
void setAngle(float value)
Sets the microTPC angle.
void setStripTimes(const std::vector< int16_t > &stripTimes)
void setChannelNumber(uint16_t strip)
void setGasGap(uint8_t gap)
void setCharge(uint32_t value)
Sets the calibrated charge.
void setAdc(int16_t adc)
Sets the ADC counts.
void setLayer(uint8_t layer_n)
Sets the layer number.
void setStatus(MdtDriftCircleStatus st)
Sets the status of the drift circle.
void setTdc(int16_t tdc)
Setter methods.
void setTube(uint16_t tube_n)
Sets the tube number.
void setAmbiguityFlag(uint8_t ambi)
Sets the ADC counts.
void setDoubletPhi(uint8_t doubPhi)
Sets the doubletPhi identifier field.
void setTriggerInfo(uint32_t triggerinfo)
Set the trigger info of the hit.
void setGasGap(uint8_t gap)
Sets the associated gasGap identifier field.
void setTimeOverThreshold(float timeoverthreshold)
Sets the TDC counts.
void setTime(float time)
Sets the the triger time of the hit.
void setStripNumber(uint16_t strip)
Sets the associated strip number identifier field.
void setMeasuresPhi(uint8_t measPhi)
sets the measuresPhi value
void setMeasuresPhi(uint8_t measPhi)
Set the measures phi flag of the measurement to true /false.
void setGasGap(uint8_t gapNum)
Set the gas gap number of the measurement [1-N].
void setChannelNumber(uint16_t chan)
Set the strip or wire group number of the measurement.
void setBcBitMap(uint16_t)
Set the bunch crossing-id map.
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
void setIdentifier(const DetectorIdentType measId)
Sets the full Identifier of the measurement.
void setTime(short int t)
: Set the calibrated time of the wire measurement
void setAuthor(Author a)
Set the author of the producing algorithm.
void setCharge(int q)
: Set the collected charge on the wire
void setChannelNumber(uint16_t channel)
Set the channel number of the measurement.
void setGasGap(uint8_t gap)
Set the associated gas gap of the measurement.
void setStripNumbers(const std::vector< uint16_t > &strips)
Set the list of individual strip clusters.
void setStripCharges(const std::vector< int > &charges)
Set the individual list of contributing charges.
void setQuality(Quality q)
Set the quality flag.
void setStripTimes(const std::vector< short int > &times)
Set the list of indivual strip times.
RpcStrip_v1 RpcStrip
Definition RpcStripFwd.h:12
MdtDriftCircle_v1 MdtDriftCircle
Eigen::Matrix< float, N, N > MeasMatrix
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
TgcStrip_v1 TgcStrip
Definition TgcStripFwd.h:9
sTgcStripCluster_v1 sTgcStripCluster
MeasVector< N > toStorage(const AmgVector(N)&amgVec)
Converts the double precision of the AmgVector into the floating point storage precision of the MeasV...
sTgcWireHit_v1 sTgcWireHit
MMCluster_v1 MMCluster
sTgcPadHit_v1 sTgcPadHit