467 {
468 double minPos = 2e8, maxPos = 0;
470
471 if (genPartList.empty()) {
472 ATH_MSG_WARNING(
"No GenParticles associated to this PRD_TruthTrajectory. Exiting segment creation.");
474 }
475
477 if (!mdtSimDataMap) {
479 << "MDT_SDO");
481 }
483 if (!mmSimDataMap) {
485 << "MM_SDO");
487 }
489 if (!stgcSimDataMap) {
491 << "sTGC_SDO");
493 }
494
495
496 std::map<Muon::MuonStationIndex::StIndex, DetectorLayer> hitsPerLayer;
497 std::map<const Trk::TrkDetElementBase*, std::pair<std::list<const Trk::PrepRawData*>, std::list<const Trk::PrepRawData*> > >
498 clustersPerDetEl;
499
500
502 const Trk::RIO_OnTrack* rot = segment.
rioOnTrack(i_cROTv);
503
504
506
508
511
512 if (chIndices.find(
m_idHelperSvc->chamberIndex(
id)) == chIndices.end()) {
513 ATH_MSG_DEBUG(
"Muon station doesn't match segment. Continuing");
514 continue;
515 }
516
517
518 const Muon::MMPrepData*
mm =
dynamic_cast<const Muon::MMPrepData*
>(prd);
519 if (mm) {
520 isEndcap = true;
521 stIndex = Muon::MuonStationIndex::StIndex::EI;
522 }
523 const Muon::sTgcPrepData* stgc = dynamic_cast<const Muon::sTgcPrepData*>(prd);
524 if (stgc) {
525 isEndcap = true;
526 stIndex = Muon::MuonStationIndex::StIndex::EI;
527 }
528
529
530 DetectorLayer& detLayer = hitsPerLayer[stIndex];
533
534
536 const Muon::MdtPrepData* mprd = dynamic_cast<const Muon::MdtPrepData*>(prd);
537 if (!mprd) {
539 continue;
540 }
541
543 for (auto it = genPartList.begin(); it != genPartList.end() && !deposit; ++it) {
544 deposit =
getDeposit(*mdtSimDataMap, *it,
id);
545 }
546 if (!deposit) {
548 continue;
549 }
550
551 Amg::Vector2D lp(deposit->second.firstEntry(), deposit->second.secondEntry());
553
554 double val = isEndcap ? fabs(gpos.z()) : gpos.
perp();
555
556
557 if (val < detLayer.
minPos) {
558 if (detLayer.maxPos < -1e8 && detLayer.minPos < 1e8) {
559 detLayer.last3D = detLayer.first3D;
560 detLayer.maxPos = detLayer.minPos;
561 }
564 }
else if (val > detLayer.
maxPos) {
567 }
568
569 if (val < minPos) {
570 if (maxPos < -1e8 && minPos < 1e8) {
571 last3D = first3D;
572 maxPos = minPos;
573 }
575 first3D = gpos;
576 } else if (val > maxPos) {
578 last3D = gpos;
579 }
580
581 const Muon::MdtDriftCircleOnTrack* mdt =
m_mdtCreator->createRIO_OnTrack(*mprd, gpos);
582 if (!mdt) {
584 continue;
585 }
587 m_mdtCreator->updateSign(*
const_cast<Muon::MdtDriftCircleOnTrack*
>(mdt), side);
590 << deposit->second.firstEntry() << " pull " << pull);
592 detLayer.
meas.push_back(mdt);
595 else
597
598 } else if (mm) {
600 for (auto it = genPartList.begin(); it != genPartList.end() && !deposit; ++it) {
602 }
603 if (!deposit) {
605 continue;
606 }
607
608 Amg::Vector2D lp(deposit->second.firstEntry(), deposit->second.secondEntry());
610
611
612
613 double val = fabs(gpos.z());
614
615 if (val < detLayer.
minPos) {
619 }
622 }
else if (val > detLayer.
maxPos) {
625 }
626
627 if (val < minPos) {
628 if (maxPos < -1e8 && detLayer.
minPos < 1e8) {
629 last3D = first3D;
630 maxPos = minPos;
631 }
633 first3D = gpos;
634 } else if (val > maxPos) {
636 last3D = gpos;
637 }
638
640 if (!rot) {
642 continue;
643 }
647 << " pull " << pull);
648 detLayer.
meas.push_back(rot);
649
651
652 } else if (stgc) {
653
655
656
657
658
660 for (auto it = genPartList.begin(); it != genPartList.end() && !deposit; ++it) {
661 deposit =
getDeposit(*stgcSimDataMap, *it,
id);
662 }
663 if (!deposit) {
665 continue;
666 }
667
668 Amg::Vector2D lp(deposit->second.firstEntry(), deposit->second.secondEntry());
670
671
672
673 double val = fabs(gpos.z());
674
675 if (val < detLayer.
minPos) {
679 }
682 }
else if (val > detLayer.
maxPos) {
685 }
686
687 if (val < minPos) {
688 if (maxPos < -1e8 && minPos < 1e8) {
689 last3D = first3D;
690 maxPos = minPos;
691 }
693 first3D = gpos;
694 } else if (val > maxPos) {
696 last3D = gpos;
697 }
698
700 if (!rot) {
702 continue;
703 }
707 << " pull " << pull);
708 detLayer.
meas.push_back(rot);
709
711 }
712 }
713
714
715 if (minPos == 2e8 || maxPos == 0) {
716 ATH_MSG_WARNING(
"Min and max positions not found. Filling with meaningless position");
718 }
719
720 if (truthPos)
721 return (first3D + last3D) / 2;
722 else {
723
724 return (last3D - first3D);
725 }
726 }
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