File indexing completed on 2024-04-06 12:22:12
0001 #ifndef __L1Trigger_VertexFinder_RecoVertex_h__
0002 #define __L1Trigger_VertexFinder_RecoVertex_h__
0003
0004 #include "DataFormats/L1Trigger/interface/Vertex.h"
0005 #include "L1Trigger/VertexFinder/interface/L1TrackTruthMatched.h"
0006 #include "L1Trigger/VertexFinder/interface/TP.h"
0007
0008 #include <numeric>
0009 #include <set>
0010 #include <vector>
0011
0012 namespace l1tVertexFinder {
0013
0014 template <typename T = L1Track>
0015 class RecoVertex {
0016 public:
0017
0018 RecoVertex(const double z0 = -999.);
0019
0020 RecoVertex(RecoVertex<L1Track>& vertex,
0021 std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>, const T*> trackAssociationMap);
0022
0023 RecoVertex(const l1t::Vertex& vertex,
0024 std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>, const T*> trackAssociationMap);
0025
0026 ~RecoVertex() {}
0027
0028
0029 RecoVertex& operator+=(const RecoVertex& rhs) {
0030 this->tracks_.insert(std::end(this->tracks_), std::begin(rhs.tracks()), std::end(rhs.tracks()));
0031 return *this;
0032 }
0033
0034
0035 void clear() { tracks_.clear(); }
0036
0037
0038
0039 bool hasHighPt() const { return highPt_; }
0040
0041 double highestPt() const { return highestPt_; }
0042
0043 void insert(const T* fitTrack) { tracks_.push_back(fitTrack); }
0044
0045 void isPrimary(bool is) { pv_ = is; }
0046
0047 unsigned int numHighPtTracks() const { return numHighPtTracks_; }
0048
0049 unsigned int numTracks() const { return tracks_.size(); }
0050
0051 unsigned int numTrueTracks() const { return trueTracks_.size(); }
0052
0053 bool primaryVertex() const { return pv_; }
0054
0055 double pt() const { return pT_; }
0056
0057 const std::vector<const T*>& tracks() const { return tracks_; }
0058
0059 const std::set<const TP*>& trueTracks() const { return trueTracks_; }
0060
0061 void setPt(double pt) { pT_ = pt; }
0062
0063 void setZ0(double z) { z0_ = z; }
0064
0065 void setParameters(double pt,
0066 double z0,
0067 double width = -999.,
0068 bool highPt = false,
0069 unsigned int nHighPt = -999,
0070 double highestPt = -999.,
0071 bool pv = false);
0072
0073 l1t::Vertex vertex() const;
0074
0075 double z0() const { return z0_; }
0076
0077 double z0width() const { return z0width_; }
0078
0079 private:
0080 double z0_;
0081 double z0width_;
0082 double pT_;
0083 double highestPt_;
0084 std::vector<const T*> tracks_;
0085 std::set<const TP*> trueTracks_;
0086 bool pv_;
0087 bool highPt_;
0088 unsigned int numHighPtTracks_;
0089 };
0090
0091 using RecoVertexWithTP = RecoVertex<L1TrackTruthMatched>;
0092
0093 template <typename T>
0094 RecoVertex<T>::RecoVertex(const double z0) : z0_(z0) {
0095 z0width_ = -999.;
0096 pT_ = -999.;
0097 highestPt_ = -999.;
0098 pv_ = false;
0099 highPt_ = false;
0100 numHighPtTracks_ = 0;
0101 clear();
0102 }
0103
0104 template <typename T>
0105 RecoVertex<T>::RecoVertex(RecoVertex<L1Track>& vertex,
0106 std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>, const T*> trackAssociationMap) {
0107 z0_ = vertex.z0();
0108 z0width_ = vertex.z0width();
0109 pT_ = vertex.pt();
0110 highestPt_ = vertex.highestPt();
0111 pv_ = vertex.primaryVertex();
0112 highPt_ = vertex.hasHighPt();
0113 numHighPtTracks_ = vertex.numHighPtTracks();
0114 clear();
0115
0116
0117
0118 for (const auto& trackIt : vertex.tracks()) {
0119
0120 insert(trackAssociationMap[trackIt->getTTTrackPtr()]);
0121 }
0122 }
0123
0124 template <typename T>
0125 RecoVertex<T>::RecoVertex(const l1t::Vertex& vertex,
0126 std::map<const edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>, const T*> trackAssociationMap) {
0127 z0_ = vertex.z0();
0128 z0width_ = -999.;
0129 pT_ = vertex.pt();
0130 highestPt_ = -999.;
0131 pv_ = false;
0132 highPt_ = false;
0133 numHighPtTracks_ = 0;
0134 clear();
0135
0136
0137
0138 for (const auto& track : vertex.tracks()) {
0139
0140 insert(trackAssociationMap.at(track));
0141 }
0142 }
0143
0144 template <typename T>
0145 void RecoVertex<T>::setParameters(
0146 double pt, double z0, double width, bool highPt, unsigned int nHighPt, double highestPt, bool pv) {
0147 pT_ = pt;
0148 z0_ = z0;
0149 z0width_ = width;
0150 highPt_ = highPt;
0151 numHighPtTracks_ = nHighPt;
0152 highestPt_ = highestPt;
0153 pv_ = pv;
0154 }
0155
0156 template <typename T>
0157 l1t::Vertex RecoVertex<T>::vertex() const {
0158 std::vector<edm::Ptr<l1t::Vertex::Track_t>> tracks;
0159 tracks.reserve(tracks_.size());
0160 for (const auto& t : tracks_) {
0161 tracks.push_back(t->getTTTrackPtr());
0162 }
0163 return l1t::Vertex(pT_, z0_, tracks);
0164 }
0165
0166
0167 template <>
0168 RecoVertexWithTP& RecoVertexWithTP::operator+=(const RecoVertexWithTP& rhs);
0169
0170 template <>
0171 void RecoVertexWithTP::clear();
0172
0173 template <>
0174 void RecoVertexWithTP::insert(const L1TrackTruthMatched* fitTrack);
0175
0176 }
0177
0178 #endif