ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonReconstruction
MuonRecTools
MuonResidualPullCalculators
src
RPC_ResidualPullCalculator.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
RPC_ResidualPullCalculator.h
"
6
7
#include "
TrkEventUtils/IdentifierExtractor.h
"
8
#include "
TrkEventPrimitives/LocalParameters.h
"
9
10
//================ Initialisation =================================================
11
12
StatusCode
Muon::RPC_ResidualPullCalculator::initialize
()
13
{
14
ATH_CHECK
(
m_idHelperSvc
.retrieve());
15
ATH_MSG_DEBUG
(
"initialize() successful in "
<< name());
16
return
StatusCode::SUCCESS;
17
}
18
19
//================ calculate residuals for RPC ==================================
20
std::array<double,5>
21
Muon::RPC_ResidualPullCalculator::residuals
(
22
const
Trk::MeasurementBase
* measurement,
23
const
Trk::TrackParameters
* trkPar,
24
const
Trk::ResidualPull::ResidualType
/*resType*/
,
25
const
Trk::TrackState::MeasurementType
)
const
{
26
std::array<double, 5>
residuals
{};
27
if
(!trkPar || !measurement)
return
residuals
;
28
Identifier
ID =
Trk::IdentifierExtractor::extract
(measurement);
29
30
if
(
m_idHelperSvc
->isRpc(ID) ) {
31
32
if
(measurement->
localParameters
().
parameterKey
() == 1) {
33
// convention to be interpreted by TrkValTools: 2nd coordinate codes orientation of RPC
34
residuals
[
Trk::loc1
] = measurement->
localParameters
()[
Trk::loc1
]
35
- trkPar->parameters()[
Trk::loc1
];
36
}
else
{
37
residuals
[
Trk::loc1
] = measurement->
localParameters
()[
Trk::loc1
]
38
- trkPar->parameters()[
Trk::loc1
];
39
residuals
[
Trk::loc2
] = measurement->
localParameters
()[
Trk::loc2
]
40
- trkPar->parameters()[
Trk::loc2
];
41
}
42
43
}
else
{
44
ATH_MSG_WARNING
(
"Input problem measurement is not RPC. "
45
<<
m_idHelperSvc
->toString(ID) );
46
return
residuals
;
47
}
48
return
residuals
;
49
}
50
51
//================ calculate residuals and pulls for RPC ==================================
52
std::optional<Trk::ResidualPull>
Muon::RPC_ResidualPullCalculator::residualPull
(
53
const
Trk::MeasurementBase
* measurement,
54
const
Trk::TrackParameters
* trkPar,
55
const
Trk::ResidualPull::ResidualType
resType,
56
const
Trk::TrackState::MeasurementType
)
const
{
57
58
if
(!trkPar || !measurement) {
59
return
std::nullopt;
60
}
61
Identifier
ID =
Trk::IdentifierExtractor::extract
(measurement);
62
63
if
(!
m_idHelperSvc
->isRpc(ID)) {
64
ATH_MSG_DEBUG
(
"Input problem measurement is not RPC but "
65
<<
m_idHelperSvc
->toString(ID));
66
return
std::nullopt;
67
}
68
69
70
// if no covariance for the track parameters is given the pull calculation is not valid
71
const
AmgSymMatrix
(5)* trkCov = trkPar->covariance();
72
73
// calculate residual
74
const
auto
& localParameters = measurement->
localParameters
();
75
const
std::size_t nParams = localParameters.
dimension
();
76
std::vector<double> residual(nParams), pull(nParams);
77
78
switch
(nParams) {
79
case
1: {
80
residual[
Trk::loc1
] = localParameters[
Trk::loc1
]
81
- trkPar->parameters()[
Trk::loc1
];
82
break
;
83
}
case
2: {
84
residual[
Trk::loc1
] = localParameters[
Trk::loc1
]
85
- trkPar->parameters()[
Trk::loc1
];
86
residual[
Trk::loc2
] = localParameters[
Trk::loc2
]
87
- trkPar->parameters()[
Trk::loc2
];
88
break
;
89
}
default
:
90
ATH_MSG_WARNING
(
"RPC ClusterOnTrack does not carry the expected "
91
<<
"LocalParameters structure!"
);
92
return
std::nullopt;
93
}
94
95
// calculate pull
96
for
(std::size_t l = 0 ; l < residual.size(); ++l) {
97
pull[l] =
calcPull
(residual[l], measurement->
localCovariance
()(l,l),
98
trkCov ? (*trkCov)(l,l) : 0., resType);
99
}
100
101
// create the Trk::ResidualPull.
102
ATH_MSG_DEBUG
(
"Calculating Pull for channel "
<<
m_idHelperSvc
->toString(ID) <<
" residual "
<< residual[
Trk::loc1
] <<
" pull "
<< pull[
Trk::loc1
] );
103
return
std::make_optional<Trk::ResidualPull>(std::move(residual),
104
std::move(pull),
105
trkCov !=
nullptr
,
106
resType, 1);
107
}
108
109
113
double
Muon::RPC_ResidualPullCalculator::calcPull
(
114
const
double
residual,
115
const
double
locMesCov,
116
const
double
locTrkCov,
117
const
Trk::ResidualPull::ResidualType
& resType ) {
118
119
double
ErrorSum(0.0);
120
if
(resType ==
Trk::ResidualPull::Unbiased
) {
121
if
( locMesCov + locTrkCov > 0 ) ErrorSum = std::sqrt(locMesCov + locTrkCov);
122
}
else
if
(resType ==
Trk::ResidualPull::Biased
) {
123
if
((locMesCov - locTrkCov) < 0.) {
124
return
0;
125
}
126
ErrorSum = std::sqrt(locMesCov - locTrkCov);
127
}
else
ErrorSum = std::sqrt(locMesCov);
128
if
(ErrorSum != 0)
return
residual/ErrorSum;
129
return
0;
130
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x,...)
Definition
AthMsgStreamMacros.h:43
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition
EventPrimitives.h:50
IdentifierExtractor.h
LocalParameters.h
RPC_ResidualPullCalculator.h
Muon::RPC_ResidualPullCalculator::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition
RPC_ResidualPullCalculator.h:62
Muon::RPC_ResidualPullCalculator::calcPull
static double calcPull(const double residual, const double locMesCov, const double locTrkCov, const Trk::ResidualPull::ResidualType &)
internal structuring: common method to calculate the hit pull.
Definition
RPC_ResidualPullCalculator.cxx:113
Muon::RPC_ResidualPullCalculator::residualPull
virtual std::optional< Trk::ResidualPull > residualPull(const Trk::MeasurementBase *measurement, const Trk::TrackParameters *trkPar, const Trk::ResidualPull::ResidualType, const Trk::TrackState::MeasurementType) const override
This function returns (creates!) a Trk::ResidualPull object, which contains the values of residual an...
Definition
RPC_ResidualPullCalculator.cxx:52
Muon::RPC_ResidualPullCalculator::initialize
virtual StatusCode initialize() override
Definition
RPC_ResidualPullCalculator.cxx:12
Muon::RPC_ResidualPullCalculator::residuals
virtual std::array< double, 5 > residuals(const Trk::MeasurementBase *measurement, const Trk::TrackParameters *trkPar, const Trk::ResidualPull::ResidualType, const Trk::TrackState::MeasurementType) const override
This function is a light-weight version of the function above, designed for track fitters where speed...
Definition
RPC_ResidualPullCalculator.cxx:21
Trk::IdentifierExtractor::extract
static void extract(std::vector< Identifier > &ids, const std::vector< const MeasurementBase * > &measurements)
Definition
IdentifierExtractor.cxx:13
Trk::LocalParameters::parameterKey
int parameterKey() const
Identifier key for matrix expansion/reduction.
Trk::LocalParameters::dimension
int dimension() const
Dimension of this localParameters() vector.
Trk::MeasurementBase
This class is the pure abstract base class for all fittable tracking measurements.
Definition
MeasurementBase.h:58
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition
MeasurementBase.h:132
Trk::MeasurementBase::localCovariance
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
Definition
MeasurementBase.h:138
Trk::ResidualPull::ResidualType
ResidualType
Definition
ResidualPull.h:53
Trk::ResidualPull::Biased
@ Biased
RP with track state including the hit.
Definition
ResidualPull.h:55
Trk::ResidualPull::Unbiased
@ Unbiased
RP with track state that has measurement not included.
Definition
ResidualPull.h:57
Identifier
Definition
IdentifierFieldParser.cxx:14
Trk::TrackState::MeasurementType
MeasurementType
enum describing the flavour of MeasurementBase
Definition
TrackStateDefs.h:26
Trk::loc2
@ loc2
generic first and second local coordinate
Definition
ParamDefs.h:35
Trk::loc1
@ loc1
Definition
ParamDefs.h:34
Trk::TrackParameters
ParametersBase< TrackParametersDim, Charged > TrackParameters
Definition
Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:27
Generated on
for ATLAS Offline Software by
1.17.0