49 {
50
51 const sTgcIdHelper& id_helper =
m_idHelperSvc->stgcIdHelper();
53
54 ATH_MSG_DEBUG(
" ***************** Start of process STGC Collection with hash Id: " << hash);
55
56 auto stgcPrepDataContainer = xAODcontainers.prd;
57
58 if ( stgcPrepDataContainer->indexFindPtr(hash) != nullptr ) {
59 ATH_MSG_DEBUG(
"In processCollection: collection already contained in the sTGC PrepData container");
60 return StatusCode::FAILURE;
61
62 }
63
64
66
68 ATH_MSG_DEBUG(
"In processCollection: collection already available in the sTgc PrepData container (via cache)");
69 return StatusCode::SUCCESS;
70 }
71
72
73 std::unique_ptr<sTgcPrepDataCollection> prdColl = std::make_unique<sTgcPrepDataCollection>(hash);
74
75
77 Identifier moduleId;
78 int getId = id_helper.
get_id(hash, moduleId, &context);
79 if ( getId != 0 ) {
80 ATH_MSG_ERROR(
"Could not convert the hash Id: " << hash <<
" to identifier");
81 } else {
82 prdColl->setIdentifier(moduleId);
83 }
84
85
86 std::vector<sTgcPrepData> sTgcStripPrds;
87 std::vector<sTgcPrepData> sTgcWirePrds;
88 std::vector<sTgcPrepData> sTgcPadPrds;
89 sTgcStripPrds.reserve(rdoColl->
size());
90 sTgcPadPrds.reserve(rdoColl->
size());
91 sTgcWirePrds.reserve(rdoColl->
size());
92
93
94
95
96
97 const MuonGM::MuonDetectorManager* muonDetMgr{nullptr};
99
100 for ( const STGC_RawData* rdo : * rdoColl) {
101
103
104 const Identifier rdoId = rdo->identify();
105
106 std::vector<Identifier> rdoList{rdoId};
107
108
111
113 if (channelType < 0 || channelType > 2) {
115 return StatusCode::FAILURE;
116 }
119 return StatusCode::FAILURE;
120 }
121
122
123
126
127 NSWCalib::CalibratedStrip calibStrip;
129 int calibratedCharge =
static_cast<int>(calibStrip.
charge);
130 if (calibratedCharge < 0 && channelType == 1) {
131 if (!hitNegativeCharge) {
132 ATH_MSG_DEBUG(
"One sTGC RDO or more, such as one with pdo = "<<rdo->charge() <<
" counts, corresponds to a negative charge (" << calibratedCharge <<
"). Skipping these RDOs");
133 hitNegativeCharge = true;
134 }
135 continue;
136 }
137
140 const MuonGM::MuonPadDesign* design = detEl->
getPadDesign(rdoId);
141 if (!design) {
143 } else {
145 }
146 } else {
147 const MuonGM::MuonChannelDesign* design = detEl->
getDesign(rdoId);
148 if (!design) {
150 } else {
152 }
153 }
154
159
160 ATH_MSG_DEBUG(
"Adding a new STGC PRD, gasGap: " << gasGap <<
" channel: " << channel <<
" type: " << channelType <<
" resolution " << resolution );
161
163 std::vector<sTgcPrepData>& sTgcPrds = channelType ==
sTgcIdHelper::Pad ? sTgcPadPrds :
165
166
167 auto it = std::find_if(sTgcPrds.begin(), sTgcPrds.end(), [&rdoId](
const sTgcPrepData& prd) {
168 return (prd.identify() == rdoId);
169 });
170 if (it == sTgcPrds.end()) {
171 sTgcPrds.emplace_back(rdoId, hash, std::move(localPos), std::move(rdoList), std::move(cov), detEl, calibratedCharge, calibStrip.
time);
173 }
else if (
it->time() > calibStrip.
time) {
174 *
it =
sTgcPrepData(rdoId, hash, std::move(localPos), std::move(rdoList), std::move(cov), detEl, calibratedCharge, calibStrip.
time);
176 }
177
178
179
180 } else {
181
182 prdColl->push_back(std::make_unique<sTgcPrepData>(rdoId,
183 hash,
184 std::move(localPos),
185 std::move(rdoList),
186 std::move(cov),
187 detEl,
188 calibratedCharge,
190 }
191 }
192
194
195 std::vector<std::unique_ptr<Muon::sTgcPrepData>> sTgcStripClusters;
197
198 for ( std::unique_ptr<Muon::sTgcPrepData>& it : sTgcStripClusters ) {
199 it->setHashAndIndex(prdColl->identifyHash(), prdColl->size());
200 prdColl->push_back(std::move(it));
201 }
202 for ( Muon::sTgcPrepData& prd : sTgcWirePrds ) {
203 prd.setHashAndIndex(prdColl->identifyHash(), prdColl->size());
204 prdColl->push_back(std::make_unique<sTgcPrepData>(std::move(prd)));
205 }
206 for (Muon::sTgcPrepData& prd : sTgcPadPrds ) {
207 prd.setHashAndIndex(prdColl->identifyHash(), prdColl->size());
208 prdColl->push_back(std::make_unique<sTgcPrepData>(std::move(prd)));
209 }
210 }
213
214 if (convertXAOD) {
215 for (const Muon::sTgcPrepData* prd : *prdColl) {
216 const Identifier prdId = prd->identify();
223 <<", cov: "<<prd->localCovariance()(0,0)
226 outHit = xAODcontainers.pad->push_back(std::make_unique<xAOD::sTgcPadHit>());
230
233 std::move(lCov));
235 outHit = xAODcontainers.wire->push_back(std::make_unique<xAOD::sTgcWireHit>());
237 auto stripHit = xAODcontainers.strip->push_back(std::make_unique<xAOD::sTgcStripCluster>());
238 stripHit->setStripCharges(prd->stripCharges());
239 stripHit->setStripNumbers(prd->stripNumbers());
240 stripHit->setStripTimes(prd->stripTimes());
241 outHit = stripHit;
242 }
243 if (!outHit) {
244 continue;
245 }
249 lCov(0,0) = prd->localCovariance()(0,0);
251 std::move(lPos),
252 std::move(lCov));
253
254 }
263 }
264 }
265 }
266
267
268
270 ATH_MSG_DEBUG(
"PRD hash " << hash <<
" has been moved to container");
271
272 return StatusCode::SUCCESS;
273}
#define ATH_MSG_VERBOSE(x)
sTgcIdHelper::sTgcChannelTypes chType
size_type size() const noexcept
Returns the number of elements in the collection.
bool OnlineAndPresentInAnotherView()
This method is to avoid calling an expensive operation in the offline case.
StatusCode addOrDelete(std::unique_ptr< T > ptr)
value_type get_compact() const
Get the compact id.
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
const MuonPadDesign * getPadDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position - should be renamed to channel position If the strip number is outside the range of va...
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override
Create compact id from hash id (return == 0 for OK)
IdContext module_context() const
id for module
const IdentifierHash & identifyHash() const
int channelType(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
ConstMatrixMap< N > localCovariance() const
Returns the 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 setReadoutElement(const MuonGMR4::sTgcReadoutElement *readoutEle)
set the pointer to the sTgcReadoutElement
void setGasGap(uint8_t gap)
Set the associated gas gap of the measurement.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
double resolution[nGasTypes][nParametersResolution]
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Eigen::Matrix< float, N, N > MeasMatrix
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
MeasVector< N > toStorage(const AmgVector(N)&amgVec)
Converts the double precision of the AmgVector into the floating point storage precision of the MeasV...
sTgcMeasurement_v1 sTgcMeasurement
double channelWidth() const
calculate local channel width
double channelWidth(const Amg::Vector2D &pos, bool measPhi, bool preciseMeas=false) const
calculate local channel width