ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::RPC_ResidualPullCalculator Class Reference

RPC-specific tool to calculate hit residual and pull from a RIO_OnTrack/TrackParameter pair. More...

#include <RPC_ResidualPullCalculator.h>

Inheritance diagram for Muon::RPC_ResidualPullCalculator:
Collaboration diagram for Muon::RPC_ResidualPullCalculator:

Public Member Functions

virtual ~RPC_ResidualPullCalculator ()=default
virtual StatusCode initialize () override
virtual std::optional< Trk::ResidualPullresidualPull (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 and pull for the given measurement and track state.
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 is critical.

Static Private Member Functions

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.

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}

Detailed Description

RPC-specific tool to calculate hit residual and pull from a RIO_OnTrack/TrackParameter pair.

Uses Muon-specific info to code the strip type (measuring phi/eta) in the 2nd coordinate of the residual.

Author
Wolfgang Liebig http://consult.cern.ch/xwho/people/54608

Definition at line 27 of file RPC_ResidualPullCalculator.h.

Constructor & Destructor Documentation

◆ ~RPC_ResidualPullCalculator()

virtual Muon::RPC_ResidualPullCalculator::~RPC_ResidualPullCalculator ( )
virtualdefault

Member Function Documentation

◆ calcPull()

double Muon::RPC_ResidualPullCalculator::calcPull ( const double residual,
const double locMesCov,
const double locTrkCov,
const Trk::ResidualPull::ResidualType & resType )
staticprivate

internal structuring: common method to calculate the hit pull.

calc pull in 1 dimension

Definition at line 113 of file RPC_ResidualPullCalculator.cxx.

117 {
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}
@ Biased
RP with track state including the hit.
@ Unbiased
RP with track state that has measurement not included.

◆ initialize()

StatusCode Muon::RPC_ResidualPullCalculator::initialize ( )
overridevirtual

Definition at line 12 of file RPC_ResidualPullCalculator.cxx.

13{
14 ATH_CHECK(m_idHelperSvc.retrieve());
15 ATH_MSG_DEBUG ("initialize() successful in " << name());
16 return StatusCode::SUCCESS;
17}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc

◆ residualPull()

std::optional< Trk::ResidualPull > Muon::RPC_ResidualPullCalculator::residualPull ( const Trk::MeasurementBase * measurement,
const Trk::TrackParameters * trkPar,
const Trk::ResidualPull::ResidualType resType,
const Trk::TrackState::MeasurementType  ) const
overridevirtual

This function returns (creates!) a Trk::ResidualPull object, which contains the values of residual and pull for the given measurement and track state.

The track state can be an unbiased one (which can be retrieved by the Trk::IUpdator), a biased one (which contains the measurement), or a truth state. The enum ResidualType must be set according to this, otherwise the pulls will be wrong. Residuals differ in all three cases; please be aware of this!

Definition at line 52 of file RPC_ResidualPullCalculator.cxx.

56 {
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}
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
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.
static void extract(std::vector< Identifier > &ids, const std::vector< const MeasurementBase * > &measurements)
int dimension() const
Dimension of this localParameters() vector.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
l
Printing final latex table to .tex output file.
@ loc2
generic first and second local coordinate
Definition ParamDefs.h:35
@ loc1
Definition ParamDefs.h:34
ID
//////////////////////////////////////// JetAlgorithmType::ID defines most common physics jet finding...

◆ residuals()

std::array< double, 5 > Muon::RPC_ResidualPullCalculator::residuals ( const Trk::MeasurementBase * measurement,
const Trk::TrackParameters * trkPar,
const Trk::ResidualPull::ResidualType ,
const Trk::TrackState::MeasurementType  ) const
overridevirtual

This function is a light-weight version of the function above, designed for track fitters where speed is critical.

Definition at line 21 of file RPC_ResidualPullCalculator.cxx.

25 {
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
35 - trkPar->parameters()[Trk::loc1];
36 } else {
38 - trkPar->parameters()[Trk::loc1];
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}
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...
int parameterKey() const
Identifier key for matrix expansion/reduction.

Member Data Documentation

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::RPC_ResidualPullCalculator::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 62 of file RPC_ResidualPullCalculator.h.

62{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

The documentation for this class was generated from the following files: