156 {
157
158 const sTgcIdHelper& id_helper =
m_idHelperSvc->stgcIdHelper();
159 const IdentifierHash
hash = rdoColl->identifyHash();
160
161 ATH_MSG_DEBUG(
" ***************** Start of process STGC Collection with hash Id: " << hash);
162
163
164 if (
cache.prdWriteHandle->indexFindPtr(hash) !=
nullptr ) {
165 ATH_MSG_DEBUG(
"In processCollection: collection already contained in the sTGC PrepData container");
166 return StatusCode::FAILURE;
167
168 }
169
170
172
173 if(
lock.OnlineAndPresentInAnotherView() ) {
174 ATH_MSG_DEBUG(
"In processCollection: collection already available in the sTgc PrepData container (via cache)");
175 return StatusCode::SUCCESS;
176 }
177
178
179 std::unique_ptr<sTgcPrepDataCollection>& prdColl =
cache.collections[
hash];
180 if (!prdColl) {
181 prdColl = std::make_unique<sTgcPrepDataCollection>(hash);
182 }
183
184
186 Identifier moduleId;
187 int getId = id_helper.
get_id(hash, moduleId, &context);
188 if ( getId != 0 ) {
189 ATH_MSG_ERROR(
"Could not convert the hash Id: " << hash <<
" to identifier");
190 } else {
191 prdColl->setIdentifier(moduleId);
192 }
193
194
195 std::vector<sTgcPrepData> sTgcStripPrds;
196 std::vector<sTgcPrepData> sTgcWirePrds;
197 std::vector<sTgcPrepData> sTgcPadPrds;
198 sTgcStripPrds.reserve(rdoColl->size());
199 sTgcPadPrds.reserve(rdoColl->size());
200 sTgcWirePrds.reserve(rdoColl->size());
201
202
203
204
205
206 const MuonGM::MuonDetectorManager* muonDetMgr{nullptr};
208
209 for ( const STGC_RawData* rdo : * rdoColl) {
210
212
213 const Identifier rdoId = rdo->identify();
214
215 std::vector<Identifier> rdoList{rdoId};
216
217
220
222 if (channelType < 0 || channelType > 2) {
224 return StatusCode::FAILURE;
225 }
228 return StatusCode::FAILURE;
229 }
230
231
232
235
236 NSWCalib::CalibratedStrip calibStrip;
238 int calibratedCharge =
static_cast<int>(calibStrip.
charge);
239 if (calibratedCharge < 0 && channelType == 1) {
240 if (!hitNegativeCharge) {
241 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");
242 hitNegativeCharge = true;
243 }
244 continue;
245 }
246
249 const MuonGM::MuonPadDesign* design = detEl->
getPadDesign(rdoId);
250 if (!design) {
252 } else {
254 }
255 } else {
256 const MuonGM::MuonChannelDesign* design = detEl->
getDesign(rdoId);
257 if (!design) {
259 } else {
261 }
262 }
263
268
269 ATH_MSG_DEBUG(
"Adding a new STGC PRD, gasGap: " << gasGap <<
" channel: " << channel <<
" type: " << channelType <<
" resolution " << resolution );
270
272 std::vector<sTgcPrepData>& sTgcPrds = channelType ==
sTgcIdHelper::Pad ? sTgcPadPrds :
274
275
276 auto it = std::find_if(sTgcPrds.begin(), sTgcPrds.end(), [&rdoId](
const sTgcPrepData& prd) {
277 return (prd.identify() == rdoId);
278 });
279 if (it == sTgcPrds.end()) {
280 sTgcPrds.emplace_back(rdoId, hash, std::move(localPos), std::move(rdoList), std::move(cov), detEl, calibratedCharge, calibStrip.
time);
282 }
else if (
it->time() > calibStrip.
time) {
283 *
it =
sTgcPrepData(rdoId, hash, std::move(localPos), std::move(rdoList), std::move(cov), detEl, calibratedCharge, calibStrip.
time);
285 }
286
287
288
289 } else {
290
291 prdColl->push_back(std::make_unique<sTgcPrepData>(rdoId,
292 hash,
293 std::move(localPos),
294 std::move(rdoList),
295 std::move(cov),
296 detEl,
297 calibratedCharge,
299 }
300 }
301
303
304 std::vector<std::unique_ptr<sTgcPrepData>> sTgcStripClusters;
306
307 for ( std::unique_ptr<sTgcPrepData>& it : sTgcStripClusters ) {
308 it->setHashAndIndex(prdColl->identifyHash(), prdColl->size());
309 prdColl->push_back(std::move(it));
310 }
312 prd.setHashAndIndex(prdColl->identifyHash(), prdColl->size());
313 prdColl->push_back(std::make_unique<sTgcPrepData>(std::move(prd)));
314 }
316 prd.setHashAndIndex(prdColl->identifyHash(), prdColl->size());
317 prdColl->push_back(std::make_unique<sTgcPrepData>(std::move(prd)));
318 }
319 }
320
321
322 ATH_MSG_DEBUG(
"PRD hash " << hash <<
" has been moved to container");
323
324 return StatusCode::SUCCESS;
325}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
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
int channelType(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
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.
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.
double channelWidth() const
calculate local channel width
double channelWidth(const Amg::Vector2D &pos, bool measPhi, bool preciseMeas=false) const
calculate local channel width