CMS 3D CMS Logo

PrimaryVertexAnalyzer4PUSlimmed.h
Go to the documentation of this file.
1 #ifndef VALIDATION_RECOVERTEX_INTERFACE_PRIMARYVERTEXANALYZER4PUSLIMMED_H_
2 #define VALIDATION_RECOVERTEX_INTERFACE_PRIMARYVERTEXANALYZER4PUSLIMMED_H_
3 
4 // -*- C++ -*-
5 //
6 // Package: PrimaryVertexAnalyzer4PUSlimmed
7 // Class: PrimaryVertexAnalyzer4PUSlimmed
8 //
16 //
17 // Original Author: Marco Rovere (code adapted from old code by
18 // Wolfram Erdmann)
19 
20 // system include files
21 #include <memory>
22 #include <string>
23 #include <vector>
24 #include <map>
25 #include <algorithm>
26 
27 // user include files
30 
31 // math
34 
35 // reco track
38 
39 // reco vertex
41 
42 // simulated track
45 
46 // pile-up
48 
49 // vertexing
51 
52 // simulated vertex
54 
55 // DQM
58 
59 // class declaration
62 
64 
65  // auxiliary class holding simulated vertices
67  simPrimaryVertex(double x1, double y1, double z1)
68  : x(x1),
69  y(y1),
70  z(z1),
71  ptsq(0),
73  nGenTrk(0),
76  ptot.setPx(0);
77  ptot.setPy(0);
78  ptot.setPz(0);
79  ptot.setE(0);
80  p4 = LorentzVector(0, 0, 0, 0);
81  r = sqrt(x * x + y * y);
82  };
83  double x, y, z, r;
84  HepMC::FourVector ptot;
86  double ptsq;
88  int nGenTrk;
93  std::vector<const reco::Vertex *> rec_vertices;
94  };
95 
96  // auxiliary class holding reconstructed vertices
98  enum VertexProperties { NONE = 0, MATCHED = 1, DUPLICATE = 2, MERGED = 4 };
99  recoPrimaryVertex(double x1, double y1, double z1)
100  : x(x1),
101  y(y1),
102  z(z1),
103  pt(0),
104  ptsq(0),
106  purity(-1.),
107  nRecoTrk(0),
109  kind_of_vertex(0),
110  recVtx(nullptr) {
111  r = sqrt(x * x + y * y);
112  };
113  double x, y, z, r;
114  double pt;
115  double ptsq;
117  double purity; // calculated and assigned in calculatePurityAndFillHistograms
118  int nRecoTrk;
121  std::vector<const TrackingVertex *> sim_vertices;
122  std::vector<const simPrimaryVertex *> sim_vertices_internal;
123  std::vector<unsigned int> sim_vertices_num_shared_tracks;
126  };
127 
128 public:
131 
132  void analyze(const edm::Event &, const edm::EventSetup &) override;
133  void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override;
134 
135 private:
136  void resetSimPVAssociation(std::vector<simPrimaryVertex> &);
137  void matchSim2RecoVertices(std::vector<simPrimaryVertex> &, const reco::VertexSimToRecoCollection &);
138  void matchReco2SimVertices(std::vector<recoPrimaryVertex> &,
140  const std::vector<simPrimaryVertex> &);
143  // void fillGenericRecoVertexHistograms(const std::string &,
144  // const simPrimaryVertex &v);
148  bool genPVMatchedToRecoPV);
151 
152  void calculatePurityAndFillHistograms(const std::string &, std::vector<recoPrimaryVertex> &, int, bool);
153 
154  std::vector<PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex> getSimPVs(
156 
157  std::vector<PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex> getRecoPVs(
159 
160  template <class T>
162 
163  // ----------member data ---------------------------
164  bool verbose_;
168 
169  std::map<std::string, std::map<std::string, MonitorElement *>> mes_;
172 
174  std::vector<edm::EDGetTokenT<edm::View<reco::Vertex>>> reco_vertex_collection_tokens_;
175  std::vector<edm::InputTag> reco_vertex_collections_;
181 
182  std::vector<bool> errorPrintedForColl_;
183 };
184 
185 #endif // VALIDATION_RECOVERTEX_INTERFACE_PRIMARYVERTEXANALYZER4PUSLIMMED_H_
void matchSim2RecoVertices(std::vector< simPrimaryVertex > &, const reco::VertexSimToRecoCollection &)
void fillGenAssociatedRecoVertexHistograms(const std::string &, int, recoPrimaryVertex &v)
std::vector< PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex > getRecoPVs(const edm::Handle< edm::View< reco::Vertex >> &)
bool matchRecoTrack2SimSignal(const reco::TrackBaseRef &)
void resetSimPVAssociation(std::vector< simPrimaryVertex > &)
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoAssociationToken_
void fillRecoAssociatedGenPVHistograms(const std::string &label, const PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex &v, bool genPVMatchedToRecoPV)
void computePairDistance(const T &collection, MonitorElement *me)
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
PrimaryVertexAnalyzer4PUSlimmed(const edm::ParameterSet &)
edm::EDGetTokenT< TrackingVertexCollection > trackingVertexCollectionToken_
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > vecPileupSummaryInfoToken_
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
char const * label
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex > getSimPVs(const edm::Handle< TrackingVertexCollection > &)
std::vector< edm::InputTag > reco_vertex_collections_
T sqrt(T t)
Definition: SSEVec.h:19
void fillResolutionAndPullHistograms(const std::string &, int, recoPrimaryVertex &v, bool)
void calculatePurityAndFillHistograms(const std::string &, std::vector< recoPrimaryVertex > &, int, bool)
const reco::SimToRecoCollection * s2r_
std::vector< edm::EDGetTokenT< edm::View< reco::Vertex > > > reco_vertex_collection_tokens_
void fillGenericGenVertexHistograms(const simPrimaryVertex &v)
std::map< std::string, std::map< std::string, MonitorElement * > > mes_
void fillRecoAssociatedGenVertexHistograms(const std::string &, const simPrimaryVertex &v)
void matchReco2SimVertices(std::vector< recoPrimaryVertex > &, const reco::VertexRecoToSimCollection &, const std::vector< simPrimaryVertex > &)
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimAssociationToken_
long double T
const reco::RecoToSimCollection * r2s_
Definition: Run.h:45
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleCollectionToken_