17 ISvcLocator* pSvcLocator)
26 return StatusCode::SUCCESS;
29 template <
class ContainerType>
32 const ContainerType*& contToPush)
const {
36 <<
typeid(ContainerType).
name());
37 return StatusCode::SUCCESS;
41 contToPush = readHandle.cptr();
42 return StatusCode::SUCCESS;
53 ATH_CHECK(writeMaxima.
record(std::make_unique<EtaHoughMaxContainer>()));
66 for (
auto& [station, stationHoughBuckets] :
data.houghSetups) {
68 for (
auto& bucket : stationHoughBuckets) {
72 writeMaxima->push_back(std::make_unique<HoughMaximum>(std::move(
max)));
76 std::stable_sort(writeMaxima->begin(), writeMaxima->end(),
78 return (*a->parentBucket()) < (*b->parentBucket());
80 return StatusCode::SUCCESS;
92 std::vector<HoughSetupForBucket>& buckets =
data.houghSetups[bucket->front()->msSector()];
95 Amg::Vector3D leftSide = globToLoc.translation() - (
hs.bucket->coveredMin() * Amg::Vector3D::UnitY());
96 Amg::Vector3D rightSide = globToLoc.translation() - (
hs.bucket->coveredMax() * Amg::Vector3D::UnitY());
100 for (
const std::shared_ptr<MuonR4::SpacePoint> & sp : *bucket) {
109 hs.searchWindowTanAngle = {tanThetaLeft, tanThetaRight};
114 for (
const std::shared_ptr<MuonR4::SpacePoint> & hit : *bucket){
116 double y0l = hit->positionInChamber().y() - hit->positionInChamber().z() * tanThetaLeft;
117 double y0r = hit->positionInChamber().y() - hit->positionInChamber().z() * tanThetaRight;
126 switch (hit->
type()){
143 HoughPlaneConfig
cfg;
150 data.houghPlane = std::make_unique<HoughPlane>(
cfg);
151 data.peakFinder = std::make_unique<ActsPeakFinderForMuon>(peakFinderCfg);
163 double yCross = (
y0 + 0.5 * (loc.
zBottom+loc.
zTop) * tanTheta);
164 return (loc.
yLeft < yCross && yCross < loc.
yRight);
168 auto proximity = [](
HoughHitType dc,
double y0,
double tanTheta){
173 int expectedPrecisionChambers = 0;
174 int seenPrecisionChambers = 0;
175 bool hasTrig =
false;
179 if (!passesThrough(mdtChamber, maximum.y, maximum.x))
continue;
182 ++expectedPrecisionChambers;
186 for (
auto & SP : maximum.hitIdentifiers){
189 if (isInside(mdtChamber, SP->positionInChamber()) && proximity(SP,maximum.y,maximum.x) < 2. *
m_targetResoIntercept){
196 seenPrecisionChambers += (hasHit);
199 else hasTrig |= hasHit;
202 std::set<std::pair<int,int>> seenLayers;
203 for (
auto & SP : maximum.hitIdentifiers){
214 int minLayers = seenLayers.size() / 2 + 1;
216 int minSeenPrecisionChambers = (expectedPrecisionChambers > 1) + 1;
220 minSeenPrecisionChambers = 1;
223 return seenPrecisionChambers >= minSeenPrecisionChambers && (
int)seenLayers.size() >= minLayers;
254 data.currAxisRanges = Acts::HoughTransformUtils::HoughAxisRanges{
255 searchStartTanTheta, searchEndTanTheta, searchStart, searchEnd};
257 data.houghPlane->reset();
258 for (
const SpacePointBucket::value_type& hit : *(bucket.
bucket)) {
261 auto maxima =
data.peakFinder->findPeaks(*(
data.houghPlane),
data.currAxisRanges);
264 "#eta Hough accumulator");
266 if (maxima.empty()) {
268 <<
":\n Mean tanTheta was "<<tanThetaMean
269 <<
" and my intercept "<<chamberCenter
272 <<
". The bucket found a search range of ("
277 <<
") , and my final search range is ["
278 <<searchStartTanTheta<<
" - "<<searchEndTanTheta
279 <<
"] and ["<<searchStart<<
" - "<<searchEnd
287 std::set<HoughHitType> seenHits;
290 for (
const auto&
max : maxima) {
293 unsigned int nPrec{0};
294 auto toBins = [&
data](
double x,
double y){
295 return std::make_pair(
300 auto accumulatorBins = toBins(
max.x,
max.y);
301 for (
const HoughHitType& hit :
data.houghPlane->hitIds(accumulatorBins.first, accumulatorBins.second)) {
302 auto res = seenHits.emplace(hit);
313 std::vector<HoughHitType> hitList;
314 hitList.reserve(
max.hitIdentifiers.size());
315 for (
auto & hit :
max.hitIdentifiers){
316 hitList.push_back(hit);
331 primitives.push_back(
MuonValR4::drawLabel(
std::format(
"Missed seed - score {}, layer score {}, comprising {} measurements ",
data.houghPlane->nHits(accumulatorBins.first, accumulatorBins.second),
data.houghPlane->nLayers(accumulatorBins.first, accumulatorBins.second),hitList.size()),0.05,0.03,12));
333 primitivesForAcc.push_back(
MuonValR4::drawLabel(
std::format(
"Missed seed - score {}, layer score {}, comprising {} measurements ",
data.houghPlane->nHits(accumulatorBins.first, accumulatorBins.second),
data.houghPlane->nLayers(accumulatorBins.first, accumulatorBins.second),hitList.size()),0.05,0.03,12));
335 "MissedAccumulator", std::move(primitivesForAcc));
336 m_visionTool->visualizeSeed(ctx, seed,
"Missed seed",std::move(primitives));
342 size_t nHits = hitList.size();
359 primitives.push_back(
MuonValR4::drawLabel(
std::format(
"score {}, layer score {}, comprising {} measurements. wx = {:.2f}, wy = {:.1f} ",
data.houghPlane->nHits(accumulatorBins.first, accumulatorBins.second),
data.houghPlane->nLayers(accumulatorBins.first, accumulatorBins.second),hitList.size(),
max.wx,
max.wy),0.05,0.03,12));
361 primitivesForAcc.push_back(
MuonValR4::drawLabel(
std::format(
"score {}, layer score {}, comprising {} measurements. wx = {:.2f}, wy = {:.1f} ",
data.houghPlane->nHits(accumulatorBins.first, accumulatorBins.second),
data.houghPlane->nLayers(accumulatorBins.first, accumulatorBins.second),hitList.size(),
max.wx /
m_targetResoTanTheta,
max.wy /
m_targetResoIntercept),0.05,0.03,12));
363 m_visionTool->visualizeAccumulator(ctx, *
data.houghPlane,
data.currAxisRanges, {max},
"#eta Hough accumulator", std::move(primitivesForAcc));
364 m_visionTool->visualizeSeed(ctx, seed,
"#eta-HoughSeed", std::move(primitives));
370 using namespace std::placeholders;
383 const unsigned precisionLayerIndex = (dc->readoutElement()->multilayer() * 10 + dc->tubeLayer());
398 for (
const SpacePointBucket::value_type& hit : *bucket.
bucket) {
399 if (!hit->measuresEta()) {
400 hitList.push_back(hit.get());