6#include "Acts/Utilities/CalibrationContext.hpp"
19#include "Acts/Surfaces/PlaneSurface.hpp"
20#include "Acts/Definitions/Units.hpp"
22using namespace Acts::UnitLiterals;
25 inline Acts::BoundTrackParameters makeBoundPars(
const ActsTrk::MutableTrackContainer::TrackStateProxy& state) {
26 return Acts::BoundTrackParameters{state.referenceSurface().getSharedPtr(),
27 state.parameters(), state.covariance(),
28 Acts::ParticleHypothesis::muon()};
40 Amg::Vector3D closestApproach(
const Acts::GeometryContext& tgContext,
48 if (simHit !=
nullptr &&
isMuon(simHit)) {
51 return secSurf.localToGlobalTransform(tgContext) *
52 measSurf.localToGlobalTransform(tgContext).inverse() *
58 return SeedingAux::extrapolateToPlane(pos, dir, spacePoint);
60 using namespace Acts::detail::LineHelper;
74 return StatusCode::SUCCESS;
82 return StatusCode::SUCCESS;
88 const double )
const {
92 seedPosInChamb, seedDirInChamb, *spacePoint))};
96 calibSp->setFitState(CalibratedSpacePoint::State::Outlier);
101 using namespace Acts::detail::LineHelper;
102 calibSp->setDriftRadius(signedDistance(seedPosInChamb, seedDirInChamb,
108 SeedingAux::strawSign(seedPosInChamb, seedDirInChamb, *calibSp));
118 const double timeDelay)
const {
121 copy->setFitState(CalibratedSpacePoint::State::Outlier);
127 const std::vector<const SpacePoint*>& spacePoints,
130 const double timeDelay)
const {
132 std::ranges::transform(spacePoints, std::back_inserter(result), [&](
const SpacePoint*
sp){
133 return calibrate(ctx,
sp, seedPosInChamb, seedDirInChamb, timeDelay);
141 const double timeDelay,
145 std::ranges::transform(spacePoints,std::back_inserter(result), [&](
const CalibSpacePointPtr&
sp){
146 return calibrate(*cctx.get<
const EventContext*>(), *
sp,
147 seedPosInChamb, seedDirInChamb, timeDelay);
158 const Acts::CalibrationContext& ,
159 const Acts::SourceLink& link,
160 ActsTrk::MutableTrackStateBackend::TrackStateProxy state)
const {
162 assert(uncalib !=
nullptr);
165 if (!simHit && uncalib->numDimensions() == 0) {
172 const auto boundPars{makeBoundPars(state)};
173 const Acts::Surface& surface{boundPars.referenceSurface()};
175 ATH_MSG_VERBOSE(__func__<<
"() "<<__LINE__<<
" - Calibrate muon measurement "
176 <<uncalib->readoutElement()->idHelperSvc()->toString(uncalib->identify())
177 <<
", @"<<surface.geometryId()
178 <<
", is truth "<<(simHit !=
nullptr)
179 <<
", parameters:\n"<<boundPars
181 <<
", momentum: "<<boundPars.absoluteMomentum());
183 if (simHit !=
nullptr) {
188 boundPars.direction()) / 1._degree);
190 if (uncalib->numDimensions() == 1) {
194 locPos.block<1,1>(uncalib->measuresPhi(),0),
195 uncalib->localCovariance<1>(), link, state);
198 uncalib->localCovariance<2>(), link, state);
201 using namespace Acts::detail::LineHelper;
202 const double r = signedDistance(locPos, xAOD::toEigen(simHit->
localDirection()),
203 Amg::Vector3D::Zero(),Amg::Vector3D::UnitZ());
205 if (uncalib->numDimensions() == 1) {
207 uncalib->localCovariance<1>(), link, state);
210 uncalib->localCovariance<2>(), link, state);
214 if (uncalib->numDimensions() == 1) {
216 uncalib->localCovariance<1>(), link, state);
219 uncalib->localCovariance<2>(), link, state);
235 const double )
const {
242 const double )
const {
248 const double )
const {
#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,...)
ProjectorType
Enum encoding the possible projectors used in ATLAS.
@ e2DimNoTime
Project out solely the locY - Complementary projector if the strip plane is rotated (Applies to Itk e...
@ e1DimRotNoTime
Project out solely the locX (Applies to Itk strips, Rpc, Tgc, sTgc, Mm).
void setState(const ProjectorType projector, const pos_t &locpos, const cov_t &cov, Acts::SourceLink link, proxy_t &trackState) const
Copy the local position & covariance into the Acts track state proxy.
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
const Acts::PlaneSurface & surface() const
Returns the associated surface.
The calibrated Space point is created during the calibration process.
const SpacePoint * spacePoint() const
The pointer to the space point out of which this space point has been built.
Acts::CloneablePtr< CalibratedSpacePoint > CalibSpacePointPtr
std::vector< CalibSpacePointPtr > CalibSpacePointVec
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
const Amg::Vector3D & sensorDirection() const
bool isStraw() const
Returns whether the measurement is a Mdt.
const MuonGMR4::SpectrometerSector * msSector() const
const xAOD::MuonMeasurement * primaryMeasurement() const
const Amg::Vector3D & localPosition() const
virtual double driftRadius(const Acts::CalibrationContext &cctx, const CalibratedSpacePoint &spacePoint, const double timeDelay) const override final
Returns the drift radius for a given drift-circle space point and time delay.
ActsTrk::ContextUtility m_ctxProvider
Context utility object to retrieve the geometry context.
virtual double driftAcceleration(const Acts::CalibrationContext &cctx, const CalibratedSpacePoint &spacePoint, const double timeDelay) const override final
Returns the drift acceleration (in ACTS units) for a given drift-circle space point.
virtual StatusCode initialize() override final
virtual void updateSigns(const Amg::Vector3D &trackPos, const Amg::Vector3D &trackDir, CalibSpacePointVec &hitsToCalib) const override final
Update the signs of the drift radii for a given straight line track to fix the left <-> right ambigui...
SG::ReadDecorHandleKeyArray< xAOD::UncalibratedMeasurementContainer > m_truthLinks
Dependencies on the truth matching of the uncalibrated measurement containers.
virtual CalibSpacePointPtr calibrate(const EventContext &ctx, const SpacePoint *spacePoint, const Amg::Vector3D &seedPosInChamb, const Amg::Vector3D &seedDirInChamb, const double timeDelay) const override final
Calibrates a single space point.
Gaudi::Property< std::vector< std::string > > m_prdContainers
Container names of the muon prd containers.
virtual void stampSignsOnMeasurements(const xAOD::MuonSegment &segment) const override final
Stamps the signs of the drift radii w.r.t.
virtual double driftVelocity(const Acts::CalibrationContext &cctx, const CalibratedSpacePoint &spacePoint) const override final
Returns the drift velocity (in ACTS units) for a given drift-circle space point.
Gaudi::Property< std::string > m_simLinkDecor
Decoration of the truth link.
virtual void calibrateSourceLink(const Acts::GeometryContext &geoctx, const Acts::CalibrationContext &cctx, const Acts::SourceLink &link, ActsTrk::MutableTrackStateBackend::TrackStateProxy state) const override final
Function that's hooked to the calibration delegate of the implemented Acts fitters.
ConstVectorMap< 3 > localDirection() const
Returns the local direction of the traversing particle.
ConstVectorMap< 3 > localPosition() const
Returns the local postion of the traversing particle.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
double angle(const Amg::Vector3D &v1, const Amg::Vector3D &v2)
calculates the opening angle between two vectors
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
ISpacePointCalibrator::CalibSpacePointVec CalibSpacePointVec
const xAOD::MuonSimHit * getTruthMatchedHit(const xAOD::MuonMeasurement &prdHit)
Returns the MuonSimHit, if there's any, matched to the uncalibrated muon measurement.
ISpacePointCalibrator::CalibSpacePointPtr CalibSpacePointPtr
MuonMeasurement_v1 MuonMeasurement
MuonSimHit_v1 MuonSimHit
Defined the version of the MuonSimHit.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.
CombinedMuonStrip_v1 CombinedMuonStrip