ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Trk::AlignResidualCalculator Class Reference

#include <AlignResidualCalculator.h>

Inheritance diagram for Trk::AlignResidualCalculator:
Collaboration diagram for Trk::AlignResidualCalculator:

Public Member Functions

 AlignResidualCalculator (const std::string &type, const std::string &name, const IInterface *parent)
 
virtual ~AlignResidualCalculator ()
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
virtual double setResiduals (DataVector< AlignTSOS > *alignTSOSColl, const Track *track) override
 sets residuals for AlignTSOS on AlignTrack and returns total chi2 More...
 
virtual double setResiduals (AlignTrack *alignTrack, const Track *track) override
 sets residuals for AlignTSOS on AlignTrack and returns total chi2 More...
 
virtual double setResiduals (DataVector< AlignTSOS >::iterator firstAtsos, DataVector< AlignTSOS >::iterator lastAtsos, const Track *track, bool newTrack) override
 sets residuals for AlignTSOS on AlignTrack and returns total chi2 More...
 
virtual double chi2ForMeasType (int measType) const override
 returns chi2 summed over hits of a particular MeasurementType 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 ()
 

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 setResidualsOnATSOS (AlignTSOS *atsos, const TrackStateOnSurface *tsos)
 
void accumulateScattering (const TrackStateOnSurface *tsos)
 
const TrackStateOnSurfacegetMatchingTSOS (const AlignTSOS *atsos, const Track *track)
 
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

ToolHandle< IResidualPullCalculatorm_pullCalculator
 
ToolHandle< IUpdatorm_updator
 
int m_resType
 
bool m_includeScatterers
 
double m_qOverP
 
double m_previousQOverP
 
int m_nDoF
 
double * m_chi2ForMeasType
 
std::vector< const TrackStateOnSurface * > m_matchedTSOS
 
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

Definition at line 37 of file AlignResidualCalculator.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

◆ AlignResidualCalculator()

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

Definition at line 26 of file AlignResidualCalculator.cxx.

30  , m_pullCalculator("Trk::ResidualPullCalculator/ResidualPullCalculator")
31  , m_updator("Trk::KalmanUpdator/TrkKalmanUpdator")
32  , m_qOverP{}
34  , m_nDoF{}
35  , m_chi2ForMeasType(nullptr)
36  {
37  declareInterface<IAlignResidualCalculator>(this);
38 
39  declareProperty("ResidualPullCalculator", m_pullCalculator);
40  declareProperty("ResidualType", m_resType = HitOnly);
41  declareProperty("IncludeScatterers", m_includeScatterers = false );
42 
43  declareProperty("UpdatorTool", m_updator);
44  }

◆ ~AlignResidualCalculator()

AlignResidualCalculator::~AlignResidualCalculator ( )
virtual

Definition at line 47 of file AlignResidualCalculator.cxx.

48  {
49  delete [] m_chi2ForMeasType;
50  }

Member Function Documentation

◆ accumulateScattering()

void AlignResidualCalculator::accumulateScattering ( const TrackStateOnSurface tsos)
private

Definition at line 309 of file AlignResidualCalculator.cxx.

310  {
311 
312  const MaterialEffectsOnTrack* meot = dynamic_cast<const MaterialEffectsOnTrack*>(tsos->materialEffectsOnTrack());
313  const TrackParameters* tpar = tsos->trackParameters();
314 
315  m_qOverP = tpar->charge()/tpar->pT()*sin( tpar->parameters()[Trk::theta]);
316 
317  if(!meot) return;
318  const EnergyLoss* energyLoss = meot->energyLoss();
319 
320 
321  if (!dynamic_cast<const CaloEnergy*>(energyLoss)) {
323  }
324 
325  }

◆ chi2ForMeasType()

virtual double Trk::AlignResidualCalculator::chi2ForMeasType ( int  measType) const
inlineoverridevirtual

returns chi2 summed over hits of a particular MeasurementType

Implements Trk::IAlignResidualCalculator.

Definition at line 62 of file AlignResidualCalculator.h.

63  { return m_chi2ForMeasType[measType]; }

◆ 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

◆ finalize()

StatusCode AlignResidualCalculator::finalize ( )
overridevirtual

Implements Trk::IAlignResidualCalculator.

Definition at line 77 of file AlignResidualCalculator.cxx.

78  {
79  return StatusCode::SUCCESS;
80  }

◆ getMatchingTSOS()

const TrackStateOnSurface * AlignResidualCalculator::getMatchingTSOS ( const AlignTSOS atsos,
const Track track 
)
private

Definition at line 329 of file AlignResidualCalculator.cxx.

330  {
331  const TrackStateOnSurface* tsos(nullptr);
332 
333  if (atsos->rio() || atsos->crio()) {
334 
335  for (const TrackStateOnSurface* itTsos : *track->trackStateOnSurfaces()) {
336  if (itTsos->type(TrackStateOnSurface::Outlier))
337  continue;
338 
339  const MeasurementBase* mesb = itTsos->measurementOnTrack();
340  const RIO_OnTrack* rio = dynamic_cast<const RIO_OnTrack*>(mesb);
341  const CompetingRIOsOnTrack* crio = dynamic_cast<const CompetingRIOsOnTrack*>(mesb);
342 
343  if (!rio && crio) {
344  rio = &(crio->rioOnTrack(0));
345  }
346  if (!rio) continue;
347  if (rio->identify() == atsos->rio()->identify()) {
348  ATH_MSG_DEBUG("matched TSOS with identifier: "<<rio->identify());
349  tsos=itTsos;
350  break;
351  }
352  }
353  ATH_MSG_DEBUG("done with measurement");
354  }
355  else {
356 
357  const Amg::Vector3D origPosition=atsos->trackParameters()->position();
358  double distance2(1.e27);
359 
360  // loop over track and get closest TSOS
361  for (const TrackStateOnSurface* itTsos : *track->trackStateOnSurfaces()) {
362  if (itTsos->type(TrackStateOnSurface::Outlier))
363  continue;
364  if (!dynamic_cast<const MaterialEffectsOnTrack*>(itTsos->materialEffectsOnTrack())) continue;
365  if (!itTsos->trackParameters()) { ATH_MSG_WARNING("no track parameters!"); continue; }
366  const Amg::Vector3D newPosition=itTsos->trackParameters()->position();
367  ATH_MSG_DEBUG("origPos: "<<origPosition<<", newPos: "<<newPosition);
368  double newdist2=(newPosition - origPosition).mag2();
369  if (newdist2<distance2) {
370  distance2=newdist2;
371  tsos=itTsos;
372  }
373  }
374  ATH_MSG_DEBUG("done with scatterer");
375  }
376  if (!tsos) return nullptr;
377  const Amg::Vector3D addPosition=tsos->trackParameters()->position();
378  if (std::find(m_matchedTSOS.begin(),m_matchedTSOS.end(),tsos)==m_matchedTSOS.end()) {
379  m_matchedTSOS.push_back(tsos);
380  ATH_MSG_DEBUG("added tsos with pos: "<<addPosition);
381  }
382  else {
383  ATH_MSG_WARNING("TSOS already found with position "<<addPosition<<"!");
384  //return 0;
385  }
386  return tsos;
387  }

◆ initialize()

StatusCode AlignResidualCalculator::initialize ( )
overridevirtual

Implements Trk::IAlignResidualCalculator.

Definition at line 53 of file AlignResidualCalculator.cxx.

54  {
55  // get residual pull calculator
56  if (m_pullCalculator.retrieve().isFailure()) {
57  msg(MSG::FATAL) << "Could not get " << m_pullCalculator << endmsg;
58  return StatusCode::FAILURE;
59  }
60  ATH_MSG_INFO("Retrieved " << m_pullCalculator);
61 
62  // get updator
63  if(m_resType==Unbiased) {
64  if (m_updator.retrieve().isFailure()) {
65  msg(MSG::FATAL) << "Could not get " << m_updator << endmsg;
66  return StatusCode::FAILURE;
67  }
68  ATH_MSG_INFO("Retrieved " << m_pullCalculator);
69  }
70 
71  ATH_MSG_INFO("Using"<<AlignResidualType(m_resType)<<"residuals.");
72 
73  return StatusCode::SUCCESS;
74  }

◆ 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 & IAlignResidualCalculator::interfaceID ( )
inlinestaticinherited

Definition at line 58 of file IAlignResidualCalculator.h.

59  { return IID_TRKALIGNINTERFACES_IAlignResidualCalculator; }

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

◆ setResiduals() [1/3]

double AlignResidualCalculator::setResiduals ( AlignTrack alignTrack,
const Track track 
)
overridevirtual

sets residuals for AlignTSOS on AlignTrack and returns total chi2

Implements Trk::IAlignResidualCalculator.

Definition at line 90 of file AlignResidualCalculator.cxx.

91  {
92  bool useNewTrack = (track!=nullptr);
93  const Track* newTrack = (useNewTrack) ? track : alignTrack;
94  return setResiduals(alignTrack->firstAtsos(), alignTrack->lastAtsos(), newTrack, useNewTrack);
95  }

◆ setResiduals() [2/3]

virtual double Trk::AlignResidualCalculator::setResiduals ( DataVector< AlignTSOS > *  alignTSOSColl,
const Track track 
)
overridevirtual

sets residuals for AlignTSOS on AlignTrack and returns total chi2

Implements Trk::IAlignResidualCalculator.

◆ setResiduals() [3/3]

virtual double Trk::AlignResidualCalculator::setResiduals ( DataVector< AlignTSOS >::iterator  firstAtsos,
DataVector< AlignTSOS >::iterator  lastAtsos,
const Track track,
bool  newTrack 
)
overridevirtual

sets residuals for AlignTSOS on AlignTrack and returns total chi2

Implements Trk::IAlignResidualCalculator.

◆ setResidualsOnATSOS()

double AlignResidualCalculator::setResidualsOnATSOS ( AlignTSOS atsos,
const TrackStateOnSurface tsos 
)
private

Definition at line 151 of file AlignResidualCalculator.cxx.

152  {
153  // this method does the following:
154  // 1. gets residuals (measurement and scattering dimensions),
155  // 2. adds to AlignTSOS, and
156  // 3. returns contribution to chi2 from this ATSOS
157 
158  ATH_MSG_DEBUG("in setResidualsOnATSOS");
159 
160  atsos->clearResiduals();
161 
162  double dchi2(0.);
163 
164  // scattering residual(s) and/or energy loss first
165  if (m_includeScatterers) {
166  ATH_MSG_DEBUG("scatterer");
167 
168  // when using unbiased residuals including scatterers doesn't make sense
169  if(m_resType == Unbiased)
170  ATH_MSG_WARNING("When using unbiased residuals including scatterers doesn't make sense!");
171 
172  const MaterialEffectsBase* meb = tsos->materialEffectsOnTrack();
173  const Trk::MaterialEffectsOnTrack* meot = dynamic_cast<const MaterialEffectsOnTrack*>(meb);
174  const ScatteringAngles* scatterer = (meot) ? meot->scatteringAngles() : nullptr;
175 
176  int nscatparam=0;
177  if (meb && meot)
178  nscatparam = (scatterer) ? 2 : 1;
179 
180  for (int iparam=0;iparam<nscatparam;iparam++) {
181 
182  double errSq=0.;
183  double residual(-999.);
184 
185  if (nscatparam==2) {
186 
187  const Trk::TrackParameters * tparp = tsos->trackParameters();
188  if (tparp) {
189  if (iparam==0) {
190  residual=-scatterer->deltaPhi()* sin (tparp->parameters()[Trk::theta]);
191  errSq = scatterer->sigmaDeltaTheta();
192  ATH_MSG_DEBUG("sigmaDeltaTheta="<<scatterer->sigmaDeltaTheta());
193  ATH_MSG_DEBUG("sigmaDeltaPhi ="<<scatterer->sigmaDeltaPhi());
194  ATH_MSG_DEBUG("residual:"<<residual<<", errSq: "<<errSq<<", err="<<std::sqrt(errSq));
195  errSq *= errSq;
196  }
197  else{
198  residual=-scatterer->deltaTheta();
199  errSq = scatterer->sigmaDeltaTheta();
200  errSq *= errSq;
201  }
202  }
203  else{
204  ATH_MSG_WARNING("scatterer has no TrackParameters!");
205  }
206 
208  atsos->addResidual(res);
209 
210  dchi2 += res.residualNorm()*res.residualNorm();
211  m_nDoF++;
212  }
213  else if (!atsos->rio() && !atsos->crio()) {
214  ATH_MSG_DEBUG("energy deposit");
215 
216  // energy deposit
217  double E0 = 1./std::fabs(m_previousQOverP);
218  double E1 = 1./std::fabs(m_qOverP);
219  double energyLoss= std::fabs(meot->energyLoss()->deltaE());
220 
221  double residual = .001*(E0-E1-energyLoss);
222  double errSq = .001*meot->energyLoss()->sigmaDeltaE();
223 
224  ATH_MSG_DEBUG("E0/E1/energyLoss: "<<E0<<"/"<<E1<<"/"<<energyLoss);
225  ATH_MSG_DEBUG("calorimeter residual: "<<residual/errSq);
226 
227  errSq*=errSq;
228 
230  atsos->addResidual(res);
231  dchi2 += res.residualNorm()*res.residualNorm();
232  m_nDoF++;
233  }
234  }
235  }
236 
237  // residuals from measurement
238  if (atsos->rio() || atsos->crio()) {
239 
240  int nparams = (atsos->measType()==TrackState::Pixel) ? 2 : 1;
241  for (int iparam=0;iparam<nparams;iparam++) {
242 
243  double errSq=0.;
244  double residual(-999.);
245 
246  if ( atsos->measType()!=TrackState::unidentified &&
247  (atsos->rio()!=nullptr || atsos->crio()!=nullptr) ) {
248 
249  const MeasurementBase* mesb = tsos->measurementOnTrack();
250 
251  const TrackParameters * trackPars = tsos->trackParameters();
252  std::optional<ResidualPull> resPull = std::nullopt;
253 
254  if ( trackPars ) {
255 
256  if (m_resType == Unbiased) {
257  // Get unbiased state
258  const Trk::TrackParameters * unbiasedTrackPars =
259  m_updator->removeFromState(*trackPars,
260  mesb->localParameters(),
261  mesb->localCovariance()).release();
262  if (unbiasedTrackPars) {
263  trackPars = unbiasedTrackPars;
264  // AlignTSOS desctructor takes care of deleting unbiasedTrackPars
265  atsos->setUnbiasedTrackPars(unbiasedTrackPars);
266  }
267  else
268  ATH_MSG_WARNING("Could not get unbiased track parameters, use normal parameters");
269  }
270 
271  ATH_MSG_DEBUG("Calling ResidualPullCalculator for residual type "
273  <<" (AlignResidualType "<<AlignResidualType(m_resType)
274  <<" "<<m_resType<<")");
275  ATH_MSG_DEBUG("mesb->localErrorMatrix().covValue(Trk::loc1): "<<mesb->localCovariance()(Trk::loc1,Trk::loc1));
276  resPull = m_pullCalculator->residualPull(mesb, trackPars,
278  atsos->measType());
279  if ( resPull ) {
280  residual = (resPull->residual())[iparam];
281  double pull=(resPull->pull())[iparam];
282  if (pull!=0.) {
283  errSq = residual/pull;
284  errSq *= errSq;
285  }
286  ATH_MSG_DEBUG("residual="<<residual<<", pull="<<pull);
287  ATH_MSG_DEBUG("pos: ("<<mesb->globalPosition().x()<<", "
288  <<mesb->globalPosition().y()<<", "
289  <<mesb->globalPosition().z()<<")");
290  ATH_MSG_DEBUG("residual:"<<residual<<", errSq: "<<errSq<<", err="<<std::sqrt(errSq));
291  }
292  }
293  }
294  else {
295  ATH_MSG_WARNING("Expected measurement for atsos of type "
296  << atsos->dumpType()<<", meas type "<<atsos->measType() );
297  }
298 
300  atsos->addResidual(res);
301  dchi2 += res.residualNorm()*res.residualNorm();
302  m_nDoF++;
303  }
304  }
305  return dchi2;
306  }

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

double* Trk::AlignResidualCalculator::m_chi2ForMeasType
private

Definition at line 82 of file AlignResidualCalculator.h.

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

bool Trk::AlignResidualCalculator::m_includeScatterers
private

Definition at line 76 of file AlignResidualCalculator.h.

◆ m_matchedTSOS

std::vector<const TrackStateOnSurface*> Trk::AlignResidualCalculator::m_matchedTSOS
private

Definition at line 84 of file AlignResidualCalculator.h.

◆ m_nDoF

int Trk::AlignResidualCalculator::m_nDoF
private

Definition at line 80 of file AlignResidualCalculator.h.

◆ m_previousQOverP

double Trk::AlignResidualCalculator::m_previousQOverP
private

Definition at line 78 of file AlignResidualCalculator.h.

◆ m_pullCalculator

ToolHandle<IResidualPullCalculator> Trk::AlignResidualCalculator::m_pullCalculator
private

Definition at line 71 of file AlignResidualCalculator.h.

◆ m_qOverP

double Trk::AlignResidualCalculator::m_qOverP
private

Definition at line 77 of file AlignResidualCalculator.h.

◆ m_resType

int Trk::AlignResidualCalculator::m_resType
private

Definition at line 74 of file AlignResidualCalculator.h.

◆ m_updator

ToolHandle<IUpdator> Trk::AlignResidualCalculator::m_updator
private

Definition at line 72 of file AlignResidualCalculator.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:
Trk::TrackState::Pixel
@ Pixel
Definition: TrackStateDefs.h:28
Trk::HitOnly
@ HitOnly
Definition: AlignResidualType.h:27
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloEnergy
class extending the basic Trk::EnergyLoss to describe the measured or parameterised muon energy loss ...
Definition: CaloEnergy.h:28
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
Trk::AlignResidualCalculator::m_matchedTSOS
std::vector< const TrackStateOnSurface * > m_matchedTSOS
Definition: AlignResidualCalculator.h:84
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trk::AlignResidualType
AlignResidualType
Definition: AlignResidualType.h:26
Trk::ParamDefs
ParamDefs
Definition: ParamDefs.h:38
Trk::EnergyLoss::sigmaDeltaE
double sigmaDeltaE() const
returns the symmatric error
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::ResidualPullType
ResidualPull::ResidualType ResidualPullType(AlignResidualType type)
Definition: AlignResidualType.cxx:41
Trk::Unbiased
@ Unbiased
Definition: AlignResidualType.h:28
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::TrackParameters
ParametersBase< 5, Charged > TrackParameters
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:24
Trk::TrackState::unidentified
@ unidentified
Definition: TrackStateDefs.h:27
Trk::AlignResidualCalculator::m_resType
int m_resType
Definition: AlignResidualCalculator.h:74
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
Trk::EnergyDeposit
@ EnergyDeposit
Definition: AlignResidualType.h:35
Trk::TrackStateOnSurface::Outlier
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
Definition: TrackStateOnSurface.h:122
Trk::MaterialEffectsOnTrack
represents the full description of deflection and e-loss of a track in material.
Definition: MaterialEffectsOnTrack.h:40
Trk::AlignResidualCalculator::m_chi2ForMeasType
double * m_chi2ForMeasType
Definition: AlignResidualCalculator.h:82
Trk::AlignResidualCalculator::m_includeScatterers
bool m_includeScatterers
Definition: AlignResidualCalculator.h:76
Trk::Measurement
@ Measurement
Definition: AlignResidualType.h:33
Trk::AlignResidualCalculator::m_qOverP
double m_qOverP
Definition: AlignResidualCalculator.h:77
Trk::Scatterer
@ Scatterer
Definition: AlignResidualType.h:34
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::MeasurementBaseType::CompetingRIOsOnTrack
@ CompetingRIOsOnTrack
Definition: MeasurementBase.h:50
Trk::theta
@ theta
Definition: ParamDefs.h:72
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Residual
Residual is a class that stores the residual, error, and type of residual.
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
Trk::EnergyLoss::deltaE
double deltaE() const
returns the
test_pyathena.parent
parent
Definition: test_pyathena.py:15
python.StandardJetMods.pull
pull
Definition: StandardJetMods.py:264
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
Trk::ParametersBase
Definition: ParametersBase.h:55
AthAlgTool::AthAlgTool
AthAlgTool()
Default constructor:
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
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
Trk::AlignResidualCalculator::m_nDoF
int m_nDoF
Definition: AlignResidualCalculator.h:80
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trk::AlignResidualCalculator::m_pullCalculator
ToolHandle< IResidualPullCalculator > m_pullCalculator
Definition: AlignResidualCalculator.h:71
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::MeasurementBaseType::RIO_OnTrack
@ RIO_OnTrack
Definition: MeasurementBase.h:49
Trk::AlignResidualCalculator::setResiduals
virtual double setResiduals(DataVector< AlignTSOS > *alignTSOSColl, const Track *track) override
sets residuals for AlignTSOS on AlignTrack and returns total chi2
Trk::AlignResidualCalculator::m_updator
ToolHandle< IUpdator > m_updator
Definition: AlignResidualCalculator.h:72
a
TList * a
Definition: liststreamerinfos.cxx:10
Trk::MaterialEffectsOnTrack::energyLoss
const EnergyLoss * energyLoss() const
returns the energy loss object.
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Trk::AlignResidualCalculator::m_previousQOverP
double m_previousQOverP
Definition: AlignResidualCalculator.h:78
Trk::MaterialEffectsOnTrack::scatteringAngles
const ScatteringAngles * scatteringAngles() const
returns the MCS-angles object.
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
Amg::distance2
float distance2(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the squared distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:48
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Trk::loc1
@ loc1
Definition: ParamDefs.h:40
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition: AmgMatrixBasePlugin.h:30
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