462 {
463 double minPos = 2e8, maxPos = 0;
465
466 if (genPartList.empty()) {
467 ATH_MSG_WARNING(
"No GenParticles associated to this PRD_TruthTrajectory. Exiting segment creation.");
469 }
470
472 if (!mdtSimDataMap) {
474 << "MDT_SDO");
476 }
478 if (!mmSimDataMap) {
480 << "MM_SDO");
482 }
484 if (!stgcSimDataMap) {
486 << "sTGC_SDO");
488 }
489
490
491 std::map<Muon::MuonStationIndex::StIndex, DetectorLayer> hitsPerLayer;
492 std::map<const Trk::TrkDetElementBase*, std::pair<std::list<const Trk::PrepRawData*>, std::list<const Trk::PrepRawData*> > >
493 clustersPerDetEl;
494
495
497 const Trk::RIO_OnTrack* rot = segment.
rioOnTrack(i_cROTv);
498
499
501
503
506
507 if (chIndices.find(
m_idHelperSvc->chamberIndex(
id)) == chIndices.end()) {
508 ATH_MSG_DEBUG(
"Muon station doesn't match segment. Continuing");
509 continue;
510 }
511
512
513 const Muon::MMPrepData*
mm =
dynamic_cast<const Muon::MMPrepData*
>(prd);
514 if (mm) {
515 isEndcap = true;
516 stIndex = Muon::MuonStationIndex::StIndex::EI;
517 }
518 const Muon::sTgcPrepData* stgc = dynamic_cast<const Muon::sTgcPrepData*>(prd);
519 if (stgc) {
520 isEndcap = true;
521 stIndex = Muon::MuonStationIndex::StIndex::EI;
522 }
523
524
525 DetectorLayer& detLayer = hitsPerLayer[stIndex];
528
529
531 const Muon::MdtPrepData* mprd = dynamic_cast<const Muon::MdtPrepData*>(prd);
532 if (!mprd) {
534 continue;
535 }
536
538 for (auto it = genPartList.begin(); it != genPartList.end() && !deposit; ++it) {
539 deposit =
getDeposit(*mdtSimDataMap, *it,
id);
540 }
541 if (!deposit) {
543 continue;
544 }
545
546 Amg::Vector2D lp(deposit->second.firstEntry(), deposit->second.secondEntry());
548
549 double val = isEndcap ? fabs(gpos.z()) : gpos.
perp();
550
551
552 if (val < detLayer.
minPos) {
553 if (detLayer.maxPos < -1e8 && detLayer.minPos < 1e8) {
554 detLayer.last3D = detLayer.first3D;
555 detLayer.maxPos = detLayer.minPos;
556 }
559 }
else if (val > detLayer.
maxPos) {
562 }
563
564 if (val < minPos) {
565 if (maxPos < -1e8 && minPos < 1e8) {
566 last3D = first3D;
567 maxPos = minPos;
568 }
570 first3D = gpos;
571 } else if (val > maxPos) {
573 last3D = gpos;
574 }
575
576 const Muon::MdtDriftCircleOnTrack* mdt =
m_mdtCreator->createRIO_OnTrack(*mprd, gpos);
577 if (!mdt) {
579 continue;
580 }
582 m_mdtCreator->updateSign(*
const_cast<Muon::MdtDriftCircleOnTrack*
>(mdt), side);
585 << deposit->second.firstEntry() << " pull " << pull);
587 detLayer.
meas.push_back(mdt);
590 else
592
593 } else if (mm) {
595 for (auto it = genPartList.begin(); it != genPartList.end() && !deposit; ++it) {
597 }
598 if (!deposit) {
600 continue;
601 }
602
603 Amg::Vector2D lp(deposit->second.firstEntry(), deposit->second.secondEntry());
605
606
607
608 double val = fabs(gpos.z());
609
610 if (val < detLayer.
minPos) {
614 }
617 }
else if (val > detLayer.
maxPos) {
620 }
621
622 if (val < minPos) {
623 if (maxPos < -1e8 && detLayer.
minPos < 1e8) {
624 last3D = first3D;
625 maxPos = minPos;
626 }
628 first3D = gpos;
629 } else if (val > maxPos) {
631 last3D = gpos;
632 }
633
635 if (!rot) {
637 continue;
638 }
642 << " pull " << pull);
643 detLayer.
meas.push_back(rot);
644
646
647 } else if (stgc) {
648
650
651
652
653
655 for (auto it = genPartList.begin(); it != genPartList.end() && !deposit; ++it) {
656 deposit =
getDeposit(*stgcSimDataMap, *it,
id);
657 }
658 if (!deposit) {
660 continue;
661 }
662
663 Amg::Vector2D lp(deposit->second.firstEntry(), deposit->second.secondEntry());
665
666
667
668 double val = fabs(gpos.z());
669
670 if (val < detLayer.
minPos) {
674 }
677 }
else if (val > detLayer.
maxPos) {
680 }
681
682 if (val < minPos) {
683 if (maxPos < -1e8 && minPos < 1e8) {
684 last3D = first3D;
685 maxPos = minPos;
686 }
688 first3D = gpos;
689 } else if (val > maxPos) {
691 last3D = gpos;
692 }
693
695 if (!rot) {
697 continue;
698 }
702 << " pull " << pull);
703 detLayer.
meas.push_back(rot);
704
706 }
707 }
708
709
710 if (minPos == 2e8 || maxPos == 0) {
711 ATH_MSG_WARNING(
"Min and max positions not found. Filling with meaningless position");
713 }
714
715 if (truthPos)
716 return (first3D + last3D) / 2;
717 else {
718
719 return (last3D - first3D);
720 }
721 }
Scalar perp() const
perp method - perpendicular length
double driftRadius() const
Returns the value of the drift radius.
const MuonSimDataCollection * retrieveTruthCollection(const std::string &colName)
ToolHandle< Muon::IMuonClusterOnTrackCreator > m_muonClusterCreator
ToolHandle< Muon::IMdtDriftCircleOnTrackCreator > m_mdtCreator
const MuonSimData::Deposit * getDeposit(const MuonSimDataCollection &simCol, const HepMC::ConstGenParticlePtr &genPart, const Identifier &id)
double get(ParamDefs par) const
Retrieve specified parameter (const version).
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
Eigen::Matrix< double, 2, 1 > Vector2D
StIndex
enum to classify the different station layers in the muon spectrometer
DriftCircleSide
Enumerates the 'side' of the wire on which the tracks passed (i.e.
@ RIGHT
the drift radius is positive (see Trk::AtaStraightLine)
@ LEFT
the drift radius is negative (see Trk::AtaStraightLine)
std::vector< const Trk::MeasurementBase * > meas
Muon::MuonStationIndex::StIndex stIndex