ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
Trk::CrossDistancesSeedFinder Class Referencefinal

#include <CrossDistancesSeedFinder.h>

Inheritance diagram for Trk::CrossDistancesSeedFinder:
Collaboration diagram for Trk::CrossDistancesSeedFinder:

Public Member Functions

 CrossDistancesSeedFinder (const std::string &t, const std::string &n, const IInterface *p)
 
virtual ~CrossDistancesSeedFinder ()
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
virtual Amg::Vector3D findSeed (const std::vector< const Trk::Track * > &vectorTrk, const xAOD::Vertex *constraint=0) const=0
 Finds a linearization point out of a vector of tracks and returns it as an Amg::Vector3D object. More...
 
virtual Amg::Vector3D findSeed (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const=0
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object. More...
 
virtual Amg::Vector3D findSeed (const double, const double, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object. More...
 
virtual Amg::Vector3D findSeed (const double, const double, std::unique_ptr< Trk::IMode3dInfo > &, const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint=0) const
 Finds a linearization point out of a vector of TrackParameters and returns it as an Amg::Vector3D object. More...
 

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 42 of file CrossDistancesSeedFinder.h.

Constructor & Destructor Documentation

◆ CrossDistancesSeedFinder()

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

Definition at line 42 of file CrossDistancesSeedFinder.cxx.

42  :
43  base_class(t,n,p),
44  m_useweights(true),
45  m_trackdistcutoff(0.020),
48  m_constrainttemp(9.),
51  {
52  declareProperty("useweights",m_useweights);
53  declareProperty("trackdistcutoff",m_trackdistcutoff);
54  declareProperty("trackdistexppower",m_trackdistexppower);
55  declareProperty("constrainttemp",m_constrainttemp);
56  declareProperty("constraintcutoff",m_constraintcutoff);
57  declareProperty("maximumTracksNoCut",m_maximumTracksNoCut);
58  declareProperty("maximumDistanceCut",m_maximumDistanceCut);
59  }

◆ ~CrossDistancesSeedFinder()

Trk::CrossDistancesSeedFinder::~CrossDistancesSeedFinder ( )
virtualdefault

Member Function Documentation

◆ findMultiSeeds() [1/2]

std::vector< Amg::Vector3D > Trk::CrossDistancesSeedFinder::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 244 of file CrossDistancesSeedFinder.cxx.

244  {
245 
246  //implemented to satisfy inheritance but this algorithm only supports one seed at a time
247  ATH_MSG_WARNING( "Multi-seeding requested but seed finder not able to operate in that mode, returning no seeds" );
248  return std::vector<Amg::Vector3D>(0);
249 
250  }

◆ findMultiSeeds() [2/2]

std::vector< Amg::Vector3D > Trk::CrossDistancesSeedFinder::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 252 of file CrossDistancesSeedFinder.cxx.

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

◆ findSeed() [1/6]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed
inline

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 79 of file IVertexSeedFinder.h.

83  {
84  return findSeed (perigeeList, constraint);
85  }

◆ findSeed() [2/6]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed
inline

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 96 of file IVertexSeedFinder.h.

101  {
102  return findSeed (perigeeList, constraint);
103  }

◆ findSeed() [3/6]

Amg::Vector3D Trk::CrossDistancesSeedFinder::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 73 of file CrossDistancesSeedFinder.cxx.

73  {
74 
75 
76  //create perigees from track list
77  std::vector<const TrackParameters*> perigeeList;
78  for (const auto *iter : VectorTrk) {
79  if (std::isnan(iter->perigeeParameters()->parameters()[Trk::d0])) {
80  continue;
81  }
82  perigeeList.push_back(iter->perigeeParameters());
83  }
84 
85  if (perigeeList.size()<2)
86  {
87  return Amg::Vector3D(0.,0.,0.);
88  }
89 
90  //create seed from perigee list
91  return findSeed(perigeeList,constraint);
92 
93  }

◆ findSeed() [4/6]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed

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.

◆ findSeed() [5/6]

Amg::Vector3D Trk::CrossDistancesSeedFinder::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 95 of file CrossDistancesSeedFinder.cxx.

95  {
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 
106  //Calculate and cache the covariance matrix for the constraint
107  AmgSymMatrix(3) weightMatrixPositionConstraint;
108  weightMatrixPositionConstraint.setIdentity(); //very arbitrary
109  if (constraint != nullptr) {
110  weightMatrixPositionConstraint = constraint->covariancePosition().inverse();
111  }
112 
113  //Prepare the vector of points, on which the 3d mode has later to be calculated
114  std::vector<PositionAndWeight> CrossingPointsAndWeights;
115  std::vector<Amg::Vector3D> CrossingPoints;
116 
117  //Implement here SeedPointFinder algorithm, acting with the track vector....
118  const std::vector<const Trk::TrackParameters*>::const_iterator begin=perigeeList.begin();
119  const std::vector<const Trk::TrackParameters*>::const_iterator end=perigeeList.end();
120 
121  for (std::vector<const Trk::TrackParameters*>::const_iterator i=begin;i!=end-1;++i) {
122 
123  const Trk::Perigee* MyI=dynamic_cast<const Trk::Perigee*>(*i);
124  if (MyI==nullptr) {
125  ATH_MSG_WARNING( "Neutrals not supported for seeding. Rejecting this track..." );
126  continue;
127  }
128 
129  for (std::vector<const Trk::TrackParameters*>::const_iterator j=i+1;j!=end;++j) {
130 
131  const Trk::Perigee* MyJ=dynamic_cast<const Trk::Perigee*>(*j);
132  if (MyJ==nullptr) {
133  ATH_MSG_WARNING( "Neutrals not supported for seeding. Rejecting this track..." );
134  continue;
135  }
136 
137 #ifdef CROSSDISTANCESSEEDFINDER_DEBUG
138 
139  ATH_MSG_DEBUG( "Track 1 d0: " << MyI->parameters()[Trk::d0] << " Track2 d0: " << MyJ->parameters()[Trk::d0] );
140  ATH_MSG_DEBUG( "Track 1 z0: " << MyI->parameters()[Trk::z0] << "Track2 z0: " << MyJ->parameters()[Trk::z0] );
141 #endif
142 
143  try {
144 
145  std::optional<ITrkDistanceFinder::TwoPoints> result
146  = m_distancefinder->CalculateMinimumDistance(*MyI,*MyJ);
147  if (!result) { ATH_MSG_DEBUG( "Problem with distance finder: THIS POINT WILL BE SKIPPED!" );
148  }
149  else
150  {
151  //Get the points which connect the minimum distance between the two tracks
152  double distance = dist (result.value());
153 #ifdef CROSSDISTANCESSEEDFINDER_DEBUG
154  ATH_MSG_DEBUG( "Point 1 x: " << result->first.x() <<
155  " y: " << result->first.y() <<
156  " z: " << result->first.z() );
157  ATH_MSG_DEBUG( "Point 2 x: " << result->second.x() <<
158  " y: " << result->second.y() <<
159  " z: " << result->second.z() );
160  ATH_MSG_DEBUG( "distance is: " << distance );
161 #endif
162 
163  Amg::Vector3D thepoint((result->first+result->second)/2.);
164 
165  if (m_useweights)
166  {
167  PositionAndWeight thispoint(thepoint,
169 
170  ATH_MSG_DEBUG( "distance weight: " << 1./pow(m_trackdistcutoff+distance,m_trackdistexppower) );
171 
172  if (constraint!=nullptr) {
173 
174  Amg::Vector3D DeltaP(thepoint-constraint->position());
175  Amg::Vector3D DeltaPConv;
176  ATH_MSG_DEBUG( "position x: " << DeltaP.x() << "position y: " << DeltaP.y() << "position z: " << DeltaP.z() );
177  DeltaPConv[0]=DeltaP.x();
178  DeltaPConv[1]=DeltaP.y();
179  DeltaPConv[2]=DeltaP.z();
180 
181 
182  double chi2=DeltaPConv.transpose()*weightMatrixPositionConstraint*DeltaPConv;
183 
184  ATH_MSG_DEBUG( " chi: " << chi2
185  << " beam weight " << 1./(1.+exp((chi2-m_constraintcutoff)/m_constrainttemp)) );
186 
187  thispoint.second=thispoint.second*1./(1.+exp((chi2-m_constraintcutoff)/m_constrainttemp));
188 
189  }
190  if ((!useCutOnDistance || distance<m_maximumDistanceCut) && thispoint.second > 1e-10)
191  {
192  CrossingPointsAndWeights.push_back(thispoint);
193  }
194  }
195  else
196  {
197  const Amg::Vector3D& thispoint(thepoint);
198  if (!useCutOnDistance || distance<m_maximumDistanceCut)
199  {
200  CrossingPoints.push_back(thispoint);
201  }
202  }
203  }
204  } catch (...) {
205  ATH_MSG_ERROR( "Something wrong in distance calculation: please report..." );
206  }
207  }
208  //to be understood...
209  }
210 
211  //Now all points have been collected (N*(N-1)/2) and
212  //the mode has to be calculated
213 
214  if (CrossingPoints.empty() && CrossingPointsAndWeights.empty())
215  {
216  return Amg::Vector3D(0,0,0);
217  }
218 
219  Amg::Vector3D myresult;
220 
221  if (m_useweights)
222  {
223  myresult=m_mode3dfinder->getMode(0, 0, CrossingPointsAndWeights);
224  }
225  else
226  {
227  myresult=m_mode3dfinder->getMode(0, 0, CrossingPoints);
228  }
229 
230 #ifdef CROSSDISTANCESSEEDFINDER_DEBUG
231  ATH_MSG_INFO( "Resulting mean POINT FOUND: x: " << myresult.x() <<
232  " y: " << myresult.y() <<
233  " z: " << myresult.z() );
234 #endif
235 
236 
237  return myresult;
238 
239 
240 
241 
242  }

◆ findSeed() [6/6]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed

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.

◆ initialize()

StatusCode Trk::CrossDistancesSeedFinder::initialize ( )
overridevirtual

Definition at line 66 of file CrossDistancesSeedFinder.cxx.

67  {
68  ATH_CHECK( m_mode3dfinder.retrieve() );
69  ATH_CHECK( m_distancefinder.retrieve() );
70  return StatusCode::SUCCESS;
71  }

Member Data Documentation

◆ m_constraintcutoff

float Trk::CrossDistancesSeedFinder::m_constraintcutoff
private

Definition at line 104 of file CrossDistancesSeedFinder.h.

◆ m_constrainttemp

float Trk::CrossDistancesSeedFinder::m_constrainttemp
private

Definition at line 105 of file CrossDistancesSeedFinder.h.

◆ m_distancefinder

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

Definition at line 112 of file CrossDistancesSeedFinder.h.

◆ m_maximumDistanceCut

double Trk::CrossDistancesSeedFinder::m_maximumDistanceCut
private

Definition at line 107 of file CrossDistancesSeedFinder.h.

◆ m_maximumTracksNoCut

unsigned int Trk::CrossDistancesSeedFinder::m_maximumTracksNoCut
private

Definition at line 106 of file CrossDistancesSeedFinder.h.

◆ m_mode3dfinder

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

Definition at line 109 of file CrossDistancesSeedFinder.h.

◆ m_trackdistcutoff

float Trk::CrossDistancesSeedFinder::m_trackdistcutoff
private

Definition at line 102 of file CrossDistancesSeedFinder.h.

◆ m_trackdistexppower

int Trk::CrossDistancesSeedFinder::m_trackdistexppower
private

Definition at line 103 of file CrossDistancesSeedFinder.h.

◆ m_useweights

bool Trk::CrossDistancesSeedFinder::m_useweights
private

Definition at line 101 of file CrossDistancesSeedFinder.h.


The documentation for this class was generated from the following files:
Trk::CrossDistancesSeedFinder::m_trackdistcutoff
float m_trackdistcutoff
Definition: CrossDistancesSeedFinder.h:102
Trk::CrossDistancesSeedFinder::m_distancefinder
ToolHandle< ITrkDistanceFinder > m_distancefinder
Definition: CrossDistancesSeedFinder.h:112
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
get_generator_info.result
result
Definition: get_generator_info.py:21
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Trk::CrossDistancesSeedFinder::findSeed
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.
Definition: CrossDistancesSeedFinder.cxx:73
Trk::CrossDistancesSeedFinder::m_maximumDistanceCut
double m_maximumDistanceCut
Definition: CrossDistancesSeedFinder.h:107
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
Trk::z0
@ z0
Definition: ParamDefs.h:64
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
Trk::AmgSymMatrix
AmgSymMatrix(5) &GXFTrackState
Definition: GXFTrackState.h:156
Trk::PositionAndWeight
std::pair< Amg::Vector3D, double > PositionAndWeight
Definition: SeedFinderParamDefs.h:17
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
Trk::CrossDistancesSeedFinder::m_trackdistexppower
int m_trackdistexppower
Definition: CrossDistancesSeedFinder.h:103
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::CrossDistancesSeedFinder::m_constrainttemp
float m_constrainttemp
Definition: CrossDistancesSeedFinder.h:105
Trk::CrossDistancesSeedFinder::m_useweights
bool m_useweights
Definition: CrossDistancesSeedFinder.h:101
Trk::d0
@ d0
Definition: ParamDefs.h:63
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::CrossDistancesSeedFinder::m_maximumTracksNoCut
unsigned int m_maximumTracksNoCut
Definition: CrossDistancesSeedFinder.h:106
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:567
Trk::CrossDistancesSeedFinder::m_mode3dfinder
ToolHandle< IMode3dFinder > m_mode3dfinder
Definition: CrossDistancesSeedFinder.h:109
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54
Trk::CrossDistancesSeedFinder::m_constraintcutoff
float m_constraintcutoff
Definition: CrossDistancesSeedFinder.h:104