289 {
290 typedef CscRawDataContainer::const_iterator collection_iterator;
291
292 IdContext cscContext =
m_idHelperSvc->cscIdHelper().module_context();
293 SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{
m_muDetMgrKey};
294 const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.
cptr();
295
296
299 << "Decoding CSC RDO into CSC PrepRawData is switched off");
300 return StatusCode::SUCCESS;
301 }
303
304 collection_iterator rdoColl = rdoContainer->
begin();
305 collection_iterator lastRdoColl = rdoContainer->
end();
306 std::vector<float> charges;
307 charges.reserve(4);
308 std::vector<uint16_t> samples;
309 samples.reserve(4);
310
311 IdentifierHash cscHashId;
312 for (; rdoColl != lastRdoColl; ++rdoColl) {
313 if (!(*rdoColl)->empty()) {
314 ATH_MSG_DEBUG(
" Number of RawData in this rdo " << (*rdoColl)->size());
315
317 unsigned int samplingTime = cscCollection->
rate();
318 unsigned int numSamples = cscCollection->
numSamples();
320
321 if (
int(samplingTime) !=
int(
m_cscCalibTool->getSamplingTime())) {
322 ATH_MSG_WARNING(
" CSC sampling time from Collection is NOT consistant to calibTool parameter!!!!!!! ");
323 }
324
325
328
329
330
331 ATH_MSG_DEBUG(
"CSC RDO ID " << (*rdoColl)->identify() <<
" with hashID " << (*rdoColl)->identifyHash());
332
334 if (
m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
336 <<
"context begin_index = " << cscContext.
begin_index()
337 <<
" context end_index = " << cscContext.
end_index() <<
" the identifier is ");
339 }
340
341 ATH_MSG_DEBUG(
"Create CSC PRD Collection with hash " << cscHashId);
342 std::unique_ptr<CscStripPrepDataCollection> collection = nullptr;
345 ATH_MSG_DEBUG(
"CSC PRD collection already exist with collection hash = " << cscHashId <<
" collection filling is skipped!");
346 continue;
347 } else {
348 ATH_MSG_DEBUG(
"CSC PRD collection does not exist - creating a new one with hash = " << cscHashId);
349 collection = std::make_unique<CscStripPrepDataCollection>(cscHashId);
350 collection->setIdentifier(stationId);
351 }
352
353
354 for (; itD != itD_e; ++itD) {
359
360 ATH_MSG_DEBUG(
"DecodeAll*Size of online cluster in this RawData: "
361 <<
" Width = " <<
width <<
" Samples = " << totalSamples <<
" stationId : " << stationId
362 << " hashOffset : " << hashOffset);
363
364 for (
unsigned int j = 0; j <
width; ++j) {
366 ATH_MSG_DEBUG(
"DecodeAll**LOOP over width " << j <<
" " << channelId);
367
369
370 if (!descriptor) {
372 << " Skipping channel ");
373 continue;
374 }
else if (!descriptor->
containsId(channelId)) {
377 << "> inconsistent with the geometry of detector element <"
379 continue;
380 }
381
382 float timeOfFirstSample = 0.0;
383 bool extractSamples =
data->samples(j, numSamples, samples);
384 if (!extractSamples) {
385 ATH_MSG_WARNING(
"Unable to extract samples for strip " << j <<
" Online Cluster width = " <<
width
386 << " for number of Samples = " << numSamples
387 << " continuing ...");
388 continue;
389 }
390
391 IdentifierHash stripHash;
392 if (
m_idHelperSvc->cscIdHelper().get_channel_hash(channelId, stripHash)) {
395 }
396
397 Identifier channelIdFromHash;
398 m_idHelperSvc->cscIdHelper().get_id(stripHash, channelIdFromHash, &cscContext);
399
400 bool adctocharge =
m_cscCalibTool->adcToCharge(samples, stripHash, charges);
401 if (!adctocharge) {
403 << "CSC PrepData not build ... skipping ");
404 continue;
405 }
406 if (samples.size() >= 4)
408 <<
m_idHelperSvc->cscIdHelper().show_to_string(channelId) <<
" " << (
int)stripHash <<
" "
409 <<
m_idHelperSvc->cscIdHelper().show_to_string(channelIdFromHash) <<
" " << samples[0] <<
" "
410 << samples[1] << " " << samples[2] << " " << samples[3] << " Charges: "
411 << " " << charges[0] << " " << charges[1] << " " << charges[2] << " " << charges[3]);
412 if (
m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
414 <<
"context begin_index = " << cscContext.
begin_index()
415 <<
" context end_index = " << cscContext.
end_index() <<
" the identifier is ");
417 }
418
419
420 bool IsThisStripDecoded = 0;
424 if (did == channelId) {
425 IsThisStripDecoded = 1;
426 break;
427 }
428 }
429 if (IsThisStripDecoded) continue;
430
431 int measuresPhi =
m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
432
434
435 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(channelId);
437 double errPos = stripWidth / sqrt(12.0);
438
440 covariance.setIdentity();
441 covariance *= errPos * errPos;
442 auto errClusterPos = Amg::MatrixX(covariance);
443
446 descriptor, charges, timeOfFirstSample, samplingTime);
447
448 if (samplingPhase) newPrepData->set_samplingPhase();
449 newPrepData->setHashAndIndex(collection->identifyHash(), collection->size());
450 collection->push_back(newPrepData);
451 }
452 }
453
454 StatusCode status_lock = lock.addOrDelete(std::move(collection));
455 if (status_lock.isFailure()) {
456 ATH_MSG_ERROR(
"Could not insert CscStripPrepdataCollection into CscStripPrepdataContainer...");
457 return StatusCode::FAILURE;
458 }
459 }
460 }
461 return StatusCode::SUCCESS;
462}
#define AmgSymMatrix(dim)
char data[hepevt_bytes_allocation_ATLAS]
Athena::TPCnvVers::Old Athena::TPCnvVers::Current CscRawDataCollection
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
void show() const
Print out in hex form.
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