ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::IndexedCrossDistancesSeedFinder Class Referencefinal

#include <IndexedCrossDistancesSeedFinder.h>

Inheritance diagram for Trk::IndexedCrossDistancesSeedFinder:
Collaboration diagram for Trk::IndexedCrossDistancesSeedFinder:

Public Member Functions

 IndexedCrossDistancesSeedFinder (const std::string &t, const std::string &n, const IInterface *p)
virtual ~IndexedCrossDistancesSeedFinder ()
virtual StatusCode initialize () override
virtual Amg::Vector3D findSeed (const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
 Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object.
virtual Amg::Vector3D findSeed (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const override final
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.
virtual Amg::Vector3D findSeed (const double vx, const double vy, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const override final
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.
virtual Amg::Vector3D findSeed (const double vx, const double vy, std::unique_ptr< Trk::IMode3dInfo > &info, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const override final
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.
virtual std::vector< Amg::Vector3DfindMultiSeeds (const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
 Finds full vector of linearization points from a vector of tracks and returns it as an Amg::Vector3D object.
virtual std::vector< Amg::Vector3DfindMultiSeeds (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const override final
 Finds full vector of linearization points from a vector of TrackParameters and returns it as an Amg::Vector3D object.

Private Attributes

bool m_useweights
float m_trackdistcutoff
int m_trackdistexppower
float m_constraintcutoff
float m_constrainttemp
unsigned int m_maximumTracksNoCut
double m_maximumDistanceCut
ToolHandle< IMode3dFinderm_mode3dfinder
ToolHandle< ITrkDistanceFinderm_distancefinder

Detailed Description

Definition at line 35 of file IndexedCrossDistancesSeedFinder.h.

Constructor & Destructor Documentation

◆ IndexedCrossDistancesSeedFinder()

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

Definition at line 27 of file IndexedCrossDistancesSeedFinder.cxx.

27 :
28 base_class(t,n,p),
29 m_useweights(true),
30 m_trackdistcutoff(0.020),
36 {
37 declareProperty("useweights",m_useweights);
38 declareProperty("trackdistcutoff",m_trackdistcutoff);
39 declareProperty("trackdistexppower",m_trackdistexppower);
40 declareProperty("constrainttemp",m_constrainttemp);
41 declareProperty("constraintcutoff",m_constraintcutoff);
42 declareProperty("maximumTracksNoCut",m_maximumTracksNoCut);
43 declareProperty("maximumDistanceCut",m_maximumDistanceCut);
44 }

◆ ~IndexedCrossDistancesSeedFinder()

Trk::IndexedCrossDistancesSeedFinder::~IndexedCrossDistancesSeedFinder ( )
virtualdefault

Member Function Documentation

◆ findMultiSeeds() [1/2]

std::vector< Amg::Vector3D > Trk::IndexedCrossDistancesSeedFinder::findMultiSeeds ( const std::vector< const Trk::Track * > & vectorTrk,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds full vector of linearization points from a vector of tracks and returns it as an Amg::Vector3D object.

Intended for seed finders that produce all at once. If you want an additional constraint can be taken into account.

Definition at line 251 of file IndexedCrossDistancesSeedFinder.cxx.

253{
254
255 //implemented to satisfy inheritance but this algorithm only supports one seed at a time
256 ATH_MSG_WARNING("Multi-seeding requested but seed finder not able to operate in that mode, returning no seeds" );
257 return std::vector<Amg::Vector3D>(0);
258}
#define ATH_MSG_WARNING(x)

◆ findMultiSeeds() [2/2]

std::vector< Amg::Vector3D > Trk::IndexedCrossDistancesSeedFinder::findMultiSeeds ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds full vector of linearization points from a vector of TrackParameters and returns it as an Amg::Vector3D object.

Intended for seed finders that produce all at once. If you want an additional constraint can be taken into account.

Definition at line 260 of file IndexedCrossDistancesSeedFinder.cxx.

262{
263
264 //implemented to satisfy inheritance but this algorithm only supports one seed at a time
265 ATH_MSG_WARNING("Multi-seeding requested but seed finder not able to operate in that mode, returning no seeds" );
266 return std::vector<Amg::Vector3D>(0);
267
268}

◆ findSeed() [1/4]

Amg::Vector3D Trk::IndexedCrossDistancesSeedFinder::findSeed ( const double vx,
const double vy,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.

If you want an additional constraint can be taken into account. Must specify the primary vertex position.

Definition at line 78 of file IndexedCrossDistancesSeedFinder.cxx.

82 {
83 std::unique_ptr<Trk::IMode3dInfo> info;
84 return findSeed (vx, vy, info, perigeeList, constraint);
85 }
virtual Amg::Vector3D findSeed(const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const override final
Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object.

◆ findSeed() [2/4]

Amg::Vector3D Trk::IndexedCrossDistancesSeedFinder::findSeed ( const double vx,
const double vy,
std::unique_ptr< Trk::IMode3dInfo > & info,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.

If you want an additional constraint can be taken into account. Must specify the primary vertex position. Allows returning additional diagnostic information.

Definition at line 89 of file IndexedCrossDistancesSeedFinder.cxx.

94 {
95 ATH_MSG_DEBUG( " Enter IndexedCrossDistancesSeedFinder " );
96
97 bool useCutOnDistance=false;
98 if (perigeeList.size()>m_maximumTracksNoCut)
99 {
100 useCutOnDistance=true;
101 }
102
103 //now implement the code you already had in the standalone code...
104
105 //Calculate and cache the covariance matrix for the constraint
106 AmgSymMatrix(3) weightMatrixPositionConstraint;
107 weightMatrixPositionConstraint.setIdentity(); //very arbitrary
108 if (constraint != nullptr) {
109 weightMatrixPositionConstraint = constraint->covariancePosition().inverse();
110 }
111
112 //Prepare the vector of points, on which the 3d mode has later to be calculated
113 std::vector<PositionAndWeight> CrossingPointsAndWeights;
114 std::vector<Amg::Vector3D> CrossingPoints;
115
116 //Implement here SeedPointFinder algorithm, acting with the track vector....
117 const std::vector<const Trk::TrackParameters*>::const_iterator begin=perigeeList.begin();
118 const std::vector<const Trk::TrackParameters*>::const_iterator end=perigeeList.end();
119
120 ATH_MSG_DEBUG( " Loop pairs of TrackParameters for modes " );
121
122 std::vector< std::pair <int, int> > trkidx ;
123 int idx_i = 0 ;
124 for (std::vector<const Trk::TrackParameters*>::const_iterator i=begin;i!=end-1;++i)
125 {
126 idx_i ++ ;
127 const Trk::Perigee* MyI=dynamic_cast<const Trk::Perigee*>(*i);
128 if (MyI==nullptr) {
129 ATH_MSG_WARNING( "Neutrals not supported for seeding. Rejecting this track..." );
130 continue;
131 }
132
133 int idx_j = idx_i ; // 1 has been added to idx_i
134 for (std::vector<const Trk::TrackParameters*>::const_iterator j=i+1;j!=end;++j++) {
135
136 idx_j ++ ;
137 const Trk::Perigee* MyJ=dynamic_cast<const Trk::Perigee*>(*j);
138
139 if (MyJ==nullptr) {
140 ATH_MSG_WARNING( "Neutrals not supported for seeding. Rejecting this track..." );
141 continue;
142 }
143
144
145 try {
146
147 std::optional<ITrkDistanceFinder::TwoPoints> result
148 = m_distancefinder->CalculateMinimumDistance(*MyI,*MyJ);
149 if (!result) {ATH_MSG_DEBUG("Problem with distance finder: THIS POINT WILL BE SKIPPED!");
150 }
151 else
152 {
153 //Get the points which connect the minimum distance between the two tracks
154 double distance = Amg::distance (result->first, result->second);
155#ifdef CROSSDISTANCESSEEDFINDER_DEBUG
156 ATH_MSG_DEBUG("Point 1 x: " << result->first.x() <<
157 " y: " << result->first.y() <<
158 " z: " << result->first.z() );
159 ATH_MSG_DEBUG("Point 2 x: " << result->second.x() <<
160 " y: " << result->second.y() <<
161 " z: " << result->second.z() );
162 ATH_MSG_DEBUG("distance is: " << distance );
163#endif
164
165 Amg::Vector3D thepoint((result->first+result->second)/2.);
166
167 if (m_useweights)
168 {
169 PositionAndWeight thispoint(thepoint,
171
172 ATH_MSG_VERBOSE("distance weight: " << 1./pow(m_trackdistcutoff+distance,m_trackdistexppower) );
173
174 if (constraint!=nullptr) {
175
176 Amg::Vector3D DeltaP(thepoint-constraint->position());
177 Amg::Vector3D DeltaPConv;
178 ATH_MSG_DEBUG("position x: " << DeltaP.x() << "position y: " << DeltaP.y() << "position z: " << DeltaP.z() );
179 DeltaPConv[0]=DeltaP.x();
180 DeltaPConv[1]=DeltaP.y();
181 DeltaPConv[2]=DeltaP.z();
182
183
184 double chi2=DeltaPConv.transpose()*weightMatrixPositionConstraint*DeltaPConv;
185
186 ATH_MSG_DEBUG(" chi: " << chi2 <<
187 " beam weight " << 1./(1.+exp((chi2-m_constraintcutoff)/m_constrainttemp)) );
188
189 thispoint.second=thispoint.second*1./(1.+exp((chi2-m_constraintcutoff)/m_constrainttemp));
190
191 }
192
193 if ((!useCutOnDistance || distance<m_maximumDistanceCut) && thispoint.second > 1e-10)
194 {
195 CrossingPointsAndWeights.push_back( thispoint );
196
197 trkidx.emplace_back( idx_i - 1 , idx_j - 1 );
198
199 ATH_MSG_VERBOSE( " crossing with track pair : " << idx_i - 1 <<" "
200 << MyI->parameters()[Trk::d0] <<" "<< idx_j - 1 <<" "
201 << MyJ->parameters()[Trk::d0] );
202
203 }
204 }
205 else
206 {
207 const Amg::Vector3D& thispoint(thepoint);
208 if ( !useCutOnDistance || distance<m_maximumDistanceCut )
209 {
210 CrossingPoints.push_back( thispoint );
211 }
212 }
213 }
214 } catch (...) {
215 ATH_MSG_ERROR("Something wrong in distance calculation: please report..." );
216 }
217 }
218 //to be understood...
219 }
220
221 //Now all points have been collected (N*(N-1)/2) and
222 //the mode has to be calculated
223
224 if ( ( CrossingPoints.empty() && ! m_useweights )
225 || ( m_useweights && CrossingPointsAndWeights.empty() ) )
226 {
227 return Amg::Vector3D(0,0,0);
228 }
229
230 ATH_MSG_DEBUG(" crossing points prepared : " << CrossingPointsAndWeights.size() );
231
232 Amg::Vector3D myresult;
233
234 if (m_useweights)
235 {
236 myresult=m_mode3dfinder->getMode(vx, vy, CrossingPointsAndWeights, info);
237 }
238 else
239 {
240 myresult=m_mode3dfinder->getMode(vx, vy, CrossingPoints, info);
241 }
242
243 info->setTrkidx (std::move (trkidx));
244 ATH_MSG_DEBUG(" 3D modes found ! " );
245
246 return myresult;
247
248 }
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
if(febId1==febId2)
constexpr int pow(int base, int exp) noexcept
const Amg::Vector3D & position() const
Returns the 3-pos.
double chi2(TH1 *h0, TH1 *h1)
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Eigen::Matrix< double, 3, 1 > Vector3D
std::pair< Amg::Vector3D, double > PositionAndWeight
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ d0
Definition ParamDefs.h:63

◆ findSeed() [3/4]

Amg::Vector3D Trk::IndexedCrossDistancesSeedFinder::findSeed ( const std::vector< const Trk::Track * > & vectorTrk,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object.

If you want an additional constraint can be taken into account.

Definition at line 60 of file IndexedCrossDistancesSeedFinder.cxx.

62 {
63 ATH_MSG_ERROR ("Need to supply a primary vertex.");
64 return Amg::Vector3D(0.,0.,0.);
65 }

◆ findSeed() [4/4]

Amg::Vector3D Trk::IndexedCrossDistancesSeedFinder::findSeed ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
finaloverridevirtual

Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object.

If you want an additional constraint can be taken into account.

Definition at line 69 of file IndexedCrossDistancesSeedFinder.cxx.

71 {
72 ATH_MSG_ERROR ("Need to supply a primary vertex.");
73 return Amg::Vector3D(0.,0.,0.);
74 }

◆ initialize()

StatusCode Trk::IndexedCrossDistancesSeedFinder::initialize ( )
overridevirtual

Definition at line 51 of file IndexedCrossDistancesSeedFinder.cxx.

52 {
53 ATH_CHECK( m_mode3dfinder.retrieve() );
54 ATH_CHECK( m_distancefinder.retrieve() );
55 return StatusCode::SUCCESS;
56 }
#define ATH_CHECK
Evaluate an expression and check for errors.

Member Data Documentation

◆ m_constraintcutoff

float Trk::IndexedCrossDistancesSeedFinder::m_constraintcutoff
private

Definition at line 124 of file IndexedCrossDistancesSeedFinder.h.

◆ m_constrainttemp

float Trk::IndexedCrossDistancesSeedFinder::m_constrainttemp
private

Definition at line 125 of file IndexedCrossDistancesSeedFinder.h.

◆ m_distancefinder

ToolHandle<ITrkDistanceFinder> Trk::IndexedCrossDistancesSeedFinder::m_distancefinder
private
Initial value:
{
this,
"TrkDistanceFinder",
"Trk::SeedNewtonTrkDistanceFinder"
}

Definition at line 132 of file IndexedCrossDistancesSeedFinder.h.

132 {
133 this,
134 "TrkDistanceFinder",
135 "Trk::SeedNewtonTrkDistanceFinder"
136 };

◆ m_maximumDistanceCut

double Trk::IndexedCrossDistancesSeedFinder::m_maximumDistanceCut
private

Definition at line 127 of file IndexedCrossDistancesSeedFinder.h.

◆ m_maximumTracksNoCut

unsigned int Trk::IndexedCrossDistancesSeedFinder::m_maximumTracksNoCut
private

Definition at line 126 of file IndexedCrossDistancesSeedFinder.h.

◆ m_mode3dfinder

ToolHandle<IMode3dFinder> Trk::IndexedCrossDistancesSeedFinder::m_mode3dfinder
private
Initial value:
{ this,
"Mode3dFinder",
"Trk::Mode3dFromFsmw1dFinder" }

Definition at line 129 of file IndexedCrossDistancesSeedFinder.h.

129 { this,
130 "Mode3dFinder",
131 "Trk::Mode3dFromFsmw1dFinder" };

◆ m_trackdistcutoff

float Trk::IndexedCrossDistancesSeedFinder::m_trackdistcutoff
private

Definition at line 122 of file IndexedCrossDistancesSeedFinder.h.

◆ m_trackdistexppower

int Trk::IndexedCrossDistancesSeedFinder::m_trackdistexppower
private

Definition at line 123 of file IndexedCrossDistancesSeedFinder.h.

◆ m_useweights

bool Trk::IndexedCrossDistancesSeedFinder::m_useweights
private

Definition at line 121 of file IndexedCrossDistancesSeedFinder.h.


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