ATLAS Offline Software
Loading...
Searching...
No Matches
InDet::SCT_ResidualPullCalculator Class Referencefinal

The InDet::SCT_ResidualPullCalculator is an AlgTool to calculate the residual and pull of a measurement and the related track state for the SCT. More...

#include <SCT_ResidualPullCalculator.h>

Inheritance diagram for InDet::SCT_ResidualPullCalculator:
Collaboration diagram for InDet::SCT_ResidualPullCalculator:

Public Member Functions

 SCT_ResidualPullCalculator (const std::string &type, const std::string &name, const IInterface *parent)
 constructor
virtual ~SCT_ResidualPullCalculator ()=default
virtual StatusCode initialize () override
 initialize
virtual std::optional< Trk::ResidualPullresidualPull (const Trk::MeasurementBase *measurement, const Trk::TrackParameters *trkPar, const Trk::ResidualPull::ResidualType resType, 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 resType, 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.
virtual std::optional< Trk::ResidualPullresidualPull (const Trk::MeasurementBase *, const Trk::TrackParameters *, const Trk::ResidualPull::ResidualType, const Trk::TrackState::MeasurementType, const std::vector< const Trk::AlignmentEffectsOnTrack * > &) const
 This function returns (creates!) a Trk::ResidualPull object, which contains the values of residual and pull for the given measurement and track state, and the Alignment effects.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()
 Interface ID, declared here, and defined below.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static double calcPull (const double residual, const double locMesCov, const double locTrkCov, const Trk::ResidualPull::ResidualType &, bool &pullIsValid)
 calc pull in 1 dimension

Private Attributes

StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

The InDet::SCT_ResidualPullCalculator is an AlgTool to calculate the residual and pull of a measurement and the related track state for the SCT.

It is called by the Trk::ResidualPullCalculator in the case of SCT measurements. This tools assumes in any cases that the given measurement belongs to the SCT! Normaly it should not be called directly, but through the Trk::ResidualPullCalculator.

Definition at line 35 of file SCT_ResidualPullCalculator.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ SCT_ResidualPullCalculator()

InDet::SCT_ResidualPullCalculator::SCT_ResidualPullCalculator ( const std::string & type,
const std::string & name,
const IInterface * parent )

constructor

Definition at line 22 of file SCT_ResidualPullCalculator.cxx.

23 : AthAlgTool(type,name,parent) {
24 declareInterface<IResidualPullCalculator>(this);
25}
AthAlgTool()
Default constructor:

◆ ~SCT_ResidualPullCalculator()

virtual InDet::SCT_ResidualPullCalculator::~SCT_ResidualPullCalculator ( )
virtualdefault

Member Function Documentation

◆ calcPull()

double InDet::SCT_ResidualPullCalculator::calcPull ( const double residual,
const double locMesCov,
const double locTrkCov,
const Trk::ResidualPull::ResidualType & resType,
bool & pullIsValid )
staticprivate

calc pull in 1 dimension

Definition at line 187 of file SCT_ResidualPullCalculator.cxx.

192 {
193
194 double ErrorSum;
195 if (resType == Trk::ResidualPull::Unbiased) {
196 if ((locMesCov + locTrkCov) < 0.) {
197 pullIsValid=false;
198 return 0;
199 }
200 ErrorSum = sqrt(locMesCov + locTrkCov);
201 } else if (resType == Trk::ResidualPull::Biased) {
202 if ((locMesCov - locTrkCov) < 0.) {
203 pullIsValid=false;
204 return 0;
205 }
206 ErrorSum = sqrt(locMesCov - locTrkCov);
207 } else {
208 if (locMesCov < 0.) {
209 pullIsValid=false;
210 return 0;
211 }
212 ErrorSum = sqrt(locMesCov);
213 }
214 if (ErrorSum != 0) {
215 return residual/ErrorSum;
216 }
217 pullIsValid=false;
218 return 0;
219}
@ Biased
RP with track state including the hit.
@ Unbiased
RP with track state that has measurement not included.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ initialize()

StatusCode InDet::SCT_ResidualPullCalculator::initialize ( )
overridevirtual

initialize

Definition at line 30 of file SCT_ResidualPullCalculator.cxx.

30 {
31 ATH_MSG_DEBUG ("initialise successful in "<<name());
32 return StatusCode::SUCCESS;
33}
#define ATH_MSG_DEBUG(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Trk::IResidualPullCalculator::interfaceID ( )
inlinestaticinherited

Interface ID, declared here, and defined below.

Definition at line 84 of file IResidualPullCalculator.h.

84 {
86}
static const InterfaceID IID_IResidualPullCalculator("IResidualPullCalculator", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ residualPull() [1/2]

virtual std::optional< Trk::ResidualPull > Trk::IResidualPullCalculator::residualPull ( const Trk::MeasurementBase * ,
const Trk::TrackParameters * ,
const Trk::ResidualPull::ResidualType ,
const Trk::TrackState::MeasurementType ,
const std::vector< const Trk::AlignmentEffectsOnTrack * > &  ) const
inlinevirtual

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

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 residualTyp must be set according to this, otherwise the pulls will be wrong. Residuals differ in all three cases; please be aware of this.

This function determines the sub-detector type itself by using the ID helper

Reimplemented from Trk::IResidualPullCalculator.

Definition at line 64 of file IResidualPullCalculator.h.

69 {
70 return std::nullopt;
71 }

◆ residualPull() [2/2]

std::optional< Trk::ResidualPull > InDet::SCT_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.

calc residual and pull for SCT measurements

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!

Implements Trk::IResidualPullCalculator.

Definition at line 38 of file SCT_ResidualPullCalculator.cxx.

42 {
43
44 // check the input:
45 const InDet::SCT_ClusterOnTrack *sctROT = dynamic_cast<const InDet::SCT_ClusterOnTrack*>(measurement);
46 if (!sctROT) return std::nullopt;
47 if (!trkPar) return std::nullopt;
48
49 // if no covariance for the track parameters is given the pull calculation is not valid
50 bool pullIsValid = trkPar->covariance()!=nullptr;
51
52 // residual and pull are always 1-dim in the end
53 std::vector<double> residual(1);
54 std::vector<double> pull(1);
55 double sinAlpha = 0.0;
56
57 // check if we have a 2-dim SCT cluster
58 if (sctROT->localParameters().parameterKey() == 1) {
59 // the (easy) 1-dim case:
60 residual[Trk::loc1] = sctROT->localParameters()[Trk::loc1] - trkPar->parameters()[Trk::loc1];
61 if (pullIsValid) {
62 pull[Trk::loc1] = calcPull(residual[Trk::loc1],
64 (*trkPar->covariance())(Trk::loc1,Trk::loc1),
65 resType, pullIsValid);
66 } else {
67 pull[Trk::loc1] = calcPull(residual[Trk::loc1],
69 0,
70 resType, pullIsValid);
71 }
72 } else {
73 // the 2-dim case:
74 // get the stereo angle (preferrably) from the PrepRawData
75 const InDet::SCT_Cluster *sctRIO = sctROT->prepRawData();
76 if (!sctRIO) {
78 sctROT->localParameters()[Trk::locY]);
79 sinAlpha = sctROT->detectorElement()->sinStereoLocal(p);
80 } else {
81 // Get angle of strip in local frame with respect to the etaAxis
82 // the position of the ROT is lorentz-drift corrected by up to 3 micron,
83 // leading to a strip frame slightly (~5murad) different than the original one
84 sinAlpha = sctRIO->detectorElement()->sinStereoLocal(sctRIO->localPosition());
85 }
86 double cosAlpha = sqrt(1 - sinAlpha*sinAlpha);
87
88 // Calculate Residual for hit: res = (vec(x_track) - vec(x_hit)) * vec(n_perpendicular)
90 (measurement->localParameters()[Trk::locX] -
91 trkPar->parameters()[Trk::locX]) * cosAlpha
92 + (measurement->localParameters()[Trk::locY] -
93 trkPar->parameters()[Trk::locY]) * sinAlpha;
94
95 // Fill transformation matrix to transform covariance matrices
96 Amg::MatrixX RotMat(2,2);
97 RotMat(0,0) = cosAlpha;
98 RotMat(0,1) = sinAlpha;
99 RotMat(1,0) = -sinAlpha;
100 RotMat(1,1) = cosAlpha;
101 // get the covariance matrix of the ROT and rotate it by stereo angle
102 Amg::MatrixX transformedROTCov = sctROT->localCovariance().similarity(RotMat);
103
104 if (trkPar->covariance()) {
105 // Get local error matrix for track to calc pull
106 // Just use first local coordinates
107 // and rotate by the stereo angle
108 Amg::MatrixX RotMatTrk(2,2);
109 RotMatTrk(0,0) = (*trkPar->covariance())(0,0);
110 RotMatTrk(0,1) = (*trkPar->covariance())(0,1);
111 RotMatTrk(1,0) = (*trkPar->covariance())(1,0);
112 RotMatTrk(1,1) = (*trkPar->covariance())(1,1);
113
114 Amg::MatrixX transformedTrkCov = RotMatTrk.similarity(RotMat);
115 // calc pull now
116 pull[Trk::loc1] = calcPull(residual[Trk::loc1],
117 transformedROTCov(0,0),
118 transformedTrkCov(0,0),
119 resType, pullIsValid);
120 } else {
121 pull[Trk::loc1] = calcPull(residual[Trk::loc1],
122 transformedROTCov(0,0),
123 0.,
124 resType, pullIsValid);
125 }
126
127 }
128
129 // create the Trk::ResidualPull:
130 // ParameterKey is always 1, because otherwise we rotated it back
131 return std::make_optional<Trk::ResidualPull>(std::move(residual),
132 std::move(pull), pullIsValid,
133 resType, 1, sinAlpha);
134}
double sinStereoLocal(const Amg::Vector2D &localPos) const
Angle of strip in local frame with respect to the etaAxis.
virtual const InDet::SCT_Cluster * prepRawData() const override final
returns the PrepRawData - is a SCT_Cluster in this scope
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
returns the detector element, assoicated with the PRD of this class
static double calcPull(const double residual, const double locMesCov, const double locTrkCov, const Trk::ResidualPull::ResidualType &, bool &pullIsValid)
calc pull in 1 dimension
virtual const InDetDD::SiDetectorElement * detectorElement() const override final
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
int parameterKey() const
Identifier key for matrix expansion/reduction.
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
const Amg::Vector2D & localPosition() const
return the local position reference
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
@ loc1
Definition ParamDefs.h:34

◆ residuals()

std::array< double, 5 > InDet::SCT_ResidualPullCalculator::residuals ( const Trk::MeasurementBase * measurement,
const Trk::TrackParameters * trkPar,
const Trk::ResidualPull::ResidualType resType,
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.

calc residuals for SCT measurements

Implements Trk::IResidualPullCalculator.

Definition at line 140 of file SCT_ResidualPullCalculator.cxx.

144 {
145 std::array<double,5> residuals{};
146 // check the input:
147 const InDet::SCT_ClusterOnTrack *sctROT = dynamic_cast<const InDet::SCT_ClusterOnTrack*>(measurement);
148 if (!sctROT) return residuals;
149 if (!trkPar) return residuals;
150 double sinAlpha = 0.0;
151
152 // check if we have a 2-dim SCT cluster
153 if (sctROT->localParameters().parameterKey() == 1) {
154 // the (easy) 1-dim case:
155 residuals[Trk::loc1] = sctROT->localParameters()[Trk::loc1] - trkPar->parameters()[Trk::loc1];
156 } else {
157 // the 2-dim case:
158 // get the stereo angle (preferrably) from the PrepRawData
159 const InDet::SCT_Cluster *sctRIO = sctROT->prepRawData();
160 if (!sctRIO) {
162 sctROT->localParameters()[Trk::locY]);
163 sinAlpha = sctROT->detectorElement()->sinStereoLocal(p);
164 } else {
165 // Get angle of strip in local frame with respect to the etaAxis
166 // the position of the ROT is lorentz-drift corrected by up to 3 micron,
167 // leading to a strip frame slightly (~5murad) different than the original one
168 sinAlpha = sctRIO->detectorElement()->sinStereoLocal(sctRIO->localPosition());
169 }
170 double cosAlpha = sqrt(1 - sinAlpha*sinAlpha);
171
172 // Calculate Residual for hit: res = (vec(x_track) - vec(x_hit)) * vec(n_perpendicular)
174 (measurement->localParameters()[Trk::locX] -
175 trkPar->parameters()[Trk::locX]) * cosAlpha
176 + (measurement->localParameters()[Trk::locY] -
177 trkPar->parameters()[Trk::locY]) * sinAlpha;
178
179 }
180 return residuals;
181}
virtual std::array< double, 5 > residuals(const Trk::MeasurementBase *measurement, const Trk::TrackParameters *trkPar, const Trk::ResidualPull::ResidualType resType, const Trk::TrackState::MeasurementType) const override
This function is a light-weight version of the function above, designed for track fitters where speed...

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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