Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SegmentFittingAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "SegmentFittingAlg.h"
6 
9 
17 
21 
22 #include <GaudiKernel/PhysicalConstants.h>
23 #include <Minuit2/Minuit2Minimizer.h>
24 #include <Math/Minimizer.h>
25 
27 
28 #include <format>
29 
30 namespace MuonR4 {
31  using namespace SegmentFit;
32  using namespace MuonValR4;
33 
36  copied.reserve(hits.size());
37  std::ranges::transform(hits, std::back_inserter(copied),
38  [](const auto& hit) { return std::make_unique<MuonR4::CalibratedSpacePoint>(*hit);});
39  return copied;
40  }
43  toRet.segmentPars = toCopy.segmentPars;
44  toRet.calibMeasurements = copy(toCopy.calibMeasurements);
45  toRet.chi2 = toCopy.chi2;
46  toRet.nDoF = toCopy.nDoF;
47  toRet.timeFit = toCopy.timeFit;
48  return toRet;
49  }
51  std::size_t before = hits.size();
52  hits.erase(std::remove_if(hits.begin(), hits.end(),
53  [](const auto& a){
54  return a->type() == xAOD::UncalibMeasType::Other;
55  }), hits.end());
56  return before != hits.size();
57  }
58 
60 
63  ATH_CHECK(m_geoCtxKey.initialize());
64  ATH_CHECK(m_seedKey.initialize());
65  ATH_CHECK(m_outSegments.initialize());
66  ATH_CHECK(m_calibTool.retrieve());
67  ATH_CHECK(m_idHelperSvc.retrieve());
68  ATH_CHECK(m_visionTool.retrieve(EnableTool{!m_visionTool.empty()}));
70  m_ambiSolver = std::make_unique<SegmentAmbiSolver>(name(), std::move(cfg));
71  return StatusCode::SUCCESS;
72  }
73  StatusCode SegmentFittingAlg::execute(const EventContext& ctx) const {
74  const ActsGeometryContext* gctx{nullptr};
75  ATH_CHECK(SG::get(gctx, m_geoCtxKey, ctx));
76  const SegmentSeedContainer* segmentSeeds=nullptr;
77  ATH_CHECK(SG::get(segmentSeeds, m_seedKey, ctx));
78 
79  SG::WriteHandle writeSegments{m_outSegments, ctx};
80  ATH_CHECK(writeSegments.record(std::make_unique<SegmentContainer>()));
81 
82  std::vector<std::unique_ptr<Segment>> allSegments{};
83  for (const SegmentSeed* seed : *segmentSeeds) {
84  std::vector<std::unique_ptr<Segment>> segments = fitSegmentSeed(ctx, *gctx, seed);
85  if (m_visionTool.isEnabled() && segments.size() > 1) {
86  auto drawFinalReco = [this, &segments, &gctx, &ctx,&seed](const std::string& nameTag) {
87  PrimitiveVec segmentLines{};
88  double yLegend{0.85};
89  segmentLines.push_back(drawLabel(std::format("# segments: {:d}", segments.size()), 0.2, yLegend, 14));
90  yLegend-=0.04;
91  for (const std::unique_ptr<Segment>& seg : segments) {
92  const Parameters pars = localSegmentPars(*gctx, *seg);
93  const auto [locPos, locDir] = makeLine(pars);
94 
95  segmentLines.emplace_back(drawLine(pars, -Gaudi::Units::m, Gaudi::Units::m, kRed));
96  std::stringstream signStream{};
97  signStream<<std::format("#chi^{{2}}/nDoF: {:.2f} ({:}), ", seg->chi2() / seg->nDoF(), seg->nDoF());
98  signStream<<std::format("y_{{0}}={:.2f}",pars[toInt(ParamDefs::y0)])<<", ";
99  signStream<<std::format("#theta={:.2f}^{{#circ}}", pars[toInt(ParamDefs::theta)]/ Gaudi::Units::deg )<<", ";
100  for (const Segment::MeasType& m : seg->measurements()) {
102  signStream<<(SegmentFitHelpers::driftSign(locPos, locDir, *m, msgStream()) == -1 ? "L" : "R");
103  }
104  }
105  segmentLines.push_back(drawLabel(signStream.str(), 0.2, yLegend, 13));
106  yLegend-=0.03;
107  }
108 
109  m_visionTool->visualizeBucket(ctx, *seed->parentBucket(), nameTag, std::move(segmentLines));
110  };
111  drawFinalReco("all segments");
112  const unsigned int nBeforeAmbi = segments.size();
113  segments = m_ambiSolver->resolveAmbiguity(*gctx, std::move(segments));
114  if (nBeforeAmbi != segments.size()) {
115  drawFinalReco("post ambiguity");
116  }
117  } else if (m_visionTool.isEnabled() && segments.empty() &&
118  std::ranges::count_if(seed->getHitsInMax(),[this](const SpacePoint* hit){
119  return m_visionTool->isLabeled(*hit);
120  })) {
121  m_visionTool->visualizeSeed(ctx, *seed, "Failed fit");
122  }
123  allSegments.insert(allSegments.end(), std::make_move_iterator(segments.begin()),
124  std::make_move_iterator(segments.end()));
125  }
126  resolveAmbiguities(*gctx, allSegments);
127  writeSegments->insert(writeSegments->end(),
128  std::make_move_iterator(allSegments.begin()),
129  std::make_move_iterator(allSegments.end()));
130  ATH_MSG_VERBOSE("Found in total "<<writeSegments->size()<<" segments. ");
131  return StatusCode::SUCCESS;
132  }
133 
135  const ActsGeometryContext& gctx,
136  const Parameters& startPars,
137  SegmentFitResult::HitVec&& calibHits) const {
139  if (calibHits.empty()) {
140  ATH_MSG_WARNING("No hits, no segment");
141  return data;
142  }
143 
145  if (m_doBeamspotConstraint) {
146  unsigned int numPhi = std::accumulate(calibHits.begin(), calibHits.end(),0,
147  [](unsigned int n, const HitVec::value_type& hit){
148  return n + (hit->fitState() == CalibratedSpacePoint::State::Valid &&
149  hit->measuresPhi());
150  });
151  if (numPhi) {
152  const Amg::Transform3D globToLoc{calibHits[0]->spacePoint()->msSector()->globalToLocalTrans(gctx)};
153  Amg::Vector3D beamSpot{globToLoc.translation()};
154  AmgSymMatrix(3) covariance{AmgSymMatrix(3)::Identity()};
156  covariance(0,0) = std::pow(m_beamSpotR, 2);
157  covariance(1,1) = std::pow(m_beamSpotR, 2);
158  covariance(2,2) = std::pow(m_beamSpotL, 2);
159  AmgSymMatrix(3) jacobian = globToLoc.linear();
160  covariance = jacobian * covariance * jacobian.transpose();
161  AmgSymMatrix(2) beamSpotCov{covariance.block<2,2>(0,0)};
162  auto beamSpotSP = std::make_unique<CalibratedSpacePoint>(nullptr, std::move(beamSpot), Amg::Vector3D::Zero());
163  beamSpotSP->setCovariance<2>(std::move(beamSpotCov));
164  ATH_MSG_VERBOSE("Beam spot constraint "<<Amg::toString(beamSpotSP->positionInChamber())<<", "<<toString(beamSpotSP->covariance()));
165  calibHits.push_back(std::move(beamSpotSP));
166  }
167  }
168 
169  const Amg::Transform3D& locToGlob{calibHits[0]->spacePoint()->msSector()->localToGlobalTrans(gctx)};
170 
171  MdtSegmentFitter::Config fitCfg{};
172  fitCfg.calibrator = m_calibTool.get();
173  fitCfg.doTimeFit = m_doT0Fit;
174  fitCfg.reCalibrate = m_recalibInFit;
175 
176  MdtSegmentFitter fitter{name(), std::move(fitCfg)};
177  return fitter.fitSegment(ctx, std::move(calibHits), startPars, locToGlob);
178  }
179  std::vector<std::unique_ptr<Segment>>
180  SegmentFittingAlg::fitSegmentSeed(const EventContext& ctx,
181  const ActsGeometryContext& gctx,
182  const SegmentSeed* patternSeed) const {
183 
184  const Amg::Transform3D& locToGlob{patternSeed->msSector()->localToGlobalTrans(gctx)};
185  std::vector<std::unique_ptr<Segment>> segments{};
186 
188  genCfg.hitPullCut = m_seedHitChi2;
189  genCfg.recalibSeedCircles = m_recalibSeed;
190  genCfg.fastSeedFit = m_refineSeed;
191  genCfg.fastSegFitWithT0 = m_doT0Fit;
192  genCfg.calibrator = m_calibTool.get();
193 
194 
196  genCfg.busyLayerLimit = 2 + 2*(patternSeed->parameters()[toInt(ParamDefs::theta)] > 50 * Gaudi::Units::deg);
198  if (m_visionTool.isEnabled()) {
199  PrimitiveVec seedLines{};
200  MdtSegmentSeedGenerator drawMe{name(), patternSeed, genCfg};
201  while(auto s = drawMe.nextSeed(ctx)) {
202  seedLines.push_back(drawLine(s->parameters, -Gaudi::Units::m, Gaudi::Units::m, kViolet));
203  }
204  seedLines.push_back(drawLabel(std::format("possible seeds: {:d}", drawMe.numGenerated()), 0.2, 0.85, 14));
205  m_visionTool->visualizeSeed(ctx, *patternSeed, "pattern", std::move(seedLines));
206  }
207 
208  MdtSegmentSeedGenerator seedGen{name(), patternSeed, std::move(genCfg)};
209  while (auto seed = seedGen.nextSeed(ctx)) {
211  data.segmentPars = seed->parameters;
212  data.calibMeasurements = std::move(seed->measurements);
214  if (m_visionTool.isEnabled()) {
215  auto seedCopy = convertToSegment(locToGlob, patternSeed, copy(data));
216  m_visionTool->visualizeSegment(ctx, *seedCopy, std::format("Pre fit {:d}", seedGen.numGenerated()));
217  }
218  data = fitSegmentHits(ctx, gctx, seed->parameters, std::move(data.calibMeasurements));
219  data.nIter += seed->nIter;
220  if (m_visionTool.isEnabled() && data.converged) {
221  auto seedCopy = convertToSegment(locToGlob, patternSeed, copy(data));
222  m_visionTool->visualizeSegment(ctx, *seedCopy, std::format("Intermediate fit {:d}", seedGen.numGenerated()));
223  }
224  if (!removeOutliers(ctx, gctx, *patternSeed, data)) {
225  continue;
226  }
227  if (!plugHoles(ctx, gctx, *patternSeed, data)) {
228  continue;
229  }
230  if (m_visionTool.isEnabled()) {
231  auto seedCopy = convertToSegment(locToGlob, patternSeed, copy(data));
232  m_visionTool->visualizeSegment(ctx, *seedCopy, std::format("Final fit {:d}", seedGen.numGenerated()));
233  }
234  segments.push_back(convertToSegment(locToGlob, patternSeed, std::move(data)));
235  }
236  return segments;
237  }
238  std::unique_ptr<Segment> SegmentFittingAlg::convertToSegment(const Amg::Transform3D& locToGlob,
239  const SegmentSeed* patternSeed,
241  const auto [locPos, locDir] = data.makeLine();
242  Amg::Vector3D globPos = locToGlob * locPos;
243  Amg::Vector3D globDir = locToGlob.linear()* locDir;
244 
245 
246  auto finalSeg = std::make_unique<Segment>(std::move(globPos), std::move(globDir),
247  patternSeed, std::move(data.calibMeasurements),
248  data.chi2, data.nDoF);
249  finalSeg->setCallsToConverge(data.nIter);
250  finalSeg->setParUncertainties(std::move(data.segmentParErrs));
251  if (data.timeFit) {
252  finalSeg->setSegmentT0(data.segmentPars[toInt(ParamDefs::time)]);
253  }
254  return finalSeg;
255  }
256 
257  bool SegmentFittingAlg::removeOutliers(const EventContext& ctx,
258  const ActsGeometryContext& gctx,
259  const SegmentSeed& seed,
260  SegmentFitResult& data) const {
261 
263  if (data.nDoF<=0 || data.calibMeasurements.empty() || data.nPrecMeas < m_precHitCut) {
264  ATH_MSG_VERBOSE("No degree of freedom available. What shall be removed?!. nDoF: "
265  <<data.nDoF<<", n-meas: "<<data.calibMeasurements);
266  return false;
267  }
268 
269  const auto [segPos, segDir] = data.makeLine();
270 
271  if (data.converged && data.chi2 / data.nDoF < m_outlierRemovalCut) {
272  ATH_MSG_VERBOSE("The segment "<<Amg::toString(segPos)<<" + "<<Amg::toString(segDir)
273  <<" is already of good quality "<<data.chi2 / std::max(data.nDoF, 1)
274  <<". Don't remove outliers");
275  return true;
276  }
277  ATH_MSG_VERBOSE("Segment "<<toString(data.segmentPars)<<" is of badish quality.");
280  if (m_doBeamspotConstraint && removeBeamSpot(data.calibMeasurements)) {
281  data.nDoF-=2;
282  data.nPhiMeas-=1;
283  }
284 
286  std::ranges::sort(data.calibMeasurements,
287  [&, this](const HitVec::value_type& a, const HitVec::value_type& b){
288  return SegmentFitHelpers::chiSqTerm(segPos, segDir, data.segmentPars[toInt(ParamDefs::time)], std::nullopt, *a, msgStream()) <
289  SegmentFitHelpers::chiSqTerm(segPos, segDir, data.segmentPars[toInt(ParamDefs::time)], std::nullopt, *b, msgStream());
290  });
291 
293  data.calibMeasurements.back()->setFitState(CalibratedSpacePoint::State::Outlier);
294  data.nDoF -= data.calibMeasurements.back()->measuresEta();
295  data.nDoF -= data.calibMeasurements.back()->measuresPhi();
296  if (m_doT0Fit && data.calibMeasurements.back()->measuresTime() &&
297  data.calibMeasurements.back()->type() != xAOD::UncalibMeasType::MdtDriftCircleType) {
298  --data.nDoF;
299  }
301  std::vector<HoughHitType> uncalib{};
302  for (const HitVec::value_type& calib : data.calibMeasurements) {
303  uncalib.push_back(calib->spacePoint());
304  }
305  SegmentFitResult newAttempt = fitSegmentHits(ctx, gctx, data.segmentPars, std::move(data.calibMeasurements));
306  if (newAttempt.converged) {
307  newAttempt.nIter+=data.nIter;
308  data = std::move(newAttempt);
309  if (m_visionTool.isEnabled()) {
310  auto seedCopy = convertToSegment(seed.msSector()->localToGlobalTrans(gctx), &seed, copy(data));
311  m_visionTool->visualizeSegment(ctx, *seedCopy, "Bad fit recovery");
312  }
313  } else {
314  data.calibMeasurements = std::move(newAttempt.calibMeasurements);
315  }
316  return removeOutliers(ctx, gctx, seed, data);
317  }
318 
319  bool SegmentFittingAlg::plugHoles(const EventContext& ctx,
320  const ActsGeometryContext& gctx,
321  const SegmentSeed& seed,
322  SegmentFitResult& beforeRecov) const {
324  ATH_MSG_VERBOSE("plugHoles() -- segment "<<toString(beforeRecov.segmentPars)
325  <<", chi2: "<<beforeRecov.chi2<<", nDoF: "<<beforeRecov.nDoF<<", "
326  <<beforeRecov.chi2 /std::max(beforeRecov.nDoF, 1) );
328  std::unordered_set<const SpacePoint*> usedSpacePoint{};
329  for (const HitVec::value_type& hit : beforeRecov.calibMeasurements) {
330  usedSpacePoint.insert(hit->spacePoint());
331  }
332 
333  HitVec candidateHits{};
334  SpacePointPerLayerSplitter hitLayers{*seed.parentBucket()};
335  bool hasCandidate{false};
336  const auto [locPos, locDir] = beforeRecov.makeLine();
337  for (const std::vector<HoughHitType>& mdtLayer : hitLayers.mdtHits()) {
338  for (const SpacePoint* mdtHit: mdtLayer) {
340  if (usedSpacePoint.count(mdtHit)) {
341  continue;
342  }
343  const double dist = Amg::lineDistance(locPos, locDir, mdtHit->positionInChamber(), mdtHit->directionInChamber());
344  const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(mdtHit->primaryMeasurement());
345  if (dist >= dc->readoutElement()->innerTubeRadius()) {
346  continue;
347  }
348  HitVec::value_type calibHit{m_calibTool->calibrate(ctx, mdtHit, locPos, locDir, beforeRecov.segmentPars[toInt(ParamDefs::time)])};
349  const double pull = std::sqrt(SegmentFitHelpers::chiSqTermMdt(locPos, locDir, *calibHit, msgStream()));
350  ATH_MSG_VERBOSE(__func__<<"() :"<<__LINE__<<" Candidate hit for recovery "<<m_idHelperSvc->toString(mdtHit->identify())<<", chi2: "<<pull);
351  if (pull <= m_recoveryPull) {
352  hasCandidate |= calibHit->fitState() == CalibratedSpacePoint::State::Valid;
353  candidateHits.push_back(std::move(calibHit));
354  } else {
355  calibHit->setFitState(CalibratedSpacePoint::State::Outlier);
356  candidateHits.push_back(std::move(calibHit));
357  }
358  }
359  }
360  if (!hasCandidate) {
361  ATH_MSG_VERBOSE("No space point candidates for recovery were found");
362  beforeRecov.calibMeasurements.insert(beforeRecov.calibMeasurements.end(),
363  std::make_move_iterator(candidateHits.begin()),
364  std::make_move_iterator(candidateHits.end()));
365  eraseWrongHits(beforeRecov);
366  return beforeRecov.nDoF > 0;
367  }
368 
369  HitVec copied = copy(beforeRecov.calibMeasurements), copiedCandidates = copy(candidateHits);
371  if (m_doBeamspotConstraint) {
372  removeBeamSpot(copied);
373  }
374 
375  candidateHits.insert(candidateHits.end(), std::make_move_iterator(copied.begin()), std::make_move_iterator(copied.end()));
376 
377  SegmentFitResult recovered = fitSegmentHits(ctx, gctx, beforeRecov.segmentPars, std::move(candidateHits));
378  if (!recovered.converged) {
379  return false;
380  }
382  if (recovered.nDoF + recovered.timeFit <= beforeRecov.nDoF + beforeRecov.timeFit) {
383  for (HitVec::value_type& hit : copiedCandidates) {
384  hit->setFitState(CalibratedSpacePoint::State::Outlier);
385  beforeRecov.calibMeasurements.push_back(std::move(hit));
386  }
387  eraseWrongHits(beforeRecov);
388  return true;
389  }
390  ATH_MSG_VERBOSE("Chi2, nDOF before:"<<beforeRecov.chi2<<", "<<beforeRecov.nDoF<<" after recovery: "<<recovered.chi2<<", "<<recovered.nDoF);
391  double redChi2 = recovered.chi2 / std::max(recovered.nDoF,1);
393  if (redChi2 < m_outlierRemovalCut || (beforeRecov.nDoF == 0) || redChi2 < beforeRecov.chi2 / beforeRecov.nDoF) {
394  ATH_MSG_VERBOSE("Accept segment with recovered "<<(recovered.nDoF + recovered.timeFit) - (beforeRecov.nDoF + beforeRecov.timeFit)<<" hits.");
395  recovered.nIter += beforeRecov.nIter;
396  beforeRecov = std::move(recovered);
398  while (true) {
399  bool runAnotherTrial = false;
400  copied = copy(beforeRecov.calibMeasurements);
401  if (m_doBeamspotConstraint) {
402  removeBeamSpot(copied);
403  }
404  const auto [beforePos, beforeDir] = beforeRecov.makeLine();
405  for (HitVec::value_type& copyHit : copied) {
406  if (copyHit->fitState() != CalibratedSpacePoint::State::Outlier) {
407  continue;
408  }
409  copyHit->setFitState(CalibratedSpacePoint::State::Valid);
410  bool append = std::sqrt(SegmentFitHelpers::chiSqTerm(beforePos, beforeDir,
411  beforeRecov.segmentPars[toInt(ParamDefs::time)],
412  std::nullopt, *copyHit, msgStream())) < m_recoveryPull;
413  if (append) {
414  runAnotherTrial = true;
415  } else {
416  copyHit->setFitState(CalibratedSpacePoint::State::Outlier);
417  }
418  }
419  if (!runAnotherTrial) {
420  break;
421  }
422  recovered = fitSegmentHits(ctx, gctx, beforeRecov.segmentPars, std::move(copied));
423  if (!recovered.converged) {
424  break;
425  }
426  if (recovered.nDoF + recovered.timeFit <= beforeRecov.nDoF + beforeRecov.timeFit) {
427  break;
428  }
429  redChi2 = recovered.chi2 / std::max(recovered.nDoF, 1);
430  if (redChi2 < m_outlierRemovalCut || redChi2 < beforeRecov.chi2 / beforeRecov.nDoF) {
431  recovered.nIter += beforeRecov.nIter;
432  beforeRecov = std::move(recovered);
433  } else {
434  break;
435  }
436  }
438  eraseWrongHits(beforeRecov);
439  } else{
440  for (HitVec::value_type& hit : copiedCandidates) {
441  hit->setFitState(CalibratedSpacePoint::State::Outlier);
442  beforeRecov.calibMeasurements.push_back(std::move(hit));
443  }
444  }
445  return true;
446  }
448  auto [segPos, segDir] = makeLine(candidate.segmentPars);
449  candidate.calibMeasurements.erase(std::remove_if(candidate.calibMeasurements.begin(), candidate.calibMeasurements.end(),
450  [&segPos, &segDir](const HitVec::value_type& hit){
451  if (hit->fitState() != CalibratedSpacePoint::State::Outlier) {
452  return false;
453  }
456  const double dist = Amg::lineDistance(segPos, segDir, hit->positionInChamber(), hit->directionInChamber());
457  const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(hit->spacePoint()->primaryMeasurement());
458  return dist >= dc->readoutElement()->innerTubeRadius();
459  }
460  return true;
461  }), candidate.calibMeasurements.end());
462 
463  std::ranges::sort(candidate.calibMeasurements, [](const Segment::MeasType& a, const Segment::MeasType& b){
464  return a->positionInChamber().z() < b->positionInChamber().z();
465  });
466  }
468  std::vector<std::unique_ptr<Segment>>& segmentCandidates) const {
469  using SegmentVec = std::vector<std::unique_ptr<Segment>>;
470  ATH_MSG_VERBOSE("Resolve ambiguities amongst "<<segmentCandidates.size()<<" segment candidates. ");
471  std::unordered_map<const MuonGMR4::SpectrometerSector*, SegmentVec> candidatesPerChamber{};
472 
473  for (std::unique_ptr<Segment>& sortMe : segmentCandidates) {
474  const MuonGMR4::SpectrometerSector* chamb = sortMe->msSector();
475  candidatesPerChamber[chamb].push_back(std::move(sortMe));
476  }
477  segmentCandidates.clear();
478  for (auto& [chamber, resolveMe] : candidatesPerChamber) {
479  SegmentVec resolvedSegments = m_ambiSolver->resolveAmbiguity(gctx, std::move(resolveMe));
480  segmentCandidates.insert(segmentCandidates.end(),
481  std::make_move_iterator(resolvedSegments.begin()),
482  std::make_move_iterator(resolvedSegments.end()));
483  }
484  }
485 }
MuonR4::SegmentFitResult::nIter
unsigned nIter
Number of iterations called to reach the minimum.
Definition: SegmentFitterEventData.h:78
MuonR4::PrimitiveVec
MuonValR4::IPatternVisualizationTool::PrimitiveVec PrimitiveVec
Definition: SegmentFittingAlg.cxx:59
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
MuonR4::MdtSegmentFitter
Definition: MdtSegmentFitter.h:19
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
MuonR4::SegmentFittingAlg::convertToSegment
static std::unique_ptr< Segment > convertToSegment(const Amg::Transform3D &locToGlobTrf, const SegmentSeed *parentSeed, SegmentFitResult &&toConvert)
Converts the fit result into a segment object.
Definition: SegmentFittingAlg.cxx:238
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
MuonR4::SpacePointPerLayerSplitter
The SpacePointPerLayerSplitter takes a set of spacepoints already sorted by layer Identifier (see Muo...
Definition: SpacePointPerLayerSplitter.h:16
MuonGMR4::SpectrometerSector
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
Definition: SpectrometerSector.h:40
vtune_athena.format
format
Definition: vtune_athena.py:14
calibdata.chamber
chamber
Definition: calibdata.py:32
VisualizationHelpers.h
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
MuonR4::SegmentFittingAlg::fitSegmentHits
SegmentFitResult fitSegmentHits(const EventContext &ctx, const ActsGeometryContext &gctx, const Parameters &startPars, SegmentFitResult::HitVec &&calibHits) const
Executes the segment fit with start parameters.
Definition: SegmentFittingAlg.cxx:134
MuonR4::SegmentFitResult::calibMeasurements
HitVec calibMeasurements
Calibrated measurements used in the fit.
Definition: SegmentFitterEventData.h:64
SegmentFittingAlg.h
deg
#define deg
Definition: SbPolyhedron.cxx:17
MuonR4::SegmentFittingAlg::initialize
virtual StatusCode initialize() override
Definition: SegmentFittingAlg.cxx:62
MuonR4::SegmentFittingAlg::HitVec
SegmentFitResult::HitVec HitVec
Definition: SegmentFittingAlg.h:38
MuonR4::CalibratedSpacePoint::State::Outlier
@ Outlier
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonR4::SegmentAmbiSolver::Config
Definition: SegmentAmbiSolver.h:18
MuonR4::SegmentFittingAlg::Parameters
SegmentFit::Parameters Parameters
Definition: SegmentFittingAlg.h:41
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
MuonR4::SegmentFittingAlg::resolveAmbiguities
void resolveAmbiguities(const ActsGeometryContext &gctx, std::vector< std::unique_ptr< Segment >> &segmentCandidates) const
Definition: SegmentFittingAlg.cxx:467
MuonR4::SegmentFitHelpers::chiSqTerm
double chiSqTerm(const Amg::Vector3D &posInChamber, const Amg::Vector3D &dirInChamber, const SpacePoint &measurement, MsgStream &msg)
Calculates the chi2 contribuation to a linear segment line from an uncalibrated measurement.
Definition: SegmentFitHelperFunctions.cxx:28
MuonR4::SegmentFit::makeLine
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
Definition: SegmentFitterEventData.cxx:26
MuonValR4::drawLabel
std::unique_ptr< TLatex > drawLabel(const std::string &text, const double xPos, const double yPos, const unsigned int fontSize=18)
Create a TLatex label,.
Definition: VisualizationHelpers.cxx:32
MuonR4::SegmentFitResult::HitVec
std::vector< HitType > HitVec
Definition: SegmentFitterEventData.h:53
MuonR4::MdtSegmentSeedGenerator
Helper class to generate valid seeds for the segment fit.
Definition: MdtSegmentSeedGenerator.h:24
RpcStripContainer.h
MuonR4::MdtSegmentFitter::Config::calibrator
const ISpacePointCalibrator * calibrator
Pointer to the calibrator tool.
Definition: MdtSegmentFitter.h:40
MuonR4::SegmentFitResult::nDoF
int nDoF
degrees of freedom
Definition: SegmentFitterEventData.h:68
MuonR4::SegmentFitHelpers::driftSign
int driftSign(const Amg::Vector3D &posInChamber, const Amg::Vector3D &dirInChamber, const SpacePoint &uncalibHit, MsgStream &msg)
Calculates whether a segement line travereses the tube measurement on the left (-1) or right (1) side...
Definition: SegmentFitHelperFunctions.cxx:235
MuonR4::Segment::MeasType
std::unique_ptr< CalibratedSpacePoint > MeasType
Calibrated space point type.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonPatternEvent/MuonPatternEvent/Segment.h:23
MuonR4::copy
MuonR4::SegmentFitResult::HitVec copy(const MuonR4::SegmentFitResult::HitVec &hits)
Definition: SegmentFittingAlg.cxx:34
MuonR4::MdtSegmentSeedGenerator::Config
Configuration switches of the module
Definition: MdtSegmentSeedGenerator.h:29
MdtSegmentSeedGenerator.h
SpacePointPerLayerSplitter.h
MuonR4::SegmentFittingAlg::fitSegmentSeed
std::vector< std::unique_ptr< Segment > > fitSegmentSeed(const EventContext &ctx, const ActsGeometryContext &gctx, const SegmentSeed *seed) const
Definition: SegmentFittingAlg.cxx:180
Amg::toString
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Definition: GeoPrimitivesToStringConverter.h:40
MuonR4::SegmentFittingAlg::plugHoles
bool plugHoles(const EventContext &ctx, const ActsGeometryContext &gctx, const SegmentSeed &seed, SegmentFitResult &toRecover) const
Recovery of missed hits.
Definition: SegmentFittingAlg.cxx:319
MuonR4::SegmentFitHelpers::chiSqTermMdt
double chiSqTermMdt(const Amg::Vector3D &posInChamber, const Amg::Vector3D &dirInChamber, const SpacePoint &measurement, MsgStream &msg)
Calculates the chi2 contribuation to a linear segment line from an uncalibrated Mdt measurement.
Definition: SegmentFitHelperFunctions.cxx:52
MuonR4::SegmentFittingAlg::removeOutliers
bool removeOutliers(const EventContext &ctx, const ActsGeometryContext &gctx, const SegmentSeed &seed, SegmentFitResult &fitResult) const
Spot hits with large discrepancy from the estimated parameters and remove them from the list.
Definition: SegmentFittingAlg.cxx:257
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:287
MuonR4::SegmentFitResult::converged
bool converged
Is the fit converged.
Definition: SegmentFitterEventData.h:76
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
UtilFunctions.h
SegmentFitHelperFunctions.h
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
MuonR4::MdtSegmentFitter::Config
Definition: MdtSegmentFitter.h:26
python.StandardJetMods.pull
pull
Definition: StandardJetMods.py:298
MuonSimHitContainer.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonR4::SegmentFitResult::segmentPars
Parameters segmentPars
Final segment parameters.
Definition: SegmentFitterEventData.h:60
MuonR4::SegmentFittingAlg::eraseWrongHits
void eraseWrongHits(SegmentFitResult &candidate) const
Removes all hits from the segment which are obvious outliers.
Definition: SegmentFittingAlg.cxx:447
MuonR4::SegmentFit::toString
std::string toString(const Parameters &pars)
Definition: SegmentFitterEventData.cxx:59
MuonR4::removeBeamSpot
bool removeBeamSpot(MuonR4::SegmentFitResult::HitVec &hits)
Definition: SegmentFittingAlg.cxx:50
MuonR4::MdtSegmentSeedGenerator::Config::hitPullCut
double hitPullCut
Upper cut on the hit chi2 w.r.t.
Definition: MdtSegmentSeedGenerator.h:35
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ParticleHypothesis.h
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MuonR4::SegmentFit::ParamDefs::time
@ time
MuonR4::CalibratedSpacePoint::State::Valid
@ Valid
MuonR4::SpacePoint
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:18
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
MdtDriftCircleContainer.h
TgcStrip.h
MuonR4::SegmentFit::ParamDefs::y0
@ y0
MuonValR4::IPatternVisualizationTool::PrimitiveVec
std::vector< PrimitivePtr > PrimitiveVec
Definition: IPatternVisualizationTool.h:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
MuonR4::SegmentFit::toInt
constexpr int toInt(const ParamDefs p)
Definition: MuonHoughDefs.h:42
RpcMeasurement.h
WriteCaloSwCorrections.cfg
cfg
Definition: WriteCaloSwCorrections.py:23
Amg::lineDistance
double lineDistance(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
: Calculates the shortest distance between two lines
Definition: GeoPrimitivesHelpers.h:308
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
python.copyTCTOutput.locDir
locDir
Definition: copyTCTOutput.py:113
MuonR4
This header ties the generic definitions in this package.
Definition: HoughEventData.h:16
PlotSFuncertainty.calib
calib
Definition: PlotSFuncertainty.py:110
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
MuonR4::SegmentVec
SegmentAmbiSolver::SegmentVec SegmentVec
Definition: SegmentAmbiSolver.cxx:10
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:63
a
TList * a
Definition: liststreamerinfos.cxx:10
MdtSegmentFitter.h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
MuonGMR4::SpectrometerSector::localToGlobalTrans
const Amg::Transform3D & localToGlobalTrans(const ActsGeometryContext &gctx) const
Returns the local -> global tarnsformation from the sector.
Definition: SpectrometerSector.cxx:51
GeoPrimitivesHelpers.h
MuonR4::SegmentFitResult::timeFit
bool timeFit
Was the time fitted.
Definition: SegmentFitterEventData.h:56
MuonR4::SegmentSeed
Representation of a segment seed (a fully processed hough maximum) produced by the hough transform.
Definition: SegmentSeed.h:14
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
MuonR4::SegmentSeed::parameters
const Parameters & parameters() const
Returns the parameter array.
Definition: SegmentSeed.cxx:35
MuonR4::SegmentFit::localSegmentPars
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Definition: SegmentFitterEventData.cxx:32
python.BuildSignatureFlags.beamSpot
AthConfigFlags beamSpot(AthConfigFlags flags, str instanceName, str recoMode)
Definition: BuildSignatureFlags.py:455
MuonR4::SegmentFitResult
Definition: SegmentFitterEventData.h:46
MuonR4::SegmentFitResult::chi2
double chi2
chi2 of the fit
Definition: SegmentFitterEventData.h:66
drawLine
void drawLine(std::ostream &os)
Definition: PrintMC.cxx:16
xAOD::MdtDriftCircle_v1
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
Definition: MdtDriftCircle_v1.h:21
MuonR4::AmgSymMatrix
const AmgSymMatrix(2) &SpacePoint
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/src/SpacePoint.cxx:150
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
MuonR4::SegmentFittingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: SegmentFittingAlg.cxx:73
xAOD::UncalibMeasType::MdtDriftCircleType
@ MdtDriftCircleType
MuonR4::SegmentFittingAlg::~SegmentFittingAlg
virtual ~SegmentFittingAlg()
MuonR4::SegmentFit::ParamDefs::theta
@ theta
MuonR4::SegmentSeed::msSector
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated chamber.
Definition: SegmentSeed.cxx:39
generate::Zero
void Zero(TH1D *hin)
Definition: generate.cxx:32
MuonR4::SegmentFitResult::makeLine
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine() const
Returns the defining parameters as a pair of Amg::Vector3D The first part is the position expressed a...
Definition: SegmentFitterEventData.h:83