287 {
288 typedef CscRawDataContainer::const_iterator collection_iterator;
289
290 IdContext cscContext =
m_idHelperSvc->cscIdHelper().module_context();
291 SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{
m_muDetMgrKey};
292 const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.
cptr();
293
294
297 << "Decoding CSC RDO into CSC PrepRawData is switched off");
298 return StatusCode::SUCCESS;
299 }
301
302 collection_iterator rdoColl = rdoContainer->
begin();
303 collection_iterator lastRdoColl = rdoContainer->
end();
304 std::vector<float> charges;
305 charges.reserve(4);
306 std::vector<uint16_t> samples;
307 samples.reserve(4);
308
309 IdentifierHash cscHashId;
310 for (; rdoColl != lastRdoColl; ++rdoColl) {
311 if (!(*rdoColl)->empty()) {
312 ATH_MSG_DEBUG(
" Number of RawData in this rdo " << (*rdoColl)->size());
313
315 unsigned int samplingTime = cscCollection->
rate();
316 unsigned int numSamples = cscCollection->
numSamples();
318
319 if (
int(samplingTime) !=
int(
m_cscCalibTool->getSamplingTime())) {
320 ATH_MSG_WARNING(
" CSC sampling time from Collection is NOT consistant to calibTool parameter!!!!!!! ");
321 }
322
323
326
327
328
329 ATH_MSG_DEBUG(
"CSC RDO ID " << (*rdoColl)->identify() <<
" with hashID " << (*rdoColl)->identifyHash());
330
332 if (
m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
334 <<
"context begin_index = " << cscContext.
begin_index()
335 <<
" context end_index = " << cscContext.
end_index() <<
" the identifier is "<<stationId);
336 }
337
338 ATH_MSG_DEBUG(
"Create CSC PRD Collection with hash " << cscHashId);
339 std::unique_ptr<CscStripPrepDataCollection> collection = nullptr;
341 if (
lock.alreadyPresent()) {
342 ATH_MSG_DEBUG(
"CSC PRD collection already exist with collection hash = " << cscHashId <<
" collection filling is skipped!");
343 continue;
344 } else {
345 ATH_MSG_DEBUG(
"CSC PRD collection does not exist - creating a new one with hash = " << cscHashId);
346 collection = std::make_unique<CscStripPrepDataCollection>(cscHashId);
347 collection->setIdentifier(stationId);
348 }
349
350
351 for (; itD != itD_e; ++itD) {
356
357 ATH_MSG_DEBUG(
"DecodeAll*Size of online cluster in this RawData: "
358 <<
" Width = " <<
width <<
" Samples = " << totalSamples <<
" stationId : " << stationId
359 << " hashOffset : " << hashOffset);
360
361 for (
unsigned int j = 0;
j <
width; ++
j) {
363 ATH_MSG_DEBUG(
"DecodeAll**LOOP over width " << j <<
" " << channelId);
364
366
367 if (!descriptor) {
369 << " Skipping channel ");
370 continue;
371 }
else if (!descriptor->
containsId(channelId)) {
374 << "> inconsistent with the geometry of detector element <"
376 continue;
377 }
378
379 float timeOfFirstSample = 0.0;
380 bool extractSamples =
data->samples(j, numSamples, samples);
381 if (!extractSamples) {
382 ATH_MSG_WARNING(
"Unable to extract samples for strip " << j <<
" Online Cluster width = " <<
width
383 << " for number of Samples = " << numSamples
384 << " continuing ...");
385 continue;
386 }
387
388 IdentifierHash stripHash;
389 if (
m_idHelperSvc->cscIdHelper().get_channel_hash(channelId, stripHash)) {
391 }
392
393 Identifier channelIdFromHash;
394 m_idHelperSvc->cscIdHelper().get_id(stripHash, channelIdFromHash, &cscContext);
395
396 bool adctocharge =
m_cscCalibTool->adcToCharge(samples, stripHash, charges);
397 if (!adctocharge) {
399 << "CSC PrepData not build ... skipping ");
400 continue;
401 }
402 if (samples.size() >= 4)
404 <<
m_idHelperSvc->cscIdHelper().show_to_string(channelId) <<
" " << (
int)stripHash <<
" "
405 <<
m_idHelperSvc->cscIdHelper().show_to_string(channelIdFromHash) <<
" " << samples[0] <<
" "
406 << samples[1] << " " << samples[2] << " " << samples[3] << " Charges: "
407 << " " << charges[0] << " " << charges[1] << " " << charges[2] << " " << charges[3]);
408 if (
m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
410 <<
"context begin_index = " << cscContext.
begin_index()
411 <<
" context end_index = " << cscContext.
end_index() <<
" the identifier is "<< stationId);
412 }
413
414
415 bool IsThisStripDecoded = 0;
419 if (did == channelId) {
420 IsThisStripDecoded = 1;
421 break;
422 }
423 }
424 if (IsThisStripDecoded) continue;
425
426 int measuresPhi =
m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
427
429
430 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(channelId);
432 double errPos = stripWidth / sqrt(12.0);
433
435 covariance.setIdentity();
436 covariance *= errPos * errPos;
437 auto errClusterPos = Amg::MatrixX(covariance);
438
441 descriptor, charges, timeOfFirstSample, samplingTime);
442
443 if (samplingPhase) newPrepData->set_samplingPhase();
444 newPrepData->setHashAndIndex(collection->identifyHash(), collection->
size());
445 collection->push_back(newPrepData);
446 }
447 }
448
449 StatusCode status_lock =
lock.addOrDelete(std::move(collection));
450 if (status_lock.isFailure()) {
451 ATH_MSG_ERROR(
"Could not insert CscStripPrepdataCollection into CscStripPrepdataContainer...");
452 return StatusCode::FAILURE;
453 }
454 }
455 }
456 return StatusCode::SUCCESS;
457}
#define AmgSymMatrix(dim)
char data[hepevt_bytes_allocation_ATLAS]
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
Athena::TPCnvVers::Old Athena::TPCnvVers::Current CscRawDataCollection
size_t size() const
Number of registered mappings.
bool samplingPhase() const
uint16_t numSamples() const
uint8_t rate() const
the rate could be 25 or 50 ns
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type begin_index() const
size_type end_index() const
const_iterator end() const
return const_iterator for end of container
const_iterator begin() const
return const_iterator for first entry
double cathodeReadoutPitch(int chLayer, int measuresPhi) const
double xCoordinateInTrackingFrame(const Identifier &id) const
virtual bool containsId(const Identifier &id) const override
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
const_pointer_type cptr()
Identifier identify() const
return the identifier
Eigen::Matrix< double, 2, 1 > Vector2D
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)