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
12
16
18
19
20#include "GaudiKernel/PhysicalConstants.h"
22#include "CLHEP/Random/RandGaussZiggurat.h"
23
24
25#include "Acts/Surfaces/PlaneSurface.hpp"
26#include "Acts/Surfaces/RectangleBounds.hpp"
27
29
30
32#include "ActsInterop/Logger.h"
33
34#include "Acts/Visualization/GeometryView3D.hpp"
35
36
37
38using namespace Acts::UnitLiterals;
39namespace{
40 constexpr double straightQoverP = 1. / (20._TeV);
42}
43
44
45namespace MuonR4{
46 using namespace SegmentFit;
47
49 ATH_CHECK(m_readKey.initialize());
50 ATH_CHECK(m_writeKey.initialize());
51 ATH_CHECK(m_linkKey.initialize());
52 ATH_CHECK(m_localParsKey.initialize());
53 ATH_CHECK(m_seedParsKey.initialize());
54 ATH_CHECK(m_auxMeasProv.initialize(m_writeKey.key()));
55 ATH_CHECK(m_calibTool.retrieve());
56 ATH_CHECK(m_ctxProvider.initialize());
57
58 ATH_CHECK(m_idHelperSvc.retrieve());
60 ATH_CHECK(m_segSelector.retrieve());
61 ATH_CHECK(detStore()->retrieve(m_detMgr));
62
63 auto logger = makeActsAthenaLogger(this, "Fitter");
64
65 Acts::StraightLineStepper stepper{};
66 Acts::Navigator::Config navConfig{m_trackingGeometrySvc->trackingGeometry()};
67 Acts::Navigator navigator(std::move(navConfig), logger->clone());
68
69 Propagator_t propagator{std::move(stepper), std::move(navigator), logger->clone()};
70
71 m_fitter = std::make_unique<Fitter_t>(std::move(propagator), logger->clone());
72
74 m_fitExtension.surfaceAccessor.connect<&ActsTrk::detail::xAODUncalibMeasSurfAcc::operator()>(&m_surfAccessor);
76 return StatusCode::SUCCESS;
77 }
78 std::tuple<Amg::Vector3D, Amg::Vector3D>
79 SegmentActsRefitAlg::smearSegment(const Acts::GeometryContext& tgContext,
80 const MuonR4::Segment& segment,
81 CLHEP::HepRandomEngine* engine) const{
82 if (!m_smearSegPars) {
83 return std::make_pair(segment.position(), segment.direction());
84 }
85 const SegmentFit::Parameters segPars = localSegmentPars(tgContext, segment);
86 SegmentFit::Parameters smearedPars = segPars;
88 for (ParamDefs precPar : {ParamDefs::y0, ParamDefs::theta,
89 ParamDefs::x0, ParamDefs::phi}) {
90 if (precPar == ParamDefs::x0 &&
91 std::ranges::none_of(segment.measurements(),
92 [](const auto& meas) {
93 return meas->measuresPhi();
94 })) {
95 break;
96 }
97 const unsigned idx = Acts::toUnderlying(precPar);
98 const double uncert = Amg::error(segment.covariance(), idx) * m_smearRange;
99 smearedPars[idx] = CLHEP::RandGaussZiggurat::shoot(engine, segPars[idx], uncert);
100 ATH_MSG_VERBOSE("Apply smearing to "<<SeedingAux::parName(precPar)
101 <<" parameter -- cov: "<<uncert
102 <<", original: "<<segPars[idx]<<", smeared: "<<smearedPars[idx]
103 <<", deviation: "
104 <<(smearedPars[idx] - segPars[idx]) / uncert );
105 }
106 auto [smearLocPos, smearLocDir] = makeLine(smearedPars);
107 const auto [locPos, locDir] = makeLine(segPars);
109 if (SeedingAux::strawSigns(locPos,locDir, segment.measurements()) !=
110 SeedingAux::strawSigns(smearLocPos, smearLocDir, segment.measurements())) {
111 ATH_MSG_DEBUG("Parameter smearng from "<<toString(segPars)<<" -> "<<toString(smearedPars)
112 <<" changes the L/R ambiguity -> avoid for this test");
113 return smearSegment(tgContext, segment, engine);
114 }
115
116 const Acts::Transform3& locToGlob{segment.msSector()->localToGlobalTransform(tgContext)};
117 if (smearLocDir.z() < 0) {
118 smearLocDir = -smearLocDir;
119 }
120 return std::make_tuple(locToGlob * smearLocPos, locToGlob.linear() * smearLocDir);
121 }
122
124 bool entrance) const {
125
126 const Acts::GeometryIdentifier volId = m_surfAccessor.get(measurement)->geometryId().withSensitive(0);
127 const Acts::TrackingVolume* volume = m_trackingGeometrySvc->trackingGeometry()->findVolume(volId);
128 return entrance ? MuonGMR4::bottomBoundary(*volume) : MuonGMR4::topBoundary(*volume);
129 }
130 StatusCode SegmentActsRefitAlg::execute(const EventContext& ctx) const {
131
132 const xAOD::MuonSegmentContainer* segments{nullptr};
133 ATH_CHECK(SG::get(segments, m_readKey, ctx));
135 const std::shared_ptr<const Acts::TrackingGeometry> trackingGeo = m_trackingGeometrySvc->trackingGeometry();
136 const Acts::GeometryContext tgContext = m_ctxProvider.getGeometryContext(ctx);
137 const Acts::MagneticFieldContext mfContext = m_ctxProvider.getMagneticFieldContext(ctx);
138 const Acts::CalibrationContext calContext = m_ctxProvider.getCalibrationContext(ctx);
139
141 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, name());
142 rngWrapper->setSeed(name(), ctx);
143 CLHEP::HepRandomEngine* randEngine = rngWrapper->getEngine(ctx);
144
145 SG::WriteHandle outHandle{m_writeKey, ctx};
146 ATH_CHECK(outHandle.record(std::make_unique<xAOD::MuonSegmentContainer>(),
147 std::make_unique<xAOD::MuonSegmentAuxContainer>()));
148
149
150 auto handleCreation = m_auxMeasProv.makeHandle(ctx, tgContext);
151 if (!handleCreation.ok()){
152 ATH_MSG_ERROR("Auxiliary measurement containers cannot be made");
153 return StatusCode::FAILURE;
154 }
155 auto& auxMeasHandle{*handleCreation};
158
159 using SegPars_t = xAOD::PosAccessor<Acts::toUnderlying(ParamDefs::nPars)>::element_type;
161
162 ParDecor_t dec_locPars{m_localParsKey, ctx};
163 ParDecor_t dec_seedPars{m_seedParsKey, ctx};
164
165 SeedingAux::Config cfg{};
166 cfg.parsToUse.clear();
167 SeedingAux pullCalculator{cfg, makeActsAthenaLogger(this, "PullCalculator")};
168
169 SeedingAux::Line_t line{};
170
171 Acts::PropagatorPlainOptions propagationOption{tgContext, mfContext};
172 propagationOption.maxSteps = m_maxPropSteps;
173 propagationOption.maxTargetSkipping = m_maxTargetSurfSkip;
174 constexpr bool doScat = false;
175 constexpr bool doEloss = false;
176 Gx2FitterOptions_t fitOptions{tgContext, mfContext, calContext, m_fitExtension,
177 std::move(propagationOption),
178 nullptr, doScat, doEloss,
179 Acts::FreeToBoundCorrection{m_doJacobianCorr},
180 m_maxIter};
181
185 Acts::ObjVisualization3D visualHelper{};
186
187
188 for (const xAOD::MuonSegment* reFitMe: *segments){
189 auto saveDisplay = [&](const std::string& state) {
190 if (!m_drawEvent) {
191 return;
192 }
193 const auto objFile = std::format("SegmentReFitTest_{:}_{:}_{:}_{:}.obj",
194 state, ctx.eventID().event_number(), reFitMe->index(),
195 MuonR4::printID(*reFitMe));
196 visualHelper.write(objFile);
197 ATH_MSG_DEBUG("Save event display under "<<objFile);
198 visualHelper = Acts::ObjVisualization3D{};
199 };
200
201 const MuonGMR4::SpectrometerSector* msSector =
202 m_detMgr->getSectorEnvelope(reFitMe->chamberIndex(),
203 reFitMe->sector(),
204 reFitMe->etaIndex());
205 const Acts::Transform3& sectorTrf{msSector->localToGlobalTransform(tgContext)};
206 const Amg::Vector3D planeNormal = sectorTrf.linear().col(2);
207
208 m_calibTool->stampSignsOnMeasurements(*reFitMe);
209 line.updateParameters(localSegmentPars(*reFitMe));
211 const auto [seedPos, seedDir] = smearSegment(tgContext, *MuonR4::detailedSegment(*reFitMe), randEngine);
213 {
214 const Acts::Transform3 invTrf = sectorTrf.inverse();
215 const Amg::Vector3D locSeedPos = invTrf * seedPos;
216 const Amg::Vector3D locSeedDir = invTrf.linear() * seedDir;
217 auto& seedPars = dec_seedPars(*reFitMe);
218 seedPars[Acts::toUnderlying(ParamDefs::x0)] = locSeedPos.x();
219 seedPars[Acts::toUnderlying(ParamDefs::y0)] = locSeedPos.y();
220 seedPars[Acts::toUnderlying(ParamDefs::theta)] = locSeedDir.theta();
221 seedPars[Acts::toUnderlying(ParamDefs::phi)] = locSeedDir.phi();
222 }
223
224 const GeoTrf::CoordEulerAngles sectorAngles = GeoTrf::getCoordRotationAngles(sectorTrf);
226 std::vector<const xAOD::UncalibratedMeasurement*> hitsToFit = MuonR4::collectMeasurements(*reFitMe);
227
228 // Identify the first measurement in the chamber volume. Skip the first one if it
229 // is the beamspot
230 const xAOD::UncalibratedMeasurement* entrance =
231 hitsToFit.front()->type() != xAOD::UncalibMeasType::Other ?
232 hitsToFit.front() : hitsToFit.at(1);
233 // Fetch the entrance & exit portals from the geometry
234 const Acts::Surface* entrancePortal = portalSurface(entrance, true);
235 const Acts::Surface* exitPortal = portalSurface(hitsToFit.back(), false);
236 ATH_MSG_DEBUG("Entrance portal: "
237 <<entrancePortal->geometryId()<<"/"<<m_idHelperSvc->toString(xAOD::identify(entrance))
238 <<", exit portal: "<<exitPortal->geometryId()<<"/"<<m_idHelperSvc->toString(xAOD::identify(hitsToFit.back())));
239
240 using namespace Acts::PlanarHelper;
241
242 const Acts::Intersection3D isectEntrance = intersectPlane(seedPos, seedDir, planeNormal,
243 entrancePortal->center(tgContext));
244 const Acts::Intersection3D isectFirst = intersectPlane(seedPos, seedDir, planeNormal,
245 m_surfAccessor.get(hitsToFit.front())->center(tgContext));
246
247 if (reFitMe->nPhiLayers() < 1) {
248
249 const Acts::Intersection3D isectExit = intersectPlane(seedPos, seedDir, planeNormal,
250 exitPortal->center(tgContext));
251 const Acts::Intersection3D isectLast = intersectPlane(seedPos, seedDir, planeNormal,
252 m_surfAccessor.get(hitsToFit.back())->center(tgContext));
253
255
256 const Acts::Transform3 trfBeneath = Amg::toIsometry3D(GeoTrf::GeoTransformRT{sectorAngles, 0.5*isectFirst.position() +
257 0.5*isectEntrance.position()});
258 const Acts::Transform3 trfAbove = Amg::toIsometry3D(GeoTrf::GeoTransformRT{sectorAngles, 0.85*isectExit.position() +
259 0.15*isectLast.position() });
260
261 auto surfBeneath = Acts::Surface::makeShared<Acts::PlaneSurface>(trfBeneath);
262 auto surfAbove = Acts::Surface::makeShared<Acts::PlaneSurface>(trfAbove);
263 ATH_MSG_DEBUG("Add auxiliary measurements @ "<<Amg::toString(surfBeneath->center(tgContext))
264 <<" and @"<<Amg::toString(surfAbove->center(tgContext)));
265
266 constexpr double covVal = Acts::square(1._cm);
267 hitsToFit.push_back(auxMeasHandle.newMeasurement<1>(surfBeneath, ProjectorType::e1DimNoTime, AmgSymMatrix(1){covVal}));
268 if (m_drawEvent) {
269 MuonValR4::drawMeasurement(tgContext, hitsToFit.back(), visualHelper, Acts::s_viewGrid);
270 }
271 hitsToFit.push_back(auxMeasHandle.newMeasurement<1>(surfAbove, ProjectorType::e1DimNoTime, AmgSymMatrix(1){covVal}));
272 if (m_drawEvent) {
273 MuonValR4::drawMeasurement(tgContext, hitsToFit.back(), visualHelper, Acts::s_viewGrid);
274 }
275 }
276
277 if (m_drawEvent) {
278 Acts::GeometryView3D::drawSurface(visualHelper, *entrancePortal, tgContext,
279 Acts::Transform3::Identity(), Acts::s_viewPortal);
280 Acts::GeometryView3D::drawSurface(visualHelper, *exitPortal, tgContext,
281 Acts::Transform3::Identity(), Acts::s_viewPortal);
282
284 MuonValR4::drawSegmentLine(tgContext, *reFitMe, visualHelper,
285 Acts::ViewConfig{.color = {220, 0, 0}});
286 MuonValR4::drawSegmentMeasurements(tgContext, *reFitMe, visualHelper, Acts::s_viewSurface);
287 }
288 ATH_MSG_VERBOSE("Entrance position "<<Amg::toString(isectEntrance.position())
289 <<", path length: "<<isectEntrance.pathLength()<<", "
290 <<" - First surface position: "<<Amg::toString(isectFirst.position())
291 <<", path length: "<<isectFirst.pathLength());
293
294 Amg::Vector3D refPos = 0.85 * isectEntrance.position()
295 + 0.15 * isectFirst.position();
296 const Acts::Transform3 trf = Amg::toIsometry3D(GeoTrf::GeoTransformRT{sectorAngles, refPos});
297 if (msgLvl(MSG::VERBOSE)) {
298 const auto [locPos, locDir] = makeLine(localSegmentPars(*reFitMe));
299
300 std::stringstream sstr{};
301 sstr<<"pos: "<<Amg::toString(seedPos)<<", dir: "<<Amg::toString(seedDir)<<", chi2/nDoF: "
302 <<reFitMe->chiSquared() / reFitMe->numberDoF()<<", nDoF: "<<reFitMe->numberDoF()
303 <<", prec: "<<reFitMe->nPrecisionHits()<<", phi: "<<reFitMe->nPhiLayers()<<std::endl;
304 for (const auto& meas : MuonR4::detailedSegment(*reFitMe)->measurements()) {
305 pullCalculator.updateSpatialResidual(line, *meas);
306 const Acts::Surface* surface = meas->spacePoint() ? m_surfAccessor.get(meas->spacePoint()->primaryMeasurement()) : nullptr;
307 const Acts::GeometryIdentifier geoId = surface ? surface->geometryId() : Acts::GeometryIdentifier{};
308 sstr<<" **** "<<(*meas)<<", chi2: "<<SeedingAux::chi2Term(locPos, locDir, *meas)
309 <<", sign: "<<(meas->isStraw() ?
310 (SeedingAux::strawSign(locPos,locDir, *meas) == 1 ? "R" : "L") : "X")
311 <<", geoId: "<<geoId;
312 if (geoId != Acts::GeometryIdentifier{}){
313 const Amg::Vector3D globPos = meas->spacePoint()->msSector()->localToGlobalTransform(tgContext) *
314 meas->localPosition();
315 const Acts::GeometryIdentifier volId = geoId.withSensitive(0);
316 const Acts::TrackingVolume* volume = m_trackingGeometrySvc->trackingGeometry()->findVolume(volId);
317 const Acts::Vector2 lPos = (*surface->globalToLocal(tgContext,globPos, reFitMe->direction()));
318 sstr<<", inside volume: "<<volume->inside(tgContext, globPos);
319 sstr<<", inside surface: "<<surface->bounds().inside(lPos);
320
321 }
322 sstr<<std::endl;
323 }
324
325 sstr<<" Target surf: "<<Amg::toString(trf)<<", firstSurf: "
326 << Amg::toString(trf.inverse()*isectFirst.position())
327 <<", refPoint: "<<Amg::toString(trf.inverse()*refPos)<<std::endl;
328 ATH_MSG_VERBOSE("Run G2F fit on "<<msSector->identString()<<std::endl<<sstr.str());
329 }
330 // Specify the surface on which the segment will be expressed.
331 std::shared_ptr<const Acts::Surface> target{};
332 if (hitsToFit.front()->type() == xAOD::UncalibMeasType::Other) {
333 target = m_surfAccessor.get(hitsToFit.front())->getSharedPtr();
334 using namespace Acts::detail::LineHelper;
335 const Acts::Intersection3D lineIsect =
336 lineIntersect<3>(target->center(tgContext),
337 Amg::Vector3D::UnitZ(),
338 seedPos, seedDir);
339 // Also update the start position to be the closest point of approach
340 // to the beamspot
341 refPos = lineIsect.position();
342 } else {
344 target = Acts::Surface::makeShared<Acts::PlaneSurface>(trf,
345 std::make_unique<Acts::RectangleBounds>(1._m, 1._m));
346 }
347 if (m_drawEvent) {
348 Acts::GeometryView3D::drawSurface(visualHelper, *target,
349 tgContext, Acts::Transform3::Identity(),
350 Acts::ViewConfig{.color={0,0,220}});
351 }
352
353 Acts::Vector<4> fourPos{ActsTrk::convertPosToActs(refPos, refPos.mag() / Gaudi::Units::c_light)};
354 Acts::BoundMatrix initialCov{Acts::BoundMatrix::Identity()};
355
356 auto initialPars = Acts::BoundTrackParameters::create(tgContext, target, fourPos, seedDir, straightQoverP,
357 initialCov, Acts::ParticleHypothesis::muon());
358 if (!initialPars.ok()) {
359 ATH_MSG_WARNING("Initial estimate of the parameters failed");
360 saveDisplay("invalidPars");
361 continue;
362 }
363 if (m_drawEvent) {
364 MuonValR4::drawBoundParameters(tgContext, *initialPars, visualHelper,
365 Acts::ViewConfig{.color={0,220,0}});
366 }
367 ATH_MSG_DEBUG("Initial parameters -- (loc0, loc1): "<<Amg::toString((*initialPars).localPosition())
368 <<", "<<std::format("theta: {:.2f}, ", (*initialPars).theta() / 1._degree)
369 <<std::format("phi: {:.2f}", (*initialPars).phi() / 1._degree));
370
371 std::vector<Acts::SourceLink> sourceLinks{};
372 std::ranges::transform(hitsToFit, std::back_inserter(sourceLinks),
373 [](const xAOD::UncalibratedMeasurement* meas) {
375 });
376 fitOptions.referenceSurface = target.get();
377
378 auto fitTraject = m_fitter->fit(sourceLinks.begin(), sourceLinks.end(),
379 *initialPars, fitOptions, tracks);
380 if (!fitTraject.ok()) {
381 saveDisplay("failed");
382 if (m_smearSegPars) {
383 ATH_MSG_WARNING("Track fit failed.");
384 continue;
385 } else {
386 ATH_MSG_ERROR("Segment refit failed. Albeit start parameters are taken from segment");
387 return StatusCode::FAILURE;
388 }
389 }
390
391 auto track = *fitTraject;
392 ATH_MSG_DEBUG("Track fit succeeded. ");
393
394 Acts::BoundTrackParameters parameters = track.createParametersAtReference();
395 if (m_drawEvent) {
396 MuonValR4::drawBoundParameters(tgContext, parameters, visualHelper,
397 Acts::ViewConfig{.color={0,220,220}});
398
399 }
400 saveDisplay("goodone");
401
402 std::uint8_t nPrecHits{0}, nTrigEtaHits{0}, nTrigPhiHits{0};
404 std::vector<const xAOD::UncalibratedMeasurement*> goodMeas{};
405 unsigned int itr{0};
406 for (const auto state :track.trackStatesReversed()) {
407 if (!state.hasUncalibratedSourceLink()){
408 continue;
409 }
410 goodMeas.insert(goodMeas.begin(),
411 ActsTrk::detail::xAODUncalibMeasCalibrator::unpack(state.getUncalibratedSourceLink()));
412
413 ATH_MSG_VERBOSE("Loop over track state: "<<(itr++)<<", "<<m_idHelperSvc->toString(xAOD::identify(goodMeas.front()))
414 <<", id: "<<m_surfAccessor.get(goodMeas.front())->geometryId());
415
416 const xAOD::UncalibratedMeasurement* m = goodMeas.front();
417 if (xAOD::isPrecisionHit(m)) {
418 ++nPrecHits;
419 nTrigPhiHits += m->numDimensions() == 2;
420 } else if (m->type() == xAOD::UncalibMeasType::Other) {
421 ++nTrigEtaHits;
422 ++nTrigPhiHits;
423 } else {
424 const auto* M = dynamic_cast<const xAOD::MuonMeasurement*>(m);
425 assert(M != nullptr);
426 //coverity[FORWARD_NULL]
427 nTrigEtaHits += (M->numDimensions() == 2 || !M->measuresPhi());
428 nTrigPhiHits += (M->numDimensions() == 2 || M->measuresPhi());
429
430 }
431 }
432
434 const Amg::Vector3D globDir = parameters.direction();
436 const Acts::Transform3 globToLoc{sectorTrf.inverse()};
437 const Amg::Vector3D refitPos = globToLoc * parameters.position(tgContext);
438 const Amg::Vector3D refitDir = globToLoc.linear() * globDir;
440 const Amg::Vector3D refitSeg = refitPos + Amg::intersect<3>(refitPos, refitDir, Amg::Vector3D::UnitZ(), 0).value_or(0.) * refitDir;
441 const Amg::Vector3D globPos{msSector->localToGlobalTransform(tgContext) * refitSeg};
442
443 xAOD::MuonSegment* newSegment = outHandle->push_back(std::make_unique<xAOD::MuonSegment>());
444 dec_segLink(*newSegment) = Link_t{*segments, reFitMe->index(), ctx};
445
446 newSegment->setDirection(globDir.x(), globDir.y(), globDir.z());
447 newSegment->setPosition(globPos.x(), globPos.y(), globPos.z());
448
449 newSegment->setFitQuality(track.chi2(), track.nDoF());
450 newSegment->setNHits(nPrecHits, nTrigPhiHits, nTrigEtaHits);
451 newSegment->setIdentifier(reFitMe->sector(), reFitMe->chamberIndex(),
452 reFitMe->etaIndex(), reFitMe->technology());
453
454 auto& locFitPars = dec_locPars(*newSegment);
455 locFitPars[Acts::toUnderlying(ParamDefs::x0)] = refitSeg.x();
456 locFitPars[Acts::toUnderlying(ParamDefs::y0)] = refitSeg.y();
457 locFitPars[Acts::toUnderlying(ParamDefs::theta)] = refitDir.theta();
458 locFitPars[Acts::toUnderlying(ParamDefs::phi)] = refitDir.phi();
459 }
460 return StatusCode::SUCCESS;
461 }
462}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define AmgSymMatrix(dim)
ElementLink< xAOD::TruthParticleContainer > Link_t
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)
Definition Logger.cxx:64
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:154
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:108
static Acts::SourceLink pack(const Ptr_t &measurement)
Pack the measurement type pointer to an Acts::SourceLink including the intermediate conversion into a...
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.
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 Acts::Transform3 & 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.
ActsTrk::ContextUtility m_ctxProvider
Auxiliary class to access the magnetic field, geometry and calibration context.
Gaudi::Property< double > m_smearRange
Smear interval in terms of standard deviations.
ToolHandle< ISpacePointCalibrator > m_calibTool
Handle to the space point calibrator.
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.
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
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
Tracking geometry tool.
Gx2FitterExtension_t m_fitExtension
Fitter setup.
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.
std::tuple< Amg::Vector3D, Amg::Vector3D > smearSegment(const Acts::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.
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(const std::uint8_t nPrecisionHits, const std::uint8_t nPhiLayers, const std::uint8_t nTrigEtaLayers)
Assign the segment hit summary.
void setPosition(float x, float y, float z)
Sets the global position.
void setIdentifier(const std::uint8_t sector, const ::Muon::MuonStationIndex::ChIndex chamberIndex, const std::int8_t etaIndex, const ::Muon::MuonStationIndex::TechnologyIndex technology)
Set the Identifier fields of the Segment.
static Root::TMsgLogger logger("iLumiCalc")
Acts::VectorMultiTrajectory MutableTrackStateBackend
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
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 ...
Amg::Isometry3D toIsometry3D(const Isometry3D &iso)
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.
xAOD::PosAccessor< Acts::toUnderlying(ParamDefs::nPars)>::element_type SegPars_t
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
void drawSegmentMeasurements(const Acts::GeometryContext &tgContext, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw all uncalibrated measurements associated to the segment.
void drawBoundParameters(const Acts::GeometryContext &tgContext, 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 drawSegmentLine(const Acts::GeometryContext &tgContext, 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.
void drawMeasurement(const Acts::GeometryContext &tgContext, const xAOD::UncalibratedMeasurement *meas, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw an uncalibrated measurement inside the obj file.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
MuonMeasurement_v1 MuonMeasurement
SG::Accessor< std::array< float, N > > PosAccessor
xAOD Accessor to the position
bool isPrecisionHit(const UncalibratedMeasurement *meas)
Returns whether the measurement is a precision hit.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
MuonSegment_v1 MuonSegment
Reference the current persistent version: