14#include "Acts/Utilities/Helpers.hpp"
17 constexpr double resetVal = 1.e10;
30 return StatusCode::SUCCESS;
39 peakFinderCfg.fractionCutoff = 0.4;
40 peakFinderCfg.threshold = 2;
41 peakFinderCfg.minSpacingBetweenPeaks = {0., 30.};
42 data.houghPlane = std::make_unique<HoughPlane>(cfg);
43 data.peakFinder = std::make_unique<ActsPeakFinderForMuon>(peakFinderCfg);
48 std::unordered_map<const xAOD::UncalibratedMeasurement*, bool> foundEtas;
51 if (hit->measuresEta() && hit->measuresPhi()) {
52 auto [iter, added] = foundEtas.emplace(hit->primaryMeasurement(),
false);
56 iter->second |= phiMaximum.hitIdentifiers.count(hit);
60 return std::ranges::count_if(foundEtas,
61 [](
const std::pair<const xAOD::UncalibratedMeasurement*, bool>& p) {
65std::unique_ptr<SegmentSeed>
67 const ActsPeakFinderForMuon::Maximum & phiMax)
const {
69 std::vector<HoughHitType> hitsOnMax{};
71 std::ranges::copy_if(etaMax.getHitsInMax(),
72 std::back_inserter(hitsOnMax), [](
const HoughHitType &hit){
73 return (hit->measuresEta() && !hit->measuresPhi());
76 hitsOnMax.insert(hitsOnMax.end(), phiMax.hitIdentifiers.begin(), phiMax.hitIdentifiers.end());
79 std::ranges::stable_sort(hitsOnMax, sorter);
80 return std::make_unique<SegmentSeed>(etaMax.tanBeta(), etaMax.interceptY(), phiMax.x, phiMax.y, hitsOnMax.size(), std::move(hitsOnMax), etaMax.parentBucket());
93 if (!hit->measuresPhi()) {
97 const Amg::Vector3D extrapDir = (hit->localPosition() - hit->msSector()->globalToLocalTrans(gctx).translation()).unit();
100 std::optional<double> dummyIntercept =
Amg::intersect<3>(hit->localPosition(), extrapDir, Amg::Vector3D::UnitZ(),0);
101 double x0 = (hit->localPosition() + dummyIntercept.value_or(0) * extrapDir).x();
127 Acts::HoughTransformUtils::HoughAxisRanges{searchStartTanPhi, searchEndTanPhi, searchStart, searchEnd};
128 ATH_MSG_VERBOSE(
"Accumulator search window: tanAlpha: ["<<searchStartTanPhi<<
";"<<searchEndTanPhi<<
"], x0: ["
129 <<searchStart<<
";"<<searchEnd<<
"]");
132std::vector<ActsPeakFinderForMuon::Maximum>
135 std::unordered_map<int, std::vector<ActsPeakFinderForMuon::Maximum>> rankedSeeds;
136 using namespace std::placeholders;
141 if (!hit->measuresPhi()) {
162 for (
const auto& solution : foundMaxPhi) {
168 auto best = rankedSeeds.begin();
175std::unique_ptr<SegmentSeed>
181 std::ranges::stable_sort(hits, sorter);
183 data.searchSpaceTanAngle.first,
184 data.searchSpaceIntercept.first,
208 ATH_CHECK(writeMaxima.
record(std::make_unique<SegmentSeedContainer>()));
213 ATH_MSG_VERBOSE(
"Search extra phi hits on maximum "<<
max->msSector()->identString()<<
", tanBeta: "<<
max->tanBeta()
214 <<
", y0: "<<
max->interceptY());
216 for (
const auto& truth :
m_visionTool->getLabeledSegments(
max->getHitsInMax())) {
220 truthPars[Acts::toUnderlying(ParamDefs::theta)])));
224 bool foundSolution=
false;
228 for (
auto & phiSolution : rankedSeeds){
229 foundSolution =
true;
232 m_visionTool->visualizeSeed(ctx, *seed,
"#phi pattern seed");
246 m_visionTool->visualizeSeed(ctx, *singleMax,
"Single #phi hit recovery");
251 writeMaxima->push_back(std::make_unique<SegmentSeed>(*
max));
257 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
char data[hepevt_bytes_allocation_ATLAS]
bool msgLvl(const MSG::Level lvl) const
Data class to represent an eta maximum in hough space.
double interceptY() const
getter
double getCounts() const
getter
double tanBeta() const
getter
const std::vector< HitType > & getHitsInMax() const
getter
const SpacePointBucket * parentBucket() const
getter
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
The SpacePointPerLayerSorter sort two given space points by their layer Identifier.
bool measuresEta() const
: Does the space point contain an eta measurement
unsigned nPhiInstanceCounts() const
How many space points have been built in total with the same phi prd.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Amg::Vector3D dirFromAngles(const double phi, const double theta)
Constructs a direction vector from the azimuthal & polar angles.
Eigen::Matrix< double, 3, 1 > Vector3D
double houghWidthStrip(double tanAlpha, const MuonR4::HoughHitType &dc, double targetReso)
Uncertainty parametrisation for strip measurements.
double houghParamStrip(double tanAlpha, const MuonR4::HoughHitType &dc)
straight line parametrisation for strip detector measurements, in the x-direction
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Acts::Experimental::CompositeSpacePointLineFitter::ParamVec_t Parameters
std::string toString(const Parameters &pars)
Dumps the parameters into a string with labels in front of each number.
This header ties the generic definitions in this package.
DataVector< HoughMaximum > EtaHoughMaxContainer
HoughEventData_impl< ActsPeakFinderForMuon, ActsPeakFinderForMuonCfg > HoughEventData
Acts::HoughTransformUtils::PeakFinders::IslandsAroundMaxConfig ActsPeakFinderForMuonCfg
double houghTanAlpha(const Amg::Vector3D &v)
: Returns the hough tanAlpha [x] / [z]
const SpacePoint * HoughHitType
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
std::pair< double, double > searchSpaceIntercept
static void updateSearchWindow(std::pair< double, double > &searchWindow, double value)
Updates a search space window to account for a value.
std::unique_ptr< peakFinder_t > peakFinder
std::unique_ptr< HoughPlane > houghPlane
std::pair< double, double > searchSpaceTanAngle
Acts::HoughTransformUtils::HoughAxisRanges currAxisRanges