ATLAS Offline Software
Loading...
Searching...
No Matches
SegmentActsRefitAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
11
15
17
18
19#include "GaudiKernel/PhysicalConstants.h"
21#include "CLHEP/Random/RandGaussZiggurat.h"
22
23
24#include "Acts/Surfaces/PlaneSurface.hpp"
25#include "Acts/Surfaces/RectangleBounds.hpp"
26
28
29
31#include "ActsInterop/Logger.h"
32
33#include "Acts/Visualization/GeometryView3D.hpp"
34
35
36
37using namespace Acts::UnitLiterals;
38namespace{
39 constexpr double straightQoverP = 1. / (20._TeV);
41}
42
43
44namespace MuonR4{
45 using namespace SegmentFit;
46
48 ATH_CHECK(m_readKey.initialize());
49 ATH_CHECK(m_writeKey.initialize());
50 ATH_CHECK(m_linkKey.initialize());
51 ATH_CHECK(m_localParsKey.initialize());
52 ATH_CHECK(m_seedParsKey.initialize());
53 ATH_CHECK(m_auxMeasProv.initialize(m_writeKey.key()));
54 ATH_CHECK(m_calibTool.retrieve());
55
56 ATH_CHECK(m_idHelperSvc.retrieve());
59 ATH_CHECK(m_segSelector.retrieve());
60 ATH_CHECK(detStore()->retrieve(m_detMgr));
61
62 auto logger = makeActsAthenaLogger(this, "Fitter");
63
64 Acts::StraightLineStepper stepper{};
65 Acts::Navigator::Config navConfig{m_trackingGeometryTool->trackingGeometry()};
66 Acts::Navigator navigator(std::move(navConfig), logger->clone());
67
68 Propagator_t propagator{std::move(stepper), std::move(navigator), logger->clone()};
69
70 m_fitter = std::make_unique<Fitter_t>(std::move(propagator), logger->clone());
71
73 m_fitExtension.surfaceAccessor.connect<&ActsTrk::detail::xAODUncalibMeasSurfAcc::operator()>(&m_surfAccessor);
75 return StatusCode::SUCCESS;
76 }
77 std::tuple<Amg::Vector3D, Amg::Vector3D>
79 const MuonR4::Segment& segment,
80 CLHEP::HepRandomEngine* engine) const{
81 if (!m_smearSegPars) {
82 return std::make_pair(segment.position(), segment.direction());
83 }
84 const SegmentFit::Parameters segPars = localSegmentPars(gctx, segment);
85 SegmentFit::Parameters smearedPars = segPars;
87 for (ParamDefs precPar : {ParamDefs::y0, ParamDefs::theta,
88 ParamDefs::x0, ParamDefs::phi}) {
89 if (precPar == ParamDefs::phi && !segment.summary().nPhiHits) {
90 break;
91 }
92 const unsigned idx = Acts::toUnderlying(precPar);
93 const double uncert = Amg::error(segment.covariance(), idx) * m_smearRange;
94 smearedPars[idx] = CLHEP::RandGaussZiggurat::shoot(engine, segPars[idx], uncert);
95 ATH_MSG_VERBOSE("Apply smearing to "<<SeedingAux::parName(precPar)
96 <<" parameter -- cov: "<<uncert
97 <<", original: "<<segPars[idx]<<", smeared: "<<smearedPars[idx]
98 <<", deviation: "
99 <<(smearedPars[idx] - segPars[idx]) / uncert );
100 }
101 auto [smearLocPos, smearLocDir] = makeLine(smearedPars);
102 const auto [locPos, locDir] = makeLine(segPars);
104 if (SeedingAux::strawSigns(locPos,locDir, segment.measurements()) !=
105 SeedingAux::strawSigns(smearLocPos, smearLocDir, segment.measurements())) {
106 ATH_MSG_DEBUG("Parameter smearng from "<<toString(segPars)<<" -> "<<toString(smearedPars)
107 <<" changes the L/R ambiguity -> avoid for this test");
108 return smearSegment(gctx, segment, engine);
109 }
110
111 const Amg::Transform3D& locToGlob{segment.msSector()->localToGlobalTransform(gctx)};
112 if (smearLocDir.z() < 0) {
113 smearLocDir = -smearLocDir;
114 }
115 return std::make_tuple(locToGlob * smearLocPos, locToGlob.linear() * smearLocDir);
116 }
117
119 bool entrance) const {
120
121 const Acts::GeometryIdentifier volId = m_surfAccessor.get(measurement)->geometryId().withSensitive(0);
122 const Acts::TrackingVolume* volume = m_trackingGeometryTool->trackingGeometry()->findVolume(volId);
123 return entrance ? MuonGMR4::bottomBoundary(*volume) : MuonGMR4::topBoundary(*volume);
124 }
125 StatusCode SegmentActsRefitAlg::execute(const EventContext& ctx) const {
126
127 const xAOD::MuonSegmentContainer* segments{nullptr};
128 ATH_CHECK(SG::get(segments, m_readKey, ctx));
130 const ActsTrk::GeometryContext& gctx{m_trackingGeometryTool->getGeometryContext(ctx)};
131 const std::shared_ptr<const Acts::TrackingGeometry> trackingGeo = m_trackingGeometryTool->trackingGeometry();
132 const Acts::GeometryContext tgContext = gctx.context();
133 const Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
134 const Acts::CalibrationContext calContext = ActsTrk::getCalibrationContext(ctx);
135
137 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, name());
138 rngWrapper->setSeed(name(), ctx);
139 CLHEP::HepRandomEngine* randEngine = rngWrapper->getEngine(ctx);
140
141 SG::WriteHandle outHandle{m_writeKey, ctx};
142 ATH_CHECK(outHandle.record(std::make_unique<xAOD::MuonSegmentContainer>(),
143 std::make_unique<xAOD::MuonSegmentAuxContainer>()));
144
145
146 auto handleCreation = m_auxMeasProv.makeHandle(ctx, tgContext);
147 if (!handleCreation.ok()){
148 ATH_MSG_ERROR("Auxiliary measurement containers cannot be made");
149 return StatusCode::FAILURE;
150 }
151 auto& auxMeasHandle{*handleCreation};
155 xAOD::MeasVector<Acts::toUnderlying(ParamDefs::nPars)>>;
156
157 ParDecor_t dec_locPars{m_localParsKey, ctx};
158 ParDecor_t dec_seedPars{m_seedParsKey, ctx};
159
160 SeedingAux::Config cfg{};
161 cfg.parsToUse.clear();
162 SeedingAux pullCalculator{cfg, makeActsAthenaLogger(this, "PullCalculator")};
163
164 SeedingAux::Line_t line{};
165
166 Acts::PropagatorPlainOptions propagationOption{tgContext, mfContext};
167 propagationOption.maxSteps = m_maxPropSteps;
168 propagationOption.maxTargetSkipping = m_maxTargetSurfSkip;
169 constexpr bool doScat = false;
170 constexpr bool doEloss = false;
171 Gx2FitterOptions_t fitOptions{tgContext, mfContext, calContext, m_fitExtension,
172 std::move(propagationOption),
173 nullptr, doScat, doEloss,
174 Acts::FreeToBoundCorrection{m_doJacobianCorr},
175 m_maxIter};
176
180 Acts::ObjVisualization3D visualHelper{};
181
182
183 for (const xAOD::MuonSegment* reFitMe: *segments){
184 auto saveDisplay = [&](const std::string& state) {
185 if (!m_drawEvent) {
186 return;
187 }
188 const auto objFile = std::format("SegmentReFitTest_{:}_{:}_{:}_{:}.obj",
189 state, ctx.eventID().event_number(), reFitMe->index(),
190 MuonR4::printID(*reFitMe));
191 visualHelper.write(objFile);
192 ATH_MSG_DEBUG("Save event display under "<<objFile);
193 visualHelper = Acts::ObjVisualization3D{};
194 };
195
196 const MuonGMR4::SpectrometerSector* msSector =
197 m_detMgr->getSectorEnvelope(reFitMe->chamberIndex(),
198 reFitMe->sector(),
199 reFitMe->etaIndex());
200 const Amg::Transform3D& sectorTrf{msSector->localToGlobalTransform(gctx)};
201 const Amg::Vector3D planeNormal = sectorTrf.linear().col(2);
202
203 m_calibTool->stampSignsOnMeasurements(*reFitMe);
204 line.updateParameters(localSegmentPars(gctx, *MuonR4::detailedSegment(*reFitMe)));
206 const auto [seedPos, seedDir] = smearSegment(gctx, *MuonR4::detailedSegment(*reFitMe), randEngine);
208 {
209 const Amg::Transform3D invTrf = sectorTrf.inverse();
210 const Amg::Vector3D locSeedPos = invTrf * seedPos;
211 const Amg::Vector3D locSeedDir = invTrf.linear() * seedDir;
212 auto& seedPars = dec_seedPars(*reFitMe);
213 seedPars[Acts::toUnderlying(ParamDefs::x0)] = locSeedPos.x();
214 seedPars[Acts::toUnderlying(ParamDefs::y0)] = locSeedPos.y();
215 seedPars[Acts::toUnderlying(ParamDefs::theta)] = locSeedDir.theta();
216 seedPars[Acts::toUnderlying(ParamDefs::phi)] = locSeedDir.phi();
217 }
218
219 const GeoTrf::CoordEulerAngles sectorAngles = GeoTrf::getCoordRotationAngles(sectorTrf);
221 std::vector<const xAOD::UncalibratedMeasurement*> hitsToFit = MuonR4::collectMeasurements(*reFitMe);
222
223 // Identify the first measurement in the chamber volume. Skip the first one if it
224 // is the beamspot
225 const xAOD::UncalibratedMeasurement* entrance =
226 hitsToFit.front()->type() != xAOD::UncalibMeasType::Other ?
227 hitsToFit.front() : hitsToFit.at(1);
228 // Fetch the entrance & exit portals from the geometry
229 const Acts::Surface* entrancePortal = portalSurface(entrance, true);
230 const Acts::Surface* exitPortal = portalSurface(hitsToFit.back(), false);
231 ATH_MSG_DEBUG("Entrance portal: "
232 <<entrancePortal->geometryId()<<"/"<<m_idHelperSvc->toString(xAOD::identify(entrance))
233 <<", exit portal: "<<exitPortal->geometryId()<<"/"<<m_idHelperSvc->toString(xAOD::identify(hitsToFit.back())));
234
235 using namespace Acts::PlanarHelper;
236
237 const Acts::Intersection3D isectEntrance = intersectPlane(seedPos, seedDir, planeNormal,
238 entrancePortal->center(tgContext));
239 const Acts::Intersection3D isectFirst = intersectPlane(seedPos, seedDir, planeNormal,
240 m_surfAccessor.get(hitsToFit.front())->center(tgContext));
241
242 if (reFitMe->nPhiLayers() < 1) {
243
244 const Acts::Intersection3D isectExit = intersectPlane(seedPos, seedDir, planeNormal,
245 exitPortal->center(tgContext));
246 const Acts::Intersection3D isectLast = intersectPlane(seedPos, seedDir, planeNormal,
247 m_surfAccessor.get(hitsToFit.back())->center(tgContext));
248
250
251 const Amg::Transform3D trfBeneath = GeoTrf::GeoTransformRT{sectorAngles, 0.5*isectFirst.position() +
252 0.5*isectEntrance.position()};
253 const Amg::Transform3D trfAbove = GeoTrf::GeoTransformRT{sectorAngles, 0.85*isectExit.position() +
254 0.15*isectLast.position() };
255
256 auto surfBeneath = Acts::Surface::makeShared<Acts::PlaneSurface>(trfBeneath);
257 auto surfAbove = Acts::Surface::makeShared<Acts::PlaneSurface>(trfAbove);
258 ATH_MSG_DEBUG("Add auxiliary measurements @ "<<Amg::toString(surfBeneath->center(tgContext))
259 <<" and @"<<Amg::toString(surfAbove->center(tgContext)));
260
261 constexpr double covVal = Acts::square(1._cm);
262 hitsToFit.push_back(auxMeasHandle.newMeasurement<1>(surfBeneath, ProjectorType::e1DimNoTime, AmgSymMatrix(1){covVal}));
263 if (m_drawEvent) {
264 MuonValR4::drawMeasurement(gctx, hitsToFit.back(), visualHelper, Acts::s_viewGrid);
265 }
266 hitsToFit.push_back(auxMeasHandle.newMeasurement<1>(surfAbove, ProjectorType::e1DimNoTime, AmgSymMatrix(1){covVal}));
267 if (m_drawEvent) {
268 MuonValR4::drawMeasurement(gctx, hitsToFit.back(), visualHelper, Acts::s_viewGrid);
269 }
270 }
271
272 if (m_drawEvent) {
273 Acts::GeometryView3D::drawSurface(visualHelper, *entrancePortal, tgContext,
274 Amg::Transform3D::Identity(), Acts::s_viewPortal);
275 Acts::GeometryView3D::drawSurface(visualHelper, *exitPortal, tgContext,
276 Amg::Transform3D::Identity(), Acts::s_viewPortal);
277
279 MuonValR4::drawSegmentLine(gctx, *reFitMe, visualHelper,
280 Acts::ViewConfig{.color = {220, 0, 0}});
281 MuonValR4::drawSegmentMeasurements(gctx, *reFitMe, visualHelper, Acts::s_viewSurface);
282 }
283 ATH_MSG_VERBOSE("Entrance position "<<Amg::toString(isectEntrance.position())
284 <<", path length: "<<isectEntrance.pathLength()<<", "
285 <<" - First surface position: "<<Amg::toString(isectFirst.position())
286 <<", path length: "<<isectFirst.pathLength());
288
289 Amg::Vector3D refPos = 0.85 * isectEntrance.position()
290 + 0.15 * isectFirst.position();
291 const Amg::Transform3D trf{GeoTrf::GeoTransformRT{sectorAngles, refPos}};
292 if (msgLvl(MSG::VERBOSE)) {
293 const auto [locPos, locDir] = makeLine(localSegmentPars(*reFitMe));
294
295 std::stringstream sstr{};
296 sstr<<"pos: "<<Amg::toString(seedPos)<<", dir: "<<Amg::toString(seedDir)<<", chi2/nDoF: "
297 <<reFitMe->chiSquared() / reFitMe->numberDoF()<<", nDoF: "<<reFitMe->numberDoF()
298 <<", prec: "<<reFitMe->nPrecisionHits()<<", phi: "<<reFitMe->nPhiLayers()<<std::endl;
299 for (const auto& meas : MuonR4::detailedSegment(*reFitMe)->measurements()) {
300 pullCalculator.updateSpatialResidual(line, *meas);
301 const Acts::Surface* surface = meas->spacePoint() ? m_surfAccessor.get(meas->spacePoint()->primaryMeasurement()) : nullptr;
302 const Acts::GeometryIdentifier geoId = surface ? surface->geometryId() : Acts::GeometryIdentifier{};
303 sstr<<" **** "<<(*meas)<<", chi2: "<<SeedingAux::chi2Term(locPos, locDir, *meas)
304 <<", sign: "<<(meas->isStraw() ?
305 (SeedingAux::strawSign(locPos,locDir, *meas) == 1 ? "R" : "L") : "X")
306 <<", geoId: "<<geoId;
307 if (geoId != Acts::GeometryIdentifier{}){
308 const Amg::Vector3D globPos = meas->spacePoint()->msSector()->localToGlobalTransform(gctx) *
309 meas->localPosition();
310 const Acts::GeometryIdentifier volId = geoId.withSensitive(0);
311 const Acts::TrackingVolume* volume = m_trackingGeometryTool->trackingGeometry()->findVolume(volId);
312 const Acts::Vector2 lPos = (*surface->globalToLocal(tgContext,globPos, reFitMe->direction()));
313 sstr<<", inside volume: "<<volume->inside(tgContext, globPos);
314 sstr<<", inside surface: "<<surface->bounds().inside(lPos);
315
316 }
317 sstr<<std::endl;
318 }
319
320 sstr<<" Target surf: "<<Amg::toString(trf)<<", firstSurf: "
321 << Amg::toString(trf.inverse()*isectFirst.position())
322 <<", refPoint: "<<Amg::toString(trf.inverse()*refPos)<<std::endl;
323 ATH_MSG_VERBOSE("Run G2F fit on "<<msSector->identString()<<std::endl<<sstr.str());
324 }
325 // Specify the surface on which the segment will be expressed.
326 std::shared_ptr<const Acts::Surface> target{};
327 if (hitsToFit.front()->type() == xAOD::UncalibMeasType::Other) {
328 target = m_surfAccessor.get(hitsToFit.front())->getSharedPtr();
329 using namespace Acts::detail::LineHelper;
330 const Acts::Intersection3D lineIsect =
331 lineIntersect<3>(target->center(tgContext),
332 Amg::Vector3D::UnitZ(),
333 seedPos, seedDir);
334 // Also update the start position to be the closest point of approach
335 // to the beamspot
336 refPos = lineIsect.position();
337 } else {
339 target = Acts::Surface::makeShared<Acts::PlaneSurface>(trf,
340 std::make_unique<Acts::RectangleBounds>(1._m, 1._m));
341 }
342 if (m_drawEvent) {
343 Acts::GeometryView3D::drawSurface(visualHelper, *target,
344 tgContext, Amg::Transform3D::Identity(),
345 Acts::ViewConfig{.color={0,0,220}});
346 }
347
348 Acts::Vector<4> fourPos{ActsTrk::convertPosToActs(refPos, refPos.mag() / Gaudi::Units::c_light)};
349 Acts::BoundMatrix initialCov{Acts::BoundMatrix::Identity()};
350
351 auto initialPars = Acts::BoundTrackParameters::create(tgContext, target, fourPos, seedDir, straightQoverP,
352 initialCov, Acts::ParticleHypothesis::muon());
353 if (!initialPars.ok()) {
354 ATH_MSG_WARNING("Initial estimate of the parameters failed");
355 saveDisplay("invalidPars");
356 continue;
357 }
358 if (m_drawEvent) {
359 MuonValR4::drawBoundParameters(gctx, *initialPars, visualHelper,
360 Acts::ViewConfig{.color={0,220,0}});
361 }
362 ATH_MSG_DEBUG("Initial parameters -- (loc0, loc1): "<<Amg::toString((*initialPars).localPosition())
363 <<", "<<std::format("theta: {:.2f}, ", (*initialPars).theta() / 1._degree)
364 <<std::format("phi: {:.2f}", (*initialPars).phi() / 1._degree));
365
366 std::vector<Acts::SourceLink> sourceLinks{};
367 std::ranges::transform(hitsToFit, std::back_inserter(sourceLinks),
368 [](const xAOD::UncalibratedMeasurement* meas) {
370 });
371 fitOptions.referenceSurface = target.get();
372
373 auto fitTraject = m_fitter->fit(sourceLinks.begin(), sourceLinks.end(),
374 *initialPars, fitOptions, tracks);
375 if (!fitTraject.ok()) {
376 saveDisplay("failed");
377 if (m_smearSegPars) {
378 ATH_MSG_WARNING("Track fit failed.");
379 continue;
380 } else {
381 ATH_MSG_ERROR("Segment refit failed. Albeit start parameters are taken from segment");
382 return StatusCode::FAILURE;
383 }
384 }
385
386 auto track = *fitTraject;
387 ATH_MSG_DEBUG("Track fit succeeded. ");
388
389 Acts::BoundTrackParameters parameters = track.createParametersAtReference();
390 if (m_drawEvent) {
391 MuonValR4::drawBoundParameters(gctx, parameters, visualHelper,
392 Acts::ViewConfig{.color={0,220,220}});
393
394 }
395 saveDisplay("goodone");
396
399 std::vector<const xAOD::UncalibratedMeasurement*> goodMeas{};
400 unsigned int itr{0};
401 tracks.trackStateContainer().visitBackwards(track.tipIndex(),[&](const auto& state){
402 if (!state.hasUncalibratedSourceLink()){
403 return;
404 }
405 goodMeas.insert(goodMeas.begin(),
406 ActsTrk::detail::xAODUncalibMeasCalibrator::unpack(state.getUncalibratedSourceLink()));
407
408 ATH_MSG_VERBOSE("Loop over track state: "<<(itr++)<<", "<<m_idHelperSvc->toString(xAOD::identify(goodMeas.front()))
409 <<", id: "<<m_surfAccessor.get(goodMeas.front())->geometryId());
410
411 const xAOD::UncalibratedMeasurement* m = goodMeas.front();
412 const bool isPrecHit = (m->type() == xAOD::UncalibMeasType::MdtDriftCircleType ||
415 !m_idHelperSvc->measuresPhi(xAOD::identify(m))));
416
417 summary.nPrecHits += isPrecHit;
418 if (m->type() == xAOD::UncalibMeasType::Other ||
419 m_idHelperSvc->measuresPhi(xAOD::identify(m))){
420 ++summary.nPhiHits;
421 } else {
422 summary.nEtaTrigHits += !isPrecHit;
423 }
424 });
425
427 const Amg::Vector3D globDir = parameters.direction();
429 const Amg::Transform3D globToLoc{sectorTrf.inverse()};
430 const Amg::Vector3D refitPos = globToLoc * parameters.position(tgContext);
431 const Amg::Vector3D refitDir = globToLoc.linear() * globDir;
433 const Amg::Vector3D refitSeg = refitPos + Amg::intersect<3>(refitPos, refitDir, Amg::Vector3D::UnitZ(), 0).value_or(0.) * refitDir;
434 const Amg::Vector3D globPos{msSector->localToGlobalTransform(gctx) * refitSeg};
435
436 xAOD::MuonSegment* newSegment = outHandle->push_back(std::make_unique<xAOD::MuonSegment>());
437 dec_segLink(*newSegment) = Link_t{*segments, reFitMe->index(), ctx};
438
439 newSegment->setDirection(globDir.x(), globDir.y(), globDir.z());
440 newSegment->setPosition(globPos.x(), globPos.y(), globPos.z());
441
442 newSegment->setFitQuality(track.chi2(), track.nDoF());
443 newSegment->setNHits(summary.nPrecHits, summary.nPhiHits, summary.nEtaTrigHits);
444 auto& locFitPars = dec_locPars(*newSegment);
445 locFitPars[Acts::toUnderlying(ParamDefs::x0)] = refitSeg.x();
446 locFitPars[Acts::toUnderlying(ParamDefs::y0)] = refitSeg.y();
447 locFitPars[Acts::toUnderlying(ParamDefs::theta)] = refitDir.theta();
448 locFitPars[Acts::toUnderlying(ParamDefs::phi)] = refitDir.phi();
449 }
450 return StatusCode::SUCCESS;
451 }
452}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
if(pathvar)
Handle class for adding a decoration to an object.
std::unique_ptr< const Acts::Logger > makeActsAthenaLogger(IMessageSvc *svc, const std::string &name, int level, std::optional< std::string > parent_name)
A wrapper class for event-slot-local random engines.
Definition RNGWrapper.h:56
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:157
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:128
Acts::GeometryContext context() const
ProjectorType
Enum encoding the possible projectors used in ATLAS.
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
static Acts::SourceLink pack(const xAOD::UncalibratedMeasurement *meas)
Helper method to pack an uncalibrated measurement to an Acts source link.
Helper class to access the Acts::surface associated with an Uncalibrated xAOD measurement.
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &gctx) const
Returns the local -> global tarnsformation from the sector.
std::string identString() const
Returns a string encoding the chamber index & the sector of the MS sector.
virtual void calibrateSourceLink(const Acts::GeometryContext &geoctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &link, ActsTrk::MutableTrackStateBackend::TrackStateProxy state) const =0
Function that's hooked to the calibration delegate of the implemented Acts fitters.
ServiceHandle< IAthRNGSvc > m_rndmSvc
Range service to smear the segment parameters.
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_localParsKey
Decorate directly the local segment parameters on to the object.
const MuonGMR4::MuonDetectorManager * m_detMgr
Detector manager to access the spectrometer sector surfaces.
Gaudi::Property< double > m_smearRange
Smear interval in terms of standard deviations.
ToolHandle< ISpacePointCalibrator > m_calibTool
Handle to the space point calibrator.
std::tuple< Amg::Vector3D, Amg::Vector3D > smearSegment(const ActsTrk::GeometryContext &gctx, const MuonR4::Segment &segment, CLHEP::HepRandomEngine *engine) const
Smear the segment's position and direction by one sigma defined by the segment's covariance.
ActsTrk::detail::xAODUncalibMeasSurfAcc m_surfAccessor
Surface accessor delegate for xAOD::UncalibratedMeasurement objects.
SG::WriteHandleKey< xAOD::MuonSegmentContainer > m_writeKey
Declare the key for the refitted segment container.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_seedParsKey
Decorate the seed parameters entering the fit.
Acts::Propagator< Acts::StraightLineStepper, Acts::Navigator > Propagator_t
Type erased track fitter function.
ToolHandle< MuonR4::ISegmentSelectionTool > m_segSelector
Segment selection tool to pick the good quality segments.
std::unique_ptr< Fitter_t > m_fitter
Gaudi::Property< bool > m_drawEvent
Dump the segment line in obj files.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_linkKey
Construct a link from the refitted segment to the input segment.
Gaudi::Property< unsigned > m_maxPropSteps
Maximum number of propagation steps.
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
Track extrapolation tool.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_readKey
Declare the data dependency on the standard Mdt+Rpc+Tgc segment container.
Gaudi::Property< bool > m_smearSegPars
ActsTrk::AuxiliaryMeasurementHandler m_auxMeasProv
Gaudi::Property< unsigned > m_maxTargetSurfSkip
Maximum number of target surfaces.
Acts::Experimental::Gx2FitterOptions< ActsTrk::MutableTrackStateBackend > Gx2FitterOptions_t
Abbrivation of the configuration to launch the fit.
Gaudi::Property< bool > m_doJacobianCorr
Free to bound Jacobian correction.
virtual StatusCode initialize() override final
Gx2FitterExtension_t m_fitExtension
Fitter setup.
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Tracking geometry tool.
const Acts::Surface * portalSurface(const xAOD::UncalibratedMeasurement *measurement, bool entrance) const
Returns the entrance / exit portal surface of the tracking volume associated with the measurement sur...
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc to decode the Identifiers.
Gaudi::Property< unsigned > m_maxIter
Maximum number of iterations.
Placeholder for what will later be the muon segment EDM representation.
const SegmentFit::Covariance & covariance() const
Returns the uncertainties of the defining parameters.
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
const MeasVec & measurements() const
Returns the associated measurements.
const Amg::Vector3D & position() const
Returns the global segment position.
const Amg::Vector3D & direction() const
Returns the global segment direction.
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
void setDirection(float px, float py, float pz)
Sets the direction.
void setFitQuality(float chiSquared, float numberDoF)
Set the 'Fit Quality' information.
void setNHits(int nPrecisionHits, int nPhiLayers, int nTrigEtaLayers)
Set the number of hits/layers.
void setPosition(float x, float y, float z)
Sets the global position.
static Root::TMsgLogger logger("iLumiCalc")
Acts::VectorMultiTrajectory MutableTrackStateBackend
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
Acts::VectorTrackContainer MutableTrackBackend
Acts::Vector4 convertPosToActs(const Amg::Vector3D &athenaPos, const double athenaTime=0.)
Converts a position vector & time from Athena units into Acts units.
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.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
const Acts::Surface * bottomBoundary(const Acts::TrackingVolume &volume)
Returns the boundary surface parallel to the x-y plane at negative local z.
const Acts::Surface * topBoundary(const Acts::TrackingVolume &volume)
Returns the boundary surface parallel to the x-y plane at positive local z.
SpacePoint::SeedingAux SeedingAux
Abrivation of the CompSpacePointAuxiliaries.
SeedingAux::FitParIndex ParamDefs
Use the same parameter indices as used by the CompSpacePointAuxiliaries.
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
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.
std::string printID(const xAOD::MuonSegment &seg)
Print the chamber ID of a segment, e.g.
std::vector< const xAOD::UncalibratedMeasurement * > collectMeasurements(const xAOD::MuonSegment &segment, bool skipOutlier=true)
Helper function to extract the measurements from the segment.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
void drawBoundParameters(const ActsTrk::GeometryContext &gctx, const Acts::BoundTrackParameters &pars, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=3.*Gaudi::Units::cm)
Draw a line representing the bound track parameters.
void drawMeasurement(const ActsTrk::GeometryContext &gctx, const xAOD::UncalibratedMeasurement *meas, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw an uncalibrated measurement inside the obj file.
void drawSegmentMeasurements(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw all uncalibrated measurements associated to the segment.
void drawSegmentLine(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=1.*Gaudi::Units::m)
Draw a segment line inside the obj file.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.