ATLAS Offline Software
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 
8 
13 
14 
18 
19 #include <format>
20 
21 namespace MuonR4 {
22  using namespace SegmentFit;
23  using namespace MuonValR4;
24 
27  copied.reserve(hits.size());
28  std::ranges::transform(hits, std::back_inserter(copied),
29  [](const auto& hit) { return std::make_unique<MuonR4::CalibratedSpacePoint>(*hit);});
30  return copied;
31  }
34  toRet.segmentPars = toCopy.segmentPars;
35  toRet.calibMeasurements = copy(toCopy.calibMeasurements);
36  toRet.chi2 = toCopy.chi2;
37  toRet.nDoF = toCopy.nDoF;
38  toRet.timeFit = toCopy.timeFit;
39  return toRet;
40  }
42  std::size_t before = hits.size();
43  hits.erase(std::remove_if(hits.begin(), hits.end(),
44  [](const auto& a){
45  return a->type() == xAOD::UncalibMeasType::Other;
46  }), hits.end());
47  return before != hits.size();
48  }
49 
51 
54  ATH_CHECK(m_geoCtxKey.initialize());
55  ATH_CHECK(m_seedKey.initialize());
56  ATH_CHECK(m_outSegments.initialize());
57  ATH_CHECK(m_calibTool.retrieve());
58  ATH_CHECK(m_idHelperSvc.retrieve());
59  ATH_CHECK(m_visionTool.retrieve(EnableTool{!m_visionTool.empty()}));
61  m_ambiSolver = std::make_unique<SegmentAmbiSolver>(name(), std::move(cfg));
62  return StatusCode::SUCCESS;
63  }
64  StatusCode SegmentFittingAlg::execute(const EventContext& ctx) const {
65  const ActsGeometryContext* gctx{nullptr};
66  ATH_CHECK(SG::get(gctx, m_geoCtxKey, ctx));
67  const SegmentSeedContainer* segmentSeeds=nullptr;
68  ATH_CHECK(SG::get(segmentSeeds, m_seedKey, ctx));
69 
70  SG::WriteHandle writeSegments{m_outSegments, ctx};
71  ATH_CHECK(writeSegments.record(std::make_unique<SegmentContainer>()));
72  std::vector<std::unique_ptr<Segment>> allSegments{};
73  for (const SegmentSeed* seed : *segmentSeeds) {
74  std::vector<std::unique_ptr<Segment>> segments = fitSegmentSeed(ctx, *gctx, seed);
75  if (m_visionTool.isEnabled() && segments.size() > 1) {
76  auto drawFinalReco = [this, &segments, &gctx, &ctx,&seed](const std::string& nameTag) {
77  PrimitiveVec segmentLines{};
78  double yLegend{0.85};
79  segmentLines.push_back(drawLabel(std::format("# segments: {:d}", segments.size()), 0.2, yLegend, 14));
80  yLegend-=0.04;
81  for (const std::unique_ptr<Segment>& seg : segments) {
82  const Parameters pars = localSegmentPars(*gctx, *seg);
83  const auto [pos, dir] = makeLine(pars);
84  segmentLines.emplace_back(drawLine(pars, -Gaudi::Units::m, Gaudi::Units::m, kRed));
85  std::stringstream signStream{};
86  signStream<<std::format("#chi^{{2}}/nDoF: {:.2f} ({:}), ", seg->chi2() / seg->nDoF(), seg->nDoF());
87  signStream<<std::format("y_{{0}}={:.2f}",pars[Acts::toUnderlying(ParamDefs::y0)])<<", ";
88  signStream<<std::format("#theta={:.2f}^{{#circ}}", pars[Acts::toUnderlying(ParamDefs::theta)]/ Gaudi::Units::deg )<<", ";
89  for (const Segment::MeasType& m : seg->measurements()) {
91  signStream<<(SeedingAux::strawSign(pos, dir, *m) == -1 ? "L" : "R");
92  }
93  }
94  segmentLines.push_back(drawLabel(signStream.str(), 0.2, yLegend, 13));
95  yLegend-=0.03;
96  }
97 
98  m_visionTool->visualizeBucket(ctx, *seed->parentBucket(), nameTag, std::move(segmentLines));
99  };
100  drawFinalReco("all segments");
101  const unsigned int nBeforeAmbi = segments.size();
102  segments = m_ambiSolver->resolveAmbiguity(*gctx, std::move(segments));
103  if (nBeforeAmbi != segments.size()) {
104  drawFinalReco("post ambiguity");
105  }
106  } else if (m_visionTool.isEnabled() && segments.empty() &&
107  std::ranges::count_if(seed->getHitsInMax(),[this](const SpacePoint* hit){
108  return m_visionTool->isLabeled(*hit);
109  })) {
110  m_visionTool->visualizeSeed(ctx, *seed, "Failed fit");
111  }
112  allSegments.insert(allSegments.end(), std::make_move_iterator(segments.begin()),
113  std::make_move_iterator(segments.end()));
114  }
115  resolveAmbiguities(*gctx, allSegments);
116  writeSegments->insert(writeSegments->end(),
117  std::make_move_iterator(allSegments.begin()),
118  std::make_move_iterator(allSegments.end()));
119  ATH_MSG_VERBOSE("Found in total "<<writeSegments->size()<<" segments. ");
120  return StatusCode::SUCCESS;
121  }
122 
124  const ActsGeometryContext& gctx,
125  const Parameters& startPars,
126  SegmentFitResult::HitVec&& calibHits) const {
128  if (calibHits.empty()) {
129  ATH_MSG_WARNING("No hits, no segment");
130  return data;
131  }
132 
134  if (m_doBeamspotConstraint) {
135  unsigned int numPhi = std::accumulate(calibHits.begin(), calibHits.end(),0,
136  [](unsigned int n, const HitVec::value_type& hit){
137  return n + (hit->fitState() == CalibratedSpacePoint::State::Valid &&
138  hit->measuresPhi());
139  });
140  if (numPhi) {
141  const Amg::Transform3D globToLoc{calibHits[0]->spacePoint()->msSector()->globalToLocalTrans(gctx)};
142  Amg::Vector3D beamSpot{globToLoc.translation()};
143  SpacePoint::Cov_t covariance{};
144  covariance[Acts::toUnderlying(AxisDefs::etaCov)] = Acts::square(m_beamSpotR);
145  covariance[Acts::toUnderlying(AxisDefs::phiCov)] = Acts::square(m_beamSpotL);
146 
148  auto beamSpotSP = std::make_unique<CalibratedSpacePoint>(nullptr, std::move(beamSpot));
149  beamSpotSP->setCovariance(std::move(covariance));
150  ATH_MSG_VERBOSE("Beam spot constraint "<<Amg::toString(beamSpotSP->localPosition())<<", "<<beamSpotSP->covariance());
151  calibHits.push_back(std::move(beamSpotSP));
152  }
153  }
154 
155  const Amg::Transform3D& locToGlob{calibHits[0]->spacePoint()->msSector()->localToGlobalTrans(gctx)};
156 
157  MdtSegmentFitter::Config fitCfg{};
158  fitCfg.calibrator = m_calibTool.get();
159  fitCfg.doTimeFit = m_doT0Fit;
160  fitCfg.reCalibrate = m_recalibInFit;
161  fitCfg.useFastFit = m_useFastFitter;
162  fitCfg.useSecOrderDeriv = m_hessianResidual;
163 
164  MdtSegmentFitter fitter{name(), std::move(fitCfg)};
165  return fitter.fitSegment(ctx, std::move(calibHits), startPars, locToGlob);
166  }
167  std::vector<std::unique_ptr<Segment>>
168  SegmentFittingAlg::fitSegmentSeed(const EventContext& ctx,
169  const ActsGeometryContext& gctx,
170  const SegmentSeed* patternSeed) const {
171 
172  const Amg::Transform3D& locToGlob{patternSeed->msSector()->localToGlobalTrans(gctx)};
173  std::vector<std::unique_ptr<Segment>> segments{};
174 
176  genCfg.hitPullCut = m_seedHitChi2;
177  genCfg.recalibSeedCircles = m_recalibSeed;
178  genCfg.calibrator = m_calibTool.get();
179  genCfg.startWithPattern = m_tryPatternPars;
180 
181 
183  genCfg.busyLayerLimit = 2 + 2*(patternSeed->parameters()[Acts::toUnderlying(ParamDefs::theta)] > 50 * Gaudi::Units::deg);
185  if (m_visionTool.isEnabled()) {
186  PrimitiveVec seedLines{};
187  MdtSegmentSeedGenerator drawMe{name(), patternSeed, genCfg};
188  while(auto s = drawMe.nextSeed(ctx)) {
189  seedLines.push_back(drawLine(s->parameters, -Gaudi::Units::m, Gaudi::Units::m, kViolet));
190  }
191  seedLines.push_back(drawLabel(std::format("possible seeds: {:d}", drawMe.numGenerated()), 0.2, 0.85, 14));
192  m_visionTool->visualizeSeed(ctx, *patternSeed, "pattern", std::move(seedLines));
193  }
194 
195  MdtSegmentSeedGenerator seedGen{name(), patternSeed, std::move(genCfg)};
196  ATH_MSG_VERBOSE("fitSegmentHits() - Start segment seed search");
197  while (auto seed = seedGen.nextSeed(ctx)) {
199  data.segmentPars = seed->parameters;
200  data.calibMeasurements = std::move(seed->measurements);
202  if (m_visionTool.isEnabled()) {
203  auto seedCopy = convertToSegment(locToGlob, patternSeed, copy(data));
204  m_visionTool->visualizeSegment(ctx, *seedCopy, std::format("Pre fit {:d}", seedGen.numGenerated()));
205  }
206  data = fitSegmentHits(ctx, gctx, seed->parameters, std::move(data.calibMeasurements));
207  data.nIter += seed->nIter;
208  if (m_visionTool.isEnabled() && data.converged) {
209  auto seedCopy = convertToSegment(locToGlob, patternSeed, copy(data));
210  m_visionTool->visualizeSegment(ctx, *seedCopy, std::format("Intermediate fit {:d}", seedGen.numGenerated()));
211  }
212  if (!removeOutliers(ctx, gctx, *patternSeed, data)) {
213  continue;
214  }
215  if (!plugHoles(ctx, gctx, *patternSeed, data)) {
216  continue;
217  }
218  if (m_visionTool.isEnabled()) {
219  auto seedCopy = convertToSegment(locToGlob, patternSeed, copy(data));
220  m_visionTool->visualizeSegment(ctx, *seedCopy, std::format("Final fit {:d}", seedGen.numGenerated()));
221  }
222  segments.push_back(convertToSegment(locToGlob, patternSeed, std::move(data)));
223  }
224  ATH_MSG_VERBOSE("fitSegmentHits() - In total "<<segments.size()<<" segment were constructed ");
225 
226  return segments;
227  }
228  std::unique_ptr<Segment> SegmentFittingAlg::convertToSegment(const Amg::Transform3D& locToGlob,
229  const SegmentSeed* patternSeed,
231  const auto [locPos, locDir] = data.makeLine();
232  Amg::Vector3D globPos = locToGlob * locPos;
233  Amg::Vector3D globDir = locToGlob.linear()* locDir;
234 
235 
236  auto finalSeg = std::make_unique<Segment>(std::move(globPos), std::move(globDir),
237  patternSeed, std::move(data.calibMeasurements),
238  data.chi2, data.nDoF);
239  finalSeg->setCallsToConverge(data.nIter);
240  finalSeg->setParUncertainties(std::move(data.segmentParErrs));
241  if (data.timeFit) {
242  finalSeg->setSegmentT0(data.segmentPars[Acts::toUnderlying(ParamDefs::t0)]);
243  }
244  return finalSeg;
245  }
246 
247  bool SegmentFittingAlg::removeOutliers(const EventContext& ctx,
248  const ActsGeometryContext& gctx,
249  const SegmentSeed& seed,
250  SegmentFitResult& data) const {
251 
253  if (data.nDoF<=0 || data.calibMeasurements.empty() || data.nPrecMeas < m_precHitCut) {
254  ATH_MSG_VERBOSE("No degree of freedom available. What shall be removed?!. nDoF: "
255  <<data.nDoF<<", n-meas: "<<data.calibMeasurements);
256  return false;
257  }
258 
259  if (data.converged && data.chi2 / data.nDoF < m_outlierRemovalCut) {
260  ATH_MSG_VERBOSE("The segment "<<toString(data.segmentPars)
261  <<" is already of good quality "<<data.chi2 / std::max(data.nDoF, 1)
262  <<". Don't remove outliers");
263  return true;
264  }
265  ATH_MSG_VERBOSE("Segment "<<toString(data.segmentPars)<<" is of badish quality.");
266 
269  if (m_doBeamspotConstraint && removeBeamSpot(data.calibMeasurements)) {
270  data.nDoF-=2;
271  data.nPhiMeas-=1;
272  }
273  const auto [segPos, segDir] = data.makeLine();
274 
276  std::ranges::sort(data.calibMeasurements,
277  [&](const HitVec::value_type& a, const HitVec::value_type& b){
278  using enum CalibratedSpacePoint::State;
279  const double chiSqA = a->fitState() == Valid ? SeedingAux::chi2Term(segPos, segDir, *a) : 0.;
280  const double chiSqB = b->fitState() == Valid ? SeedingAux::chi2Term(segPos, segDir, *b) : 0.;
281  return chiSqA < chiSqB;
282  });
283 
285  data.calibMeasurements.back()->setFitState(CalibratedSpacePoint::State::Outlier);
286  data.nDoF -= data.calibMeasurements.back()->measuresEta();
287  data.nDoF -= data.calibMeasurements.back()->measuresPhi();
288  if (m_doT0Fit && data.calibMeasurements.back()->hasTime() &&
289  data.calibMeasurements.back()->type() != xAOD::UncalibMeasType::MdtDriftCircleType) {
290  --data.nDoF;
291  }
293  std::vector<HoughHitType> uncalib{};
294  for (const HitVec::value_type& calib : data.calibMeasurements) {
295  uncalib.push_back(calib->spacePoint());
296  }
297  SegmentFitResult newAttempt = fitSegmentHits(ctx, gctx, data.segmentPars, std::move(data.calibMeasurements));
298  if (newAttempt.converged) {
299  newAttempt.nIter+=data.nIter;
300  data = std::move(newAttempt);
301  if (m_visionTool.isEnabled()) {
302  auto seedCopy = convertToSegment(seed.msSector()->localToGlobalTrans(gctx), &seed, copy(data));
303  m_visionTool->visualizeSegment(ctx, *seedCopy, "Bad fit recovery");
304  }
305  } else {
306  data.calibMeasurements = std::move(newAttempt.calibMeasurements);
307  }
308  return removeOutliers(ctx, gctx, seed, data);
309  }
310 
311  bool SegmentFittingAlg::plugHoles(const EventContext& ctx,
312  const ActsGeometryContext& gctx,
313  const SegmentSeed& seed,
314  SegmentFitResult& beforeRecov) const {
316  ATH_MSG_VERBOSE("plugHoles() -- segment "<<toString(beforeRecov.segmentPars)
317  <<", chi2: "<<beforeRecov.chi2<<", nDoF: "<<beforeRecov.nDoF<<", "
318  <<beforeRecov.chi2 /std::max(beforeRecov.nDoF, 1) );
320  std::unordered_set<const SpacePoint*> usedSpacePoint{};
321  for (const HitVec::value_type& hit : beforeRecov.calibMeasurements) {
322  usedSpacePoint.insert(hit->spacePoint());
323  }
324 
325  HitVec candidateHits{};
326  SpacePointPerLayerSplitter hitLayers{*seed.parentBucket()};
327  bool hasCandidate{false};
328  const auto [locPos, locDir] = beforeRecov.makeLine();
329  for (const std::vector<HoughHitType>& mdtLayer : hitLayers.mdtHits()) {
330  for (const SpacePoint* mdtHit: mdtLayer) {
332  if (usedSpacePoint.count(mdtHit)) {
333  continue;
334  }
335  const double dist = Amg::lineDistance(locPos, locDir, mdtHit->localPosition(), mdtHit->sensorDirection());
336  const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(mdtHit->primaryMeasurement());
337  if (dist >= dc->readoutElement()->innerTubeRadius()) {
338  continue;
339  }
340  HitVec::value_type calibHit{m_calibTool->calibrate(ctx, mdtHit, locPos, locDir, beforeRecov.segmentPars[Acts::toUnderlying(ParamDefs::t0)])};
341  const double pull = std::sqrt(SeedingAux::chi2Term(locPos, locDir, *calibHit));
342  ATH_MSG_VERBOSE(__func__<<"() :"<<__LINE__<<" Candidate hit for recovery "<<m_idHelperSvc->toString(mdtHit->identify())<<", chi2: "<<pull);
343  if (pull <= m_recoveryPull) {
344  hasCandidate |= calibHit->fitState() == CalibratedSpacePoint::State::Valid;
345  candidateHits.push_back(std::move(calibHit));
346  } else {
347  calibHit->setFitState(CalibratedSpacePoint::State::Outlier);
348  candidateHits.push_back(std::move(calibHit));
349  }
350  }
351  }
352  if (!hasCandidate) {
353  ATH_MSG_VERBOSE("No space point candidates for recovery were found");
354  beforeRecov.calibMeasurements.insert(beforeRecov.calibMeasurements.end(),
355  std::make_move_iterator(candidateHits.begin()),
356  std::make_move_iterator(candidateHits.end()));
357  eraseWrongHits(beforeRecov);
358  return beforeRecov.nDoF > 0;
359  }
360 
361  HitVec copied = copy(beforeRecov.calibMeasurements), copiedCandidates = copy(candidateHits);
363  if (m_doBeamspotConstraint) {
364  removeBeamSpot(copied);
365  }
366 
367  candidateHits.insert(candidateHits.end(), std::make_move_iterator(copied.begin()), std::make_move_iterator(copied.end()));
368 
369  SegmentFitResult recovered = fitSegmentHits(ctx, gctx, beforeRecov.segmentPars, std::move(candidateHits));
370  if (!recovered.converged) {
371  return false;
372  }
374  if (recovered.nDoF + recovered.timeFit <= beforeRecov.nDoF + beforeRecov.timeFit) {
375  for (HitVec::value_type& hit : copiedCandidates) {
376  hit->setFitState(CalibratedSpacePoint::State::Outlier);
377  beforeRecov.calibMeasurements.push_back(std::move(hit));
378  }
379  eraseWrongHits(beforeRecov);
380  return true;
381  }
382  ATH_MSG_VERBOSE("Chi2, nDOF before:"<<beforeRecov.chi2<<", "<<beforeRecov.nDoF<<" after recovery: "<<recovered.chi2<<", "<<recovered.nDoF);
383  double redChi2 = recovered.chi2 / std::max(recovered.nDoF,1);
385  if (redChi2 < m_outlierRemovalCut || (beforeRecov.nDoF == 0) || redChi2 < beforeRecov.chi2 / beforeRecov.nDoF) {
386  ATH_MSG_VERBOSE("Accept segment with recovered "<<(recovered.nDoF + recovered.timeFit) - (beforeRecov.nDoF + beforeRecov.timeFit)<<" hits.");
387  recovered.nIter += beforeRecov.nIter;
388  beforeRecov = std::move(recovered);
390  while (true) {
391  bool runAnotherTrial = false;
392  copied = copy(beforeRecov.calibMeasurements);
393  if (m_doBeamspotConstraint) {
394  removeBeamSpot(copied);
395  }
396  const auto [beforePos, beforeDir] = beforeRecov.makeLine();
397  for (HitVec::value_type& copyHit : copied) {
398  if (copyHit->fitState() != CalibratedSpacePoint::State::Outlier) {
399  continue;
400  }
401  copyHit->setFitState(CalibratedSpacePoint::State::Valid);
402  bool append = std::sqrt(SeedingAux::chi2Term(beforePos, beforeDir, *copyHit)) < m_recoveryPull;
403  if (append) {
404  runAnotherTrial = true;
405  } else {
406  copyHit->setFitState(CalibratedSpacePoint::State::Outlier);
407  }
408  }
409  if (!runAnotherTrial) {
410  break;
411  }
412  recovered = fitSegmentHits(ctx, gctx, beforeRecov.segmentPars, std::move(copied));
413  if (!recovered.converged) {
414  break;
415  }
416  if (recovered.nDoF + recovered.timeFit <= beforeRecov.nDoF + beforeRecov.timeFit) {
417  break;
418  }
419  redChi2 = recovered.chi2 / std::max(recovered.nDoF, 1);
420  if (redChi2 < m_outlierRemovalCut || redChi2 < beforeRecov.chi2 / beforeRecov.nDoF) {
421  recovered.nIter += beforeRecov.nIter;
422  beforeRecov = std::move(recovered);
423  } else {
424  break;
425  }
426  }
428  eraseWrongHits(beforeRecov);
429  } else{
430  for (HitVec::value_type& hit : copiedCandidates) {
431  hit->setFitState(CalibratedSpacePoint::State::Outlier);
432  beforeRecov.calibMeasurements.push_back(std::move(hit));
433  }
434  }
435  return true;
436  }
438  auto [segPos, segDir] = makeLine(candidate.segmentPars);
439  candidate.calibMeasurements.erase(std::remove_if(candidate.calibMeasurements.begin(), candidate.calibMeasurements.end(),
440  [&segPos, &segDir](const HitVec::value_type& hit){
441  if (hit->fitState() != CalibratedSpacePoint::State::Outlier) {
442  return false;
443  }
446  const double dist = Amg::lineDistance(segPos, segDir, hit->localPosition(), hit->sensorDirection());
447  const auto* dc = static_cast<const xAOD::MdtDriftCircle*>(hit->spacePoint()->primaryMeasurement());
448  return dist >= dc->readoutElement()->innerTubeRadius();
449  }
450  return true;
451  }), candidate.calibMeasurements.end());
452 
453  std::ranges::sort(candidate.calibMeasurements, [](const Segment::MeasType& a, const Segment::MeasType& b){
454  return a->localPosition().z() < b->localPosition().z();
455  });
456  }
458  std::vector<std::unique_ptr<Segment>>& segmentCandidates) const {
459  if (segmentCandidates.empty()) {
460  return;
461  }
462  using SegmentVec = std::vector<std::unique_ptr<Segment>>;
463  ATH_MSG_VERBOSE("Resolve ambiguities amongst "<<segmentCandidates.size()<<" segment candidates. ");
464  std::unordered_map<const MuonGMR4::SpectrometerSector*, SegmentVec> candidatesPerChamber{};
465 
466  for (std::unique_ptr<Segment>& sortMe : segmentCandidates) {
467  const MuonGMR4::SpectrometerSector* chamb = sortMe->msSector();
468  candidatesPerChamber[chamb].push_back(std::move(sortMe));
469  }
470  segmentCandidates.clear();
471  for (auto& [chamber, resolveMe] : candidatesPerChamber) {
472  SegmentVec resolvedSegments = m_ambiSolver->resolveAmbiguity(gctx, std::move(resolveMe));
473  segmentCandidates.insert(segmentCandidates.end(),
474  std::make_move_iterator(resolvedSegments.begin()),
475  std::make_move_iterator(resolvedSegments.end()));
476  }
477  }
478 }
MuonR4::SegmentFitResult::nIter
unsigned nIter
Number of iterations called to reach the minimum.
Definition: SegmentFitterEventData.h:76
MuonR4::PrimitiveVec
MuonValR4::IPatternVisualizationTool::PrimitiveVec PrimitiveVec
Definition: SegmentFittingAlg.cxx:50
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
LArSamples::FitterData::fitter
const ShapeFitter * fitter
Definition: ShapeFitter.cxx:23
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
MuonR4::SegmentFit::MdtSegmentFitter
Definition: MdtSegmentFitter.h:21
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:228
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
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:31
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:123
MuonR4::SegmentFitResult::calibMeasurements
HitVec calibMeasurements
Calibrated measurements used in the fit.
Definition: SegmentFitterEventData.h:62
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
MuonR4::SpacePoint::Cov_t
std::array< double, 3 > Cov_t
Abrivation of the covariance type.
Definition: MuonSpectrometer/MuonPhaseII/Event/MuonSpacePoint/MuonSpacePoint/SpacePoint.h:27
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
MuonR4::SegmentFit::SegmentAmbiSolver::Config
Definition: SegmentAmbiSolver.h:17
SegmentFittingAlg.h
deg
#define deg
Definition: SbPolyhedron.cxx:17
MuonR4::SegmentFittingAlg::initialize
virtual StatusCode initialize() override
Definition: SegmentFittingAlg.cxx:53
MuonR4::SegmentFittingAlg::HitVec
SegmentFitResult::HitVec HitVec
Definition: SegmentFittingAlg.h:38
MuonR4::CalibratedSpacePoint::State::Outlier
@ Outlier
MuonR4::SegmentFit::SegmentVec
SegmentAmbiSolver::SegmentVec SegmentVec
Definition: SegmentAmbiSolver.cxx:9
MuonR4::SegmentFit::MdtSegmentSeedGenerator
Helper class to generate valid seeds for the segment fit.
Definition: MdtSegmentSeedGenerator.h:26
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
MuonR4::SegmentFittingAlg::Parameters
SegmentFit::Parameters Parameters
Definition: SegmentFittingAlg.h:41
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
MuonR4::SpacePoint::CovIdx::etaCov
@ etaCov
MuonR4::SegmentFittingAlg::resolveAmbiguities
void resolveAmbiguities(const ActsGeometryContext &gctx, std::vector< std::unique_ptr< Segment >> &segmentCandidates) const
Definition: SegmentFittingAlg.cxx:457
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config::hitPullCut
double hitPullCut
Upper cut on the hit chi2 w.r.t.
Definition: MdtSegmentSeedGenerator.h:36
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:27
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::SegmentFitResult::nDoF
int nDoF
degrees of freedom
Definition: SegmentFitterEventData.h:66
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:25
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:168
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:311
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:247
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:74
beamspotman.n
n
Definition: beamspotman.py:727
MuonR4::SegmentFit::MdtSegmentSeedGenerator::Config
Configuration switches of the module
Definition: MdtSegmentSeedGenerator.h:30
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
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
python.StandardJetMods.pull
pull
Definition: StandardJetMods.py:309
MuonSimHitContainer.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MuonR4::SegmentFitResult::segmentPars
Parameters segmentPars
Final segment parameters.
Definition: SegmentFitterEventData.h:58
MuonR4::SegmentFittingAlg::eraseWrongHits
void eraseWrongHits(SegmentFitResult &candidate) const
Removes all hits from the segment which are obvious outliers.
Definition: SegmentFittingAlg.cxx:437
MuonR4::SegmentFit::toString
std::string toString(const Parameters &pars)
Definition: SegmentFitterEventData.cxx:60
MuonR4::removeBeamSpot
bool removeBeamSpot(MuonR4::SegmentFitResult::HitVec &hits)
Definition: SegmentFittingAlg.cxx:41
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
ActsGeometryContext
Include the GeoPrimitives which need to be put first.
Definition: ActsGeometryContext.h:27
MdtDriftCircle.h
beamspotman.dir
string dir
Definition: beamspotman.py:619
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:24
MuonValR4
Lightweight algorithm to read xAOD MDT sim hits and (fast-digitised) drift circles from SG and fill a...
Definition: IPatternVisualizationTool.h:23
MuonValR4::IPatternVisualizationTool::PrimitiveVec
std::vector< PrimitivePtr > PrimitiveVec
Definition: IPatternVisualizationTool.h:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MuonR4::SpacePoint::CovIdx::phiCov
@ phiCov
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:76
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:110
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:16
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
runIDAlign.accumulate
accumulate
Update flags based on parser line args.
Definition: runIDAlign.py:107
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:75
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:36
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
MuonR4::SegmentFit::localSegmentPars
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
Definition: SegmentFitterEventData.cxx:33
python.BuildSignatureFlags.beamSpot
AthConfigFlags beamSpot(AthConfigFlags flags, str instanceName, str recoMode)
Definition: BuildSignatureFlags.py:475
MuonR4::SegmentFitResult
Definition: SegmentFitterEventData.h:46
MuonR4::SegmentFitResult::chi2
double chi2
chi2 of the fit
Definition: SegmentFitterEventData.h:64
drawLine
void drawLine(std::ostream &os)
Definition: PrintMC.cxx:16
MuonR4::SegmentFit::MdtSegmentFitter::Config
Definition: MdtSegmentFitter.h:26
xAOD::MdtDriftCircle_v1
https://gitlab.cern.ch/atlas/athena/-/blob/master/MuonSpectrometer/MuonReconstruction/MuonRecEvent/Mu...
Definition: MdtDriftCircle_v1.h:21
MuonR4::SegmentFittingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: SegmentFittingAlg.cxx:64
xAOD::UncalibMeasType::MdtDriftCircleType
@ MdtDriftCircleType
MuonR4::SegmentFittingAlg::~SegmentFittingAlg
virtual ~SegmentFittingAlg()
MuonR4::SegmentSeed::msSector
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated chamber.
Definition: SegmentSeed.cxx:40
python.SystemOfUnits.m
float m
Definition: SystemOfUnits.py:106
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:81
MuonR4::SegmentFit::MdtSegmentFitter::Config::calibrator
const ISpacePointCalibrator * calibrator
Pointer to the calibrator tool.
Definition: MdtSegmentFitter.h:49