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 Types

using HitStationPair = std::pair<std::reference_wrapper<const HitPayload>, StIndex>

Public Member Functions

 PatternState (const HitPayload &seed, const StIndex seedStation, const int sectorCoord, const double seedTheta)
 Constructor taking the seed information.
 PatternState ()=delete
void addHit (const HitPayload &hit, const StIndex stationHit, const double residual)
 Add a hit to the pattern and update the internal state.
void overWriteHit (const HitPayload &oldHit, const HitPayload &newHit, const StIndex station, const double newResidual)
 Overwrite a hit in the pattern and update the internal state.
HitStationPair getNthLastHit (const std::size_t n) const
 Get the nth last inserted hit and the associated station.
bool isInPattern (const HitPayload &hit, const StIndex station) const
 Check wheter a hit is present in the pattern.
void finalizePattern ()
 Finalize the pattern and update its state.
bool operator== (const PatternState &other) const
 Equal operator, it checks the hit-per-station map.
void print (std::ostream &ostr) const
 Print the pattern candidate and stream operator.

Public Attributes

std::unordered_map< StIndex, std::vector< HitPayload > > hitsPerStation {}
 Map collection of hits per station.
std::vector< StIndexstations {}
 Pattern hit stations to save the filling order.
BucketPerContainer bucketsPerContainer {}
 Map of spacepoint buckets per spacepoint container associated to the pattern.
int sectorCoord {-1}
 expanded sector coordinate & average theta & average phi of the pattern
double theta {0.}
double phi {0.}
unsigned nPrecisionHits {0}
 Counts of precision measurements / non-precision in bending direction / phi measurements.
unsigned nBendingTriggerHits {0}
unsigned nPhiHits {0}
double totalResidual {0.}
 Total residual and last contribution to the residual (needed when replacing a hit)
double lastResidual {0.}
bool isOverlap {false}
 Flag to indicate if the pattern is overlapping with another one, used during overlap removal.
unsigned nInsertedHits {0}
 Number of inserted hits during one of the two search stages (from seed outward and from seed inward)
unsigned nMissedLayerHits {0}
 Number of missed candidate hits in different measurement layers during pattern building.
Acts::CloneablePtr< PatternHitVisualInfovisualInfo {nullptr}
 Pointer to Visual Information for pattern visualization.

Friends

std::ostream & operator<< (std::ostream &ostr, const PatternState &candidate)

Detailed Description

Pattern state object storing pattern information during construction.

Definition at line 124 of file GlobalPatternFinder.h.

Member Typedef Documentation

◆ HitStationPair

Definition at line 151 of file GlobalPatternFinder.h.

Constructor & Destructor Documentation

◆ PatternState() [1/2]

MuonR4::FastReco::GlobalPatternFinder::PatternState::PatternState ( const HitPayload & seed,
const StIndex seedStation,
const int sectorCoord,
const double seedTheta )

Constructor taking the seed information.

Parameters
seedseed hit
seedStationstation of the seed hit
sectorCoordexpanded sector coordinate
seedThetaglobal theta of the seed

Definition at line 630 of file GlobalPatternFinder.cxx.

634 : sectorCoord{sectorCoord}, theta{seedTheta} {
635 addHit(seed, seedStation, 0.0);
636}
int sectorCoord
expanded sector coordinate & average theta & average phi of the pattern
void addHit(const HitPayload &hit, const StIndex stationHit, const double residual)
Add a hit to the pattern and update the internal state.

◆ PatternState() [2/2]

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

Member Function Documentation

◆ addHit()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::addHit ( const HitPayload & hit,
const StIndex stationHit,
const double residual )

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

Parameters
hithit to be added
stationHitstation of the hit
residualresidual of the hit

Increment the number of inserted hits

Reset the number of missed layer hits

Update the hit counts in bending direction

Update the phi hit count and the average phi value

Update the residual

Definition at line 637 of file GlobalPatternFinder.cxx.

639 {
640 hitsPerStation[stationHit].push_back(hit);
641 if (stations.empty() || stations.back() != stationHit) {
642 stations.push_back(stationHit);
643 }
649 if (isPrecisionHit(*hit.hit)) nPrecisionHits++;
650 else if (hit.hit->measuresEta()) nBendingTriggerHits++;
652 if (hit.hit->measuresPhi()) {
653 updateMean(phi, nPhiHits, hit.phi);
654 nPhiHits++;
655 }
659}
bool hit(const std::valarray< int > &ids, int pdgId)
bool isPrecisionHit(const SpacePoint &hit)
Returns whether the uncalibrated spacepoint is a precision hit (Mdt, micromegas, stgc strips)
unsigned nMissedLayerHits
Number of missed candidate hits in different measurement layers during pattern building.
std::vector< StIndex > stations
Pattern hit stations to save the filling order.
unsigned nInsertedHits
Number of inserted hits during one of the two search stages (from seed outward and from seed inward)
unsigned nPrecisionHits
Counts of precision measurements / non-precision in bending direction / phi measurements.
std::unordered_map< StIndex, std::vector< HitPayload > > hitsPerStation
Map collection of hits per station.
double totalResidual
Total residual and last contribution to the residual (needed when replacing a hit)

◆ finalizePattern()

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

Finalize the pattern and update its state.

Update the bucket map

Update eta

Definition at line 701 of file GlobalPatternFinder.cxx.

701 {
702 theta = 0.;
703 unsigned nHits {0};
704 for (const auto& [_, hits] : hitsPerStation) {
705 for (const auto& hit : hits) {
707 auto& bucketVec {bucketsPerContainer[hit.container]};
708 if (std::ranges::find(bucketVec, hit.bucket) == bucketVec.end()){
709 bucketVec.push_back(hit.bucket);
710 }
712 theta += atan2(hit.R, hit.Z);
713 nHits++;
714 }
715 }
716 theta /= nHits;
717}
static const uint32_t nHits
BucketPerContainer bucketsPerContainer
Map of spacepoint buckets per spacepoint container associated to the pattern.

◆ getNthLastHit()

GlobalPatternFinder::PatternState::HitStationPair MuonR4::FastReco::GlobalPatternFinder::PatternState::getNthLastHit ( const std::size_t n) const

Get the nth last inserted hit and the associated station.

Parameters
nthe index of the hit to retrieve
Returns
: the pair of the n-th last inserted hit and station

Definition at line 741 of file GlobalPatternFinder.cxx.

741 {
742 if (n > nInsertedHits) {
743 // If we have not yet inserted n hits, we return the seed hit
744 return std::make_pair(std::cref(hitsPerStation.at(stations.front()).front()),
745 stations.front());
746 }
747 std::size_t remaining {n};
748 for (auto stIt = stations.rbegin(); stIt != stations.rend(); ++stIt) {
749 const auto& hits {hitsPerStation.at(*stIt)};
750 const size_t nHits {hits.size()};
751 if (remaining <= nHits) {
752 return std::make_pair(std::cref(hits.at(nHits - remaining)),
753 *stIt);
754 }
755 remaining -= nHits;
756 }
757 // Fall-back return, should not happen if the input n is consistent with nInsertedHits
758 return std::make_pair(std::cref(hitsPerStation.at(stations.front()).front()),
759 stations.front());
760}

◆ isInPattern()

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

Check wheter a hit is present in the pattern.

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

Definition at line 761 of file GlobalPatternFinder.cxx.

762 {
763 const auto seedStationIt {hitsPerStation.find(station)};
764 return seedStationIt != hitsPerStation.end() &&
765 std::ranges::find(seedStationIt->second, hit) != seedStationIt->second.end();
766}

◆ operator==()

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

Equal operator, it checks the hit-per-station map.

It'svery expensive and in principle should be avoided

Definition at line 767 of file GlobalPatternFinder.cxx.

767 {
768 return hitsPerStation == other.hitsPerStation;
769}

◆ overWriteHit()

void MuonR4::FastReco::GlobalPatternFinder::PatternState::overWriteHit ( const HitPayload & oldHit,
const HitPayload & newHit,
const StIndex station,
const double newResidual )

Overwrite a hit in the pattern and update the internal state.

Parameters
oldHithit to be replaced
newHitnew hit to replace with
stationstation of the new hit
newResidualresidual of the new hit

Update the phi hit count and average phi of the pattern

Definition at line 661 of file GlobalPatternFinder.cxx.

664 {
665 // We expect to overwrite hits of the same type (precision/trigger), since we only branch when we have
666 // compatible hits in the same layer, except for sTGC hits, where we have pad and strips in the same layer
667 if ((isPrecisionHit(*oldHit.hit) != isPrecisionHit(*newHit.hit) ||
668 oldHit.hit->measuresEta() != newHit.hit->measuresEta()) && newHit.hit->type() != xAOD::UncalibMeasType::sTgcStripType) {
669 std::stringstream ss {"Trying to overwrite a hit with incompatible type\n"};
670 ss << "Old hit: " << *oldHit.hit << ", isPrecision: " << isPrecisionHit(*oldHit.hit) << ", measuresEta: " << oldHit.hit->measuresEta() << "\n";
671 ss << "New hit: " << *newHit.hit << ", isPrecision: " << isPrecisionHit(*newHit.hit) << ", measuresEta: " << newHit.hit->measuresEta();
672 throw std::runtime_error(ss.str());
673 return;
674 }
675 auto it = hitsPerStation.find(station);
676 if (it == hitsPerStation.end()) {
677 throw std::runtime_error("Trying to remove a hit from a station that is not in the pattern cache");
678 return;
679 }
680 auto& hitsInThisStation = it->second;
681 auto toRemove = std::ranges::find(hitsInThisStation, oldHit);
682 if (toRemove == hitsInThisStation.end()) {
683 throw std::runtime_error("Trying to remove a hit that is not in the pattern cache station hits");
684 return;
685 }
686 *toRemove = newHit;
687
689 if (oldHit.hit->measuresPhi()) {
690 updateMean(phi, nPhiHits, oldHit.phi, false);
691 nPhiHits--;
692 }
693 if (newHit.hit->measuresPhi()) {
694 updateMean(phi, nPhiHits, newHit.phi, true);
695 nPhiHits++;
696 }
697 // Update the residual
698 totalResidual += newResidual - lastResidual;
699 lastResidual = newResidual;
700}
static Double_t ss

◆ print()

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

Print the pattern candidate and stream operator.

Definition at line 773 of file GlobalPatternFinder.cxx.

773 {
774 ostr<<"Pattern state, Expanded Sector: "<<sectorCoord<<", Theta: "<<theta << ", Phi: "<<phi;
775 ostr<<", nPrecisionHits: "<<nPrecisionHits<<", nEtaNonPrecisionHits: "<<nBendingTriggerHits<<", nPhiHits: "<<nPhiHits<<", total residual: "<<totalResidual;
776 ostr<<", Hit per station: \n";
777 for (const auto& [station,hits] : hitsPerStation) {
778 ostr<<" Station "<<Muon::MuonStationIndex::stName(station)<<" has "<<hits.size()<<" hits\n";
779 for (const auto& hit : hits) {
780 ostr<<" "<<*hit.hit<<", R: "<<hit.R<<", Phi:"<<hit.phi<<"\n";
781 }
782 }
783}
const std::string & stName(StIndex index)
convert StIndex into a string

◆ operator<<

std::ostream & operator<< ( std::ostream & ostr,
const PatternState & candidate )
friend

Definition at line 194 of file GlobalPatternFinder.h.

194 {
195 candidate.print(ostr);
196 return ostr;
197 }

Member Data Documentation

◆ bucketsPerContainer

BucketPerContainer MuonR4::FastReco::GlobalPatternFinder::PatternState::bucketsPerContainer {}

Map of spacepoint buckets per spacepoint container associated to the pattern.

Definition at line 172 of file GlobalPatternFinder.h.

172{};

◆ hitsPerStation

std::unordered_map<StIndex, std::vector<HitPayload> > MuonR4::FastReco::GlobalPatternFinder::PatternState::hitsPerStation {}

Map collection of hits per station.

A pattern is determined by the hits belonging to it.

Definition at line 167 of file GlobalPatternFinder.h.

167{};

◆ 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 185 of file GlobalPatternFinder.h.

185{false};

◆ lastResidual

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

Definition at line 183 of file GlobalPatternFinder.h.

183{0.};

◆ nBendingTriggerHits

unsigned MuonR4::FastReco::GlobalPatternFinder::PatternState::nBendingTriggerHits {0}

Definition at line 179 of file GlobalPatternFinder.h.

179{0};

◆ nInsertedHits

unsigned MuonR4::FastReco::GlobalPatternFinder::PatternState::nInsertedHits {0}

Number of inserted hits during one of the two search stages (from seed outward and from seed inward)

Definition at line 187 of file GlobalPatternFinder.h.

187{0};

◆ nMissedLayerHits

unsigned MuonR4::FastReco::GlobalPatternFinder::PatternState::nMissedLayerHits {0}

Number of missed candidate hits in different measurement layers during pattern building.

Definition at line 189 of file GlobalPatternFinder.h.

189{0};

◆ nPhiHits

unsigned MuonR4::FastReco::GlobalPatternFinder::PatternState::nPhiHits {0}

Definition at line 180 of file GlobalPatternFinder.h.

180{0};

◆ nPrecisionHits

unsigned MuonR4::FastReco::GlobalPatternFinder::PatternState::nPrecisionHits {0}

Counts of precision measurements / non-precision in bending direction / phi measurements.

Definition at line 178 of file GlobalPatternFinder.h.

178{0};

◆ phi

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

Definition at line 176 of file GlobalPatternFinder.h.

176{0.};

◆ sectorCoord

int MuonR4::FastReco::GlobalPatternFinder::PatternState::sectorCoord {-1}

expanded sector coordinate & average theta & average phi of the pattern

Definition at line 174 of file GlobalPatternFinder.h.

174{-1};

◆ stations

std::vector<StIndex> MuonR4::FastReco::GlobalPatternFinder::PatternState::stations {}

Pattern hit stations to save the filling order.

Stations can be repeated when we invert the search direction (e.g. from seed ourward -> BM BO, then from seed inward BM BI)

Definition at line 170 of file GlobalPatternFinder.h.

170{};

◆ theta

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

Definition at line 175 of file GlobalPatternFinder.h.

175{0.};

◆ totalResidual

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

Total residual and last contribution to the residual (needed when replacing a hit)

Definition at line 182 of file GlobalPatternFinder.h.

182{0.};

◆ visualInfo

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

Pointer to Visual Information for pattern visualization.

Definition at line 191 of file GlobalPatternFinder.h.

191{nullptr};

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