ATLAS Offline Software
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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. 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 Member Functions

std::pair< double, double > estimateWeight (const Trk::Perigee &iTrk, const xAOD::Vertex *constraint) const
 Estimate z-position and weight for one track. More...
 
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 28 of file ZScanSeedFinder.cxx.

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  }
46 
47 

◆ ~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 222 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
254  if (!m_disableAllWeights && ( m_usePt || m_useLogPt) )
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  }
269 
270 

◆ finalize()

StatusCode Trk::ZScanSeedFinder::finalize ( )
overridevirtual

Definition at line 76 of file ZScanSeedFinder.cxx.

◆ 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 273 of file ZScanSeedFinder.cxx.

◆ 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 282 of file ZScanSeedFinder.cxx.

◆ 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::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 83 of file ZScanSeedFinder.cxx.

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  }
103 
104  Amg::Vector3D ZScanSeedFinder::findSeed(const std::vector<const Trk::TrackParameters*> & perigeeList,const xAOD::Vertex * constraint) const {

◆ 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::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 106 of file ZScanSeedFinder.cxx.

109  {
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  }
133 
134 

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

◆ getPositionsCached()

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

Definition at line 168 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  }
214 
215 

◆ getPositionsUncached()

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

Definition at line 138 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  }
163 
164 

◆ initialize()

StatusCode Trk::ZScanSeedFinder::initialize ( )
overridevirtual

Definition at line 54 of file ZScanSeedFinder.cxx.

55  {
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  }
73 

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.

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

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

◆ 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:
Trk::ZScanSeedFinder::m_expPt
double m_expPt
Definition: ZScanSeedFinder.h:143
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
max
#define max(a, b)
Definition: cfImp.cxx:41
Trk::ZScanSeedFinder::m_usePt
bool m_usePt
Definition: ZScanSeedFinder.h:142
Trk::z
@ z
global position (cartesian)
Definition: ParamDefs.h:57
Trk::ZScanSeedFinder::m_IPEstimator
ToolHandle< ITrackToVertexIPEstimator > m_IPEstimator
Definition: ZScanSeedFinder.h:131
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
Trk::ZScanSeedFinder::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: ZScanSeedFinder.cxx:83
Trk::ZScanSeedFinder::Cache::value_t
std::pair< double, double > value_t
Definition: ZScanSeedFinder.h:149
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
Trk::ZScanSeedFinder::m_cacheWeights
bool m_cacheWeights
Definition: ZScanSeedFinder.h:144
Trk::ZScanSeedFinder::finalize
virtual StatusCode finalize() override
Definition: ZScanSeedFinder.cxx:76
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Trk::ImpactParametersAndSigma::IPd0
double IPd0
Definition: ITrackToVertexIPEstimator.h:34
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
Trk::ZScanSeedFinder::m_minPt
double m_minPt
Definition: ZScanSeedFinder.h:141
Trk::Perigee
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Definition: Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:33
Trk::ZScanSeedFinder::m_mode1dfinder
ToolHandle< IMode1dFinder > m_mode1dfinder
Definition: ZScanSeedFinder.h:127
Trk::ZScanSeedFinder::estimateWeight
std::pair< double, double > estimateWeight(const Trk::Perigee &iTrk, const xAOD::Vertex *constraint) const
Estimate z-position and weight for one track.
Definition: ZScanSeedFinder.cxx:222
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::theta
@ theta
Definition: ParamDefs.h:66
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
master.flag
bool flag
Definition: master.py:29
Trk::ImpactParametersAndSigma::IPz0
double IPz0
Definition: ITrackToVertexIPEstimator.h:35
Trk::ZScanSeedFinder::getPositionsUncached
std::vector< Trk::DoubleAndWeight > getPositionsUncached(const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint) const
Definition: ZScanSeedFinder.cxx:138
Trk::ZScanSeedFinder::m_constraintcutoff
float m_constraintcutoff
Definition: ZScanSeedFinder.h:138
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::ImpactParametersAndSigma::sigmad0
double sigmad0
Definition: ITrackToVertexIPEstimator.h:37
Trk::ZScanSeedFinder::m_constrainttemp
float m_constrainttemp
Definition: ZScanSeedFinder.h:139
min
#define min(a, b)
Definition: cfImp.cxx:40
Trk::ZScanSeedFinder::m_disableAllWeights
bool m_disableAllWeights
Definition: ZScanSeedFinder.h:137
Trk::ZScanSeedFinder::getPositionsCached
std::vector< Trk::DoubleAndWeight > getPositionsCached(const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint) const
Definition: ZScanSeedFinder.cxx:168
Trk::d0
@ d0
Definition: ParamDefs.h:63
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Prompt::Def::Pt
@ Pt
Definition: VarHolder.h:76
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
Trk::ZScanSeedFinder::m_useLogPt
bool m_useLogPt
Definition: ZScanSeedFinder.h:140
Trk::ZScanSeedFinder::Cache::key_t
std::pair< Trk::Perigee, Amg::Vector2D > key_t
Definition: ZScanSeedFinder.h:148
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37