ATLAS Offline Software
Loading...
Searching...
No Matches
CalibratedSpacePoint.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
7namespace {
8 static const Amg::Vector3D zero{Amg::Vector3D::Zero()};
9}
10namespace MuonR4{
12 switch (s){
13 case State::Valid:
14 return "valid";
15 case State::Outlier:
16 return "outlier";
17 case State::FailedCalib:
18 return "failed calibration";
19 case State::Duplicate:
20 return "duplicate";
21
22 }
23 return "unknown";
24 }
26 Amg::Vector3D&& posInChamber,
27 State st):
28 m_posInChamber{std::move(posInChamber)},
29 m_parent{uncalibSpacePoint},
30 m_state{st} {
31 }
35 static const Amg::Vector3D s_Dir{Amg::Vector3D::UnitX()};
36 return m_parent? m_parent->sensorDirection() : (m_beamLine ? (*m_beamLine) : s_Dir);
37 }
39 static const Amg::Vector3D s_Dir{Amg::Vector3D::UnitY()};
43 return m_parent? m_parent->toNextSensor() : (m_beamLine ? zero : s_Dir);
44 }
46 static const Amg::Vector3D s_Dir{Amg::Vector3D::UnitZ()};
47 return m_parent ? m_parent->planeNormal() : (m_beamLine ? zero : s_Dir);
48 }
51 return m_cov;
52 }
53
54 bool CalibratedSpacePoint::hasChi2() const { return m_chi2Term != std::nullopt; }
55 double CalibratedSpacePoint::chi2Term() const { return m_chi2Term.value_or(std::numeric_limits<double>::max()); }
58 }
63 using enum xAOD::UncalibMeasType;
64 const auto t = type();
65 return t == MdtDriftCircleType || (t == Other && m_beamLine != nullptr);
66 }
68 return m_driftRadius;
69 }
74 double CalibratedSpacePoint::time() const { return m_time; }
76 m_time = t;
77 m_measuresTime = true;
78 }
79 bool CalibratedSpacePoint::measuresPhi() const { return !m_parent || m_parent->measuresPhi(); }
80 bool CalibratedSpacePoint::measuresEta() const { return !m_parent || m_parent->measuresEta(); }
83 unsigned CalibratedSpacePoint::dimension() const { return measuresEta() + measuresPhi(); }
86 m_beamLine = std::make_unique<Amg::Vector3D>(std::move(beamDir));
87 }
88
89 void CalibratedSpacePoint::print(std::ostream& ostr) const {
91 ostr<<"Calibrated SP "<<spacePoint()->msSector()->idHelperSvc()->toString(spacePoint()->identify());
92 } else {
93 ostr<<"Auxiliary measurement";
94 }
95 ostr<<" ("<<fitState()<<")";
96 ostr<<" @ "<<Amg::toString(localPosition());
98 ostr<<", wire: "<<Amg::toString(sensorDirection())<<", drift R: "<<driftRadius();
99 } else {
100 ostr<<", (dir/toNext/planeNormal): "<<Amg::toString(sensorDirection())
102 }
103 auto boolToStr = [](const bool B) -> std::string {
104 return B ? "yay" : "nay";
105 };
106 if (hasTime()) {
107 ostr<<", time: "<<ActsTrk::timeToAthena(time());
108 }
109 ostr<<", measures eta/phi/time: "<<boolToStr(measuresEta())
110 <<"/"<<boolToStr(measuresPhi())<<"/"<<boolToStr(hasTime());
111 ostr<<", covariance (eta/phi/time): ("<<m_cov[Acts::toUnderlying(CovIdx::etaCov)]<<", "
112 <<m_cov[Acts::toUnderlying(CovIdx::phiCov)]<<", "<<m_cov[Acts::toUnderlying(CovIdx::timeCov)]<<")";
113 if (hasChi2()) {
114 ostr<<", pull: "<<std::sqrt(chi2Term());
115 }
116 }
117}
const Muon::IMuonIdHelperSvc * idHelperSvc() const
Returns the IdHelpeSvc.
double driftRadius() const
: Returns the size of the drift radius
Amg::Vector3D m_posInChamber
Calibrated position.
std::optional< double > m_chi2Term
The chi2 term w.r.t the associated segment.
void setDriftRadius(const double r)
Update the drift radius of the space point measurement.
void setTimeMeasurement(double t)
Set the time measurement.
const Amg::Vector3D & toNextSensor() const
bool hasChi2() const
Returns whether the space point has a defined chi2.
const Amg::Vector3D & sensorDirection() const
bool hasTime() const
Returns whether the measurement carries time information.
bool m_measuresTime
time flag (By default true for Mdt detectors)
void setBeamDirection(Amg::Vector3D &&beamDir)
Sets the beamline direction.
bool measuresEta() const
Returns whether the calibrated space point measures eta.
const Amg::Vector3D & planeNormal() const
Returns the vector pointing out of the measurement plane.
double m_time
Calibrated time (Acts units).
const Amg::Vector3D & localPosition() const
bool isStraw() const
Returns whether the measurement is a Mdt.
static std::string toString(const State s)
Converts the state enum into a string.
void setFitState(State st)
Set the state of the calibrated space point.
bool measuresLoc1() const
Returns whether the measurement constains the bending direction.
bool measuresLoc0() const
Returns whether the measurement constains the non-bending direction.
void setCovariance(const Cov_t &cov)
Set the covariance matrix of the calibrated space point.
double time() const
Returns the measurement's recorded time.
State m_state
Calibration state.
CalibratedSpacePoint(const SpacePoint *uncalibSpacePoint, Amg::Vector3D &&posInChamber, State st=State::Valid)
Standard constructor.
void print(std::ostream &ostr) const
Print function.
const SpacePoint * spacePoint() const
The pointer to the space point out of which this space point has been built.
void setChi2Term(const double chi2)
Sets the chi2 term w.r.t.
xAOD::UncalibMeasType type() const
Returns the space point type.
std::shared_ptr< Amg::Vector3D > m_beamLine
Direction of the beamline (Beamspot constraint).
const Cov_t & covariance() const
Returns the covariance array.
bool measuresPhi() const
Returns whether the calibrated space point measures phi.
unsigned dimension() const
Returns the local dimension of the measurement.
const SpacePoint * m_parent
Uncalibrated space point from which this space point is constructed.
State
State flag to distinguish different space point states.
double m_driftRadius
Calibrated drift radius.
double chi2Term() const
Returns the cached chi2 term w.r.t.
State fitState() const
Returns the state of the calibrated space point.
The muon space point is the combination of two uncalibrated measurements one of them measures the eta...
virtual std::string toString(const Identifier &id) const =0
print all fields to string
void zero(TH2 *h)
zero the contents of a 2d histogram
double chi2(TH1 *h0, TH1 *h1)
int r
Definition globals.cxx:22
constexpr double timeToAthena(const double actsT)
Converts a time unit from Acts to Athena units.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D
This header ties the generic definitions in this package.
STL namespace.
UncalibMeasType
Define the type of the uncalibrated measurement.