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