ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Muon::TGC_ResidualPullCalculator Class Referencefinal

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

#include <TGC_ResidualPullCalculator.h>

Inheritance diagram for Muon::TGC_ResidualPullCalculator:
Collaboration diagram for Muon::TGC_ResidualPullCalculator:

Public Member Functions

 TGC_ResidualPullCalculator (const std::string &, const std::string &, const IInterface *)
 
virtual ~TGC_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. More...
 
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. More...
 
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. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & evtStore () const
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Static Public Member Functions

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

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
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. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

double calcPull (const double residual, const double locMesCov, const double locTrkCov, const Trk::ResidualPull::ResidualType &) const
 internal structuring: common code for calculating hit pulls More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

TGC-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 and to un-do the rotation from strip to chamber system. That is, the residual and pull is calculated in the direction perpendicular to the strip allowing e.g. a validation of the strip errors.

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

Definition at line 31 of file TGC_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

◆ TGC_ResidualPullCalculator()

Muon::TGC_ResidualPullCalculator::TGC_ResidualPullCalculator ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 14 of file TGC_ResidualPullCalculator.cxx.

14  :
15  AthAlgTool(t,n,p) {
16  declareInterface<IResidualPullCalculator>(this);
17 }

◆ ~TGC_ResidualPullCalculator()

virtual Muon::TGC_ResidualPullCalculator::~TGC_ResidualPullCalculator ( )
virtualdefault

Member Function Documentation

◆ calcPull()

double Muon::TGC_ResidualPullCalculator::calcPull ( const double  residual,
const double  locMesCov,
const double  locTrkCov,
const Trk::ResidualPull::ResidualType resType 
) const
private

internal structuring: common code for calculating hit pulls

calc pull in 1 dimension

Definition at line 223 of file TGC_ResidualPullCalculator.cxx.

227  {
228  if( locMesCov < 0 ) {
229  ATH_MSG_DEBUG("Bad error " << locMesCov << " " << locTrkCov << " using measured error ");
230  return 0;
231  }
232  double ErrorSum;
233  if (resType == Trk::ResidualPull::Unbiased) {
234  if( locMesCov + locTrkCov > 0 ) ErrorSum = std::sqrt(locMesCov + locTrkCov);
235  else{
236  ATH_MSG_DEBUG("Bad error measurement " << locMesCov << " from track " << locTrkCov << ", using measured error ");
237  ErrorSum = std::sqrt(locMesCov);
238  }
239  } else if (resType == Trk::ResidualPull::Biased) {
240  if ((locMesCov - locTrkCov) < 0.) {
241  return 0;
242  }
243  ErrorSum = std::sqrt(locMesCov - locTrkCov);
244  } else ErrorSum = std::sqrt(locMesCov);
245  if (ErrorSum != 0) return residual/ErrorSum;
246  return 0;
247 }

◆ declareGaudiProperty() [1/4]

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

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

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

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

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

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

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

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

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

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

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ 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.

95 { return m_detStore; }

◆ evtStore() [1/2]

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.

85 { return m_evtStore; }

◆ evtStore() [2/2]

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

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

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ 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 Muon::TGC_ResidualPullCalculator::initialize ( )
overridevirtual

Definition at line 21 of file TGC_ResidualPullCalculator.cxx.

22 {
23  ATH_CHECK(m_idHelperSvc.retrieve());
24  ATH_MSG_DEBUG ("initialize() successful in " << name());
25  return StatusCode::SUCCESS;
26 }

◆ 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  {
85  return IID_IResidualPullCalculator;
86 }

◆ msg() [1/2]

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msg() [2/2]

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

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ 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();
383  PBASE::renounce (h);
384  }

◆ 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  {
365  handlesArray.renounce();
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
inlinevirtualinherited

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 in Trk::ResidualPullCalculator.

Definition at line 64 of file IResidualPullCalculator.h.

69  {
70  return std::nullopt;
71  }

◆ residualPull() [2/2]

std::optional< Trk::ResidualPull > Muon::TGC_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!!!

Implements Trk::IResidualPullCalculator.

Definition at line 98 of file TGC_ResidualPullCalculator.cxx.

102  {
103 
104  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(measurement);
105  if (!rot) {
106  const Muon::CompetingMuonClustersOnTrack* muonCompClusters =
107  dynamic_cast<const Muon::CompetingMuonClustersOnTrack*>(measurement);
108  if (muonCompClusters) rot = muonCompClusters->containedROTs().empty() ? nullptr :
109  muonCompClusters->containedROTs().front();
110  }
111  if (!trkPar || !rot) {
112  if( !trkPar ) ATH_MSG_WARNING ("No TrackParameters, cannot calculate residual/pull ");
113  if( !rot ) ATH_MSG_WARNING ("No ROT, cannot calculate residual/pull ");
114  return std::nullopt;
115  }
116  Identifier ID = rot->identify();
117 
118  if( m_idHelperSvc->isTgc(ID) ) {
119 
120  // try to cast the track parameters to measured ones
121  const AmgSymMatrix(5)* trkCov = trkPar->covariance();
122  bool pullIsValid = (trkCov);
123 
124  double sinAlpha = 0.0;
125 
126  bool isStrip = m_idHelperSvc->tgcIdHelper().isStrip(ID);
127 
128  // calculate residual
129  std::vector<double> residual(1);
130  std::vector<double> pull(1);
131  if (isStrip) {
132  // consistency check that Muon EDM is as expected
133  if (measurement->localParameters().parameterKey() !=3) {
134  ATH_MSG_WARNING ( "TGC ClusterOnTrack does not carry the expected "
135  << "LocalParameters structure!");
136  return std::nullopt;
137  }
138  // get orientation angle of strip to rotate back from local frame to strip
139  const Amg::MatrixX &covmat=measurement->localCovariance();
140  double v0=0.5*(covmat(0,0)+covmat(1,1)-sqrt((covmat(0,0)+covmat(1,1))*(covmat(0,0)+covmat(1,1))-
141  4*(covmat(0,0)*covmat(1,1)-covmat(0,1)*covmat(0,1))));
142  double v1=0.5*(covmat(0,0)+covmat(1,1)+sqrt((covmat(0,0)+covmat(1,1))*(covmat(0,0)+covmat(1,1))-
143  4*(covmat(0,0)*covmat(1,1)-covmat(0,1)*covmat(0,1))));
144  sinAlpha=std::sin(0.5*std::asin(2*covmat(0,1)/(v0-v1)));
145 
146  const MuonGM::TgcReadoutElement *ele =
147  dynamic_cast<const MuonGM::TgcReadoutElement*>(rot->detectorElement());
148  if (!ele) {
149  ATH_MSG_WARNING ("Could not obtain TGC detEl from TGC ROT, this is a bug!" );
150  return std::nullopt;
151  }
152 
153  double cosAlpha = std::sqrt(1 - sinAlpha*sinAlpha);
154 
155  // Calculate Residual for hit: res = (vec(x_hit) - vec(x_track)) * vec(n_perpendicular)
157  (measurement->localParameters()[Trk::locX] - trkPar->parameters()[Trk::locX]) * cosAlpha
158  + (measurement->localParameters()[Trk::locY] - trkPar->parameters()[Trk::locY]) * sinAlpha;
159 
160  // Fill transformation matrix to transform covariance matrices
161  Amg::MatrixX RotMat(2,2);
162  RotMat(0,0) = cosAlpha;
163  RotMat(0,1) = sinAlpha;
164  RotMat(1,0) = -sinAlpha;
165  RotMat(1,1) = cosAlpha;
166  // get the covariance matrix of the ROT and rotate it by stereo angle
167  Amg::MatrixX transformedROTCov = measurement->localCovariance().similarity(RotMat);
168 
169  if (pullIsValid) {
170  // Get local error matrix for track to calc pull
171  // Just use first local coordinates
172  // and rotate by the stereo angle
173  Amg::MatrixX subm = trkCov->block<2,2>(0,0);
174  Amg::MatrixX transformedTrkCov = subm.similarity(RotMat);
175  // calc pull now
177  transformedROTCov(0,0),
178  transformedTrkCov(0,0),
179  resType);
180  } else {
182  transformedROTCov(0,0),
183  0.,
184  resType);
185  }
186 
187  } else {
188  if (measurement->localParameters().parameterKey() != 1) {
189  ATH_MSG_WARNING ("TGC ClusterOnTrack does not carry the expected "
190  << "LocalParameters structure!" );
191  return std::nullopt;
192  } else {
193  // convention to be interpreted by TrkValTools: 2nd coordinate codes orientation of TGC
194  residual[Trk::loc1] = measurement->localParameters()[Trk::loc1]
195  - trkPar->parameters()[Trk::loc1];
196  // calculate pull
197  if (pullIsValid)
199  measurement->localCovariance()(Trk::loc1,Trk::loc1),
200  (*trkCov)(Trk::loc1,Trk::loc1),
201  resType);
202  else
204  measurement->localCovariance()(Trk::loc1,Trk::loc1),
205  0,
206  resType);
207  }
208  }
209  // create the Trk::ResidualPull.
210  ATH_MSG_VERBOSE ( "Calculating Pull for channel " << m_idHelperSvc->toString(ID) << " residual " << residual[Trk::loc1] << " pull " << pull[Trk::loc1] );
211 
212  return std::make_optional<Trk::ResidualPull>(std::move(residual), std::move(pull), pullIsValid, resType, 1, sinAlpha);
213 
214  } else {
215  ATH_MSG_DEBUG ( "Input problem measurement is not TGC." );
216  return std::nullopt;
217  }
218 }

◆ residuals()

std::array< double, 5 > Muon::TGC_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.

Implements Trk::IResidualPullCalculator.

Definition at line 30 of file TGC_ResidualPullCalculator.cxx.

34  {
35  std::array<double,5> residuals{};
36  const Trk::RIO_OnTrack* rot = dynamic_cast<const Trk::RIO_OnTrack*>(measurement);
37  if (!rot) {
38  const Muon::CompetingMuonClustersOnTrack* muonCompClusters =
39  dynamic_cast<const Muon::CompetingMuonClustersOnTrack*>(measurement);
40  if (muonCompClusters) rot = muonCompClusters->containedROTs().empty() ? nullptr :
41  muonCompClusters->containedROTs().front();
42  }
43  if (!trkPar || !rot) {
44  if( !trkPar ) ATH_MSG_WARNING ("No TrackParameters, cannot calculate residual/pull ");
45  if( !rot ) ATH_MSG_WARNING ("No ROT, cannot calculate residual/pull ");
46  return residuals;
47  }
48  Identifier ID = rot->identify();
49 
50  if( m_idHelperSvc->isTgc(ID) ) {
51 
52  double sinAlpha = 0.0;
53 
54  bool isStrip = m_idHelperSvc->tgcIdHelper().isStrip(ID);
55 
56  // calculate residual
57  if (isStrip) {
58  // consistency check that Muon EDM is as expected
59  if (measurement->localParameters().parameterKey() !=3) {
60  ATH_MSG_WARNING ( "TGC ClusterOnTrack does not carry the expected "
61  << "LocalParameters structure!");
62  return residuals;
63  }
64  // get orientation angle of strip to rotate back from local frame to strip
65  const Amg::MatrixX &covmat=measurement->localCovariance();
66  double v0=0.5*(covmat(0,0)+covmat(1,1)-sqrt((covmat(0,0)+covmat(1,1))*(covmat(0,0)+covmat(1,1))-
67  4*(covmat(0,0)*covmat(1,1)-covmat(0,1)*covmat(0,1))));
68  double v1=0.5*(covmat(0,0)+covmat(1,1)+sqrt((covmat(0,0)+covmat(1,1))*(covmat(0,0)+covmat(1,1))-
69  4*(covmat(0,0)*covmat(1,1)-covmat(0,1)*covmat(0,1))));
70  sinAlpha=std::sin(0.5*std::asin(2*covmat(0,1)/(v0-v1)));
71 
72  double cosAlpha = std::sqrt(1 - sinAlpha*sinAlpha);
73 
74  // Calculate Residual for hit: res = (vec(x_hit) - vec(x_track)) * vec(n_perpendicular)
76  (measurement->localParameters()[Trk::locX] - trkPar->parameters()[Trk::locX]) * cosAlpha
77  + (measurement->localParameters()[Trk::locY] - trkPar->parameters()[Trk::locY]) * sinAlpha;
78 
79  } else {
80  if (measurement->localParameters().parameterKey() != 1) {
81  ATH_MSG_WARNING ("TGC ClusterOnTrack does not carry the expected "
82  << "LocalParameters structure!" );
83  return residuals;
84  } else {
85  // convention to be interpreted by TrkValTools: 2nd coordinate codes orientation of TGC
86  residuals[Trk::loc1] = measurement->localParameters()[Trk::loc1]
87  - trkPar->parameters()[Trk::loc1];
88  }
89  }
90  } else {
91  ATH_MSG_DEBUG ( "Input problem measurement is not TGC." );
92  return residuals;
93  }
94  return residuals;
95 }

◆ 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 DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ 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) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

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_idHelperSvc

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

Definition at line 68 of file TGC_ResidualPullCalculator.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:
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
ID
std::vector< Identifier > ID
Definition: CalibHitIDCheck.h:24
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
Trk::LocalParameters::parameterKey
int parameterKey() const
Identifier key for matrix expansion/reduction.
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
plotBeamSpotVxVal.covmat
covmat
Definition: plotBeamSpotVxVal.py:206
Trk::ResidualPull::Unbiased
@ Unbiased
RP with track state that has measurement not included.
Definition: ResidualPull.h:57
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
Trk::RIO_OnTrack
Definition: RIO_OnTrack.h:70
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Muon::CompetingMuonClustersOnTrack
Definition: CompetingMuonClustersOnTrack.h:54
AmgSymMatrix
#define AmgSymMatrix(dim)
Definition: EventPrimitives.h:50
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
parseMapping.v0
def v0
Definition: parseMapping.py:149
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MuonGM::TgcReadoutElement
A TgcReadoutElement corresponds to a single TGC chamber; therefore typically a TGC station contains s...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/TgcReadoutElement.h:42
python.StandardJetMods.pull
pull
Definition: StandardJetMods.py:282
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
Trk::MeasurementBase::localCovariance
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
Definition: MeasurementBase.h:138
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
dumpTgcDigiThreshold.isStrip
list isStrip
Definition: dumpTgcDigiThreshold.py:33
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Muon::CompetingMuonClustersOnTrack::containedROTs
const std::vector< const MuonClusterOnTrack * > & containedROTs() const
returns the vector of SCT_ClusterOnTrack objects .
Definition: CompetingMuonClustersOnTrack.h:184
Trk::MeasurementBase::localParameters
const LocalParameters & localParameters() const
Interface method to get the LocalParameters.
Definition: MeasurementBase.h:132
Trk::ResidualPull::Biased
@ Biased
RP with track state including the hit.
Definition: ResidualPull.h:55
a
TList * a
Definition: liststreamerinfos.cxx:10
Muon::TGC_ResidualPullCalculator::calcPull
double calcPull(const double residual, const double locMesCov, const double locTrkCov, const Trk::ResidualPull::ResidualType &) const
internal structuring: common code for calculating hit pulls
Definition: TGC_ResidualPullCalculator.cxx:223
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition: RIO_OnTrack.h:152
Muon::TGC_ResidualPullCalculator::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: TGC_ResidualPullCalculator.h:68
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
Trk::RIO_OnTrack::detectorElement
virtual const TrkDetElementBase * detectorElement() const =0
returns the detector element, assoicated with the PRD of this class
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Muon::TGC_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: TGC_ResidualPullCalculator.cxx:30
Trk::loc1
@ loc1
Definition: ParamDefs.h:34
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
fitman.k
k
Definition: fitman.py:528
Identifier
Definition: IdentifierFieldParser.cxx:14