CMS 3D CMS Logo

RecoVertex.h
Go to the documentation of this file.
1 #ifndef __L1Trigger_VertexFinder_RecoVertex_h__
2 #define __L1Trigger_VertexFinder_RecoVertex_h__
3 
7 
8 #include <numeric>
9 #include <set>
10 #include <vector>
11 
12 namespace l1tVertexFinder {
13 
14  template <typename T = L1Track>
15  class RecoVertex {
16  public:
18  RecoVertex(const double z0 = -999.);
21  std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>, const T*> trackAssociationMap);
24  std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>, const T*> trackAssociationMap);
27 
30  this->tracks_.insert(std::end(this->tracks_), std::begin(rhs.tracks()), std::end(rhs.tracks()));
31  return *this;
32  }
33 
35  void clear() { tracks_.clear(); }
37  //void computeParameters(unsigned int weightedmean = false, double highPtThreshold = 50., int highPtBehavior = -1);
39  bool hasHighPt() const { return highPt_; }
41  double highestPt() const { return highestPt_; }
43  void insert(const T* fitTrack) { tracks_.push_back(fitTrack); }
45  void isPrimary(bool is) { pv_ = is; }
47  unsigned int numHighPtTracks() const { return numHighPtTracks_; }
49  unsigned int numTracks() const { return tracks_.size(); }
51  unsigned int numTrueTracks() const { return trueTracks_.size(); }
53  bool primaryVertex() const { return pv_; }
55  double pt() const { return pT_; }
57  const std::vector<const T*>& tracks() const { return tracks_; }
59  const std::set<const TP*>& trueTracks() const { return trueTracks_; }
61  void setPt(double pt) { pT_ = pt; }
63  void setZ0(double z) { z0_ = z; }
65  void setParameters(double pt,
66  double z0,
67  double width = -999.,
68  bool highPt = false,
69  unsigned int nHighPt = -999,
70  double highestPt = -999.,
71  bool pv = false);
73  l1t::Vertex vertex() const;
75  double z0() const { return z0_; }
77  double z0width() const { return z0width_; }
78 
79  private:
80  double z0_;
81  double z0width_;
82  double pT_;
83  double highestPt_;
84  std::vector<const T*> tracks_;
85  std::set<const TP*> trueTracks_;
86  bool pv_;
87  bool highPt_;
88  unsigned int numHighPtTracks_;
89  };
90 
92 
93  template <typename T>
94  RecoVertex<T>::RecoVertex(const double z0) : z0_(z0) {
95  z0width_ = -999.;
96  pT_ = -999.;
97  highestPt_ = -999.;
98  pv_ = false;
99  highPt_ = false;
100  numHighPtTracks_ = 0;
101  clear();
102  }
103 
104  template <typename T>
106  std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>, const T*> trackAssociationMap) {
107  z0_ = vertex.z0();
108  z0width_ = vertex.z0width();
109  pT_ = vertex.pt();
110  highestPt_ = vertex.highestPt();
111  pv_ = vertex.primaryVertex();
112  highPt_ = vertex.hasHighPt();
113  numHighPtTracks_ = vertex.numHighPtTracks();
114  clear();
115 
116  // loop over base fitted tracks in reco vertex and find the corresponding TP
117  // track using the TTTrack - L1TrackTruthMatched map from above
118  for (const auto& trackIt : vertex.tracks()) {
119  // using insert ensures that true tracks are also stored in vertex object
120  insert(trackAssociationMap[trackIt->getTTTrackPtr()]);
121  }
122  }
123 
124  template <typename T>
126  std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>, const T*> trackAssociationMap) {
127  z0_ = vertex.z0();
128  z0width_ = -999.;
129  pT_ = vertex.pt();
130  highestPt_ = -999.;
131  pv_ = false;
132  highPt_ = false;
133  numHighPtTracks_ = 0;
134  clear();
135 
136  // populate vertex with tracks and TP track using the
137  // TTTrack - L1TrackTruthMatched map from above
138  for (const auto& track : vertex.tracks()) {
139  // using insert ensures that true tracks are also stored in vertex object
140  insert(trackAssociationMap.at(track));
141  }
142  }
143 
144  template <typename T>
146  double pt, double z0, double width, bool highPt, unsigned int nHighPt, double highestPt, bool pv) {
147  pT_ = pt;
148  z0_ = z0;
149  z0width_ = width;
150  highPt_ = highPt;
151  numHighPtTracks_ = nHighPt;
152  highestPt_ = highestPt;
153  pv_ = pv;
154  }
155 
156  template <typename T>
158  std::vector<edm::Ptr<l1t::Vertex::Track_t>> tracks;
159  tracks.reserve(tracks_.size());
160  for (const auto& t : tracks_) {
161  tracks.push_back(t->getTTTrackPtr());
162  }
163  return l1t::Vertex(pT_, z0_, tracks);
164  }
165 
166  // Template specializations
167  template <>
169 
170  template <>
172 
173  template <>
174  void RecoVertexWithTP::insert(const L1TrackTruthMatched* fitTrack);
175 
176 } // namespace l1tVertexFinder
177 
178 #endif
bool primaryVertex() const
True if primary vertex.
Definition: RecoVertex.h:53
unsigned int numHighPtTracks() const
Number of high-pT tracks (pT > 10 GeV)
Definition: RecoVertex.h:47
double pt() const
Sum of fitted tracks transverse momentum [GeV].
Definition: RecoVertex.h:55
unsigned int numTrueTracks() const
Number of true particles assigned to this vertex.
Definition: RecoVertex.h:51
unsigned int numHighPtTracks_
Definition: RecoVertex.h:88
~RecoVertex()
Basic destructor.
Definition: RecoVertex.h:26
const std::set< const TP * > & trueTracks() const
Tracking particles asociated to the vertex.
Definition: RecoVertex.h:59
void setZ0(double z)
Set z0 position [cm].
Definition: RecoVertex.h:63
double highestPt() const
highest track pT in the vertex
Definition: RecoVertex.h:41
RecoVertex & operator+=(const RecoVertex &rhs)
Operators.
Definition: RecoVertex.h:29
l1t::Vertex vertex() const
Get the equivalent l1t::Vertex.
Definition: RecoVertex.h:157
double z0() const
Vertex z0 position [cm].
Definition: RecoVertex.h:75
void setPt(double pt)
set the pT [GeV] of the vertex
Definition: RecoVertex.h:61
const std::vector< const T * > & tracks() const
Tracks in the vertex.
Definition: RecoVertex.h:57
RecoVertex(const double z0=-999.)
Basic constructor.
Definition: RecoVertex.h:94
Simple wrapper class for TTTrack, with match to a tracking particle.
double z0width() const
Vertex z0 width [cm].
Definition: RecoVertex.h:77
bool hasHighPt() const
Compute vertex parameters.
Definition: RecoVertex.h:39
def pv(vc)
Definition: MetAnalyzer.py:7
std::vector< const T * > tracks_
Definition: RecoVertex.h:84
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
void isPrimary(bool is)
Set primary vertex tag.
Definition: RecoVertex.h:45
Class to store the L1 Track Trigger tracks.
Definition: TTTrack.h:29
void clear()
Clear track vector.
Definition: RecoVertex.h:35
void clear(EGIsoObj &c)
Definition: egamma.h:82
long double T
std::set< const TP * > trueTracks_
Definition: RecoVertex.h:85
void setParameters(double pt, double z0, double width=-999., bool highPt=false, unsigned int nHighPt=-999, double highestPt=-999., bool pv=false)
Set the vertex parameters.
Definition: RecoVertex.h:145
unsigned int numTracks() const
Number of tracks originating from this vertex.
Definition: RecoVertex.h:49
void insert(const T *fitTrack)
Assign fitted track to this vertex.
Definition: RecoVertex.h:43