ATLAS Offline Software
ZScanSeedFinder.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRKVERTEXSEEDFINDERTOOLS_ZScanSeedFinder_H
6 #define TRKVERTEXSEEDFINDERTOOLS_ZScanSeedFinder_H
7 
9 #include "GaudiKernel/ToolHandle.h"
14 
17 
18 
20 
21 #include <unordered_map>
22 
23 namespace Trk
24 {
25 
26  class Track;
27 
28  // @author N. Giacinto Piacquadio (Albert-Ludwigs-Universitaet Freiburg - Germany)
29  //
30  // @ATLAS software
31  //
32  // This class implements a seed finder for the primary vertex finding
33  // which is based on the use of a clustering algorithm over the z position at
34  // point of closest approach to the beam (2d).
35  //
36  // -------------------------------------------
37  // Changes:
38  //
39  // David Shope <david.richard.shope@cern.ch> (2016-04-19)
40  //
41  // EDM Migration to xAOD - from Trk::VxCandidate to xAOD::Vertex,
42  // from Trk::RecVertex to xAOD::Vertex,
43  // from Trk::Vertex to Amg::Vector3D
44 
45 
46  class ZScanSeedFinder final: public extends<AthAlgTool, IVertexSeedFinder>
47  {
48  public:
49  // Standard Gaudi constructor.
50  ZScanSeedFinder (const std::string& t,
51  const std::string& n,
52  const IInterface* p);
53 
54 
55  virtual ~ZScanSeedFinder();
56 
57 
58  virtual StatusCode initialize() override;
59  virtual StatusCode finalize() override;
60 
61 
63 
69  virtual Amg::Vector3D
70  findSeed (const std::vector<const Trk::Track*> & vectorTrk,
71  const xAOD::Vertex * constraint=0) const override final;
72 
73 
79  virtual Amg::Vector3D
80  findSeed (const std::vector<const Trk::TrackParameters*> & perigeeList,
81  const xAOD::Vertex * constraint=0) const override final;
82 
83 
89  virtual std::vector<Amg::Vector3D>
90  findMultiSeeds (const std::vector<const Trk::Track*>& vectorTrk,
91  const xAOD::Vertex * constraint=0) const override final;
92 
93 
100  virtual std::vector<Amg::Vector3D>
101  findMultiSeeds(const std::vector<const Trk::TrackParameters*>& perigeeList,
102  const xAOD::Vertex * constraint=0) const override final;
103 
104 
105  private:
107  std::pair<double, double>
109  const xAOD::Vertex* constraint) const;
110 
111  std::vector<Trk::DoubleAndWeight>
112  getPositionsUncached (const std::vector<const Trk::TrackParameters*> & perigeeList,
113  const xAOD::Vertex * constraint) const;
114 
115 
116  std::vector<Trk::DoubleAndWeight>
117  getPositionsCached (const std::vector<const Trk::TrackParameters*> & perigeeList,
118  const xAOD::Vertex * constraint) const;
119 
120  SG::ReadHandleKey<xAOD::EventInfo> m_eventInfoKey{
121  this,
122  "EventInfo",
123  "EventInfo",
124  "key for EventInfo retrieval"
125  };
126 
127  ToolHandle<IMode1dFinder> m_mode1dfinder{ this,
128  "Mode1dFinder",
129  "Trk::FsmwMode1dFinder" };
130 
131  ToolHandle<ITrackToVertexIPEstimator> m_IPEstimator{
132  this,
133  "IPEstimator",
134  "Trk::TrackToVertexIPEstimator"
135  };
136 
141  double m_minPt;
142  bool m_usePt;
143  double m_expPt;
145 
146 
147  struct Cache {
148  typedef std::pair<Trk::Perigee, Amg::Vector2D> key_t;
149  typedef std::pair<double, double> value_t;
150 
151  // functor to hash key for unordered_map
152  struct hash_perigee {
153  size_t operator()(const key_t& p) const
154  {
155  return
156  std::hash<double>()(p.first.parameters()[Trk::d0]) ^
157  std::hash<double>()(p.first.parameters()[Trk::z0]) ^
158  std::hash<double>()(p.first.parameters()[Trk::phi]) ^
159  std::hash<double>()(p.first.parameters()[Trk::theta]) ^
160  std::hash<double>()(p.first.parameters()[Trk::qOverP]) ^
161  std::hash<double>()(p.second.x()) ^
162  std::hash<double>()(p.second.y());
163  }
164  };
165 
166  // functor to compare two unordered_map Key values for equality
167  struct pred_perigee {
168  bool operator()(const key_t& left, const key_t& right) const
169  {
170  const AmgVector(5)& lparams = left.first.parameters();
171  const AmgVector(5)& rparams = right.first.parameters();
172  return
173  lparams[Trk::d0] == rparams[Trk::d0] &&
174  lparams[Trk::z0] == rparams[Trk::z0] &&
175  lparams[Trk::phi] == rparams[Trk::phi] &&
176  lparams[Trk::theta] == rparams[Trk::theta] &&
177  lparams[Trk::qOverP] == rparams[Trk::qOverP] &&
178  left.second.x() == right.second.x() &&
179  left.second.y() == right.second.y();
180  }
181  };
182 
183 
184  // hashtable to avoid computing perigee more than once per track
185  typedef std::unordered_map< key_t, value_t, hash_perigee, pred_perigee>
188 
189  EventContext::ContextEvt_t m_evt = -1;
191  };
192 
194  };
195 }
196 #endif
Trk::ZScanSeedFinder::m_expPt
double m_expPt
Definition: ZScanSeedFinder.h:143
Trk::Vertex
Definition: Tracking/TrkEvent/VxVertex/VxVertex/Vertex.h:26
IVertexSeedFinder.h
IMode1dFinder.h
Trk::ZScanSeedFinder::m_usePt
bool m_usePt
Definition: ZScanSeedFinder.h:142
SG
Forward declaration.
Definition: CaloCellPacker_400_500.h:32
Trk::ZScanSeedFinder::m_IPEstimator
ToolHandle< ITrackToVertexIPEstimator > m_IPEstimator
Definition: ZScanSeedFinder.h:131
Trk::ZScanSeedFinder::ATLAS_THREAD_SAFE
SG::SlotSpecificObj< Cache > m_cache ATLAS_THREAD_SAFE
Definition: ZScanSeedFinder.h:193
Trk::ZScanSeedFinder::Cache::m_mutex
std::mutex m_mutex
Definition: ZScanSeedFinder.h:190
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
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
Trk::ZScanSeedFinder::m_cacheWeights
bool m_cacheWeights
Definition: ZScanSeedFinder.h:144
Trk::ZScanSeedFinder::finalize
virtual StatusCode finalize() override
Definition: ZScanSeedFinder.cxx:76
Trk::ZScanSeedFinder::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: ZScanSeedFinder.h:120
Trk::z0
@ z0
Definition: ParamDefs.h:64
xAOD
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
Definition: ICaloAffectedTool.h:24
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:560
Trk::ZScanSeedFinder::Cache::pred_perigee::operator()
bool operator()(const key_t &left, const key_t &right) const
Definition: ZScanSeedFinder.h:168
Trk::ZScanSeedFinder::m_minPt
double m_minPt
Definition: ZScanSeedFinder.h:141
Trk::ZScanSeedFinder::findMultiSeeds
virtual std::vector< Amg::Vector3D > findMultiSeeds(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 ...
Definition: ZScanSeedFinder.cxx:273
Trk::ZScanSeedFinder::m_mode1dfinder
ToolHandle< IMode1dFinder > m_mode1dfinder
Definition: ZScanSeedFinder.h:127
Trk::ZScanSeedFinder::Cache
Definition: ZScanSeedFinder.h:147
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
Trk::DoubleAndWeight
std::pair< double, double > DoubleAndWeight
Definition: SeedFinderParamDefs.h:18
Trk::ZScanSeedFinder::Cache::m_evt
EventContext::ContextEvt_t m_evt
Definition: ZScanSeedFinder.h:189
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
beamspotman.n
n
Definition: beamspotman.py:731
Trk::theta
@ theta
Definition: ParamDefs.h:66
Trk::ZScanSeedFinder::Cache::hash_perigee::operator()
size_t operator()(const key_t &p) const
Definition: ZScanSeedFinder.h:153
Trk::ZScanSeedFinder::Cache::hash_perigee
Definition: ZScanSeedFinder.h:152
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
AmgVector
AmgVector(4) T2BSTrackFilterTool
Definition: T2BSTrackFilterTool.cxx:114
AthAlgTool.h
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
Definition: ZScanSeedFinder.h:47
Trk::ZScanSeedFinder::m_constraintcutoff
float m_constraintcutoff
Definition: ZScanSeedFinder.h:138
Trk::ZScanSeedFinder::initialize
virtual StatusCode initialize() override
Definition: ZScanSeedFinder.cxx:54
Trk::ZScanSeedFinder::ZScanSeedFinder
ZScanSeedFinder(const std::string &t, const std::string &n, const IInterface *p)
Definition: ZScanSeedFinder.cxx:28
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::ZScanSeedFinder::m_constrainttemp
float m_constrainttemp
Definition: ZScanSeedFinder.h:139
Trk::ZScanSeedFinder::Cache::m_weightMap
WeightMap_t m_weightMap
Definition: ZScanSeedFinder.h:187
Trk::ZScanSeedFinder::m_disableAllWeights
bool m_disableAllWeights
Definition: ZScanSeedFinder.h:137
Trk::IVertexSeedFinder::findSeed
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.
Trk::ZScanSeedFinder::Cache::pred_perigee
Definition: ZScanSeedFinder.h:167
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Trk::ZScanSeedFinder::Cache::WeightMap_t
std::unordered_map< key_t, value_t, hash_perigee, pred_perigee > WeightMap_t
Definition: ZScanSeedFinder.h:186
Trk::ZScanSeedFinder::getPositionsCached
std::vector< Trk::DoubleAndWeight > getPositionsCached(const std::vector< const Trk::TrackParameters * > &perigeeList, const xAOD::Vertex *constraint) const
Definition: ZScanSeedFinder.cxx:168
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
Trk::d0
@ d0
Definition: ParamDefs.h:63
EventInfo
This class provides general information about an event. Event information is provided by the accessor...
Definition: EventInfo/EventInfo/EventInfo.h:43
SeedFinderParamDefs.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
EventInfo.h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
Trk::ZScanSeedFinder::~ZScanSeedFinder
virtual ~ZScanSeedFinder()
Trk::qOverP
@ qOverP
perigee
Definition: ParamDefs.h:67
Trk::ZScanSeedFinder::m_useLogPt
bool m_useLogPt
Definition: ZScanSeedFinder.h:140
ITrackToVertexIPEstimator.h
SlotSpecificObj.h
Maintain a set of objects, one per slot.
Track
Definition: TriggerChamberClusterOnTrackCreator.h:21
Trk::phi
@ phi
Definition: ParamDefs.h:75
Trk::ZScanSeedFinder::Cache::key_t
std::pair< Trk::Perigee, Amg::Vector2D > key_t
Definition: ZScanSeedFinder.h:148
checker_macros.h
Define macros for attributes used to control the static checker.