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::NewtonTrkDistanceFinder Class Referencefinal

#include <NewtonTrkDistanceFinder.h>

Inheritance diagram for Trk::NewtonTrkDistanceFinder:
Collaboration diagram for Trk::NewtonTrkDistanceFinder:

Public Member Functions

 NewtonTrkDistanceFinder (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~NewtonTrkDistanceFinder ()
 
virtual StatusCode initialize () override
 
virtual StatusCode finalize () override
 
std::variant< TwoPoints, std::string > GetClosestPoints (const Perigee &a, const Perigee &b) const
 
std::variant< TwoPoints, std::string > GetClosestPoints (const PointOnTrack &, const PointOnTrack &) const
 
std::variant< TwoPoints, std::string > GetClosestPoints (const TwoTracks &twotracks) const
 
std::variant< TwoPoints, std::string > GetClosestPoints (const TwoPointOnTrack &twopointontrack) const
 
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

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

double m_precision
 
double m_maxloopnumber
 
SG::ReadCondHandleKey< AtlasFieldCacheCondObjm_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}
 
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

AlgoTool which uses an iterative Newton method in two dimensions (the two points along the two tracks) in order to find their minimum distance. For each track you can also provade a starting point, in order to avoid local maxima or an undefined quadratic form near a point...

Author
Giaci.nosp@m.nto..nosp@m.Piacq.nosp@m.uadi.nosp@m.o@phy.nosp@m.sik..nosp@m.uni-f.nosp@m.reib.nosp@m.urg.d.nosp@m.e

Definition at line 30 of file NewtonTrkDistanceFinder.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

◆ NewtonTrkDistanceFinder()

Trk::NewtonTrkDistanceFinder::NewtonTrkDistanceFinder ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Definition at line 31 of file NewtonTrkDistanceFinder.cxx.

31  :
32  AthAlgTool(t,n,p),
33  m_precision(1e-8),
34  m_maxloopnumber(20)
35  {
36  declareProperty("Precision",m_precision);
37  declareProperty("MaxLoops",m_maxloopnumber);
38  declareInterface<NewtonTrkDistanceFinder>(this);
39  }

◆ ~NewtonTrkDistanceFinder()

Trk::NewtonTrkDistanceFinder::~NewtonTrkDistanceFinder ( )
virtualdefault

Member Function Documentation

◆ 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 Trk::NewtonTrkDistanceFinder::finalize ( )
overridevirtual

Definition at line 50 of file NewtonTrkDistanceFinder.cxx.

51  {
52  ATH_MSG_DEBUG( "Finalize successful" );
53  return StatusCode::SUCCESS;
54  }

◆ GetClosestPoints() [1/4]

std::variant<TwoPoints, std::string> Trk::NewtonTrkDistanceFinder::GetClosestPoints ( const Perigee a,
const Perigee b 
) const
inline

Definition at line 55 of file NewtonTrkDistanceFinder.h.

55  {
56  //with the constractur of PointOnTrackPar a track is constructed with, as seed,
57  //directly the point of closest approach (see for info PointOnTrack.h)
58  return GetClosestPoints(PointOnTrack(a),PointOnTrack(b));
59  }

◆ GetClosestPoints() [2/4]

std::variant< TwoPoints, std::string > Trk::NewtonTrkDistanceFinder::GetClosestPoints ( const PointOnTrack firsttrack,
const PointOnTrack secondtrack 
) const

Definition at line 57 of file NewtonTrkDistanceFinder.cxx.

59 {
60  //Now the direction of momentum at point of closest approach (but only direction, not versus)
61  const double a_phi0 = firsttrack.getPerigee().parameters()[Trk::phi0];
62  const double a_cosphi0 = -sin(a_phi0);//do i need it?
63  const double a_sinphi0 = cos(a_phi0);//~?
64 
65  //Now initialize the variable you need to go on
66  const double a_x0=firsttrack.getPerigee().associatedSurface().center().x() +
67  firsttrack.getPerigee().parameters()[Trk::d0]*a_cosphi0;
68  const double a_y0=firsttrack.getPerigee().associatedSurface().center().y() +
69  firsttrack.getPerigee().parameters()[Trk::d0]*a_sinphi0;
70  const double a_z0=firsttrack.getPerigee().associatedSurface().center().z() +
71  firsttrack.getPerigee().parameters()[Trk::z0];
72 
73 #ifdef TrkDistance_DEBUG
74  ATH_MSG_DEBUG( "a_x0 " << a_x0 << " a_y0 " << a_y0 << " a_z0 " << a_z0 );
75  ATH_MSG_DEBUG( "m_a_phi0 " << a_phi0 );
76 #endif
77 
78  // Setup magnetic field retrieval
79  SG::ReadCondHandle<AtlasFieldCacheCondObj> readHandle{m_fieldCacheCondObjInputKey, Gaudi::Hive::currentContext()};
80  const AtlasFieldCacheCondObj* fieldCondObj{*readHandle};
81 
82  MagField::AtlasFieldCache fieldCache;
83  fieldCondObj->getInitializedCache (fieldCache);
84 
85  double magnFieldVect[3];
86  double posXYZ[3];
87  posXYZ[0] = firsttrack.getPerigee().associatedSurface().center().x();
88  posXYZ[1] = firsttrack.getPerigee().associatedSurface().center().y();
89  posXYZ[2] = firsttrack.getPerigee().associatedSurface().center().z();
90  fieldCache.getField(posXYZ,magnFieldVect);
91 
92 
93  //Magnetic field at (x0,y0,z0)
94  const double a_Bz=magnFieldVect[2]*299.792;//B field in Gev/mm
95  //EvaluateMagneticField(a_x0,b_y0,b_z0);
96 
97  const double a_Rt = getRadiusOfCurvature(firsttrack.getPerigee(),a_Bz);
98  const double a_cotantheta = 1./tan(firsttrack.getPerigee().parameters()[Trk::theta]);
99 
100 #ifdef TrkDistance_DEBUG
101  ATH_MSG_DEBUG( "a_Rt" << a_Rt << " a_cotantheta " << a_cotantheta );
102  ATH_MSG_DEBUG( "Magnetic field at perigee is " << a_Bz << "GeV/mm " );
103 #endif
104 
105  //Now the direction of momentum at point of closest approach (but only direction, not versus)
106  const double b_phi0 = secondtrack.getPerigee().parameters()[Trk::phi0];
107  const double b_cosphi0 = -sin(b_phi0);//do i need it?
108  const double b_sinphi0 = cos(b_phi0);//~?
109 
110  //Now initialize the variable you need to go on
111  const double b_x0=secondtrack.getPerigee().associatedSurface().center().x() +
112  secondtrack.getPerigee().parameters()[Trk::d0]*b_cosphi0;
113  const double b_y0=secondtrack.getPerigee().associatedSurface().center().y() +
114  secondtrack.getPerigee().parameters()[Trk::d0]*b_sinphi0;
115  const double b_z0=secondtrack.getPerigee().associatedSurface().center().z() +
116  secondtrack.getPerigee().parameters()[Trk::z0];
117 
118 #ifdef TrkDistance_DEBUG
119  ATH_MSG_DEBUG( "b_x0 " << b_x0 << " b_y0 " << b_y0 << " b_z0 " << b_z0 );
120  ATH_MSG_DEBUG( "b_phi0 " << b_phi0 );
121 #endif
122 
123 
124  posXYZ[0] = secondtrack.getPerigee().associatedSurface().center().x();
125  posXYZ[1] = secondtrack.getPerigee().associatedSurface().center().y();
126  posXYZ[2] = secondtrack.getPerigee().associatedSurface().center().z();
127  fieldCache.getField(posXYZ,magnFieldVect);
128 
129  //Magnetic field at (x0,y0,z0)
130  const double b_Bz = magnFieldVect[2]*299.792;//B field in Gev/mm - for the moment use a constant field offline
131  //use the right value expressed in GeV
132  //EvaluateMagneticField(b_x0,b_y0,b_z0);
133 
134  const double b_Rt = getRadiusOfCurvature(secondtrack.getPerigee(),b_Bz);
135  const double b_cotantheta = 1./tan(secondtrack.getPerigee().parameters()[Trk::theta]);
136 
137 #ifdef TrkDistance_DEBUG
138  ATH_MSG_DEBUG( "b_Rt" << b_Rt << " b_cotantheta " << b_cotantheta );
139  ATH_MSG_DEBUG( "Magnetic field at perigee is " << b_Bz << " GeV/mm " );
140 #endif
141 
142 
143  //Now prepare some more elaborate pieces for later
144  const double ab_Dx0 = a_x0-b_x0-a_Rt*a_cosphi0+b_Rt*b_cosphi0;
145  const double ab_Dy0 = a_y0-b_y0-a_Rt*a_sinphi0+b_Rt*b_sinphi0;
146  const double ab_Dz0 = a_z0-b_z0+a_Rt*a_cotantheta*a_phi0-b_Rt*b_cotantheta*b_phi0;
147 
148 #ifdef TrkDistance_DEBUG
149  ATH_MSG_DEBUG( "ab_Dx0 " << ab_Dx0 << " ab_Dy0 " << ab_Dy0 << " ab_Dz0 " << ab_Dz0 );
150 #endif
151 
152 
153  //Prepare the initial point that can be different from point of closest approach
154  //If you don't specify any point the default will be the point of closest approach!!
155  //Another subroutine will be implemented if you want to use
156  //a certain seed
157  double a_phi = firsttrack.getPhiPoint();//this has to be corrected as soon as you adjust the Trk2dDistanceSeeder...
158  double b_phi = secondtrack.getPhiPoint();
159 
160  //store cos and sin of phi
161  double a_cosphi = -sin(a_phi);
162  double a_sinphi = cos(a_phi);
163  double b_cosphi = -sin(b_phi);
164  double b_sinphi = cos(b_phi);
165 
166 
167 #ifdef TrkDistance_DEBUG
168  ATH_MSG_DEBUG( "Beginning phi is a_phi: " << a_phi << " b_phi " << b_phi );
169  ATH_MSG_DEBUG( "LOOP number 0" );
170 #endif
171 
172 
173  int loopsnumber = 0;
174 
175  bool isok=false;
176 
177  while (!isok) {
178 
179 #ifdef TrkDistance_DEBUG
180  ATH_MSG_DEBUG( "Entered LOOP number: " << loopsnumber );
181  ATH_MSG_DEBUG( "actual value of a_phi: " << a_phi << " of b_phi " << b_phi );
182 #endif
183 
184 
185  //count the loop number
186  ++loopsnumber;
187 
188 
189 #ifdef TrkDistance_DEBUG
190  ATH_MSG_DEBUG( "First point x: " << GetClosestPoints().first.x()
191  << "y: " << GetClosestPoints().first.y()
192  << "z: " << GetClosestPoints().first.z() );
193  ATH_MSG_DEBUG( << "Second point x: " << GetClosestPoints().second.x()
194  << "y: " << GetClosestPoints().second.y()
195  << "z: " << GetClosestPoints().second.z() );
196 
197  ATH_MSG_DEBUG( "ActualDistance: " << GetDistance() );
198  ATH_MSG_DEBUG( "real Dx0 " << ab_Dx0+a_Rt*a_cosphi-b_Rt*b_cosphi );
199  ATH_MSG_DEBUG( "real Dy0 " << ab_Dy0+a_Rt*a_sinphi-b_Rt*b_sinphi );
200 #endif
201 
202  //I remove the factor two from the formula
203  const double d1da_phi =
204  (ab_Dx0-b_Rt*b_cosphi)*(-a_Rt*a_sinphi)+
205  (ab_Dy0-b_Rt*b_sinphi)*a_cosphi*a_Rt+
206  (ab_Dz0-a_Rt*a_cotantheta*a_phi+b_Rt*b_cotantheta*b_phi)*(-a_Rt*a_cotantheta);
207 
208 
209  //same for second deriv respective to phi
210  const double d1db_phi =
211  (ab_Dx0+a_Rt*a_cosphi)*b_Rt*b_sinphi-//attention!MINUS here
212  (ab_Dy0+a_Rt*a_sinphi)*b_cosphi*b_Rt+
213  (ab_Dz0-a_Rt*a_cotantheta*a_phi+b_Rt*b_cotantheta*b_phi)*(+b_Rt*b_cotantheta);
214 
215  //second derivatives (d^2/d^2(a) d^2/d^2(b) d^2/d(a)d(b) )
216 
217  const double d2da_phi2 =
218  (ab_Dx0-b_Rt*b_cosphi)*(-a_Rt*a_cosphi)+
219  (ab_Dy0-b_Rt*b_sinphi)*(-a_Rt*a_sinphi)+
220  +a_Rt*a_Rt*(a_cotantheta*a_cotantheta);
221 
222  const double d2db_phi2 =
223  (ab_Dx0+a_Rt*a_cosphi)*(+b_Rt*b_cosphi)+
224  (ab_Dy0+a_Rt*a_sinphi)*(+b_Rt*b_sinphi)+
225  +b_Rt*b_Rt*(b_cotantheta*b_cotantheta);
226 
227 
228  const double d2da_phib_phi = -a_Rt*b_Rt*(a_sinphi*b_sinphi+a_cosphi*b_cosphi+a_cotantheta*b_cotantheta);
229 
230  //Calculate the determinant of the Jacobian
231 
232  const double det = d2da_phi2*d2db_phi2-d2da_phib_phi*d2da_phib_phi;
233 
234 
235 #ifdef TrkDistance_DEBUG
236  ATH_MSG_DEBUG( "d1da_phi " << d1da_phi << " d1db_phi " << d1db_phi << " d2da_phi2 " << d2da_phi2 << " d2db_phi2 " << d2db_phi2
237  << " d2da_phib_phi " << d2da_phib_phi << " det " << det );
238 #endif
239 
240  //if the quadratic form is defined negative or is semidefined, throw the event
241  //(you are in a maximum or in a saddle point)
242  if (det<0) {
243  ATH_MSG_DEBUG( "Hessian is negative: saddle point" );
244  return "Hessian is negative";
245  }
246  if (det>0&&d2da_phi2<0) {
247  ATH_MSG_DEBUG( "Hessian indicates a maximum: derivative will be zero but result incorrect" );
248  return "Maximum point found";
249  }
250 
251  //Now apply the Newton formula in more than one dimension
252  const double deltaa_phi = -(d2db_phi2*d1da_phi-d2da_phib_phi*d1db_phi)/det;
253  const double deltab_phi = -(-d2da_phib_phi*d1da_phi+d2da_phi2*d1db_phi)/det;
254 
255 #ifdef TrkDistance_DEBUG
256  ATH_MSG_DEBUG( "deltaa_phi: " << deltaa_phi );
257  ATH_MSG_DEBUG( "deltab_phi: " << deltab_phi );
258 #endif
259 
260 
261  a_phi += deltaa_phi;
262  b_phi += deltab_phi;
263 
264  //store cos and sin of phi
265  a_cosphi = -sin(a_phi);
266  a_sinphi = cos(a_phi);
267  b_cosphi = -sin(b_phi);
268  b_sinphi = cos(b_phi);
269 
270  if (std::sqrt(std::pow(deltaa_phi,2)+std::pow(deltab_phi,2))<m_precision ||
271  loopsnumber>m_maxloopnumber) isok=true;
272 
273  }
274 
275  if (loopsnumber>m_maxloopnumber) {
276  return "Could not find minimum distance: max loops number reached"; //now return error, see how to do it...
277  }
278 
279 
280  return TwoPoints(Amg::Vector3D(a_x0+a_Rt*(a_cosphi-a_cosphi0),
281  a_y0+a_Rt*(a_sinphi-a_sinphi0),
282  a_z0-a_Rt*(a_phi-a_phi0)*a_cotantheta),
283  Amg::Vector3D(b_x0+b_Rt*(b_cosphi-b_cosphi0),
284  b_y0+b_Rt*(b_sinphi-b_sinphi0),
285  b_z0-b_Rt*(b_phi-b_phi0)*b_cotantheta));
286 }

◆ GetClosestPoints() [3/4]

std::variant<TwoPoints, std::string> Trk::NewtonTrkDistanceFinder::GetClosestPoints ( const TwoPointOnTrack twopointontrack) const
inline

Definition at line 70 of file NewtonTrkDistanceFinder.h.

70  {
71  return GetClosestPoints(twopointontrack.first,twopointontrack.second);
72  }

◆ GetClosestPoints() [4/4]

std::variant<TwoPoints, std::string> Trk::NewtonTrkDistanceFinder::GetClosestPoints ( const TwoTracks twotracks) const
inline

Definition at line 65 of file NewtonTrkDistanceFinder.h.

65  {
66  return GetClosestPoints(twotracks.getFirstPerigee(),twotracks.getSecondPerigee());
67  }

◆ initialize()

StatusCode Trk::NewtonTrkDistanceFinder::initialize ( )
overridevirtual

Definition at line 43 of file NewtonTrkDistanceFinder.cxx.

44  {
47  ATH_MSG_DEBUG( "Initialize successful" );
48  return StatusCode::SUCCESS;
49  }

◆ 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()

static const InterfaceID& Trk::NewtonTrkDistanceFinder::interfaceID ( )
inlinestatic

Definition at line 34 of file NewtonTrkDistanceFinder.h.

35  {
36  return IID_NewtonTrkDistanceFinder;
37  };

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

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

SG::ReadCondHandleKey<AtlasFieldCacheCondObj> Trk::NewtonTrkDistanceFinder::m_fieldCacheCondObjInputKey {this, "AtlasFieldCacheCondObj", "fieldCondObj", "Name of the Magnetic Field conditions object key"}
private

Definition at line 80 of file NewtonTrkDistanceFinder.h.

◆ m_maxloopnumber

double Trk::NewtonTrkDistanceFinder::m_maxloopnumber
private

Definition at line 77 of file NewtonTrkDistanceFinder.h.

◆ m_precision

double Trk::NewtonTrkDistanceFinder::m_precision
private

Definition at line 76 of file NewtonTrkDistanceFinder.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:
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
Trk::NewtonTrkDistanceFinder::m_precision
double m_precision
Definition: NewtonTrkDistanceFinder.h:76
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
AtlasFieldCacheCondObj
Definition: AtlasFieldCacheCondObj.h:19
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
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::z0
@ z0
Definition: ParamDefs.h:70
Trk::TwoPoints
std::pair< Amg::Vector3D, Amg::Vector3D > TwoPoints
Definition: SeedFinderParamDefs.h:20
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trk::NewtonTrkDistanceFinder::GetClosestPoints
std::variant< TwoPoints, std::string > GetClosestPoints(const Perigee &a, const Perigee &b) const
Definition: NewtonTrkDistanceFinder.h:55
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:72
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
WritePulseShapeToCool.det
det
Definition: WritePulseShapeToCool.py:204
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
python.compareTCTs.isok
isok
Definition: compareTCTs.py:350
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
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Trk::d0
@ d0
Definition: ParamDefs.h:69
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::NewtonTrkDistanceFinder::m_fieldCacheCondObjInputKey
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCacheCondObjInputKey
Definition: NewtonTrkDistanceFinder.h:81
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
a
TList * a
Definition: liststreamerinfos.cxx:10
h
Trk::NewtonTrkDistanceFinder::m_maxloopnumber
double m_maxloopnumber
Definition: NewtonTrkDistanceFinder.h:77
DeMoScan.first
bool first
Definition: DeMoScan.py:534
MagField::AtlasFieldCache
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h)
Definition: AtlasFieldCache.h:43
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
MagField::AtlasFieldCache::getField
void getField(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT bxyz, double *ATH_RESTRICT deriv=nullptr)
get B field value at given position xyz[3] is in mm, bxyz[3] is in kT if deriv[9] is given,...
Definition: AtlasFieldCache.cxx:42
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
Trk::phi0
@ phi0
Definition: ParamDefs.h:71
fitman.k
k
Definition: fitman.py:528