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, V, H > &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, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &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
 
IntegerProperty m_resType
 
BooleanProperty m_includeScatterers {this, "IncludeScatterers", false}
 
double m_qOverP {}
 
double m_previousQOverP {}
 
int m_nDoF {}
 
double * m_chi2ForMeasType = nullptr
 
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 39 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 24 of file AlignResidualCalculator.cxx.

26  {
27  declareInterface<IAlignResidualCalculator>(this);
28  }

◆ ~AlignResidualCalculator()

AlignResidualCalculator::~AlignResidualCalculator ( )
virtual

Definition at line 31 of file AlignResidualCalculator.cxx.

32  {
33  delete [] m_chi2ForMeasType;
34  }

Member Function Documentation

◆ accumulateScattering()

void AlignResidualCalculator::accumulateScattering ( const TrackStateOnSurface tsos)
private

Definition at line 290 of file AlignResidualCalculator.cxx.

291  {
292 
293  const MaterialEffectsOnTrack* meot = dynamic_cast<const MaterialEffectsOnTrack*>(tsos->materialEffectsOnTrack());
294  const TrackParameters* tpar = tsos->trackParameters();
295 
296  m_qOverP = tpar->charge()/tpar->pT()*sin( tpar->parameters()[Trk::theta]);
297 
298  if(!meot) return;
299  const EnergyLoss* energyLoss = meot->energyLoss();
300 
301 
302  if (!dynamic_cast<const CaloEnergy*>(energyLoss)) {
304  }
305 
306  }

◆ 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 64 of file AlignResidualCalculator.h.

65  { return m_chi2ForMeasType[measType]; }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > &  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, V, H > &  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, V, H > &  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, V, H > &  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, V, H > &  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 61 of file AlignResidualCalculator.cxx.

62  {
63  return StatusCode::SUCCESS;
64  }

◆ getMatchingTSOS()

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

Definition at line 310 of file AlignResidualCalculator.cxx.

311  {
312  const TrackStateOnSurface* tsos(nullptr);
313 
314  if (atsos->rio() || atsos->crio()) {
315 
316  for (const TrackStateOnSurface* itTsos : *track->trackStateOnSurfaces()) {
317  if (itTsos->type(TrackStateOnSurface::Outlier))
318  continue;
319 
320  const MeasurementBase* mesb = itTsos->measurementOnTrack();
321  const RIO_OnTrack* rio = dynamic_cast<const RIO_OnTrack*>(mesb);
322  const CompetingRIOsOnTrack* crio = dynamic_cast<const CompetingRIOsOnTrack*>(mesb);
323 
324  if (!rio && crio) {
325  rio = &(crio->rioOnTrack(0));
326  }
327  if (!rio) continue;
328  if (rio->identify() == atsos->rio()->identify()) {
329  ATH_MSG_DEBUG("matched TSOS with identifier: "<<rio->identify());
330  tsos=itTsos;
331  break;
332  }
333  }
334  ATH_MSG_DEBUG("done with measurement");
335  }
336  else {
337 
338  const Amg::Vector3D origPosition=atsos->trackParameters()->position();
339  double distance2(1.e27);
340 
341  // loop over track and get closest TSOS
342  for (const TrackStateOnSurface* itTsos : *track->trackStateOnSurfaces()) {
343  if (itTsos->type(TrackStateOnSurface::Outlier))
344  continue;
345  if (!dynamic_cast<const MaterialEffectsOnTrack*>(itTsos->materialEffectsOnTrack())) continue;
346  if (!itTsos->trackParameters()) { ATH_MSG_WARNING("no track parameters!"); continue; }
347  const Amg::Vector3D newPosition=itTsos->trackParameters()->position();
348  ATH_MSG_DEBUG("origPos: "<<origPosition<<", newPos: "<<newPosition);
349  double newdist2=(newPosition - origPosition).mag2();
350  if (newdist2<distance2) {
351  distance2=newdist2;
352  tsos=itTsos;
353  }
354  }
355  ATH_MSG_DEBUG("done with scatterer");
356  }
357  if (!tsos) return nullptr;
358  const Amg::Vector3D addPosition=tsos->trackParameters()->position();
359  if (std::find(m_matchedTSOS.begin(),m_matchedTSOS.end(),tsos)==m_matchedTSOS.end()) {
360  m_matchedTSOS.push_back(tsos);
361  ATH_MSG_DEBUG("added tsos with pos: "<<addPosition);
362  }
363  else {
364  ATH_MSG_WARNING("TSOS already found with position "<<addPosition<<"!");
365  }
366  return tsos;
367  }

◆ initialize()

StatusCode AlignResidualCalculator::initialize ( )
overridevirtual

Implements Trk::IAlignResidualCalculator.

Definition at line 37 of file AlignResidualCalculator.cxx.

38  {
39  // get residual pull calculator
40  if (m_pullCalculator.retrieve().isFailure()) {
41  ATH_MSG_FATAL("Could not get " << m_pullCalculator);
42  return StatusCode::FAILURE;
43  }
44  ATH_MSG_INFO("Retrieved " << m_pullCalculator);
45 
46  // get updator
47  if(m_resType==Unbiased) {
48  if (m_updator.retrieve().isFailure()) {
49  ATH_MSG_FATAL("Could not get " << m_updator);
50  return StatusCode::FAILURE;
51  }
52  ATH_MSG_INFO("Retrieved " << m_pullCalculator);
53  }
54 
55  ATH_MSG_INFO("Using"<<static_cast<AlignResidualType>(m_resType.value())<<"residuals.");
56 
57  return StatusCode::SUCCESS;
58  }

◆ 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 74 of file AlignResidualCalculator.cxx.

75  {
76  bool useNewTrack = (track!=nullptr);
77  const Track* newTrack = (useNewTrack) ? track : alignTrack;
78  return setResiduals(alignTrack->firstAtsos(), alignTrack->lastAtsos(), newTrack, useNewTrack);
79  }

◆ 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 130 of file AlignResidualCalculator.cxx.

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

◆ 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 = nullptr
private

Definition at line 88 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

BooleanProperty Trk::AlignResidualCalculator::m_includeScatterers {this, "IncludeScatterers", false}
private

Definition at line 82 of file AlignResidualCalculator.h.

◆ m_matchedTSOS

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

Definition at line 90 of file AlignResidualCalculator.h.

◆ m_nDoF

int Trk::AlignResidualCalculator::m_nDoF {}
private

Definition at line 86 of file AlignResidualCalculator.h.

◆ m_previousQOverP

double Trk::AlignResidualCalculator::m_previousQOverP {}
private

Definition at line 84 of file AlignResidualCalculator.h.

◆ m_pullCalculator

ToolHandle<IResidualPullCalculator> Trk::AlignResidualCalculator::m_pullCalculator
private
Initial value:
{
this, "ResidualPullCalculator", "Trk::ResidualPullCalculator/ResidualPullCalculator"}

Definition at line 73 of file AlignResidualCalculator.h.

◆ m_qOverP

double Trk::AlignResidualCalculator::m_qOverP {}
private

Definition at line 83 of file AlignResidualCalculator.h.

◆ m_resType

IntegerProperty Trk::AlignResidualCalculator::m_resType
private
Initial value:
{
this, "ResidualType", Trk::AlignResidualType::HitOnly,
"residual type as defined in the Trk::AlignResidualType enum"}

Definition at line 78 of file AlignResidualCalculator.h.

◆ m_updator

ToolHandle<IUpdator> Trk::AlignResidualCalculator::m_updator
private
Initial value:
{
this, "UpdatorTool", "Trk::KalmanUpdator/TrkKalmanUpdator"}

Definition at line 75 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:
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
Trk::TrackState::Pixel
@ Pixel
Definition: TrackStateDefs.h:28
Trk::HitOnly
@ HitOnly
Definition: AlignResidualType.h:27
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:90
ClusterSeg::residual
@ residual
Definition: ClusterNtuple.h:20
Trk::ParamDefs
ParamDefs
Definition: ParamDefs.h:32
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::AlignResidualCalculator::m_resType
IntegerProperty m_resType
Definition: AlignResidualCalculator.h:78
Trk::TrackState::unidentified
@ unidentified
Definition: TrackStateDefs.h:27
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
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
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:29
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
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:88
Trk::Measurement
@ Measurement
Definition: AlignResidualType.h:33
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
Trk::AlignResidualCalculator::m_qOverP
double m_qOverP
Definition: AlignResidualCalculator.h:83
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:66
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.
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:11
Trk::EnergyLoss::deltaE
double deltaE() const
returns the
test_pyathena.parent
parent
Definition: test_pyathena.py:15
python.StandardJetMods.pull
pull
Definition: StandardJetMods.py:304
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:86
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
Trk::TrackParameters
ParametersBase< TrackParametersDim, Charged > TrackParameters
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:27
Trk::AlignResidualCalculator::m_pullCalculator
ToolHandle< IResidualPullCalculator > m_pullCalculator
Definition: AlignResidualCalculator.h:73
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:75
Trk::AlignResidualCalculator::m_includeScatterers
BooleanProperty m_includeScatterers
Definition: AlignResidualCalculator.h:82
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
Trk::AlignResidualCalculator::m_previousQOverP
double m_previousQOverP
Definition: AlignResidualCalculator.h:84
Trk::MaterialEffectsOnTrack::scatteringAngles
const ScatteringAngles * scatteringAngles() const
returns the MCS-angles object.
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:629
AlignResidualType
AlignResidualType is an enum describing the type of residual AlignMesType is an enum describing the t...
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
xAOD::track
@ track
Definition: TrackingPrimitives.h:513
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:34
mag2
Scalar mag2() const
mag2 method - forward to squaredNorm()
Definition: AmgMatrixBasePlugin.h:31
fitman.k
k
Definition: fitman.py:528