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

#include <ZScanSeedFinder.h>

Inheritance diagram for Trk::ZScanSeedFinder:
Collaboration diagram for Trk::ZScanSeedFinder:

Classes

struct  Cache

Public Member Functions

 ZScanSeedFinder (const std::string &t, const std::string &n, const IInterface *p)
virtual ~ZScanSeedFinder ()
virtual StatusCode initialize () override
virtual StatusCode finalize () 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 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.
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.
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.

Private Member Functions

std::pair< double, double > estimateWeight (const Trk::Perigee &iTrk, const xAOD::Vertex *constraint) const
 Estimate z-position and weight for one track.
std::vector< Trk::DoubleAndWeightgetPositionsUncached (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint) const
std::vector< Trk::DoubleAndWeightgetPositionsCached (const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint) const

Private Attributes

SG::ReadHandleKey< xAOD::EventInfom_eventInfoKey
ToolHandle< IMode1dFinderm_mode1dfinder
ToolHandle< ITrackToVertexIPEstimatorm_IPEstimator
bool m_disableAllWeights
float m_constraintcutoff
float m_constrainttemp
bool m_useLogPt
double m_minPt
bool m_usePt
double m_expPt
bool m_cacheWeights
SG::SlotSpecificObj< Cache > m_cache ATLAS_THREAD_SAFE

Detailed Description

Definition at line 46 of file ZScanSeedFinder.h.

Constructor & Destructor Documentation

◆ ZScanSeedFinder()

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

Definition at line 26 of file ZScanSeedFinder.cxx.

26 :
27 base_class(t,n,p),
31 m_useLogPt(true),
32 m_minPt(400.),
33 m_usePt(false),
34 m_expPt(1.),
35 m_cacheWeights(true)
36 {
37 declareProperty("disableAllWeights", m_disableAllWeights);
38 declareProperty("constrainttemp", m_constrainttemp);
39 declareProperty("constraintcutoff", m_constraintcutoff);
40 declareProperty("UsePt", m_usePt);
41 declareProperty("ExpPt", m_expPt);
42 declareProperty("UseLogPt", m_useLogPt);
43 declareProperty("MinPt", m_minPt);
44 declareProperty("CacheWeights", m_cacheWeights);
45 }

◆ ~ZScanSeedFinder()

Trk::ZScanSeedFinder::~ZScanSeedFinder ( )
virtualdefault

Member Function Documentation

◆ estimateWeight()

std::pair< double, double > Trk::ZScanSeedFinder::estimateWeight ( const Trk::Perigee & iTrk,
const xAOD::Vertex * constraint ) const
private

Estimate z-position and weight for one track.

Definition at line 220 of file ZScanSeedFinder.cxx.

222 {
223 // protect against overflow in exponential function
224 static const double maxExpArg = log(std::numeric_limits<double>::max()/1.1);
225
226 std::unique_ptr<const Trk::ImpactParametersAndSigma> ipas;
227 if (constraint != nullptr && constraint->covariancePosition()(0,0)!=0) {
228 ipas = std::unique_ptr<const Trk::ImpactParametersAndSigma> (m_IPEstimator->estimate (&iTrk, constraint));
229 }
230
231 std::pair<double, double> z0AndWeight;
232 if (ipas != nullptr && ipas->sigmad0 > 0)
233 {
234 z0AndWeight.first = ipas->IPz0 + constraint->position().z();
235 double chi2IP = std::pow(ipas->IPd0/ipas->sigmad0, 2);
236 ATH_MSG_VERBOSE("d0 from tool: " << ipas->IPd0 << " error: " << ipas->sigmad0 << " chi2: " << chi2IP);
237 if ( !m_disableAllWeights )
238 {
239 z0AndWeight.second = 1./(1.+exp(std::min((chi2IP-m_constraintcutoff)/m_constrainttemp, maxExpArg)));
240 }
241 else
242 {
243 z0AndWeight.second = 1.;
244 }
245 }
246 else
247 {
248 if (constraint != nullptr) ATH_MSG_WARNING("Unable to compute impact parameter significance; setting IPWeight = 1");
249 z0AndWeight.first = iTrk.position()[Trk::z];
250 z0AndWeight.second = 1.;
251 }
252
253 // apply pT weighting as/if configured
255 {
256 double Pt = fabs(1./iTrk.parameters()[Trk::qOverP])*sin(iTrk.parameters()[Trk::theta]);
257 if ( m_usePt )
258 {
259 z0AndWeight.second *= std::pow(Pt, m_expPt);
260 }
261 else
262 {
263 z0AndWeight.second *= log(std::max(Pt / m_minPt, 1.001));
264 }
265 }
266
267 return z0AndWeight;
268 }
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
const Amg::Vector3D & position() const
Access method for the position.
ToolHandle< ITrackToVertexIPEstimator > m_IPEstimator
const Amg::Vector3D & position() const
Returns the 3-pos.
@ z
global position (cartesian)
Definition ParamDefs.h:57
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67

◆ finalize()

StatusCode Trk::ZScanSeedFinder::finalize ( )
overridevirtual

Definition at line 74 of file ZScanSeedFinder.cxx.

75 {
76 ATH_MSG_DEBUG("Finalize successful");
77 return StatusCode::SUCCESS;
78 }
#define ATH_MSG_DEBUG(x)

◆ findMultiSeeds() [1/2]

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

271 {
272
273 //implemented to satisfy inheritance but this algorithm only supports one seed at a time
274 ATH_MSG_WARNING("Multi-seeding requested but seed finder not able to operate in that mode, returning no seeds");
275 return std::vector<Amg::Vector3D>(0);
276
277 }

◆ findMultiSeeds() [2/2]

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

280 {
281
282 //implemented to satisfy inheritance but this algorithm only supports one seed at a time
283 ATH_MSG_WARNING("Multi-seeding requested but seed finder not able to operate in that mode, returning no seeds");
284 return std::vector<Amg::Vector3D>(0);
285
286 }

◆ findSeed() [1/4]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed ( const double ,
const double ,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
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 }
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]

virtual Amg::Vector3D Trk::IVertexSeedFinder::findSeed ( const double ,
const double ,
std::unique_ptr< Trk::IMode3dInfo > & ,
const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint = 0 ) const
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/4]

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

81 {
82
83 //create perigees from track list
84 std::vector<const TrackParameters*> perigeeList;
85
86 std::vector<const Trk::Track*>::const_iterator begin=VectorTrk.begin();
87 std::vector<const Trk::Track*>::const_iterator end=VectorTrk.end();
88
89 for (std::vector<const Trk::Track*>::const_iterator iter=begin;
90 iter!=end;++iter)
91 {
92 if (std::isnan((*iter)->perigeeParameters()->parameters()[Trk::d0]))
93 {
94 continue;
95 }
96 perigeeList.push_back((*iter)->perigeeParameters());
97 }
98
99 //create seed from perigee list
100 return findSeed(perigeeList,constraint);
101
102 }
@ d0
Definition ParamDefs.h:63

◆ findSeed() [4/4]

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

104 {
105
106
107 double ZResult=0.;
108 std::vector<Trk::DoubleAndWeight> ZPositions;
109 if (m_cacheWeights) {
110 ZPositions = getPositionsCached (perigeeList, constraint);
111 }
112 else {
113 ZPositions = getPositionsUncached (perigeeList, constraint);
114 }
115
116 if ( !ZPositions.empty() )
117 {
118 ZResult=m_mode1dfinder->getMode(ZPositions);
119 ATH_MSG_DEBUG("Resulting mean Z position found: " << ZResult);
120 }
121 else
122 {
123 ATH_MSG_DEBUG("No tracks with sufficient weight; return z position = 0");
124 }
125
126 if (constraint)
127 {
128 return Amg::Vector3D(constraint->position().x(),constraint->position().y(),ZResult);
129 }
130 return Amg::Vector3D(0.,0.,ZResult);
131
132 }
std::vector< Trk::DoubleAndWeight > getPositionsCached(const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint) const
std::vector< Trk::DoubleAndWeight > getPositionsUncached(const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint) const
ToolHandle< IMode1dFinder > m_mode1dfinder
Eigen::Matrix< double, 3, 1 > Vector3D

◆ getPositionsCached()

std::vector< Trk::DoubleAndWeight > Trk::ZScanSeedFinder::getPositionsCached ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint ) const
private

Definition at line 166 of file ZScanSeedFinder.cxx.

168 {
169 const EventContext& ctx = Gaudi::Hive::currentContext();
170 Cache& cache = *m_cache;
171
172 Amg::Vector2D constraintkey;
173 if (constraint) {
174 constraintkey.x() = constraint->position().x();
175 constraintkey.y() = constraint->position().y();
176 }
177 else {
178 constraintkey.x() = std::numeric_limits<double>::max();
179 constraintkey.y() = std::numeric_limits<double>::min();
180 }
181
182 std::vector<Trk::DoubleAndWeight> ZPositions;
183
184 std::lock_guard<std::mutex> lock (cache.m_mutex);
185 if (ctx.evt() != cache.m_evt) {
186 cache.m_weightMap.clear();
187 }
188
189 for (const Trk::TrackParameters* i : perigeeList)
190 {
191 const Perigee* iTrk = dynamic_cast<const Trk::Perigee*>(i);
192 if (iTrk == nullptr)
193 {
194 ATH_MSG_WARNING("Neutrals not supported for seeding. Rejecting track...");
195 continue;
196 }
197
198 Cache::key_t key (*iTrk, constraintkey);
199 auto [it, flag] = cache.m_weightMap.try_emplace (key, Cache::value_t());
200 if (flag) {
201 it->second = estimateWeight (*iTrk, constraint);
202 ATH_MSG_DEBUG("Found position z: " << it->second.first <<
203 " with weight " << it->second.second);
204 }
205
206 if (it->second.second >= 0.01)
207 {
208 ZPositions.push_back (it->second);
209 }
210 }
211
212 return ZPositions;
213 }
std::pair< double, double > estimateWeight(const Trk::Perigee &iTrk, const xAOD::Vertex *constraint) const
Estimate z-position and weight for one track.
Eigen::Matrix< double, 2, 1 > Vector2D
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersBase< TrackParametersDim, Charged > TrackParameters
bool flag
Definition master.py:29
std::pair< double, double > value_t
std::pair< Trk::Perigee, Amg::Vector2D > key_t

◆ getPositionsUncached()

std::vector< Trk::DoubleAndWeight > Trk::ZScanSeedFinder::getPositionsUncached ( const std::vector< const Trk::TrackParameters * > & perigeeList,
const xAOD::Vertex * constraint ) const
private

Definition at line 136 of file ZScanSeedFinder.cxx.

138 {
139 std::vector<Trk::DoubleAndWeight> ZPositions;
140
141 for (const Trk::TrackParameters* i : perigeeList)
142 {
143 const Perigee* iTrk = dynamic_cast<const Trk::Perigee*>(i);
144 if (iTrk == nullptr)
145 {
146 ATH_MSG_WARNING("Neutrals not supported for seeding. Rejecting track...");
147 continue;
148 }
149
150 std::pair<double, double> z0AndWeight =
151 estimateWeight (*iTrk, constraint);
152 ATH_MSG_DEBUG("Found position z: " << z0AndWeight.first <<
153 " with weight " << z0AndWeight.second);
154
155 if (z0AndWeight.second >= 0.01)
156 {
157 ZPositions.push_back(z0AndWeight);
158 }
159 }
160
161 return ZPositions;
162 }

◆ initialize()

StatusCode Trk::ZScanSeedFinder::initialize ( )
overridevirtual

Definition at line 52 of file ZScanSeedFinder.cxx.

53 {
54 ATH_CHECK( m_eventInfoKey.initialize() );
55 if ( m_mode1dfinder.retrieve().isFailure() ) {
56 ATH_MSG_FATAL("Failed to retrieve tool " << m_mode1dfinder);
57 return StatusCode::FAILURE;
58 } else if ( m_IPEstimator.retrieve().isFailure() ) {
59 ATH_MSG_FATAL("Failed to retrieve tool " << m_IPEstimator);
60 } else {
61 ATH_MSG_INFO("Retrieved tools " << m_mode1dfinder << " and " << m_IPEstimator);
62 }
63
64 if ( m_usePt && m_useLogPt )
65 {
66 ATH_MSG_FATAL("At most one of Pt and LogPt weighting may be selected");
67 return StatusCode::FAILURE;
68 }
69
70 ATH_MSG_DEBUG("Initialize successful");
71 return StatusCode::SUCCESS;
72 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey

Member Data Documentation

◆ ATLAS_THREAD_SAFE

SG::SlotSpecificObj<Cache> m_cache Trk::ZScanSeedFinder::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 193 of file ZScanSeedFinder.h.

◆ m_cacheWeights

bool Trk::ZScanSeedFinder::m_cacheWeights
private

Definition at line 144 of file ZScanSeedFinder.h.

◆ m_constraintcutoff

float Trk::ZScanSeedFinder::m_constraintcutoff
private

Definition at line 138 of file ZScanSeedFinder.h.

◆ m_constrainttemp

float Trk::ZScanSeedFinder::m_constrainttemp
private

Definition at line 139 of file ZScanSeedFinder.h.

◆ m_disableAllWeights

bool Trk::ZScanSeedFinder::m_disableAllWeights
private

Definition at line 137 of file ZScanSeedFinder.h.

◆ m_eventInfoKey

SG::ReadHandleKey<xAOD::EventInfo> Trk::ZScanSeedFinder::m_eventInfoKey
private
Initial value:
{
this,
"EventInfo",
"EventInfo",
"key for EventInfo retrieval"
}

Definition at line 120 of file ZScanSeedFinder.h.

120 {
121 this,
122 "EventInfo",
123 "EventInfo",
124 "key for EventInfo retrieval"
125 };

◆ m_expPt

double Trk::ZScanSeedFinder::m_expPt
private

Definition at line 143 of file ZScanSeedFinder.h.

◆ m_IPEstimator

ToolHandle<ITrackToVertexIPEstimator> Trk::ZScanSeedFinder::m_IPEstimator
private
Initial value:
{
this,
"IPEstimator",
"Trk::TrackToVertexIPEstimator"
}

Definition at line 131 of file ZScanSeedFinder.h.

131 {
132 this,
133 "IPEstimator",
134 "Trk::TrackToVertexIPEstimator"
135 };

◆ m_minPt

double Trk::ZScanSeedFinder::m_minPt
private

Definition at line 141 of file ZScanSeedFinder.h.

◆ m_mode1dfinder

ToolHandle<IMode1dFinder> Trk::ZScanSeedFinder::m_mode1dfinder
private
Initial value:
{ this,
"Mode1dFinder",
"Trk::FsmwMode1dFinder" }

Definition at line 127 of file ZScanSeedFinder.h.

127 { this,
128 "Mode1dFinder",
129 "Trk::FsmwMode1dFinder" };

◆ m_useLogPt

bool Trk::ZScanSeedFinder::m_useLogPt
private

Definition at line 140 of file ZScanSeedFinder.h.

◆ m_usePt

bool Trk::ZScanSeedFinder::m_usePt
private

Definition at line 142 of file ZScanSeedFinder.h.


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