ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::FastReco::GlobalPatternFinder::PatternState Struct Reference

Pattern state object storing pattern information during construction. More...

Collaboration diagram for MuonR4::FastReco::GlobalPatternFinder::PatternState:

Public Member Functions

 PatternState (const CandidateHit &seed, const std::int8_t expSector, const Config *cfg, const AthMessaging *logger)
 Constructor taking the seed information.
 PatternState ()=delete
 Delete default destructor - ensure patterns are always constructed from a seed or another pattern.
 PatternState (PatternState &&other) noexcept=default
 Move constructor.
PatternStateoperator= (PatternState &&other) noexcept=default
 Move assignment operator.
 PatternState (const PatternState &other)=default
 Copy constructor.
PatternStateoperator= (const PatternState &other)=default
 Copy assignment operator.
 ~PatternState ()=default
 Destructor.
void addHit (const CandidateHit &hit, const double residual, const double acceptWindow)
 Add a hit to the pattern and update the internal state.
void overWriteHit (const CandidateHit &newHit, const double newResidual, const double newAcceptWindow)
 Overwrite the hits on the last layer with the new one.
LineTestRes checkLineComp (const CandidateHit &testHit, const Amg::Vector3D &beamSpot)
 Method checking line compatibility of a test hit against the pattern.
LineTestRes computeLineResidual (const CandidateHit &testHit) const
 Method to compute the residual of a test hit against the pattern line.
Amg::Vector3D projToPhiPlane (const HitPayload &hit) const
 Project a certain hit position onto the bending plane where the pattern is defined.
bool isPhiCompatible (const double testPhi) const
 Method to check the phi compatibility of a test hit with a given pattern.
bool isInPattern (const HitPayload &hit) const
 Check wheter a hit is present in the pattern.
void finalizePatternPhi ()
 Finalize the pattern building in phi and update its state.
void moveLineAnchorHit (const CandidateHit &refHit)
 Move the line anchor hit given a reference hit.
void updateLineParameters (const Amg::Vector3D &beamSpot)
 Update the line parameters based on the current hits.
void updatePatternPhi (const double newPhi)
 Helper method to update the pattern phi and bending plane normal.
double getMeanResidual2 () const
 Return the mean normalized residual squared.
uint8_t nBendingHits () const
 Return the number of hits in bending coordinate.
uint8_t nBendingLayers () const
 Return the number of layers in bending coordinate.
uint8_t nStations (const bool onlyGoodStations) const
 Method returning the number of stations.
std::vector< const SpacePointBucket * > getParentBuckets () const
 Get the buckets associated with the pattern.
bool isInLastLayer (const CandidateHit &hit) const
 Check whether a given hit is in the last layer.
bool operator== (const PatternState &other) const =delete
 Patterns are considered identical if they have the same hit content.
void print (std::ostream &ostr, bool detailed) const
 Print the pattern candidate.

Public Attributes

const Configcfg {nullptr}
 Pointer to cfg option.
const AthMessaginglogger {nullptr}
 Logger.
Acts::CloneablePtr< PatternHitVisualInfovisualInfo {nullptr}
 Pointer to Visual Information for pattern visualization.
CandidateHit lastInsertedHit {}
 Last inserted hit.
CandidateHit prevLayerHit {}
 Last hit in the second-to-last layer.
CandidateHit lineAnchorHit {}
 Line anchor hit.
CandidateHit seedHit {}
 Seed hit.
Amg::Vector3D bendPlaneNorm {Amg::Vector3D::Zero()}
 Normal vector to the bending plane where the pattern lies.
Amg::Vector3D linePos {Amg::Vector3D::Zero()}
 Position and direction of the pattern line.
Amg::Vector3D lineDir {Amg::Vector3D::Zero()}
double leverArm {0.}
 Distance between the two points defining the pattern line.
double meanNormResidual2 {0.}
 Mean over eta hits of the square of their residual divided by acceptance window.
double lastResidual {0.}
 Residual & acceptance window of the last inserted hit (needed when replacing a hit).
double lastAcceptWindow {0.}
double patPhi {0.}
 Pattern phi, which is the phi of the bending plane where the pattern lies.
ExpandedSector expSect {static_cast<int8_t>(0)}
 expanded MS sector
uint8_t nPrecisionLayers {0u}
 Counts of precision / non-precision / phi layers.
uint8_t nTriggerLayers {0u}
uint8_t nPhiLayers {0u}
bool isFinalized {false}
 Flag to indicate if the pattern has been finalized.
bool isOverlap {false}
 Flag to indicate if the pattern is overlapping with another one, used during overlap removal.
bool useBeamspot {false}
 Whether we used the beamspot to compute the line parameters.
bool needLineUpdate {false}
 Whether we need to update the pattern line the next time we find a hit in a new layer.
std::array< uint8_t, s_nStationsnMeasurementLayers {}
 Counts of measurement layers per station.
std::array< std::vector< CandidateHit >, s_nStationshitsPerStation {}
 Map collection of hits per station.
std::vector< HitPayloadphiOnlyHits {}
 Array holding phi-only hits.

Detailed Description

Pattern state object storing pattern information during construction.

Definition at line 194 of file GlobalPatternFinder.h.

Constructor & Destructor Documentation

◆ PatternState() [1/4]

MuonR4::FastReco::GlobalPatternFinder::PatternState::PatternState ( const CandidateHit & seed,
const std::int8_t expSector,
const Config * cfg,
const AthMessaging * logger )

Constructor taking the seed information.

Parameters
seedseed hit
expSectorexpanded sector coordinate
cfgpointer to configuration object
loggerpointer to messaging object

Update the hit counts in bending direction

Add now the new hit

Definition at line 747 of file GlobalPatternFinder.cxx.

751 : cfg{cfg},
752 logger{logger},
756 seedHit{seed},
757 expSect{ExpandedSector{expSector}} {
758
760 nMeasurementLayers[Acts::toUnderlying(seed.station)]++;
761 if (seed->isPrecision) nPrecisionLayers++;
762 else nTriggerLayers++;
763 if (seed->sp()->measuresPhi()) nPhiLayers++;
764
765 updatePatternPhi(seed->position.phi());
766
768 hitsPerStation[Acts::toUnderlying(seed.station)].push_back(seed);
769 needLineUpdate = true;
770}
void updatePatternPhi(const double newPhi)
Helper method to update the pattern phi and bending plane normal.
std::array< uint8_t, s_nStations > nMeasurementLayers
Counts of measurement layers per station.
bool needLineUpdate
Whether we need to update the pattern line the next time we find a hit in a new layer.
CandidateHit prevLayerHit
Last hit in the second-to-last layer.
std::array< std::vector< CandidateHit >, s_nStations > hitsPerStation
Map collection of hits per station.
uint8_t nPrecisionLayers
Counts of precision / non-precision / phi layers.

◆ PatternState() [2/4]

MuonR4::FastReco::GlobalPatternFinder::PatternState::PatternState ( )
delete

Delete default destructor - ensure patterns are always constructed from a seed or another pattern.

◆ PatternState() [3/4]

MuonR4::FastReco::GlobalPatternFinder::PatternState::PatternState ( PatternState && other)
defaultnoexcept

Move constructor.

Parameters
otherother pattern state to move from

◆ PatternState() [4/4]

MuonR4::FastReco::GlobalPatternFinder::PatternState::PatternState ( const PatternState & other)
default

Copy constructor.

Parameters
otherother pattern state to copy from

◆ ~PatternState()

MuonR4::FastReco::GlobalPatternFinder::PatternState::~PatternState ( )
default

Destructor.

Member Function Documentation

◆ addHit()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::addHit ( const CandidateHit & hit,
const double residual,
const double acceptWindow )

Add a hit to the pattern and update the internal state.

Parameters
hithit to be added
residualresidual of the hit
acceptWindowacceptance window

Update the pointers to previous layer hit

Update the hit counts in bending direction

Update the phi of the pattern if there are no phi hits yet

Add now the new hit

Update the residual. Since we can also add consecutive MDT hits without updating the residual, we need to check the accept window

Definition at line 981 of file GlobalPatternFinder.cxx.

983 {
984
985 if (hit.globLayer != lastInsertedHit.globLayer) {
988
990 nMeasurementLayers[Acts::toUnderlying(hit.station)]++;
991 if (hit->isPrecision) nPrecisionLayers++;
992 else nTriggerLayers++;
994 if (hit.sp()->measuresPhi()) {
995 if (nPhiLayers == 0) {\
996 updatePatternPhi(hit->position.phi());
997 }
998 nPhiLayers++;
999 }
1000 }
1002 hitsPerStation[Acts::toUnderlying(hit.station)].push_back(hit);
1003 lastInsertedHit = hit;
1004
1006 if (acceptWindow > 0.) {
1007 meanNormResidual2 += Acts::square(residual / acceptWindow);
1008 lastAcceptWindow = acceptWindow;
1010 }
1011 // If the new compatible hit is in a different station, update the line anchor
1012 if (hit.station != lastInsertedHit.station) {
1013 moveLineAnchorHit(hit);
1014 }
1015 needLineUpdate = true;
1016}
void moveLineAnchorHit(const CandidateHit &refHit)
Move the line anchor hit given a reference hit.
double lastResidual
Residual & acceptance window of the last inserted hit (needed when replacing a hit).
double meanNormResidual2
Mean over eta hits of the square of their residual divided by acceptance window.

◆ checkLineComp()

GlobalPatternFinder::LineTestRes MuonR4::FastReco::GlobalPatternFinder::PatternState::checkLineComp ( const CandidateHit & testHit,
const Amg::Vector3D & beamSpot )

Method checking line compatibility of a test hit against the pattern.

Parameters
testHittest hit information
beamSpotBeam spot position, needed to update the pattern line
Returns
: result of the test, including the computed line residual and acceptance window

Helper function to make the result

Parameters
decisionThe decision for the test result if the residual is within the acceptance window
Returns
The test result

Sanity check: Test hit coincides with the last inserted hit

We add the test hit to the pattern if they are consecutive MDT hits

If they are not consecutive MDT hits && all insterted hits are on the same layer

If the primary measurement is the same and both measure phi, we keep the most compatible in phi

sTGCs: we can have trigger hits (Pad) and precision hits (strip) on the same layer

Test hit is a trigger hit and last inserted is precision, keep the precision hit

Test hit is a precision hit and last inserted is trigger, if compatible we overwrite the last inserted hit

Definition at line 772 of file GlobalPatternFinder.cxx.

773 {
774 // We test hits in same **expanded** sector, so we need just to compare hit's phi with pattern's phi, if available
775 const double phiHit {testHit->position.phi()};
776 if (nPhiLayers) {
777 const double maxPhiDiff {testHit.sp()->measuresPhi() ?
778 cfg->phiTolerance : sectorMap.sectorWidth(testHit.sector)};
779 if (std::abs(P4Helpers::deltaPhi(patPhi, phiHit)) > maxPhiDiff) {
780 PRINT_VERBOSE(__func__<<"() The pattern with phi = "<<inDeg(patPhi)
781 <<" is not compatible with the test hit with phi "<<inDeg(phiHit) << " - reject.");
782 return LineTestRes{};
783 }
784 }
785
789 auto makeResult = [&testHit, this](const LineTestDecision decision) -> LineTestRes {
790 LineTestRes res{computeLineResidual(testHit)};
791 if (res.residual < res.accWindow) {
792 res.result = decision;
793 }
794 if (visualInfo) {
795 visualInfo->hitLineInfo[testHit.sp()] =
796 std::make_pair(std::tan(lineDir.theta()), res.accWindow);
797 }
798 return res;
799 };
800
801 /*************** Test hit is on a new layer — draw line from line anchor to lastHit */
802 if(testHit.globLayer != lastInsertedHit.globLayer) {
803 updateLineParameters(beamSpot);
804 return makeResult(LineTestDecision::eAddHit);
805 }
806 /*************** Test hit is on the same layer as the last inserted hit ***************/
808 if (testHit == lastInsertedHit) {
809 PRINT_VERBOSE(__func__<<"() Test hit is the same as last inserted hit - reject.");
810 return LineTestRes{};
811 }
813 if (areConsecutiveMdt(testHit, lastInsertedHit)) {
814 return makeResult(LineTestDecision::eConsecutiveMdt);
815 }
817 if (lineAnchorHit.globLayer == lastInsertedHit.globLayer) {
818 PRINT_VERBOSE(__func__<<"() Test hit on same layer as seed with no prior hits, but not consecutive MDT hits - reject.");
819 return LineTestRes{};
820 }
822 if (testHit.sp()->primaryMeasurement() == lastInsertedHit.sp()->primaryMeasurement()) {
823 if (testHit.sp()->measuresPhi() && !lastInsertedHit.sp()->measuresPhi()) {
824 return makeResult(LineTestDecision::eOverwriteLastHit);
825 }
826 if (!testHit.sp()->measuresPhi() && lastInsertedHit.sp()->measuresPhi()) {
827 return LineTestRes{};
828 }
829 if (nPhiLayers && std::abs(P4Helpers::deltaPhi(patPhi, phiHit)) <
830 std::abs(P4Helpers::deltaPhi(patPhi, lastInsertedHit->position.phi()))) {
831 return makeResult(LineTestDecision::eOverwriteLastHit);
832 }
833 return LineTestRes{};
834 }
836 if (testHit->isPrecision != lastInsertedHit->isPrecision) {
837 if (lastInsertedHit->isPrecision) {
839 PRINT_VERBOSE(__func__<<"() Test hit is trigger hit and last inserted hit is precision, on the same layer - keep precision hit.");
840 return LineTestRes{};
841 }
843 PRINT_VERBOSE(__func__<<"() Test hit is a precision hit and last inserted hit is trigger on the same layer - check residual...");
844 return makeResult(LineTestDecision::eOverwriteLastHit);
845 }
846 return makeResult(LineTestDecision::eBranchPattern);
847}
std::pair< std::vector< unsigned int >, bool > res
#define PRINT_VERBOSE(MSG)
Helper macro for printing verbose messages for debugging.
static bool areConsecutiveMdt(const CandidateHit &hit1, const CandidateHit &hit2)
Helper function to check whether two hits are consecutive MDT measurements.
LineTestDecision
: Enum for possible outcomes of pattern line compatibility test
@ eBranchPattern
Test successfull with multiple pattern hits on same layer, branch the pattern.
constexpr float inDeg(const float rad)
double deltaPhi(double phiA, double phiB)
delta Phi in range [-pi,pi[
Definition P4Helpers.h:34
Acts::CloneablePtr< PatternHitVisualInfo > visualInfo
Pointer to Visual Information for pattern visualization.
LineTestRes computeLineResidual(const CandidateHit &testHit) const
Method to compute the residual of a test hit against the pattern line.
void updateLineParameters(const Amg::Vector3D &beamSpot)
Update the line parameters based on the current hits.
double patPhi
Pattern phi, which is the phi of the bending plane where the pattern lies.

◆ computeLineResidual()

GlobalPatternFinder::LineTestRes MuonR4::FastReco::GlobalPatternFinder::PatternState::computeLineResidual ( const CandidateHit & testHit) const

Method to compute the residual of a test hit against the pattern line.

Parameters
testHittest hit information
Returns
: Test result holding the residual and acceptance window. The decision is set later.

Dynamic acceptance window derived from the propagation of the measurement variance to the residual. In this simple model, the measurement variance is assumed isotropic. The residual variance increases
with the normalized extrapolation distance alpha = s / L, where s is the projection of the hit onto the pattern direction and L is the pattern lever arm.

Loosen the window when using the beamspot as reference, as the line slope is less well defined, and when we are looking for hits in a new station.

Definition at line 922 of file GlobalPatternFinder.cxx.

922 {
923 LineTestRes res{};
924
925 // Compute the residual
926 const Amg::Vector3D pos {projToPhiPlane(*testHit)};
927 const Amg::Vector3D K {pos - linePos};
928 res.residual = (K.cross(lineDir)).mag();
929
934 const double alpha {K.dot(lineDir) / leverArm};
935 const double varianceScale {2. * (1. - alpha + Acts::square(alpha))};
936 res.accWindow = cfg->baseResidualSigma * std::sqrt(varianceScale);
939 if (useBeamspot || testHit->station != lastInsertedHit.station ||
940 (testHit->station != prevLayerHit.station && testHit.globLayer == lastInsertedHit.globLayer)) {
941 res.accWindow *= 2.;
942 }
943 PRINT_VERBOSE(__func__<<"() "<< brief(*this)<<"\nUse beamspot: "<<useBeamspot<<", Slope: "
944 <<std::tan(lineDir.theta())<<", Residual: "<<res.residual<<", Window: "<<res.accWindow
945 <<", alpha: "<<alpha<<", Scale Factor: "<<std::sqrt(varianceScale));
946 return res;
947}
static PatternPrintView brief(const PatternState &p)
Print the pattern candidate and stream operator.
Eigen::Matrix< double, 3, 1 > Vector3D
Amg::Vector3D projToPhiPlane(const HitPayload &hit) const
Project a certain hit position onto the bending plane where the pattern is defined.
Amg::Vector3D linePos
Position and direction of the pattern line.
bool useBeamspot
Whether we used the beamspot to compute the line parameters.
double leverArm
Distance between the two points defining the pattern line.

◆ finalizePatternPhi()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::finalizePatternPhi ( )

Finalize the pattern building in phi and update its state.

If there are no phi hits, we just use the central phi of the sector/overlap region

Definition at line 1073 of file GlobalPatternFinder.cxx.

1073 {
1074 if (!nPhiLayers) {
1076 patPhi = sectorMap.sectorOverlapPhi(expSect.msSector(), expSect.adjacentMsSector());
1077 return;
1078 }
1079 double deltaPhiAcc {0.};
1080 std::optional<double> centralPhi {};
1081 auto processPhiHit = [&deltaPhiAcc, &centralPhi](const HitPayload& hit){
1082 if (!hit->measuresPhi()) {
1083 return;
1084 }
1085 const double hitPhi {hit.position.phi()};
1086 if (!centralPhi) {
1087 centralPhi = hitPhi;
1088 }
1089 deltaPhiAcc += P4Helpers::deltaPhi(hitPhi, *centralPhi);
1090 };
1091 for (const std::vector<CandidateHit>& hits : hitsPerStation) {
1092 for (const auto& hit : hits) {
1093 processPhiHit(*hit);
1094 }
1095 }
1096 for (const HitPayload& hit : phiOnlyHits) {
1097 processPhiHit(hit);
1098 }
1099 patPhi = P4Helpers::deltaPhi(centralPhi.value_or(0.) + deltaPhiAcc / nPhiLayers, 0.);
1100}
std::vector< HitPayload > phiOnlyHits
Array holding phi-only hits.

◆ getMeanResidual2()

double MuonR4::FastReco::GlobalPatternFinder::PatternState::getMeanResidual2 ( ) const

Return the mean normalized residual squared.

Definition at line 1118 of file GlobalPatternFinder.cxx.

1118 {
1119 if (isFinalized) {
1120 return meanNormResidual2;
1121 }
1123}
bool isFinalized
Flag to indicate if the pattern has been finalized.
uint8_t nBendingLayers() const
Return the number of layers in bending coordinate.

◆ getParentBuckets()

std::vector< const SpacePointBucket * > MuonR4::FastReco::GlobalPatternFinder::PatternState::getParentBuckets ( ) const

Get the buckets associated with the pattern.

Definition at line 1124 of file GlobalPatternFinder.cxx.

1124 {
1125 std::vector<const SpacePointBucket*> buckets{};
1126 for (const std::vector<CandidateHit>& hits : hitsPerStation) {
1127 for (const auto& hit : hits) {
1128 if (std::ranges::find(buckets, hit->bucket) == buckets.end()) {
1129 buckets.push_back(hit->bucket);
1130 }
1131 }
1132 }
1133 return buckets;
1134}

◆ isInLastLayer()

bool MuonR4::FastReco::GlobalPatternFinder::PatternState::isInLastLayer ( const CandidateHit & hit) const

Check whether a given hit is in the last layer.

Definition at line 1135 of file GlobalPatternFinder.cxx.

1135 {
1136 if (lastInsertedHit.globLayer != hit.globLayer) {
1137 return false;
1138 }
1139 if (hit.isStraw && lastInsertedHit.isStraw) {
1140 const auto& stationHits {hitsPerStation[Acts::toUnderlying(hit.station)]};
1141 for (auto it = stationHits.rbegin(); it != stationHits.rend(); ++it) {
1142 if (it->globLayer != hit.globLayer) {
1143 return false;
1144 }
1145 if (*it == hit) {
1146 return true;
1147 }
1148 }
1149 return false;
1150 }
1151 return lastInsertedHit == hit;
1152}

◆ isInPattern()

bool MuonR4::FastReco::GlobalPatternFinder::PatternState::isInPattern ( const HitPayload & hit) const

Check wheter a hit is present in the pattern.

Parameters
hithit to be checked
Returns
: boolean indicating if the hit is in the pattern

Definition at line 1068 of file GlobalPatternFinder.cxx.

1068 {
1069 const auto& hits {hitsPerStation[Acts::toUnderlying(hit.station)]};
1070 return std::ranges::find_if(hits,
1071 [&hit](const CandidateHit& c){ return *c == hit; }) != hits.end();
1072}

◆ isPhiCompatible()

bool MuonR4::FastReco::GlobalPatternFinder::PatternState::isPhiCompatible ( const double testPhi) const

Method to check the phi compatibility of a test hit with a given pattern.

Parameters
testPhitest global phi
Returns
: true if the test hit is phi compatible with the pattern, false otherwise

We check that the test hit is compatible with the pattern phi, if available, which is given by the first phi measurement in the pattern. If the pattern doesn't have a phi yet, we check that the test hit is in the same pattern sector(s)

Definition at line 957 of file GlobalPatternFinder.cxx.

957 {
961 if (nPhiLayers) {
962 if (std::abs(P4Helpers::deltaPhi(patPhi, testPhi)) > cfg->phiTolerance) {
963 PRINT_VERBOSE(__func__<<"() The pattern with phi = "<<inDeg(patPhi)
964 <<" is not compatible with the test hit with phi "<<inDeg(testPhi));
965 return false;
966 }
967 } else {
968 const unsigned sector1 {expSect.msSector()};
969 const unsigned sector2 {expSect.adjacentMsSector()};
970 const bool isCompatible {sector1 == sector2
971 ? sectorMap.insideSector(sector1, testPhi)
972 : sectorMap.insideSector(sector1, testPhi) && sectorMap.insideSector(sector2, testPhi)};
973 if (!isCompatible) {
974 PRINT_VERBOSE(__func__<<"() The test hit with phi = "<<inDeg(testPhi)
975 <<" is not inside the pattern sectors: "<<sector1<<" and "<<sector2);
976 return false;
977 }
978 }
979 return true;
980}

◆ moveLineAnchorHit()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::moveLineAnchorHit ( const CandidateHit & refHit)

Move the line anchor hit given a reference hit.

The anchor is defined as the closest hit in the closest station to the referece hit,

Definition at line 848 of file GlobalPatternFinder.cxx.

848 {
849 // Treat first the special case where we have only one station
850 if (nStations(/*onlyGoodStations=*/ false) < 2) {
851 // If we call this method with only one station, it means that we inverted the hit search direction without
852 // finding any hit in other stations beside the initial one. So the anchor is the last added hit.
854 return;
855 }
856 // Find first the closest station to the reference station among the pattern stations
857 const auto& closestStIt = std::ranges::min_element(hitsPerStation, std::ranges::less{},
858 [&refHit](const auto& hits){
859 if (hits.empty() || hits.front().station == refHit.station) {
860 return std::numeric_limits<int>::max();
861 }
862 return std::abs(hits.front().globLayer - refHit.globLayer);
863 });
864
865 // Then find the closest hit in that station to the reference hit
866 const auto& hits {*closestStIt};
867 auto it {std::ranges::min_element(hits, std::ranges::less{},
868 [&refHit](const CandidateHit& hit){
869 return std::abs(hit.globLayer - refHit.globLayer); })};
870
871 // Find how many hits in the same layer we have, to be able to set the line anchor at the central hit
872 uint8_t nSameLayer {1u};
873 for (auto jt = std::next(it); jt != hits.end() && jt->globLayer == it->globLayer; ++jt) {
874 ++nSameLayer;
875 }
876 lineAnchorHit = *std::next(it, (nSameLayer - 1u) / 2u);
877}
uint8_t nStations(const bool onlyGoodStations) const
Method returning the number of stations.

◆ nBendingHits()

uint8_t MuonR4::FastReco::GlobalPatternFinder::PatternState::nBendingHits ( ) const

Return the number of hits in bending coordinate.

Definition at line 1110 of file GlobalPatternFinder.cxx.

1110 {
1111 return std::accumulate(hitsPerStation.begin(), hitsPerStation.end(), uint8_t{0u},
1112 [](uint8_t acc, const auto& hits){
1113 return acc + hits.size(); });
1114}

◆ nBendingLayers()

uint8_t MuonR4::FastReco::GlobalPatternFinder::PatternState::nBendingLayers ( ) const

Return the number of layers in bending coordinate.

Definition at line 1115 of file GlobalPatternFinder.cxx.

1115 {
1117}

◆ nStations()

uint8_t MuonR4::FastReco::GlobalPatternFinder::PatternState::nStations ( const bool onlyGoodStations) const

Method returning the number of stations.

Parameters
onlyGoodStationsflag to indicate if only good stations should be counted, i.e. having a minimum number of hits

Definition at line 1101 of file GlobalPatternFinder.cxx.

1101 {
1102 uint8_t nStations {0u};
1103 for (uint8_t st{0u}; st < s_nStations; ++st) {
1104 if (!hitsPerStation[st].empty() && (!onlyGoodStations || nMeasurementLayers[st] >= cfg->minStationLayers)) {
1105 nStations++;
1106 }
1107 }
1108 return nStations;
1109}
static const Attributes_t empty
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ operator=() [1/2]

PatternState & MuonR4::FastReco::GlobalPatternFinder::PatternState::operator= ( const PatternState & other)
default

Copy assignment operator.

Parameters
otherother pattern state to copy from

◆ operator=() [2/2]

PatternState & MuonR4::FastReco::GlobalPatternFinder::PatternState::operator= ( PatternState && other)
defaultnoexcept

Move assignment operator.

Parameters
otherother pattern state to move from

◆ operator==()

bool MuonR4::FastReco::GlobalPatternFinder::PatternState::operator== ( const PatternState & other) const
delete

Patterns are considered identical if they have the same hit content.

However, map comparison is very expensive

◆ overWriteHit()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::overWriteHit ( const CandidateHit & newHit,
const double newResidual,
const double newAcceptWindow )

Overwrite the hits on the last layer with the new one.

Parameters
newHitnew hit to replace with
newResidualresidual of the new hit
newAcceptWindowacceptance window of the new hit
beamSpotneeded to update line parameters

Update the phi counts

Update the residual

Add now the new hit

Definition at line 1017 of file GlobalPatternFinder.cxx.

1019 {
1020 const StIndex st {newHit.station};
1021 if (st != lastInsertedHit.station || lastInsertedHit.globLayer != newHit.globLayer) {
1022 throw std::runtime_error(std::format(
1023 "Trying to overwrite a hit in station/layer {}/{} with another one from station/layer {}/{}",
1024 stName(lastInsertedHit.station), lastInsertedHit.globLayer, stName(st), newHit.globLayer));
1025 }
1026 /* We expect to overwrite hits of the same type (precision/trigger), since we only branch when we have
1027 * compatible hits in the same layer, except for sTGC hits, where we have pad and strips in the same layer */
1028 if (lastInsertedHit->isPrecision != newHit->isPrecision) {
1029 if (newHit.sp()->type() != xAOD::UncalibMeasType::sTgcStripType) {
1030 std::stringstream ss {};
1031 ss << "Trying to overwrite a hit with incompatible type\n";
1032 ss << "Old hit: " << **lastInsertedHit << ", isPrecision: " << lastInsertedHit->isPrecision << ", measuresEta: " << lastInsertedHit.sp()->measuresEta() << "\n";
1033 ss << "New hit: " << **newHit << ", isPrecision: " << newHit->isPrecision << ", measuresEta: " << newHit.sp()->measuresEta();
1034 throw std::runtime_error(ss.str());
1035 }
1038 }
1040 if (lastInsertedHit.sp()->measuresPhi()) nPhiLayers--;
1041 if (newHit.sp()->measuresPhi()) {
1042 if (nPhiLayers == 0) {
1043 updatePatternPhi(newHit->position.phi());
1044 }
1045 nPhiLayers++;
1046 }
1048 meanNormResidual2 += Acts::square(newResidual / newAcceptWindow) - Acts::square(lastResidual / lastAcceptWindow);
1049 lastAcceptWindow = newAcceptWindow;
1050 lastResidual = newResidual;
1051
1052 auto& stHits {hitsPerStation[Acts::toUnderlying(st)]};
1053 /* Remove ALL hits in the same layer */
1054 while (!stHits.empty()) {
1055 if (stHits.back().globLayer != lastInsertedHit.globLayer) {
1056 break;
1057 }
1058 if (visualInfo) {
1059 visualInfo->replacedHits.push_back(stHits.back().sp());
1060 }
1061 stHits.pop_back();
1062 }
1064 hitsPerStation[Acts::toUnderlying(st)].push_back(newHit);
1065 lastInsertedHit = newHit;
1066 needLineUpdate = true;
1067}
static Double_t ss
Muon::MuonStationIndex::StIndex StIndex
Type alias for the station index.
const std::string & stName(StIndex index)
convert StIndex into a string

◆ print()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::print ( std::ostream & ostr,
bool detailed ) const

Print the pattern candidate.

Definition at line 1267 of file GlobalPatternFinder.cxx.

1267 {
1268 ostr<<"PatternState Exp Sector: "<<static_cast<int>(expSect.sector())
1269 <<", Theta: "<<inDeg(seedHit->position.theta()) << ", Phi: "<<inDeg(patPhi);
1270 ostr<<", nPrec: "<<(int)nPrecisionLayers<<", nEtaNonPrec: "<<(int)nTriggerLayers<<", nPhi: "<<(int)nPhiLayers;
1271 ostr<<", mean norma res sq: "<<getMeanResidual2();
1272 ostr<<", Hit per station: \n";
1273 for (uint8_t st{0u}; st < s_nStations; ++st) {
1274 const auto& hits {hitsPerStation[st]};
1275 if (hits.empty()) continue;
1276
1277 ostr<<" Station "<<static_cast<StIndex>(st)<<" has "<<hits.size()<<" hits ";
1278 if (detailed) {
1279 ostr<<"\n";
1280 for (const auto& hit : hits) {
1281 ostr<<" "<<hit<<"\n";
1282 }
1283 }
1284 }
1285 if (!detailed) {
1286 ostr <<"\n Last hit: "<<lastInsertedHit<<"\n prevLayerHit: "
1287 <<prevLayerHit << "\n lineAnchorHit: "<<lineAnchorHit;
1288 }
1289}
static PatternPrintView detailed(const PatternState &p)
double getMeanResidual2() const
Return the mean normalized residual squared.

◆ projToPhiPlane()

Amg::Vector3D MuonR4::FastReco::GlobalPatternFinder::PatternState::projToPhiPlane ( const HitPayload & hit) const

Project a certain hit position onto the bending plane where the pattern is defined.

The hit is moved along the sensor direction if it does not measure phi, or is rotated around the Z axis if it does.

Parameters
hithit whose position is to be projected
Returns
: projected position

Definition at line 948 of file GlobalPatternFinder.cxx.

948 {
949 const Amg::Vector3D& toProject {hit.position};
950 if (hit->measuresPhi()) {
951 const double R {toProject.perp()};
952 return Amg::Vector3D{R * std::cos(patPhi), R * std::sin(patPhi), toProject.z()};
953 }
954 return Acts::PlanarHelper::intersectPlane(toProject, hit.sensorDir,
955 bendPlaneNorm, Amg::Vector3D::Zero()).position();
956}
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
Amg::Vector3D bendPlaneNorm
Normal vector to the bending plane where the pattern lies.

◆ updateLineParameters()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::updateLineParameters ( const Amg::Vector3D & beamSpot)

Update the line parameters based on the current hits.

Parameters
beamSpotposition of the beam spot, needed when there are not enough hits

Definition at line 878 of file GlobalPatternFinder.cxx.

878 {
879 if (!needLineUpdate) {
880 return;
881 }
882 const StIndex lastSt {lastInsertedHit.station};
885
886 // Check whether we have to use the beamspot instead of the last pattern hit to draw the line with the line anchor.
887 useBeamspot = (lastSt == lineAnchorHit.station) &&
888 (pos1 - pos2).mag() < cfg->minHitDistance4Line;
889
890 if (useBeamspot) {
891 pos1 = beamSpot;
892 }
893
894 /* Determine the (average) coordinates of the last added hit(s). If it is a straw, find
895 * the consecutive (MDT) hits on the same layer and return use average position
896 * for next computations — gives a more central reference for the line direction */
897 std::vector<CandidateHit>& hitsLastSt {hitsPerStation[Acts::toUnderlying(lastSt)]};
898 uint8_t nSameLayer {1u};
899 for (const CandidateHit& hit : hitsLastSt) {
900 if (hit == lastInsertedHit ||
901 hit.globLayer != lastInsertedHit.globLayer) {
902 continue;
903 }
904 pos2 += projToPhiPlane(*hit);
905 ++nSameLayer;
906 }
907 if (nSameLayer > 1u) {
908 pos2 = pos2 / nSameLayer;
909 }
910
911 const Amg::Vector3D d {pos2 - pos1};
912 linePos = pos1;
913 leverArm = d.mag();
914 lineDir = d / leverArm;
915 needLineUpdate = false;
916
917 PRINT_VERBOSE(__func__<<"() Update line parameters --> Pos: "<<Amg::toString(linePos)
918 <<" R/Z: "<<linePos.perp()<<"/"<<linePos.z()<<", Dir: " << Amg::toString(lineDir)
919 <<", slope: "<<std::tan(lineDir.theta())<<", LeverArm: " << leverArm);
920}
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
AthConfigFlags beamSpot(AthConfigFlags flags, str instanceName, str recoMode)

◆ updatePatternPhi()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::updatePatternPhi ( const double newPhi)

Helper method to update the pattern phi and bending plane normal.

Definition at line 1153 of file GlobalPatternFinder.cxx.

1153 {
1154 patPhi = newPhi;
1155 bendPlaneNorm = Acts::makeDirectionFromPhiTheta(newPhi + 90._degree, 90._degree);
1156}

Member Data Documentation

◆ bendPlaneNorm

Amg::Vector3D MuonR4::FastReco::GlobalPatternFinder::PatternState::bendPlaneNorm {Amg::Vector3D::Zero()}

Normal vector to the bending plane where the pattern lies.

Definition at line 299 of file GlobalPatternFinder.h.

299{Amg::Vector3D::Zero()};

◆ cfg

const Config* MuonR4::FastReco::GlobalPatternFinder::PatternState::cfg {nullptr}

Pointer to cfg option.

Definition at line 285 of file GlobalPatternFinder.h.

285{nullptr};

◆ expSect

ExpandedSector MuonR4::FastReco::GlobalPatternFinder::PatternState::expSect {static_cast<int8_t>(0)}

expanded MS sector

Definition at line 314 of file GlobalPatternFinder.h.

314{static_cast<int8_t>(0)};

◆ hitsPerStation

std::array<std::vector<CandidateHit>, s_nStations> MuonR4::FastReco::GlobalPatternFinder::PatternState::hitsPerStation {}

Map collection of hits per station.

A pattern is determined by the hits belonging to it.

Definition at line 331 of file GlobalPatternFinder.h.

331{};

◆ isFinalized

bool MuonR4::FastReco::GlobalPatternFinder::PatternState::isFinalized {false}

Flag to indicate if the pattern has been finalized.

Definition at line 320 of file GlobalPatternFinder.h.

320{false};

◆ isOverlap

bool MuonR4::FastReco::GlobalPatternFinder::PatternState::isOverlap {false}

Flag to indicate if the pattern is overlapping with another one, used during overlap removal.

Definition at line 322 of file GlobalPatternFinder.h.

322{false};

◆ lastAcceptWindow

double MuonR4::FastReco::GlobalPatternFinder::PatternState::lastAcceptWindow {0.}

Definition at line 310 of file GlobalPatternFinder.h.

310{0.};

◆ lastInsertedHit

CandidateHit MuonR4::FastReco::GlobalPatternFinder::PatternState::lastInsertedHit {}

Last inserted hit.

Needed to speed-up lookup

Definition at line 291 of file GlobalPatternFinder.h.

291{};

◆ lastResidual

double MuonR4::FastReco::GlobalPatternFinder::PatternState::lastResidual {0.}

Residual & acceptance window of the last inserted hit (needed when replacing a hit).

Definition at line 309 of file GlobalPatternFinder.h.

309{0.};

◆ leverArm

double MuonR4::FastReco::GlobalPatternFinder::PatternState::leverArm {0.}

Distance between the two points defining the pattern line.

Definition at line 305 of file GlobalPatternFinder.h.

305{0.};

◆ lineAnchorHit

CandidateHit MuonR4::FastReco::GlobalPatternFinder::PatternState::lineAnchorHit {}

Line anchor hit.

Definition at line 295 of file GlobalPatternFinder.h.

295{};

◆ lineDir

Amg::Vector3D MuonR4::FastReco::GlobalPatternFinder::PatternState::lineDir {Amg::Vector3D::Zero()}

Definition at line 303 of file GlobalPatternFinder.h.

303{Amg::Vector3D::Zero()};

◆ linePos

Amg::Vector3D MuonR4::FastReco::GlobalPatternFinder::PatternState::linePos {Amg::Vector3D::Zero()}

Position and direction of the pattern line.

Both are constructed to be within the bending plane of the pattern

Definition at line 302 of file GlobalPatternFinder.h.

302{Amg::Vector3D::Zero()};

◆ logger

const AthMessaging* MuonR4::FastReco::GlobalPatternFinder::PatternState::logger {nullptr}

Logger.

Definition at line 287 of file GlobalPatternFinder.h.

287{nullptr};

◆ meanNormResidual2

double MuonR4::FastReco::GlobalPatternFinder::PatternState::meanNormResidual2 {0.}

Mean over eta hits of the square of their residual divided by acceptance window.

Definition at line 307 of file GlobalPatternFinder.h.

307{0.};

◆ needLineUpdate

bool MuonR4::FastReco::GlobalPatternFinder::PatternState::needLineUpdate {false}

Whether we need to update the pattern line the next time we find a hit in a new layer.

Definition at line 326 of file GlobalPatternFinder.h.

326{false};

◆ nMeasurementLayers

std::array<uint8_t, s_nStations> MuonR4::FastReco::GlobalPatternFinder::PatternState::nMeasurementLayers {}

Counts of measurement layers per station.

Definition at line 329 of file GlobalPatternFinder.h.

329{};

◆ nPhiLayers

uint8_t MuonR4::FastReco::GlobalPatternFinder::PatternState::nPhiLayers {0u}

Definition at line 318 of file GlobalPatternFinder.h.

318{0u};

◆ nPrecisionLayers

uint8_t MuonR4::FastReco::GlobalPatternFinder::PatternState::nPrecisionLayers {0u}

Counts of precision / non-precision / phi layers.

Definition at line 316 of file GlobalPatternFinder.h.

316{0u};

◆ nTriggerLayers

uint8_t MuonR4::FastReco::GlobalPatternFinder::PatternState::nTriggerLayers {0u}

Definition at line 317 of file GlobalPatternFinder.h.

317{0u};

◆ patPhi

double MuonR4::FastReco::GlobalPatternFinder::PatternState::patPhi {0.}

Pattern phi, which is the phi of the bending plane where the pattern lies.

Definition at line 312 of file GlobalPatternFinder.h.

312{0.};

◆ phiOnlyHits

std::vector<HitPayload> MuonR4::FastReco::GlobalPatternFinder::PatternState::phiOnlyHits {}

Array holding phi-only hits.

Definition at line 333 of file GlobalPatternFinder.h.

333{};

◆ prevLayerHit

CandidateHit MuonR4::FastReco::GlobalPatternFinder::PatternState::prevLayerHit {}

Last hit in the second-to-last layer.

Definition at line 293 of file GlobalPatternFinder.h.

293{};

◆ seedHit

CandidateHit MuonR4::FastReco::GlobalPatternFinder::PatternState::seedHit {}

Seed hit.

Definition at line 297 of file GlobalPatternFinder.h.

297{};

◆ useBeamspot

bool MuonR4::FastReco::GlobalPatternFinder::PatternState::useBeamspot {false}

Whether we used the beamspot to compute the line parameters.

Definition at line 324 of file GlobalPatternFinder.h.

324{false};

◆ visualInfo

Acts::CloneablePtr<PatternHitVisualInfo> MuonR4::FastReco::GlobalPatternFinder::PatternState::visualInfo {nullptr}

Pointer to Visual Information for pattern visualization.

Definition at line 289 of file GlobalPatternFinder.h.

289{nullptr};

The documentation for this struct was generated from the following files: