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