CMS 3D CMS Logo

PrimaryVertexAnalyzer4PUSlimmed.cc
Go to the documentation of this file.
2 
7 
8 // reco track and vertex
11 
12 // TrackingParticle
15 
16 // associator
19 
20 // DQM
22 
23 #include <numeric>
24 
25 namespace {
26  template <typename T, size_t N>
27  std::array<T, N + 1> makeLogBins(const double min, const double max) {
28  const double minLog10 = std::log10(min);
29  const double maxLog10 = std::log10(max);
30  const double width = (maxLog10 - minLog10) / N;
31  std::array<T, N + 1> ret;
32  ret[0] = std::pow(10, minLog10);
33  const double mult = std::pow(10, width);
34  for (size_t i = 1; i <= N; ++i) {
35  ret[i] = ret[i - 1] * mult;
36  }
37  return ret;
38  }
39 } // namespace
40 
41 //
42 // constructors and destructor
43 //
45  : verbose_(iConfig.getUntrackedParameter<bool>("verbose", false)),
46  use_only_charged_tracks_(iConfig.getUntrackedParameter<bool>("use_only_charged_tracks", true)),
47  do_generic_sim_plots_(iConfig.getUntrackedParameter<bool>("do_generic_sim_plots")),
48  root_folder_(iConfig.getUntrackedParameter<std::string>("root_folder", "Validation/Vertices")),
49  vecPileupSummaryInfoToken_(consumes<std::vector<PileupSummaryInfo>>(edm::InputTag(std::string("addPileupInfo")))),
50  trackingParticleCollectionToken_(consumes<TrackingParticleCollection>(
51  iConfig.getUntrackedParameter<edm::InputTag>("trackingParticleCollection"))),
52  trackingVertexCollectionToken_(
53  consumes<TrackingVertexCollection>(iConfig.getUntrackedParameter<edm::InputTag>("trackingVertexCollection"))),
54  simToRecoAssociationToken_(
55  consumes<reco::SimToRecoCollection>(iConfig.getUntrackedParameter<edm::InputTag>("trackAssociatorMap"))),
56  recoToSimAssociationToken_(
57  consumes<reco::RecoToSimCollection>(iConfig.getUntrackedParameter<edm::InputTag>("trackAssociatorMap"))),
58  vertexAssociatorToken_(consumes<reco::VertexToTrackingVertexAssociator>(
59  iConfig.getUntrackedParameter<edm::InputTag>("vertexAssociator"))) {
60  reco_vertex_collections_ = iConfig.getParameter<std::vector<edm::InputTag>>("vertexRecoCollections");
61  for (auto const& l : reco_vertex_collections_) {
64  }
65  errorPrintedForColl_.resize(reco_vertex_collections_.size(), false);
66 }
67 
69 
70 //
71 // member functions
72 //
74  edm::Run const& iRun,
75  edm::EventSetup const& iSetup) {
76  // TODO(rovere) make this booking method shorter and smarter,
77  // factorizing similar histograms with different prefix in a single
78  // method call.
79  float log_bins[31] = {0.0, 0.0002, 0.0004, 0.0006, 0.0008, 0.001, 0.002, 0.004, 0.006, 0.008, 0.01,
80  0.02, 0.04, 0.06, 0.08, 0.1, 0.2, 0.4, 0.6, 0.8, 1.0, 2.0,
81  4.0, 6.0, 8.0, 10.0, 20.0, 40.0, 60.0, 80.0, 100.0};
82  auto const log_mergez_bins = makeLogBins<float, 16>(1e-4, 1); // 4 bins / 10x
83 
84  auto const log_pt_bins = makeLogBins<float, 100>(0.1, 1e4);
85  float log_pt2_bins[16] = {
86  0.0, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0};
87  float log_ntrk_bins[25] = {0., 2.0, 4.0, 6.0, 8.0, 10., 12.0, 14.0, 16.0, 18.0, 22.0, 26.0, 30.0,
88  35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 70.0, 80.0, 90.0, 100.0, 150.0, 200.0};
89 
90  // TODO(rovere) Possibly change or add the main DQMStore booking
91  // interface to allow booking a TProfile with variable bin-width
92  // using an array of floats, as done for the TH1F case, not of
93  // doubles.
94  double log_pt2_bins_double[16] = {
95  0.0, 0.1, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0, 500.0, 1000.0, 2000.0, 5000.0, 10000.0};
96 
97  i.setCurrentFolder(root_folder_);
99  mes_["root_folder"]["GenVtx_vs_BX"] = i.book2D("GenVtx_vs_BX", "GenVtx_vs_BX", 16, -12.5, 3.5, 200, 0., 200.);
100  // Generated Primary Vertex Plots
101  mes_["root_folder"]["GenPV_X"] = i.book1D("GenPV_X", "GeneratedPV_X", 120, -0.6, 0.6);
102  mes_["root_folder"]["GenPV_Y"] = i.book1D("GenPV_Y", "GeneratedPV_Y", 120, -0.6, 0.6);
103  mes_["root_folder"]["GenPV_Z"] = i.book1D("GenPV_Z", "GeneratedPV_Z", 120, -60., 60.);
104  mes_["root_folder"]["GenPV_R"] = i.book1D("GenPV_R", "GeneratedPV_R", 120, 0, 0.6);
105  mes_["root_folder"]["GenPV_Pt2"] = i.book1D("GenPV_Pt2", "GeneratedPV_Sum-pt2", 15, &log_pt2_bins[0]);
106  mes_["root_folder"]["GenPV_NumTracks"] =
107  i.book1D("GenPV_NumTracks", "GeneratedPV_NumTracks", 24, &log_ntrk_bins[0]);
108  mes_["root_folder"]["GenPV_ClosestDistanceZ"] =
109  i.book1D("GenPV_ClosestDistanceZ", "GeneratedPV_ClosestDistanceZ", 30, &log_bins[0]);
110 
111  // All Generated Vertices, used for efficiency plots
112  mes_["root_folder"]["GenAllV_NumVertices"] =
113  i.book1D("GenAllV_NumVertices", "GeneratedAllV_NumVertices", 100, 0., 200.);
114  mes_["root_folder"]["GenAllV_X"] = i.book1D("GenAllV_X", "GeneratedAllV_X", 120, -0.6, 0.6);
115  mes_["root_folder"]["GenAllV_Y"] = i.book1D("GenAllV_Y", "GeneratedAllV_Y", 120, -0.6, 0.6);
116  mes_["root_folder"]["GenAllV_Z"] = i.book1D("GenAllV_Z", "GeneratedAllV_Z", 120, -60, 60);
117  mes_["root_folder"]["GenAllV_R"] = i.book1D("GenAllV_R", "GeneratedAllV_R", 120, 0, 0.6);
118  mes_["root_folder"]["GenAllV_Pt2"] = i.book1D("GenAllV_Pt2", "GeneratedAllV_Sum-pt2", 15, &log_pt2_bins[0]);
119  mes_["root_folder"]["GenAllV_NumTracks"] =
120  i.book1D("GenAllV_NumTracks", "GeneratedAllV_NumTracks", 24, &log_ntrk_bins[0]);
121  mes_["root_folder"]["GenAllV_ClosestDistanceZ"] =
122  i.book1D("GenAllV_ClosestDistanceZ", "GeneratedAllV_ClosestDistanceZ", 30, &log_bins[0]);
123  mes_["root_folder"]["GenAllV_PairDistanceZ"] =
124  i.book1D("GenAllV_PairDistanceZ", "GeneratedAllV_PairDistanceZ", 1000, 0, 20);
125  mes_["root_folder"]["SignalIsHighestPt2"] = i.book1D("SignalIsHighestPt2", "SignalIsHighestPt2", 2, -0.5, 1.5);
126  }
127 
128  for (auto const& l : reco_vertex_collections_) {
129  std::string label = l.label();
130  std::string current_folder = root_folder_ + "/" + label;
131  i.setCurrentFolder(current_folder);
132 
133  auto book1d = [&](const char* name, int bins, double min, double max) {
134  mes_[label][name] = i.book1D(name, name, bins, min, max);
135  };
136  auto book1dlogx = [&](const char* name, int bins, const float* xbinedges) {
137  mes_[label][name] = i.book1D(name, name, bins, xbinedges);
138  };
139  auto book2d = [&](const char* name, int xbins, double xmin, double xmax, int ybins, double ymin, double ymax) {
140  mes_[label][name] = i.book2D(name, name, xbins, xmin, xmax, ybins, ymin, ymax);
141  };
142  auto book2dlogx = [&](const char* name, int xbins, const float* xbinedges, int ybins, double ymin, double ymax) {
143  auto me = i.book2D(name, name, xbins, xbinedges[0], xbinedges[xbins], ybins, ymin, ymax);
144  me->getTH2F()->GetXaxis()->Set(xbins, xbinedges);
145  mes_[label][name] = me;
146  };
147 
148  mes_[label]["RecoVtx_vs_GenVtx"] =
149  i.bookProfile("RecoVtx_vs_GenVtx", "RecoVtx_vs_GenVtx", 125, 0., 250., 250, 0., 250.);
150  mes_[label]["MatchedRecoVtx_vs_GenVtx"] =
151  i.bookProfile("MatchedRecoVtx_vs_GenVtx", "MatchedRecoVtx_vs_GenVtx", 125, 0., 250., 250, 0., 250.);
152  mes_[label]["KindOfSignalPV"] = i.book1D("KindOfSignalPV", "KindOfSignalPV", 9, -0.5, 8.5);
153  mes_[label]["KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(1, "!Highest!Assoc2Any");
154  mes_[label]["KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(2, "Highest!Assoc2Any");
155  mes_[label]["KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(3, "!HighestAssoc2First");
156  mes_[label]["KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(4, "HighestAssoc2First");
157  mes_[label]["KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(5, "!HighestAssoc2!First");
158  mes_[label]["KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(6, "HighestAssoc2!First");
159  mes_[label]["KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(7, "!HighestAssoc2First");
160  mes_[label]["KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(8, "HighestAssoc2First");
161  mes_[label]["MisTagRate"] = i.book1D("MisTagRate", "MisTagRate", 2, -0.5, 1.5);
162  mes_[label]["MisTagRate_vs_PU"] = i.bookProfile("MisTagRate_vs_PU", "MisTagRate_vs_PU", 125, 0., 250., 2, 0., 1.);
163  mes_[label]["MisTagRate_vs_sum-pt2"] =
164  i.bookProfile("MisTagRate_vs_sum-pt2", "MisTagRate_vs_sum-pt2", 15, &log_pt2_bins_double[0], 2, 0., 1.);
165  mes_[label]["MisTagRate_vs_Z"] = i.bookProfile("MisTagRate_vs_Z", "MisTagRate_vs_Z", 120, -60., 60., 2, 0., 1.);
166  mes_[label]["MisTagRate_vs_R"] = i.bookProfile("MisTagRate_vs_R", "MisTagRate_vs_R", 120, 0., 0.6, 2, 0., 1.);
167  mes_[label]["MisTagRate_vs_NumTracks"] =
168  i.bookProfile("MisTagRate_vs_NumTracks", "MisTagRate_vs_NumTracks", 100, 0., 200, 2, 0., 1.);
169  mes_[label]["MisTagRateSignalIsHighest"] =
170  i.book1D("MisTagRateSignalIsHighest", "MisTagRateSignalIsHighest", 2, -0.5, 1.5);
171  mes_[label]["MisTagRateSignalIsHighest_vs_PU"] =
172  i.bookProfile("MisTagRateSignalIsHighest_vs_PU", "MisTagRateSignalIsHighest_vs_PU", 125, 0., 250., 2, 0., 1.);
173  mes_[label]["MisTagRateSignalIsHighest_vs_sum-pt2"] = i.bookProfile("MisTagRateSignalIsHighest_vs_sum-pt2",
174  "MisTagRateSignalIsHighest_vs_sum-pt2",
175  15,
176  &log_pt2_bins_double[0],
177  2,
178  0.,
179  1.);
180  mes_[label]["MisTagRateSignalIsHighest_vs_Z"] =
181  i.bookProfile("MisTagRateSignalIsHighest_vs_Z", "MisTagRateSignalIsHighest_vs_Z", 120, -60., 60., 2, 0., 1.);
182  mes_[label]["MisTagRateSignalIsHighest_vs_R"] =
183  i.bookProfile("MisTagRateSignalIsHighest_vs_R", "MisTagRateSignalIsHighest_vs_R", 120, 0., 0.6, 2, 0., 1.);
184  mes_[label]["MisTagRateSignalIsHighest_vs_NumTracks"] = i.bookProfile(
185  "MisTagRateSignalIsHighest_vs_NumTracks", "MisTagRateSignalIsHighest_vs_NumTracks", 100, 0., 200, 2, 0., 1.);
186  mes_[label]["MisTagRateSignalIsNotHighest"] =
187  i.book1D("MisTagRateSignalIsNotHighest", "MisTagRateSignalIsNotHighest", 2, -0.5, 1.5);
188  mes_[label]["MisTagRateSignalIsNotHighest_vs_PU"] = i.bookProfile(
189  "MisTagRateSignalIsNotHighest_vs_PU", "MisTagRateSignalIsNotHighest_vs_PU", 125, 0., 250., 2, 0., 1.);
190  mes_[label]["MisTagRateSignalIsNotHighest_vs_sum-pt2"] = i.bookProfile("MisTagRateSignalIsNotHighest_vs_sum-pt2",
191  "MisTagRateSignalIsNotHighest_vs_sum-pt2",
192  15,
193  &log_pt2_bins_double[0],
194  2,
195  0.,
196  1.);
197  mes_[label]["MisTagRateSignalIsNotHighest_vs_Z"] = i.bookProfile(
198  "MisTagRateSignalIsNotHighest_vs_Z", "MisTagRateSignalIsNotHighest_vs_Z", 120, -60., 60., 2, 0., 1.);
199  mes_[label]["MisTagRateSignalIsNotHighest_vs_R"] = i.bookProfile(
200  "MisTagRateSignalIsNotHighest_vs_R", "MisTagRateSignalIsNotHighest_vs_R", 120, 0., 0.6, 2, 0., 1.);
201  mes_[label]["MisTagRateSignalIsNotHighest_vs_NumTracks"] =
202  i.bookProfile("MisTagRateSignalIsNotHighest_vs_NumTracks",
203  "MisTagRateSignalIsNotHighest_vs_NumTracks",
204  100,
205  0.,
206  200,
207  2,
208  0.,
209  1.);
210  mes_[label]["TruePVLocationIndex"] =
211  i.book1D("TruePVLocationIndex", "TruePVLocationIndexInRecoVertexCollection", 12, -1.5, 10.5);
212  mes_[label]["TruePVLocationIndexCumulative"] =
213  i.book1D("TruePVLocationIndexCumulative", "TruePVLocationIndexInRecoVertexCollectionCumulative", 3, -1.5, 1.5);
214  mes_[label]["TruePVLocationIndexSignalIsHighest"] =
215  i.book1D("TruePVLocationIndexSignalIsHighest",
216  "TruePVLocationIndexSignalIsHighestInRecoVertexCollection",
217  12,
218  -1.5,
219  10.5);
220  mes_[label]["TruePVLocationIndexSignalIsNotHighest"] =
221  i.book1D("TruePVLocationIndexSignalIsNotHighest",
222  "TruePVLocationIndexSignalIsNotHighestInRecoVertexCollection",
223  12,
224  -1.5,
225  10.5);
226  // All Generated Vertices. Used for Efficiency plots We kind of
227  // duplicate plots here in case we want to perform more detailed
228  // studies on a selection of generated vertices, not on all of them.
229  mes_[label]["GenAllAssoc2Reco_NumVertices"] =
230  i.book1D("GenAllAssoc2Reco_NumVertices", "GeneratedAllAssoc2Reco_NumVertices", 100, 0., 200.);
231  mes_[label]["GenAllAssoc2Reco_X"] = i.book1D("GenAllAssoc2Reco_X", "GeneratedAllAssoc2Reco_X", 120, -0.6, 0.6);
232  mes_[label]["GenAllAssoc2Reco_Y"] = i.book1D("GenAllAssoc2Reco_Y", "GeneratedAllAssoc2Reco_Y", 120, -0.6, 0.6);
233  mes_[label]["GenAllAssoc2Reco_Z"] = i.book1D("GenAllAssoc2Reco_Z", "GeneratedAllAssoc2Reco_Z", 120, -60, 60);
234  mes_[label]["GenAllAssoc2Reco_R"] = i.book1D("GenAllAssoc2Reco_R", "GeneratedAllAssoc2Reco_R", 120, 0, 0.6);
235  mes_[label]["GenAllAssoc2Reco_Pt2"] =
236  i.book1D("GenAllAssoc2Reco_Pt2", "GeneratedAllAssoc2Reco_Sum-pt2", 15, &log_pt2_bins[0]);
237  mes_[label]["GenAllAssoc2Reco_NumTracks"] =
238  i.book1D("GenAllAssoc2Reco_NumTracks", "GeneratedAllAssoc2Reco_NumTracks", 24, &log_ntrk_bins[0]);
239  mes_[label]["GenAllAssoc2Reco_ClosestDistanceZ"] =
240  i.book1D("GenAllAssoc2Reco_ClosestDistanceZ", "GeneratedAllAssoc2Reco_ClosestDistanceZ", 30, &log_bins[0]);
241  book1d("GenPVAssoc2RecoPV_X", 120, -0.6, 0.6);
242  book1d("GenPVAssoc2RecoPV_Y", 120, -0.6, 0.6);
243  book1d("GenPVAssoc2RecoPV_Z", 120, -60, 60);
244 
245  // All Generated Vertices Matched to a Reconstructed vertex. Used
246  // for Efficiency plots
247  mes_[label]["GenAllAssoc2RecoMatched_NumVertices"] =
248  i.book1D("GenAllAssoc2RecoMatched_NumVertices", "GeneratedAllAssoc2RecoMatched_NumVertices", 100, 0., 200.);
249  mes_[label]["GenAllAssoc2RecoMatched_X"] =
250  i.book1D("GenAllAssoc2RecoMatched_X", "GeneratedAllAssoc2RecoMatched_X", 120, -0.6, 0.6);
251  mes_[label]["GenAllAssoc2RecoMatched_Y"] =
252  i.book1D("GenAllAssoc2RecoMatched_Y", "GeneratedAllAssoc2RecoMatched_Y", 120, -0.6, 0.6);
253  mes_[label]["GenAllAssoc2RecoMatched_Z"] =
254  i.book1D("GenAllAssoc2RecoMatched_Z", "GeneratedAllAssoc2RecoMatched_Z", 120, -60, 60);
255  mes_[label]["GenAllAssoc2RecoMatched_R"] =
256  i.book1D("GenAllAssoc2RecoMatched_R", "GeneratedAllAssoc2RecoMatched_R", 120, 0, 0.6);
257  mes_[label]["GenAllAssoc2RecoMatched_Pt2"] =
258  i.book1D("GenAllAssoc2RecoMatched_Pt2", "GeneratedAllAssoc2RecoMatched_Sum-pt2", 15, &log_pt2_bins[0]);
259  mes_[label]["GenAllAssoc2RecoMatched_NumTracks"] =
260  i.book1D("GenAllAssoc2RecoMatched_NumTracks", "GeneratedAllAssoc2RecoMatched_NumTracks", 24, &log_ntrk_bins[0]);
261  mes_[label]["GenAllAssoc2RecoMatched_ClosestDistanceZ"] = i.book1D(
262  "GenAllAssoc2RecoMatched_ClosestDistanceZ", "GeneratedAllAssoc2RecoMatched_ClosestDistanceZ", 30, &log_bins[0]);
263  book1d("GenPVAssoc2RecoPVMatched_X", 120, -0.6, 0.6);
264  book1d("GenPVAssoc2RecoPVMatched_Y", 120, -0.6, 0.6);
265  book1d("GenPVAssoc2RecoPVMatched_Z", 120, -60, 60);
266 
267  // All Generated Vertices Multi-Matched to a Reconstructed vertex. Used
268  // for Duplicate rate plots
269  mes_[label]["GenAllAssoc2RecoMultiMatched_NumVertices"] = i.book1D(
270  "GenAllAssoc2RecoMultiMatched_NumVertices", "GeneratedAllAssoc2RecoMultiMatched_NumVertices", 100, 0., 200.);
271  mes_[label]["GenAllAssoc2RecoMultiMatched_X"] =
272  i.book1D("GenAllAssoc2RecoMultiMatched_X", "GeneratedAllAssoc2RecoMultiMatched_X", 120, -0.6, 0.6);
273  mes_[label]["GenAllAssoc2RecoMultiMatched_Y"] =
274  i.book1D("GenAllAssoc2RecoMultiMatched_Y", "GeneratedAllAssoc2RecoMultiMatched_Y", 120, -0.6, 0.6);
275  mes_[label]["GenAllAssoc2RecoMultiMatched_Z"] =
276  i.book1D("GenAllAssoc2RecoMultiMatched_Z", "GeneratedAllAssoc2RecoMultiMatched_Z", 120, -60, 60);
277  mes_[label]["GenAllAssoc2RecoMultiMatched_R"] =
278  i.book1D("GenAllAssoc2RecoMultiMatched_R", "GeneratedAllAssoc2RecoMultiMatched_R", 120, 0, 0.6);
279  mes_[label]["GenAllAssoc2RecoMultiMatched_Pt2"] = i.book1D(
280  "GenAllAssoc2RecoMultiMatched_Pt2", "GeneratedAllAssoc2RecoMultiMatched_Sum-pt2", 15, &log_pt2_bins[0]);
281  mes_[label]["GenAllAssoc2RecoMultiMatched_NumTracks"] = i.book1D("GenAllAssoc2RecoMultiMatched_NumTracks",
282  "GeneratedAllAssoc2RecoMultiMatched_NumTracks",
283  24,
284  &log_ntrk_bins[0]);
285  mes_[label]["GenAllAssoc2RecoMultiMatched_ClosestDistanceZ"] =
286  i.book1D("GenAllAssoc2RecoMultiMatched_ClosestDistanceZ",
287  "GeneratedAllAssoc2RecoMultiMatched_ClosestDistanceZ",
288  30,
289  &log_bins[0]);
290 
291  // All Reco Vertices. Used for {Fake,Duplicate}-Rate plots
292  mes_[label]["RecoAllAssoc2Gen_NumVertices"] =
293  i.book1D("RecoAllAssoc2Gen_NumVertices", "ReconstructedAllAssoc2Gen_NumVertices", 100, 0., 200.);
294  mes_[label]["RecoAllAssoc2Gen_X"] = i.book1D("RecoAllAssoc2Gen_X", "ReconstructedAllAssoc2Gen_X", 120, -0.6, 0.6);
295  mes_[label]["RecoAllAssoc2Gen_Y"] = i.book1D("RecoAllAssoc2Gen_Y", "ReconstructedAllAssoc2Gen_Y", 120, -0.6, 0.6);
296  mes_[label]["RecoAllAssoc2Gen_Z"] = i.book1D("RecoAllAssoc2Gen_Z", "ReconstructedAllAssoc2Gen_Z", 120, -60, 60);
297  mes_[label]["RecoAllAssoc2Gen_R"] = i.book1D("RecoAllAssoc2Gen_R", "ReconstructedAllAssoc2Gen_R", 120, 0, 0.6);
298  mes_[label]["RecoAllAssoc2Gen_Pt2"] =
299  i.book1D("RecoAllAssoc2Gen_Pt2", "ReconstructedAllAssoc2Gen_Sum-pt2", 15, &log_pt2_bins[0]);
300  mes_[label]["RecoAllAssoc2Gen_Ndof"] =
301  i.book1D("RecoAllAssoc2Gen_Ndof", "ReconstructedAllAssoc2Gen_Ndof", 120, 0., 240.);
302  mes_[label]["RecoAllAssoc2Gen_NumTracks"] =
303  i.book1D("RecoAllAssoc2Gen_NumTracks", "ReconstructedAllAssoc2Gen_NumTracks", 24, &log_ntrk_bins[0]);
304  mes_[label]["RecoAllAssoc2Gen_PU"] = i.book1D("RecoAllAssoc2Gen_PU", "ReconstructedAllAssoc2Gen_PU", 125, 0., 250.);
305  mes_[label]["RecoAllAssoc2Gen_ClosestDistanceZ"] =
306  i.book1D("RecoAllAssoc2Gen_ClosestDistanceZ", "ReconstructedAllAssoc2Gen_ClosestDistanceZ", 30, &log_bins[0]);
307  mes_[label]["RecoAllAssoc2GenProperties"] =
308  i.book1D("RecoAllAssoc2GenProperties", "ReconstructedAllAssoc2Gen_Properties", 8, -0.5, 7.5);
309  mes_[label]["RecoAllAssoc2Gen_PairDistanceZ"] =
310  i.book1D("RecoAllAssoc2Gen_PairDistanceZ", "RecoAllAssoc2Gen_PairDistanceZ", 1000, 0, 20);
311 
312  // All Reconstructed Vertices Matched to a Generated vertex. Used
313  // for Fake-Rate plots
314  mes_[label]["RecoAllAssoc2GenMatched_NumVertices"] =
315  i.book1D("RecoAllAssoc2GenMatched_NumVertices", "ReconstructedAllAssoc2GenMatched_NumVertices", 100, 0., 200.);
316  mes_[label]["RecoAllAssoc2GenMatched_X"] =
317  i.book1D("RecoAllAssoc2GenMatched_X", "ReconstructedAllAssoc2GenMatched_X", 120, -0.6, 0.6);
318  mes_[label]["RecoAllAssoc2GenMatched_Y"] =
319  i.book1D("RecoAllAssoc2GenMatched_Y", "ReconstructedAllAssoc2GenMatched_Y", 120, -0.6, 0.6);
320  mes_[label]["RecoAllAssoc2GenMatched_Z"] =
321  i.book1D("RecoAllAssoc2GenMatched_Z", "ReconstructedAllAssoc2GenMatched_Z", 120, -60, 60);
322  mes_[label]["RecoAllAssoc2GenMatched_R"] =
323  i.book1D("RecoAllAssoc2GenMatched_R", "ReconstructedAllAssoc2GenMatched_R", 120, 0, 0.6);
324  mes_[label]["RecoAllAssoc2GenMatched_Pt2"] =
325  i.book1D("RecoAllAssoc2GenMatched_Pt2", "ReconstructedAllAssoc2GenMatched_Sum-pt2", 15, &log_pt2_bins[0]);
326  mes_[label]["RecoAllAssoc2GenMatched_Ndof"] =
327  i.book1D("RecoAllAssoc2GenMatched_Ndof", "ReconstructedAllAssoc2GenMatched_Ndof", 120, 0., 240.);
328  mes_[label]["RecoAllAssoc2GenMatched_NumTracks"] = i.book1D(
329  "RecoAllAssoc2GenMatched_NumTracks", "ReconstructedAllAssoc2GenMatched_NumTracks", 24, &log_ntrk_bins[0]);
330  mes_[label]["RecoAllAssoc2GenMatched_PU"] =
331  i.book1D("RecoAllAssoc2GenMatched_PU", "ReconstructedAllAssoc2GenMatched_PU", 125, 0., 250.);
332  mes_[label]["RecoAllAssoc2GenMatched_ClosestDistanceZ"] =
333  i.book1D("RecoAllAssoc2GenMatched_ClosestDistanceZ",
334  "ReconstructedAllAssoc2GenMatched_ClosestDistanceZ",
335  30,
336  &log_bins[0]);
337 
338  // All Reconstructed Vertices Multi-Matched to a Generated vertex. Used
339  // for Merge-Rate plots
340  mes_[label]["RecoAllAssoc2GenMultiMatched_NumVertices"] = i.book1D(
341  "RecoAllAssoc2GenMultiMatched_NumVertices", "ReconstructedAllAssoc2GenMultiMatched_NumVertices", 100, 0., 200.);
342  mes_[label]["RecoAllAssoc2GenMultiMatched_X"] =
343  i.book1D("RecoAllAssoc2GenMultiMatched_X", "ReconstructedAllAssoc2GenMultiMatched_X", 120, -0.6, 0.6);
344  mes_[label]["RecoAllAssoc2GenMultiMatched_Y"] =
345  i.book1D("RecoAllAssoc2GenMultiMatched_Y", "ReconstructedAllAssoc2GenMultiMatched_Y", 120, -0.6, 0.6);
346  mes_[label]["RecoAllAssoc2GenMultiMatched_Z"] =
347  i.book1D("RecoAllAssoc2GenMultiMatched_Z", "ReconstructedAllAssoc2GenMultiMatched_Z", 120, -60, 60);
348  mes_[label]["RecoAllAssoc2GenMultiMatched_R"] =
349  i.book1D("RecoAllAssoc2GenMultiMatched_R", "ReconstructedAllAssoc2GenMultiMatched_R", 120, 0, 0.6);
350  mes_[label]["RecoAllAssoc2GenMultiMatched_Pt2"] = i.book1D(
351  "RecoAllAssoc2GenMultiMatched_Pt2", "ReconstructedAllAssoc2GenMultiMatched_Sum-pt2", 15, &log_pt2_bins[0]);
352  mes_[label]["RecoAllAssoc2GenMultiMatched_NumTracks"] = i.book1D("RecoAllAssoc2GenMultiMatched_NumTracks",
353  "ReconstructedAllAssoc2GenMultiMatched_NumTracks",
354  24,
355  &log_ntrk_bins[0]);
356  mes_[label]["RecoAllAssoc2GenMultiMatched_PU"] =
357  i.book1D("RecoAllAssoc2GenMultiMatched_PU", "ReconstructedAllAssoc2GenMultiMatched_PU", 125, 0., 250.);
358  mes_[label]["RecoAllAssoc2GenMultiMatched_ClosestDistanceZ"] =
359  i.book1D("RecoAllAssoc2GenMultiMatched_ClosestDistanceZ",
360  "ReconstructedAllAssoc2GenMultiMatched_ClosestDistanceZ",
361  log_mergez_bins.size() - 1,
362  &log_mergez_bins[0]);
363 
364  // All Reconstructed Vertices Matched to a Multi-Matched Gen
365  // Vertex. Used for Duplicate rate plots done w.r.t. Reco
366  // Quantities. We basically want to ask how many times a RecoVTX
367  // has been reconstructed and associated to a SimulatedVTX that
368  // has been linked to at least another RecoVTX. In this sense this
369  // RecoVTX is a duplicate of the same, real GenVTX.
370  mes_[label]["RecoAllAssoc2MultiMatchedGen_NumVertices"] =
371  i.book1D("RecoAllAssoc2MultiMatchedGen_NumVertices", "RecoAllAssoc2MultiMatchedGen_NumVertices", 100, 0., 200.);
372  mes_[label]["RecoAllAssoc2MultiMatchedGen_X"] =
373  i.book1D("RecoAllAssoc2MultiMatchedGen_X", "RecoAllAssoc2MultiMatchedGen_X", 120, -0.6, 0.6);
374  mes_[label]["RecoAllAssoc2MultiMatchedGen_Y"] =
375  i.book1D("RecoAllAssoc2MultiMatchedGen_Y", "RecoAllAssoc2MultiMatchedGen_Y", 120, -0.6, 0.6);
376  mes_[label]["RecoAllAssoc2MultiMatchedGen_Z"] =
377  i.book1D("RecoAllAssoc2MultiMatchedGen_Z", "RecoAllAssoc2MultiMatchedGen_Z", 120, -60, 60);
378  mes_[label]["RecoAllAssoc2MultiMatchedGen_R"] =
379  i.book1D("RecoAllAssoc2MultiMatchedGen_R", "RecoAllAssoc2MultiMatchedGen_R", 120, 0, 0.6);
380  mes_[label]["RecoAllAssoc2MultiMatchedGen_Pt2"] =
381  i.book1D("RecoAllAssoc2MultiMatchedGen_Pt2", "RecoAllAssoc2MultiMatchedGen_Sum-pt2", 15, &log_pt2_bins[0]);
382  mes_[label]["RecoAllAssoc2MultiMatchedGen_NumTracks"] = i.book1D(
383  "RecoAllAssoc2MultiMatchedGen_NumTracks", "RecoAllAssoc2MultiMatchedGen_NumTracks", 24, &log_ntrk_bins[0]);
384  mes_[label]["RecoAllAssoc2MultiMatchedGen_PU"] =
385  i.book1D("RecoAllAssoc2MultiMatchedGen_PU", "RecoAllAssoc2MultiMatchedGen_PU", 125, 0., 250.);
386  mes_[label]["RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ"] =
387  i.book1D("RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ",
388  "RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ",
389  30,
390  &log_bins[0]);
391  mes_[label]["RecoAllAssoc2GenSimForMerge_ClosestDistanceZ"] =
392  i.book1D("RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
393  "RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
394  log_mergez_bins.size() - 1,
395  &log_mergez_bins[0]);
396 
397  // Resolution and pull histograms
398  const double resolpt2 = 10;
399 
400  const double minPull = -10;
401  const double maxPull = 10;
402  const double nPull = 100;
403 
404  auto bookResolPull = [&](const std::string& prefix, const double resolx, const double resoly, const double resolz) {
405  book1d((prefix + "_ResolX").c_str(), 100, -resolx, resolx);
406  book1d((prefix + "_ResolY").c_str(), 100, -resoly, resoly);
407  book1d((prefix + "_ResolZ").c_str(), 100, -resolz, resolz);
408  book1d((prefix + "_ResolPt2").c_str(), 100, -resolpt2, resolpt2);
409  book1d((prefix + "_PullX").c_str(), 250, -25, 25);
410  book1d((prefix + "_PullY").c_str(), 250, -25, 25);
411  book1d((prefix + "_PullZ").c_str(), 250, -25, 25);
412 
413  book2d((prefix + "_ResolX_vs_PU").c_str(), 125, 0., 250., 100, -resolx, resolx);
414  book2d((prefix + "_ResolY_vs_PU").c_str(), 125, 0., 250., 100, -resoly, resoly);
415  book2d((prefix + "_ResolZ_vs_PU").c_str(), 125, 0., 250., 100, -resolz, resolz);
416  book2d((prefix + "_ResolPt2_vs_PU").c_str(), 125, 0., 250., 100, -resolpt2, resolpt2);
417  book2d((prefix + "_PullX_vs_PU").c_str(), 125, 0., 250., nPull, minPull, maxPull);
418  book2d((prefix + "_PullY_vs_PU").c_str(), 125, 0., 250., nPull, minPull, maxPull);
419  book2d((prefix + "_PullZ_vs_PU").c_str(), 125, 0., 250., nPull, minPull, maxPull);
420 
421  book2dlogx((prefix + "_ResolX_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolx, resolx);
422  book2dlogx((prefix + "_ResolY_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resoly, resoly);
423  book2dlogx((prefix + "_ResolZ_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolz, resolz);
424  book2dlogx((prefix + "_ResolPt2_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolpt2, resolpt2);
425  book2dlogx((prefix + "_PullX_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
426  book2dlogx((prefix + "_PullY_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
427  book2dlogx((prefix + "_PullZ_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
428 
429  book2d((prefix + "_ResolX_vs_Z").c_str(), 120, -60, 60, 100, -resolx, resolx);
430  book2d((prefix + "_ResolY_vs_Z").c_str(), 120, -60, 60, 100, -resoly, resoly);
431  book2d((prefix + "_ResolZ_vs_Z").c_str(), 120, -60, 60, 100, -resolz, resolz);
432  book2d((prefix + "_ResolPt2_vs_Z").c_str(), 120, -60, 60, 100, -resolpt2, resolpt2);
433  book2d((prefix + "_PullX_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
434  book2d((prefix + "_PullY_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
435  book2d((prefix + "_PullZ_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
436 
437  book2dlogx((prefix + "_ResolX_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolx, resolx);
438  book2dlogx((prefix + "_ResolY_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resoly, resoly);
439  book2dlogx((prefix + "_ResolZ_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolz, resolz);
440  book2dlogx(
441  (prefix + "_ResolPt2_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolpt2, resolpt2);
442  book2dlogx((prefix + "_PullX_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
443  book2dlogx((prefix + "_PullY_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
444  book2dlogx((prefix + "_PullZ_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
445  };
446 
447  bookResolPull("RecoAllAssoc2GenMatched", 0.1, 0.1, 0.1); // Non-merged vertices
448  bookResolPull("RecoAllAssoc2GenMatchedMerged", 0.1, 0.1, 0.1); // Merged vertices
449  bookResolPull(
450  "RecoPVAssoc2GenPVMatched", 0.01, 0.01, 0.01); // PV, when correctly matched, regardless if merged or not
451 
452  // Purity histograms
453  // Reco PV (vtx0) matched to hard-scatter gen vertex
454  book1d("RecoPVAssoc2GenPVMatched_Purity", 50, 0, 1);
455  book1d("RecoPVAssoc2GenPVMatched_Missing", 50, 0, 1);
456  book2d("RecoPVAssoc2GenPVMatched_Purity_vs_Index", 100, 0, 100, 50, 0, 1);
457 
458  // RECO PV (vtx0) not matched to hard-scatter gen vertex
459  book1d("RecoPVAssoc2GenPVNotMatched_Purity", 50, 0, 1);
460  book1d("RecoPVAssoc2GenPVNotMatched_Missing", 50, 0, 1);
461  book2d("RecoPVAssoc2GenPVNotMatched_Purity_vs_Index", 100, 0, 100, 50, 0, 1);
462 
463  // Purity vs. fake rate
464  book1d("RecoAllAssoc2Gen_Purity", 50, 0, 1); // denominator
465  book1d("RecoAllAssoc2GenMatched_Purity", 50, 0, 1); // 1-numerator
466 
467  // Vertex sum(pt2)
468  // The first two are orthogonal (i.e. their sum includes all reco vertices)
469  book1dlogx("RecoAssoc2GenPVMatched_Pt2", 15, &log_pt2_bins[0]);
470  book1dlogx("RecoAssoc2GenPVNotMatched_Pt2", 15, &log_pt2_bins[0]);
471 
472  book1dlogx("RecoAssoc2GenPVMatchedNotHighest_Pt2", 15, &log_pt2_bins[0]);
473  book1dlogx("RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2", 15, &log_pt2_bins[0]);
474 
475  // Shared tracks
476  book1d("RecoAllAssoc2GenSingleMatched_SharedTrackFractionReco", 50, 0, 1);
477  book1d("RecoAllAssoc2GenMultiMatched_SharedTrackFractionReco", 50, 0, 1);
478  book1d("RecoAllAssoc2GenSingleMatched_SharedTrackFractionRecoMatched", 50, 0, 1);
479  book1d("RecoAllAssoc2GenMultiMatched_SharedTrackFractionRecoMatched", 50, 0, 1);
480 
481  book1d("RecoAllAssoc2GenSingleMatched_SharedTrackFractionSim", 50, 0, 1);
482  book1d("RecoAllAssoc2GenMultiMatched_SharedTrackFractionSim", 50, 0, 1);
483  book1d("RecoAllAssoc2GenSingleMatched_SharedTrackFractionSimMatched", 50, 0, 1);
484  book1d("RecoAllAssoc2GenMultiMatched_SharedTrackFractionSimMatched", 50, 0, 1);
485  }
486 }
487 
489  if (v.eventId.event() == 0) {
490  mes_["root_folder"]["GenPV_X"]->Fill(v.x);
491  mes_["root_folder"]["GenPV_Y"]->Fill(v.y);
492  mes_["root_folder"]["GenPV_Z"]->Fill(v.z);
493  mes_["root_folder"]["GenPV_R"]->Fill(v.r);
494  mes_["root_folder"]["GenPV_Pt2"]->Fill(v.ptsq);
495  mes_["root_folder"]["GenPV_NumTracks"]->Fill(v.nGenTrk);
496  if (v.closest_vertex_distance_z > 0.)
497  mes_["root_folder"]["GenPV_ClosestDistanceZ"]->Fill(v.closest_vertex_distance_z);
498  }
499  mes_["root_folder"]["GenAllV_X"]->Fill(v.x);
500  mes_["root_folder"]["GenAllV_Y"]->Fill(v.y);
501  mes_["root_folder"]["GenAllV_Z"]->Fill(v.z);
502  mes_["root_folder"]["GenAllV_R"]->Fill(v.r);
503  mes_["root_folder"]["GenAllV_Pt2"]->Fill(v.ptsq);
504  mes_["root_folder"]["GenAllV_NumTracks"]->Fill(v.nGenTrk);
505  if (v.closest_vertex_distance_z > 0.)
506  mes_["root_folder"]["GenAllV_ClosestDistanceZ"]->Fill(v.closest_vertex_distance_z);
507 }
508 
511  mes_[label]["GenAllAssoc2Reco_X"]->Fill(v.x);
512  mes_[label]["GenAllAssoc2Reco_Y"]->Fill(v.y);
513  mes_[label]["GenAllAssoc2Reco_Z"]->Fill(v.z);
514  mes_[label]["GenAllAssoc2Reco_R"]->Fill(v.r);
515  mes_[label]["GenAllAssoc2Reco_Pt2"]->Fill(v.ptsq);
516  mes_[label]["GenAllAssoc2Reco_NumTracks"]->Fill(v.nGenTrk);
517  if (v.closest_vertex_distance_z > 0.)
518  mes_[label]["GenAllAssoc2Reco_ClosestDistanceZ"]->Fill(v.closest_vertex_distance_z);
519  if (!v.rec_vertices.empty()) {
520  mes_[label]["GenAllAssoc2RecoMatched_X"]->Fill(v.x);
521  mes_[label]["GenAllAssoc2RecoMatched_Y"]->Fill(v.y);
522  mes_[label]["GenAllAssoc2RecoMatched_Z"]->Fill(v.z);
523  mes_[label]["GenAllAssoc2RecoMatched_R"]->Fill(v.r);
524  mes_[label]["GenAllAssoc2RecoMatched_Pt2"]->Fill(v.ptsq);
525  mes_[label]["GenAllAssoc2RecoMatched_NumTracks"]->Fill(v.nGenTrk);
526  if (v.closest_vertex_distance_z > 0.)
527  mes_[label]["GenAllAssoc2RecoMatched_ClosestDistanceZ"]->Fill(v.closest_vertex_distance_z);
528  }
529  if (v.rec_vertices.size() > 1) {
530  mes_[label]["GenAllAssoc2RecoMultiMatched_X"]->Fill(v.x);
531  mes_[label]["GenAllAssoc2RecoMultiMatched_Y"]->Fill(v.y);
532  mes_[label]["GenAllAssoc2RecoMultiMatched_Z"]->Fill(v.z);
533  mes_[label]["GenAllAssoc2RecoMultiMatched_R"]->Fill(v.r);
534  mes_[label]["GenAllAssoc2RecoMultiMatched_Pt2"]->Fill(v.ptsq);
535  mes_[label]["GenAllAssoc2RecoMultiMatched_NumTracks"]->Fill(v.nGenTrk);
536  if (v.closest_vertex_distance_z > 0.)
537  mes_[label]["GenAllAssoc2RecoMultiMatched_ClosestDistanceZ"]->Fill(v.closest_vertex_distance_z);
538  }
539 }
540 
542  const std::string& label, const PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex& v, bool genPVMatchedToRecoPV) {
543  mes_[label]["GenPVAssoc2RecoPV_X"]->Fill(v.x);
544  mes_[label]["GenPVAssoc2RecoPV_Y"]->Fill(v.y);
545  mes_[label]["GenPVAssoc2RecoPV_Z"]->Fill(v.z);
546  if (genPVMatchedToRecoPV) {
547  mes_[label]["GenPVAssoc2RecoPVMatched_X"]->Fill(v.x);
548  mes_[label]["GenPVAssoc2RecoPVMatched_Y"]->Fill(v.y);
549  mes_[label]["GenPVAssoc2RecoPVMatched_Z"]->Fill(v.z);
550  }
551 }
552 
554  const std::string& label, int num_pileup_vertices, PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex& v) {
555  mes_[label]["RecoAllAssoc2Gen_X"]->Fill(v.x);
556  mes_[label]["RecoAllAssoc2Gen_Y"]->Fill(v.y);
557  mes_[label]["RecoAllAssoc2Gen_Z"]->Fill(v.z);
558  mes_[label]["RecoAllAssoc2Gen_R"]->Fill(v.r);
559  mes_[label]["RecoAllAssoc2Gen_Pt2"]->Fill(v.ptsq);
560  mes_[label]["RecoAllAssoc2Gen_Ndof"]->Fill(v.recVtx->ndof());
561  mes_[label]["RecoAllAssoc2Gen_NumTracks"]->Fill(v.nRecoTrk);
562  mes_[label]["RecoAllAssoc2Gen_PU"]->Fill(num_pileup_vertices);
563  mes_[label]["RecoAllAssoc2Gen_Purity"]->Fill(v.purity);
564  if (v.closest_vertex_distance_z > 0.)
565  mes_[label]["RecoAllAssoc2Gen_ClosestDistanceZ"]->Fill(v.closest_vertex_distance_z);
566  if (!v.sim_vertices.empty()) {
567  v.kind_of_vertex |= recoPrimaryVertex::MATCHED;
568  mes_[label]["RecoAllAssoc2GenMatched_X"]->Fill(v.x);
569  mes_[label]["RecoAllAssoc2GenMatched_Y"]->Fill(v.y);
570  mes_[label]["RecoAllAssoc2GenMatched_Z"]->Fill(v.z);
571  mes_[label]["RecoAllAssoc2GenMatched_R"]->Fill(v.r);
572  mes_[label]["RecoAllAssoc2GenMatched_Pt2"]->Fill(v.ptsq);
573  mes_[label]["RecoAllAssoc2GenMatched_Ndof"]->Fill(v.recVtx->ndof());
574  mes_[label]["RecoAllAssoc2GenMatched_NumTracks"]->Fill(v.nRecoTrk);
575  mes_[label]["RecoAllAssoc2GenMatched_PU"]->Fill(num_pileup_vertices);
576  mes_[label]["RecoAllAssoc2GenMatched_Purity"]->Fill(v.purity);
577  if (v.closest_vertex_distance_z > 0.)
578  mes_[label]["RecoAllAssoc2GenMatched_ClosestDistanceZ"]->Fill(v.closest_vertex_distance_z);
579 
580  // Fill resolution and pull plots here (as in MultiTrackValidator)
581  fillResolutionAndPullHistograms(label, num_pileup_vertices, v, false);
582 
583  // Now keep track of all RecoVTX associated to a SimVTX that
584  // itself is associated to more than one RecoVTX, for
585  // duplicate-rate plots on reco quantities.
586  if (v.sim_vertices_internal[0]->rec_vertices.size() > 1) {
587  v.kind_of_vertex |= recoPrimaryVertex::DUPLICATE;
588  mes_[label]["RecoAllAssoc2MultiMatchedGen_X"]->Fill(v.x);
589  mes_[label]["RecoAllAssoc2MultiMatchedGen_Y"]->Fill(v.y);
590  mes_[label]["RecoAllAssoc2MultiMatchedGen_Z"]->Fill(v.z);
591  mes_[label]["RecoAllAssoc2MultiMatchedGen_R"]->Fill(v.r);
592  mes_[label]["RecoAllAssoc2MultiMatchedGen_Pt2"]->Fill(v.ptsq);
593  mes_[label]["RecoAllAssoc2MultiMatchedGen_NumTracks"]->Fill(v.nRecoTrk);
594  mes_[label]["RecoAllAssoc2MultiMatchedGen_PU"]->Fill(num_pileup_vertices);
595  if (v.closest_vertex_distance_z > 0.)
596  mes_[label]["RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ"]->Fill(v.closest_vertex_distance_z);
597  }
598  // This is meant to be used as "denominator" for the merge-rate
599  // plots produced starting from reco quantities. We enter here
600  // only if the reco vertex has been associated, since we need info
601  // from the SimVTX associated to it. In this regard, the final
602  // merge-rate plot coming from reco is not to be intended as a
603  // pure efficiency-like plot, since the normalization is biased.
604  if (v.sim_vertices_internal[0]->closest_vertex_distance_z > 0.)
605  mes_[label]["RecoAllAssoc2GenSimForMerge_ClosestDistanceZ"]->Fill(
606  v.sim_vertices_internal[0]->closest_vertex_distance_z);
607  }
608  // this plots are meant to be used to compute the merge rate
609  if (v.sim_vertices.size() > 1) {
610  v.kind_of_vertex |= recoPrimaryVertex::MERGED;
611  mes_[label]["RecoAllAssoc2GenMultiMatched_X"]->Fill(v.x);
612  mes_[label]["RecoAllAssoc2GenMultiMatched_Y"]->Fill(v.y);
613  mes_[label]["RecoAllAssoc2GenMultiMatched_Z"]->Fill(v.z);
614  mes_[label]["RecoAllAssoc2GenMultiMatched_R"]->Fill(v.r);
615  mes_[label]["RecoAllAssoc2GenMultiMatched_Pt2"]->Fill(v.ptsq);
616  mes_[label]["RecoAllAssoc2GenMultiMatched_NumTracks"]->Fill(v.nRecoTrk);
617  mes_[label]["RecoAllAssoc2GenMultiMatched_PU"]->Fill(num_pileup_vertices);
618  if (v.sim_vertices_internal[0]->closest_vertex_distance_z > 0.)
619  mes_[label]["RecoAllAssoc2GenMultiMatched_ClosestDistanceZ"]->Fill(
620  v.sim_vertices_internal[0]->closest_vertex_distance_z);
621  }
622  mes_[label]["RecoAllAssoc2GenProperties"]->Fill(v.kind_of_vertex);
623 
625  if (v.sim_vertices.size() == 1) {
626  prefix = "RecoAllAssoc2GenSingleMatched_SharedTrackFraction";
627  } else if (v.sim_vertices.size() > 1) {
628  prefix = "RecoAllAssoc2GenMultiMatched_SharedTrackFraction";
629  }
630 
631  for (size_t i = 0; i < v.sim_vertices.size(); ++i) {
632  const double sharedTracks = v.sim_vertices_num_shared_tracks[i];
633  const simPrimaryVertex* simV = v.sim_vertices_internal[i];
634  mes_[label][prefix + "Reco"]->Fill(sharedTracks / v.nRecoTrk);
635  mes_[label][prefix + "RecoMatched"]->Fill(sharedTracks / v.num_matched_sim_tracks);
636  mes_[label][prefix + "Sim"]->Fill(sharedTracks / simV->nGenTrk);
637  mes_[label][prefix + "SimMatched"]->Fill(sharedTracks / simV->num_matched_reco_tracks);
638  }
639 }
640 
642  const std::string& label,
643  int num_pileup_vertices,
645  bool isPV) {
646  std::string prefix = "RecoAllAssoc2GenMatched";
647  if (v.sim_vertices_internal.size() > 1) {
648  prefix += "Merged";
649  }
650  if (isPV) {
651  prefix = "RecoPVAssoc2GenPVMatched";
652  }
653 
654  // Use the best match as defined by the vertex truth associator
655  // reco-tracks as the best match
656  const simPrimaryVertex& bestMatch = *(v.sim_vertices_internal[0]);
657  const double xres = v.x - bestMatch.x;
658  const double yres = v.y - bestMatch.y;
659  const double zres = v.z - bestMatch.z;
660  const double pt2res = v.ptsq - bestMatch.ptsq;
661 
662  const double xresol = xres;
663  const double yresol = yres;
664  const double zresol = zres;
665  const double pt2resol = pt2res / v.ptsq;
666  const double xpull = xres / v.recVtx->xError();
667  const double ypull = yres / v.recVtx->yError();
668  const double zpull = zres / v.recVtx->zError();
669 
670  mes_[label][prefix + "_ResolX"]->Fill(xresol);
671  mes_[label][prefix + "_ResolY"]->Fill(yresol);
672  mes_[label][prefix + "_ResolZ"]->Fill(zresol);
673  mes_[label][prefix + "_ResolPt2"]->Fill(pt2resol);
674  mes_[label][prefix + "_PullX"]->Fill(xpull);
675  mes_[label][prefix + "_PullY"]->Fill(ypull);
676  mes_[label][prefix + "_PullZ"]->Fill(zpull);
677 
678  mes_[label][prefix + "_ResolX_vs_PU"]->Fill(num_pileup_vertices, xresol);
679  mes_[label][prefix + "_ResolY_vs_PU"]->Fill(num_pileup_vertices, yresol);
680  mes_[label][prefix + "_ResolZ_vs_PU"]->Fill(num_pileup_vertices, zresol);
681  mes_[label][prefix + "_ResolPt2_vs_PU"]->Fill(num_pileup_vertices, pt2resol);
682  mes_[label][prefix + "_PullX_vs_PU"]->Fill(num_pileup_vertices, xpull);
683  mes_[label][prefix + "_PullY_vs_PU"]->Fill(num_pileup_vertices, ypull);
684  mes_[label][prefix + "_PullZ_vs_PU"]->Fill(num_pileup_vertices, zpull);
685 
686  mes_[label][prefix + "_ResolX_vs_NumTracks"]->Fill(v.nRecoTrk, xresol);
687  mes_[label][prefix + "_ResolY_vs_NumTracks"]->Fill(v.nRecoTrk, yresol);
688  mes_[label][prefix + "_ResolZ_vs_NumTracks"]->Fill(v.nRecoTrk, zresol);
689  mes_[label][prefix + "_ResolPt2_vs_NumTracks"]->Fill(v.nRecoTrk, pt2resol);
690  mes_[label][prefix + "_PullX_vs_NumTracks"]->Fill(v.nRecoTrk, xpull);
691  mes_[label][prefix + "_PullY_vs_NumTracks"]->Fill(v.nRecoTrk, ypull);
692  mes_[label][prefix + "_PullZ_vs_NumTracks"]->Fill(v.nRecoTrk, zpull);
693 
694  mes_[label][prefix + "_ResolX_vs_Z"]->Fill(v.z, xresol);
695  mes_[label][prefix + "_ResolY_vs_Z"]->Fill(v.z, yresol);
696  mes_[label][prefix + "_ResolZ_vs_Z"]->Fill(v.z, zresol);
697  mes_[label][prefix + "_ResolPt2_vs_Z"]->Fill(v.z, pt2resol);
698  mes_[label][prefix + "_PullX_vs_Z"]->Fill(v.z, xpull);
699  mes_[label][prefix + "_PullY_vs_Z"]->Fill(v.z, ypull);
700  mes_[label][prefix + "_PullZ_vs_Z"]->Fill(v.z, zpull);
701 
702  mes_[label][prefix + "_ResolX_vs_Pt"]->Fill(v.pt, xresol);
703  mes_[label][prefix + "_ResolY_vs_Pt"]->Fill(v.pt, yresol);
704  mes_[label][prefix + "_ResolZ_vs_Pt"]->Fill(v.pt, zresol);
705  mes_[label][prefix + "_ResolPt2_vs_Pt"]->Fill(v.pt, pt2resol);
706  mes_[label][prefix + "_PullX_vs_Pt"]->Fill(v.pt, xpull);
707  mes_[label][prefix + "_PullY_vs_Pt"]->Fill(v.pt, ypull);
708  mes_[label][prefix + "_PullZ_vs_Pt"]->Fill(v.pt, zpull);
709 }
710 
712  auto found = r2s_->find(recoTrack);
713 
714  // reco track not matched to any TP
715  if (found == r2s_->end())
716  return false;
717 
718  // reco track matched to some TP from signal vertex
719  for (const auto& tp : found->val) {
720  if (tp.first->eventId().bunchCrossing() == 0 && tp.first->eventId().event() == 0)
721  return true;
722  }
723 
724  // reco track not matched to any TP from signal vertex
725  return false;
726 }
727 
729  std::vector<recoPrimaryVertex>& recopvs,
730  int genpv_position_in_reco_collection,
731  bool signal_is_highest_pt) {
732  if (recopvs.empty())
733  return;
734 
735  std::vector<double> vtx_sumpt_sigmatched;
736  std::vector<double> vtx_sumpt2_sigmatched;
737 
738  vtx_sumpt_sigmatched.reserve(recopvs.size());
739  vtx_sumpt2_sigmatched.reserve(recopvs.size());
740 
741  // Calculate purity
742  for (auto& v : recopvs) {
743  double sumpt_all = 0;
744  double sumpt_sigmatched = 0;
745  double sumpt2_sigmatched = 0;
746  const reco::Vertex* vertex = v.recVtx;
747  for (auto iTrack = vertex->tracks_begin(); iTrack != vertex->tracks_end(); ++iTrack) {
748  double pt = (*iTrack)->pt();
749  sumpt_all += pt;
750  if (matchRecoTrack2SimSignal(*iTrack)) {
751  sumpt_sigmatched += pt;
752  sumpt2_sigmatched += pt * pt;
753  }
754  }
755  v.purity = sumpt_sigmatched / sumpt_all;
756 
757  vtx_sumpt_sigmatched.push_back(sumpt_sigmatched);
758  vtx_sumpt2_sigmatched.push_back(sumpt2_sigmatched);
759  }
760 
761  const double vtxAll_sumpt_sigmatched = std::accumulate(vtx_sumpt_sigmatched.begin(), vtx_sumpt_sigmatched.end(), 0.0);
762  const double vtxNot0_sumpt_sigmatched = vtxAll_sumpt_sigmatched - vtx_sumpt_sigmatched[0];
763  const double missing = vtxNot0_sumpt_sigmatched / vtxAll_sumpt_sigmatched;
764 
765  // Fill purity
766  std::string prefix = "RecoPVAssoc2GenPVNotMatched_";
767  if (genpv_position_in_reco_collection == 0)
768  prefix = "RecoPVAssoc2GenPVMatched_";
769 
770  mes_[label][prefix + "Purity"]->Fill(recopvs[0].purity);
771  mes_[label][prefix + "Missing"]->Fill(missing);
772  auto hpurity = mes_[label][prefix + "Purity_vs_Index"];
773  for (size_t i = 0; i < recopvs.size(); ++i) {
774  hpurity->Fill(i, recopvs[i].purity);
775  }
776 
777  // Fill sumpt2
778  for (size_t i = 0; i < recopvs.size(); ++i) {
779  if (static_cast<int>(i) == genpv_position_in_reco_collection) {
780  mes_[label]["RecoAssoc2GenPVMatched_Pt2"]->Fill(recopvs[i].ptsq);
781  } else {
782  double pt2 = recopvs[i].ptsq;
783  mes_[label]["RecoAssoc2GenPVNotMatched_Pt2"]->Fill(pt2);
784  // Subtract hard-scatter track pt2 from the pileup pt2
785  double pt2_pu = pt2 - vtx_sumpt2_sigmatched[i];
786  mes_[label]["RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2"]->Fill(pt2_pu);
787  }
788  }
789  if (!signal_is_highest_pt && genpv_position_in_reco_collection >= 0)
790  mes_[label]["RecoAssoc2GenPVMatchedNotHighest_Pt2"]->Fill(recopvs[genpv_position_in_reco_collection].ptsq);
791 }
792 
793 /* Extract information form TrackingParticles/TrackingVertex and fill
794  * the helper class simPrimaryVertex with proper generation-level
795  * information */
796 std::vector<PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex> PrimaryVertexAnalyzer4PUSlimmed::getSimPVs(
798  std::vector<PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex> simpv;
799  int current_event = -1;
800 
801  if (verbose_) {
802  std::cout << "getSimPVs TrackingVertexCollection " << std::endl;
803  }
804 
805  for (TrackingVertexCollection::const_iterator v = tVC->begin(); v != tVC->end(); ++v) {
806  if (verbose_) {
807  std::cout << "BunchX.EventId: " << v->eventId().bunchCrossing() << "." << (v->eventId()).event()
808  << " Position: " << v->position() << " G4/HepMC Vertices: " << v->g4Vertices().size() << "/"
809  << v->genVertices().size() << " t = " << v->position().t() * 1.e12
810  << " == 0:" << (v->position().t() > 0) << std::endl;
811  for (TrackingVertex::g4v_iterator gv = v->g4Vertices_begin(); gv != v->g4Vertices_end(); gv++) {
812  std::cout << *gv << std::endl;
813  }
814  std::cout << "----------" << std::endl;
815 
816  } // end of verbose_ session
817 
818  // I'd rather change this and select only vertices that come from
819  // BX=0. We should keep only the first vertex from all the events
820  // at BX=0.
821  if (v->eventId().bunchCrossing() != 0)
822  continue;
823  if (v->eventId().event() != current_event) {
824  current_event = v->eventId().event();
825  } else {
826  continue;
827  }
828  // TODO(rovere) is this really necessary?
829  if (fabs(v->position().z()) > 1000)
830  continue; // skip funny junk vertices
831 
832  // could be a new vertex, check all primaries found so far to avoid
833  // multiple entries
834  simPrimaryVertex sv(v->position().x(), v->position().y(), v->position().z());
835  sv.eventId = v->eventId();
836  sv.sim_vertex = TrackingVertexRef(tVC, std::distance(tVC->begin(), v));
837 
838  for (TrackingParticleRefVector::iterator iTrack = v->daughterTracks_begin(); iTrack != v->daughterTracks_end();
839  ++iTrack) {
840  // TODO(rovere) isn't it always the case? Is it really worth
841  // checking this out?
842  // sv.eventId = (**iTrack).eventId();
843  assert((**iTrack).eventId().bunchCrossing() == 0);
844  }
845  // TODO(rovere) maybe get rid of this old logic completely ... ?
846  simPrimaryVertex* vp = nullptr; // will become non-NULL if a vertex
847  // is found and then point to it
848  for (std::vector<simPrimaryVertex>::iterator v0 = simpv.begin(); v0 != simpv.end(); v0++) {
849  if ((sv.eventId == v0->eventId) && (fabs(sv.x - v0->x) < 1e-5) && (fabs(sv.y - v0->y) < 1e-5) &&
850  (fabs(sv.z - v0->z) < 1e-5)) {
851  vp = &(*v0);
852  break;
853  }
854  }
855  if (!vp) {
856  // this is a new vertex, add it to the list of sim-vertices
857  simpv.push_back(sv);
858  vp = &simpv.back();
859  if (verbose_) {
860  std::cout << "this is a new vertex " << sv.eventId.event() << " " << sv.x << " " << sv.y << " " << sv.z
861  << std::endl;
862  }
863  } else {
864  if (verbose_) {
865  std::cout << "this is not a new vertex" << sv.x << " " << sv.y << " " << sv.z << std::endl;
866  }
867  }
868 
869  // Loop over daughter track(s) as Tracking Particles
870  for (TrackingVertex::tp_iterator iTP = v->daughterTracks_begin(); iTP != v->daughterTracks_end(); ++iTP) {
871  auto momentum = (*(*iTP)).momentum();
872  const reco::Track* matched_best_reco_track = nullptr;
873  double match_quality = -1;
874  if (use_only_charged_tracks_ && (**iTP).charge() == 0)
875  continue;
876  if (s2r_->find(*iTP) != s2r_->end()) {
877  matched_best_reco_track = (*s2r_)[*iTP][0].first.get();
878  match_quality = (*s2r_)[*iTP][0].second;
879  }
880  if (verbose_) {
881  std::cout << " Daughter momentum: " << momentum;
882  std::cout << " Daughter type " << (*(*iTP)).pdgId();
883  std::cout << " matched: " << (matched_best_reco_track != nullptr);
884  std::cout << " match-quality: " << match_quality;
885  std::cout << std::endl;
886  }
887  vp->ptot.setPx(vp->ptot.x() + momentum.x());
888  vp->ptot.setPy(vp->ptot.y() + momentum.y());
889  vp->ptot.setPz(vp->ptot.z() + momentum.z());
890  vp->ptot.setE(vp->ptot.e() + (**iTP).energy());
891  vp->ptsq += ((**iTP).pt() * (**iTP).pt());
892  // TODO(rovere) only select charged sim-particles? If so, maybe
893  // put it as a configuration parameter?
894  if (matched_best_reco_track) {
896  vp->average_match_quality += match_quality;
897  }
898  // TODO(rovere) get rid of cuts on sim-tracks
899  // TODO(rovere) be consistent between simulated tracks and
900  // reconstructed tracks selection
901  // count relevant particles
902  if (((**iTP).pt() > 0.2) && (fabs((**iTP).eta()) < 2.5) && (**iTP).charge() != 0) {
903  vp->nGenTrk++;
904  }
905  } // End of for loop on daughters sim-particles
906  if (vp->num_matched_reco_tracks)
907  vp->average_match_quality /= static_cast<float>(vp->num_matched_reco_tracks);
908  if (verbose_) {
909  std::cout << "average number of associated tracks: "
910  << vp->num_matched_reco_tracks / static_cast<float>(vp->nGenTrk)
911  << " with average quality: " << vp->average_match_quality << std::endl;
912  }
913  } // End of for loop on tracking vertices
914 
915  if (verbose_) {
916  std::cout << "------- PrimaryVertexAnalyzer4PUSlimmed simPVs from "
917  "TrackingVertices "
918  "-------"
919  << std::endl;
920  for (std::vector<simPrimaryVertex>::iterator v0 = simpv.begin(); v0 != simpv.end(); v0++) {
921  std::cout << "z=" << v0->z << " event=" << v0->eventId.event() << std::endl;
922  }
923  std::cout << "-----------------------------------------------" << std::endl;
924  } // End of for summary on discovered simulated primary vertices.
925 
926  // In case of no simulated vertices, break here
927  if (simpv.empty())
928  return simpv;
929 
930  // Now compute the closest distance in z between all simulated vertex
931  // first initialize
932  auto prev_z = simpv.back().z;
933  for (simPrimaryVertex& vsim : simpv) {
934  vsim.closest_vertex_distance_z = std::abs(vsim.z - prev_z);
935  prev_z = vsim.z;
936  }
937  // then calculate
938  for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin(); vsim != simpv.end(); vsim++) {
939  std::vector<simPrimaryVertex>::iterator vsim2 = vsim;
940  vsim2++;
941  for (; vsim2 != simpv.end(); vsim2++) {
942  double distance = std::abs(vsim->z - vsim2->z);
943  // need both to be complete
944  vsim->closest_vertex_distance_z = std::min(vsim->closest_vertex_distance_z, distance);
945  vsim2->closest_vertex_distance_z = std::min(vsim2->closest_vertex_distance_z, distance);
946  }
947  }
948  return simpv;
949 }
950 
951 /* Extract information form recoVertex and fill the helper class
952  * recoPrimaryVertex with proper reco-level information */
953 std::vector<PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex> PrimaryVertexAnalyzer4PUSlimmed::getRecoPVs(
954  const edm::Handle<edm::View<reco::Vertex>>& tVC) {
955  std::vector<PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex> recopv;
956 
957  if (verbose_) {
958  std::cout << "getRecoPVs TrackingVertexCollection " << std::endl;
959  }
960 
961  for (auto v = tVC->begin(); v != tVC->end(); ++v) {
962  if (verbose_) {
963  std::cout << " Position: " << v->position() << std::endl;
964  }
965 
966  // Skip junk vertices
967  if (fabs(v->z()) > 1000)
968  continue;
969  if (v->isFake() || !v->isValid())
970  continue;
971 
972  recoPrimaryVertex sv(v->position().x(), v->position().y(), v->position().z());
973  sv.recVtx = &(*v);
974  sv.recVtxRef = reco::VertexBaseRef(tVC, std::distance(tVC->begin(), v));
975  // this is a new vertex, add it to the list of reco-vertices
976  recopv.push_back(sv);
978 
979  // Loop over daughter track(s)
980  for (auto iTrack = v->tracks_begin(); iTrack != v->tracks_end(); ++iTrack) {
981  auto momentum = (*(*iTrack)).innerMomentum();
982  // TODO(rovere) better handle the pixelVertices, whose tracks
983  // do not have the innerMomentum defined. This is a temporary
984  // hack to overcome this problem.
985  if (momentum.mag2() == 0)
986  momentum = (*(*iTrack)).momentum();
987  if (verbose_) {
988  std::cout << " Daughter momentum: " << momentum;
989  std::cout << std::endl;
990  }
991  vp->pt += std::sqrt(momentum.perp2());
992  vp->ptsq += (momentum.perp2());
993  vp->nRecoTrk++;
994 
995  auto matched = r2s_->find(*iTrack);
996  if (matched != r2s_->end()) {
998  }
999 
1000  } // End of for loop on daughters reconstructed tracks
1001  } // End of for loop on tracking vertices
1002 
1003  if (verbose_) {
1004  std::cout << "------- PrimaryVertexAnalyzer4PUSlimmed recoPVs from "
1005  "VertexCollection "
1006  "-------"
1007  << std::endl;
1008  for (std::vector<recoPrimaryVertex>::iterator v0 = recopv.begin(); v0 != recopv.end(); v0++) {
1009  std::cout << "z=" << v0->z << std::endl;
1010  }
1011  std::cout << "-----------------------------------------------" << std::endl;
1012  } // End of for summary on reconstructed primary vertices.
1013 
1014  // In case of no reco vertices, break here
1015  if (recopv.empty())
1016  return recopv;
1017 
1018  // Now compute the closest distance in z between all reconstructed vertex
1019  // first initialize
1020  auto prev_z = recopv.back().z;
1021  for (recoPrimaryVertex& vreco : recopv) {
1022  vreco.closest_vertex_distance_z = std::abs(vreco.z - prev_z);
1023  prev_z = vreco.z;
1024  }
1025  for (std::vector<recoPrimaryVertex>::iterator vreco = recopv.begin(); vreco != recopv.end(); vreco++) {
1026  std::vector<recoPrimaryVertex>::iterator vreco2 = vreco;
1027  vreco2++;
1028  for (; vreco2 != recopv.end(); vreco2++) {
1029  double distance = std::abs(vreco->z - vreco2->z);
1030  // need both to be complete
1031  vreco->closest_vertex_distance_z = std::min(vreco->closest_vertex_distance_z, distance);
1032  vreco2->closest_vertex_distance_z = std::min(vreco2->closest_vertex_distance_z, distance);
1033  }
1034  }
1035  return recopv;
1036 }
1037 
1038 void PrimaryVertexAnalyzer4PUSlimmed::resetSimPVAssociation(std::vector<simPrimaryVertex>& simpv) {
1039  for (auto& v : simpv) {
1040  v.rec_vertices.clear();
1041  }
1042 }
1043 
1044 // ------------ method called to produce the data ------------
1045 void PrimaryVertexAnalyzer4PUSlimmed::matchSim2RecoVertices(std::vector<simPrimaryVertex>& simpv,
1046  const reco::VertexSimToRecoCollection& vertex_s2r) {
1047  if (verbose_) {
1048  std::cout << "PrimaryVertexAnalyzer4PUSlimmed::matchSim2RecoVertices " << std::endl;
1049  }
1050  for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin(); vsim != simpv.end(); vsim++) {
1051  auto matched = vertex_s2r.find(vsim->sim_vertex);
1052  if (matched != vertex_s2r.end()) {
1053  for (const auto& vertexRefQuality : matched->val) {
1054  vsim->rec_vertices.push_back(&(*(vertexRefQuality.first)));
1055  }
1056  }
1057 
1058  if (verbose_) {
1059  if (!vsim->rec_vertices.empty()) {
1060  for (auto const& v : vsim->rec_vertices) {
1061  std::cout << "Found a matching vertex for genVtx " << vsim->z << " at " << v->z()
1062  << " with sign: " << fabs(v->z() - vsim->z) / v->zError() << std::endl;
1063  }
1064  } else {
1065  std::cout << "No matching vertex for " << vsim->z << std::endl;
1066  }
1067  }
1068  } // end for loop on simulated vertices
1069  if (verbose_) {
1070  std::cout << "Done with matching sim vertices" << std::endl;
1071  }
1072 }
1073 
1074 void PrimaryVertexAnalyzer4PUSlimmed::matchReco2SimVertices(std::vector<recoPrimaryVertex>& recopv,
1075  const reco::VertexRecoToSimCollection& vertex_r2s,
1076  const std::vector<simPrimaryVertex>& simpv) {
1077  for (std::vector<recoPrimaryVertex>::iterator vrec = recopv.begin(); vrec != recopv.end(); vrec++) {
1078  auto matched = vertex_r2s.find(vrec->recVtxRef);
1079  if (matched != vertex_r2s.end()) {
1080  for (const auto& vertexRefQuality : matched->val) {
1081  const auto tvPtr = &(*(vertexRefQuality.first));
1082  vrec->sim_vertices.push_back(tvPtr);
1083  }
1084 
1085  for (const TrackingVertex* tv : vrec->sim_vertices) {
1086  // Set pointers to internal simVertex objects
1087  for (const auto& vv : simpv) {
1088  if (&(*(vv.sim_vertex)) == tv) {
1089  vrec->sim_vertices_internal.push_back(&vv);
1090  continue;
1091  }
1092  }
1093 
1094  // Calculate number of shared tracks
1095  vrec->sim_vertices_num_shared_tracks.push_back(calculateVertexSharedTracks(*(vrec->recVtx), *tv, *r2s_));
1096  }
1097  }
1098 
1099  if (verbose_) {
1100  for (auto v : vrec->sim_vertices) {
1101  std::cout << "Found a matching vertex for reco: " << vrec->z << " at gen:" << v->position().z()
1102  << " with sign: " << fabs(vrec->z - v->position().z()) / vrec->recVtx->zError() << std::endl;
1103  }
1104  }
1105  } // end for loop on reconstructed vertices
1106 }
1107 
1109  using edm::Handle;
1110  using edm::View;
1111  using std::cout;
1112  using std::endl;
1113  using std::vector;
1114  using namespace reco;
1115 
1116  std::vector<float> pileUpInfo_z;
1117 
1118  // get the pileup information
1120  if (iEvent.getByToken(vecPileupSummaryInfoToken_, puinfoH)) {
1121  for (auto const& pu_info : *puinfoH.product()) {
1122  if (do_generic_sim_plots_) {
1123  mes_["root_folder"]["GenVtx_vs_BX"]->Fill(pu_info.getBunchCrossing(), pu_info.getPU_NumInteractions());
1124  }
1125  if (pu_info.getBunchCrossing() == 0) {
1126  pileUpInfo_z = pu_info.getPU_zpositions();
1127  if (verbose_) {
1128  for (auto const& p : pileUpInfo_z) {
1129  std::cout << "PileUpInfo on Z vertex: " << p << std::endl;
1130  }
1131  }
1132  break;
1133  }
1134  }
1135  }
1136 
1138  iEvent.getByToken(trackingParticleCollectionToken_, TPCollectionH);
1139  if (!TPCollectionH.isValid())
1140  edm::LogWarning("PrimaryVertexAnalyzer4PUSlimmed") << "TPCollectionH is not valid";
1141 
1143  iEvent.getByToken(trackingVertexCollectionToken_, TVCollectionH);
1144  if (!TVCollectionH.isValid())
1145  edm::LogWarning("PrimaryVertexAnalyzer4PUSlimmed") << "TVCollectionH is not valid";
1146 
1147  // TODO(rovere) the idea is to put in case a track-selector in front
1148  // of this module and then use its label to get the selected tracks
1149  // out of the event instead of making an hard-coded selection in the
1150  // code.
1151 
1153  iEvent.getByToken(simToRecoAssociationToken_, simToRecoH);
1154  if (simToRecoH.isValid())
1155  s2r_ = simToRecoH.product();
1156  else
1157  edm::LogWarning("PrimaryVertexAnalyzer4PUSlimmed") << "simToRecoH is not valid";
1158 
1160  iEvent.getByToken(recoToSimAssociationToken_, recoToSimH);
1161  if (recoToSimH.isValid())
1162  r2s_ = recoToSimH.product();
1163  else
1164  edm::LogWarning("PrimaryVertexAnalyzer4PUSlimmed") << "recoToSimH is not valid";
1165 
1166  // Vertex associator
1168  iEvent.getByToken(vertexAssociatorToken_, vertexAssociatorH);
1169  if (!vertexAssociatorH.isValid()) {
1170  edm::LogWarning("PrimaryVertexAnalyzer4PUSlimmed") << "vertexAssociatorH is not valid";
1171  return;
1172  }
1173  const reco::VertexToTrackingVertexAssociator& vertexAssociator = *(vertexAssociatorH.product());
1174 
1175  std::vector<simPrimaryVertex> simpv; // a list of simulated primary
1176  // MC vertices
1177  // TODO(rovere) use move semantic?
1178  simpv = getSimPVs(TVCollectionH);
1179  // TODO(rovere) 1 vertex is not, by definition, pileup, and should
1180  // probably be subtracted?
1181  int kind_of_signal_vertex = 0;
1182  int num_pileup_vertices = simpv.size();
1184  mes_["root_folder"]["GenAllV_NumVertices"]->Fill(simpv.size());
1185  bool signal_is_highest_pt =
1186  std::max_element(simpv.begin(), simpv.end(), [](const simPrimaryVertex& lhs, const simPrimaryVertex& rhs) {
1187  return lhs.ptsq < rhs.ptsq;
1188  }) == simpv.begin();
1189  kind_of_signal_vertex |= (signal_is_highest_pt << HIGHEST_PT);
1190  if (do_generic_sim_plots_) {
1191  mes_["root_folder"]["SignalIsHighestPt2"]->Fill(signal_is_highest_pt ? 1. : 0.);
1192  computePairDistance(simpv, mes_["root_folder"]["GenAllV_PairDistanceZ"]);
1193  }
1194 
1195  int label_index = -1;
1196  for (size_t iToken = 0, endToken = reco_vertex_collection_tokens_.size(); iToken < endToken; ++iToken) {
1197  auto const& vertex_token = reco_vertex_collection_tokens_[iToken];
1198  std::vector<recoPrimaryVertex> recopv; // a list of reconstructed
1199  // primary MC vertices
1200  std::string label = reco_vertex_collections_[++label_index].label();
1202  if (!iEvent.getByToken(vertex_token, recVtxs)) {
1203  if (!errorPrintedForColl_[iToken]) {
1204  edm::LogWarning("PrimaryVertexAnalyzer4PUSlimmed")
1205  << "Skipping vertex collection: " << label << " since it is missing.";
1206  errorPrintedForColl_[iToken] = true;
1207  }
1208  continue;
1209  }
1210 
1211  {
1212  // check upfront that refs to track are (likely) to be valid
1213  bool ok = true;
1214  for (const auto& v : *recVtxs) {
1215  if (v.tracksSize() > 0) {
1216  const auto& ref = v.trackRefAt(0);
1217  if (ref.isNull() || !ref.isAvailable()) {
1218  if (!errorPrintedForColl_[iToken]) {
1219  edm::LogWarning("PrimaryVertexAnalyzer4PUSlimmed")
1220  << "Skipping vertex collection: " << label
1221  << " since likely the track collection the vertex has refs pointing to is missing (at least the "
1222  "first TrackBaseRef is null or not available)";
1223  errorPrintedForColl_[iToken] = true;
1224  }
1225  ok = false;
1226  }
1227  }
1228  }
1229  if (!ok)
1230  continue;
1231  }
1232 
1233  reco::VertexRecoToSimCollection vertex_r2s = vertexAssociator.associateRecoToSim(recVtxs, TVCollectionH);
1234  reco::VertexSimToRecoCollection vertex_s2r = vertexAssociator.associateSimToReco(recVtxs, TVCollectionH);
1235 
1236  resetSimPVAssociation(simpv);
1237  matchSim2RecoVertices(simpv, vertex_s2r);
1238  recopv = getRecoPVs(recVtxs);
1239  computePairDistance(recopv, mes_[label]["RecoAllAssoc2Gen_PairDistanceZ"]);
1240  matchReco2SimVertices(recopv, vertex_r2s, simpv);
1241 
1242  int num_total_gen_vertices_assoc2reco = 0;
1243  int num_total_reco_vertices_assoc2gen = 0;
1244  int num_total_gen_vertices_multiassoc2reco = 0;
1245  int num_total_reco_vertices_multiassoc2gen = 0;
1246  int num_total_reco_vertices_duplicate = 0;
1247  int genpv_position_in_reco_collection = -1;
1248  for (auto const& v : simpv) {
1249  float mistag = 1.;
1250  // TODO(rovere) put selectors here in front of fill* methods.
1251  if (v.eventId.event() == 0) {
1252  if (!recVtxs->empty() && std::find(v.rec_vertices.begin(), v.rec_vertices.end(), &((*recVtxs.product())[0])) !=
1253  v.rec_vertices.end()) {
1254  mistag = 0.;
1255  kind_of_signal_vertex |= (1 << IS_ASSOC2FIRST_RECO);
1256  } else {
1257  if (!v.rec_vertices.empty()) {
1258  kind_of_signal_vertex |= (1 << IS_ASSOC2ANY_RECO);
1259  }
1260  }
1261  mes_[label]["KindOfSignalPV"]->Fill(kind_of_signal_vertex);
1262  mes_[label]["MisTagRate"]->Fill(mistag);
1263  mes_[label]["MisTagRate_vs_PU"]->Fill(simpv.size(), mistag);
1264  mes_[label]["MisTagRate_vs_sum-pt2"]->Fill(v.ptsq, mistag);
1265  mes_[label]["MisTagRate_vs_Z"]->Fill(v.z, mistag);
1266  mes_[label]["MisTagRate_vs_R"]->Fill(v.r, mistag);
1267  mes_[label]["MisTagRate_vs_NumTracks"]->Fill(v.nGenTrk, mistag);
1268  if (signal_is_highest_pt) {
1269  mes_[label]["MisTagRateSignalIsHighest"]->Fill(mistag);
1270  mes_[label]["MisTagRateSignalIsHighest_vs_PU"]->Fill(simpv.size(), mistag);
1271  mes_[label]["MisTagRateSignalIsHighest_vs_sum-pt2"]->Fill(v.ptsq, mistag);
1272  mes_[label]["MisTagRateSignalIsHighest_vs_Z"]->Fill(v.z, mistag);
1273  mes_[label]["MisTagRateSignalIsHighest_vs_R"]->Fill(v.r, mistag);
1274  mes_[label]["MisTagRateSignalIsHighest_vs_NumTracks"]->Fill(v.nGenTrk, mistag);
1275  } else {
1276  mes_[label]["MisTagRateSignalIsNotHighest"]->Fill(mistag);
1277  mes_[label]["MisTagRateSignalIsNotHighest_vs_PU"]->Fill(simpv.size(), mistag);
1278  mes_[label]["MisTagRateSignalIsNotHighest_vs_sum-pt2"]->Fill(v.ptsq, mistag);
1279  mes_[label]["MisTagRateSignalIsNotHighest_vs_Z"]->Fill(v.z, mistag);
1280  mes_[label]["MisTagRateSignalIsNotHighest_vs_R"]->Fill(v.r, mistag);
1281  mes_[label]["MisTagRateSignalIsNotHighest_vs_NumTracks"]->Fill(v.nGenTrk, mistag);
1282  }
1283  // Now check at which location the Simulated PV has been
1284  // reconstructed in the primary vertex collection
1285  // at-hand. Mark it with fake index -1 if it was not
1286  // reconstructed at all.
1287 
1288  auto iv = (*recVtxs.product()).begin();
1289  for (int pv_position_in_reco_collection = 0; iv != (*recVtxs.product()).end();
1290  ++pv_position_in_reco_collection, ++iv) {
1291  if (std::find(v.rec_vertices.begin(), v.rec_vertices.end(), &(*iv)) != v.rec_vertices.end()) {
1292  mes_[label]["TruePVLocationIndex"]->Fill(pv_position_in_reco_collection);
1293  const bool genPVMatchedToRecoPV = (pv_position_in_reco_collection == 0);
1294  mes_[label]["TruePVLocationIndexCumulative"]->Fill(genPVMatchedToRecoPV ? 0 : 1);
1295 
1296  if (signal_is_highest_pt) {
1297  mes_[label]["TruePVLocationIndexSignalIsHighest"]->Fill(pv_position_in_reco_collection);
1298  } else {
1299  mes_[label]["TruePVLocationIndexSignalIsNotHighest"]->Fill(pv_position_in_reco_collection);
1300  }
1301 
1302  fillRecoAssociatedGenPVHistograms(label, v, genPVMatchedToRecoPV);
1303  if (genPVMatchedToRecoPV) {
1304  auto pv = recopv[0];
1305  assert(pv.recVtx == &(*iv));
1306  fillResolutionAndPullHistograms(label, num_pileup_vertices, pv, true);
1307  }
1308  genpv_position_in_reco_collection = pv_position_in_reco_collection;
1309  break;
1310  }
1311  }
1312 
1313  // If we reached the end, it means that the Simulated PV has not
1314  // been associated to any reconstructed vertex: mark it as
1315  // missing in the reconstructed vertex collection using the fake
1316  // index -1.
1317  if (iv == (*recVtxs.product()).end()) {
1318  mes_[label]["TruePVLocationIndex"]->Fill(-1.);
1319  mes_[label]["TruePVLocationIndexCumulative"]->Fill(-1.);
1320  if (signal_is_highest_pt)
1321  mes_[label]["TruePVLocationIndexSignalIsHighest"]->Fill(-1.);
1322  else
1323  mes_[label]["TruePVLocationIndexSignalIsNotHighest"]->Fill(-1.);
1324  }
1325  }
1326 
1327  if (!v.rec_vertices.empty())
1328  num_total_gen_vertices_assoc2reco++;
1329  if (v.rec_vertices.size() > 1)
1330  num_total_gen_vertices_multiassoc2reco++;
1331  // No need to N-tplicate the Gen-related cumulative histograms:
1332  // fill them only at the first iteration
1333  if (do_generic_sim_plots_ && label_index == 0)
1336  }
1337  calculatePurityAndFillHistograms(label, recopv, genpv_position_in_reco_collection, signal_is_highest_pt);
1338 
1339  mes_[label]["GenAllAssoc2Reco_NumVertices"]->Fill(simpv.size(), simpv.size());
1340  mes_[label]["GenAllAssoc2RecoMatched_NumVertices"]->Fill(simpv.size(), num_total_gen_vertices_assoc2reco);
1341  mes_[label]["GenAllAssoc2RecoMultiMatched_NumVertices"]->Fill(simpv.size(), num_total_gen_vertices_multiassoc2reco);
1342  for (auto& v : recopv) {
1343  fillGenAssociatedRecoVertexHistograms(label, num_pileup_vertices, v);
1344  if (!v.sim_vertices.empty()) {
1345  num_total_reco_vertices_assoc2gen++;
1346  if (v.sim_vertices_internal[0]->rec_vertices.size() > 1) {
1347  num_total_reco_vertices_duplicate++;
1348  }
1349  }
1350  if (v.sim_vertices.size() > 1)
1351  num_total_reco_vertices_multiassoc2gen++;
1352  }
1353  mes_[label]["RecoAllAssoc2Gen_NumVertices"]->Fill(recopv.size(), recopv.size());
1354  mes_[label]["RecoAllAssoc2GenMatched_NumVertices"]->Fill(recopv.size(), num_total_reco_vertices_assoc2gen);
1355  mes_[label]["RecoAllAssoc2GenMultiMatched_NumVertices"]->Fill(recopv.size(),
1356  num_total_reco_vertices_multiassoc2gen);
1357  mes_[label]["RecoAllAssoc2MultiMatchedGen_NumVertices"]->Fill(recopv.size(), num_total_reco_vertices_duplicate);
1358  mes_[label]["RecoVtx_vs_GenVtx"]->Fill(simpv.size(), recopv.size());
1359  mes_[label]["MatchedRecoVtx_vs_GenVtx"]->Fill(simpv.size(), num_total_reco_vertices_assoc2gen);
1360  }
1361 } // end of analyze
1362 
1363 template <class T>
1365  for (unsigned int i = 0; i < collection.size(); ++i) {
1366  for (unsigned int j = i + 1; j < collection.size(); ++j) {
1367  me->Fill(std::abs(collection[i].z - collection[j].z));
1368  }
1369  }
1370 }
muonTagProbeFilters_cff.matched
matched
Definition: muonTagProbeFilters_cff.py:62
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
PrimaryVertexAnalyzer4PUSlimmed::matchRecoTrack2SimSignal
bool matchRecoTrack2SimSignal(const reco::TrackBaseRef &)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:711
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
electrons_cff.bool
bool
Definition: electrons_cff.py:366
V0Monitor_cff.v0
v0
Definition: V0Monitor_cff.py:7
fw3dlego::xbins
const double xbins[]
Definition: fw3dlego_xbins.cc:16
edm::AssociationMap::find
const_iterator find(const key_type &k) const
find element with specified reference key
Definition: AssociationMap.h:173
mps_fire.i
i
Definition: mps_fire.py:428
PrimaryVertexAnalyzer4PUSlimmed::mes_
std::map< std::string, std::map< std::string, MonitorElement * > > mes_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:170
PrimaryVertexAnalyzer4PUSlimmed::HIGHEST_PT
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:64
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
PrimaryVertexAnalyzer4PUSlimmed::PrimaryVertexAnalyzer4PUSlimmed
PrimaryVertexAnalyzer4PUSlimmed(const edm::ParameterSet &)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:44
PrimaryVertexAnalyzer4PUSlimmed::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:1108
edm::Handle::product
T const * product() const
Definition: Handle.h:70
PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex::MATCHED
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:99
sistrip::View
View
Definition: ConstantsForView.h:26
PrimaryVertexAnalyzer4PUSlimmed::use_only_charged_tracks_
bool use_only_charged_tracks_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:166
PrimaryVertexAnalyzer4PUSlimmed::trackingParticleCollectionToken_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleCollectionToken_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:177
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
edm::Run
Definition: Run.h:45
min
T min(T a, T b)
Definition: MathUtil.h:58
hgcal::RecoToSimCollection
edm::AssociationMap< edm::OneToManyWithQualityGeneric< reco::CaloClusterCollection, CaloParticleCollection, float > > RecoToSimCollection
Definition: LayerClusterToCaloParticleAssociatorBaseImpl.h:26
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
PrimaryVertexAnalyzer4PUSlimmed::~PrimaryVertexAnalyzer4PUSlimmed
~PrimaryVertexAnalyzer4PUSlimmed() override
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:68
gpuVertexFinder::iv
int32_t *__restrict__ iv
Definition: gpuClusterTracksDBSCAN.h:42
PrimaryVertexAnalyzer4PUSlimmed::do_generic_sim_plots_
const bool do_generic_sim_plots_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:167
PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex::num_matched_sim_tracks
int num_matched_sim_tracks
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:120
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TrackingVertex::g4v_iterator
std::vector< SimVertex >::const_iterator g4v_iterator
Definition: TrackingVertex.h:30
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
cms::cuda::assert
assert(be >=bs)
TrackingVertexCollection
std::vector< TrackingVertex > TrackingVertexCollection
Definition: TrackingVertexContainer.h:8
DQMStore.h
PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex::ptsq
double ptsq
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:87
PrimaryVertexAnalyzer4PUSlimmed::calculatePurityAndFillHistograms
void calculatePurityAndFillHistograms(const std::string &, std::vector< recoPrimaryVertex > &, int, bool)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:728
PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex::ptot
HepMC::FourVector ptot
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:85
PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex::nRecoTrk
int nRecoTrk
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:119
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:46
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
newFWLiteAna.found
found
Definition: newFWLiteAna.py:118
edm::Handle
Definition: AssociativeIterator.h:50
deltar.bestMatch
def bestMatch(object, matchCollection)
Definition: deltar.py:138
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
PrimaryVertexAnalyzer4PUSlimmed::fillGenericGenVertexHistograms
void fillGenericGenVertexHistograms(const simPrimaryVertex &v)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:488
PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex::ptsq
double ptsq
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:116
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition: AssociationMap.h:171
PrimaryVertexAnalyzer4PUSlimmed::fillResolutionAndPullHistograms
void fillResolutionAndPullHistograms(const std::string &, int, recoPrimaryVertex &v, bool)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:641
L1TOccupancyClient_cfi.ymax
ymax
Definition: L1TOccupancyClient_cfi.py:43
TrackingVertexContainer.h
PrimaryVertexAnalyzer4PUSlimmed::trackingVertexCollectionToken_
edm::EDGetTokenT< TrackingVertexCollection > trackingVertexCollectionToken_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:178
PrimaryVertexAnalyzer4PUSlimmed::reco_vertex_collections_
std::vector< edm::InputTag > reco_vertex_collections_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:176
PVValHelper::makeLogBins
std::array< T, N+1 > makeLogBins(const T &min, const T &max)
Definition: PVValidationHelpers.h:30
PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex::nGenTrk
int nGenTrk
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:89
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
pfDeepBoostedJetPreprocessParams_cfi.sv
sv
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:352
mps_fire.end
end
Definition: mps_fire.py:242
PrimaryVertexAnalyzer4PUSlimmed::vecPileupSummaryInfoToken_
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > vecPileupSummaryInfoToken_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:174
DDAxes::z
PrimaryVertexAnalyzer4PUSlimmed::fillRecoAssociatedGenVertexHistograms
void fillRecoAssociatedGenVertexHistograms(const std::string &, const simPrimaryVertex &v)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:509
reco::Track
Definition: Track.h:27
N
#define N
Definition: blowfish.cc:9
TrackingVertexRef
edm::Ref< TrackingVertexCollection > TrackingVertexRef
Definition: TrackingVertexContainer.h:9
packedPFCandidates_cff.vertexAssociator
vertexAssociator
Definition: packedPFCandidates_cff.py:18
PrimaryVertexAnalyzer4PUSlimmed::getSimPVs
std::vector< PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex > getSimPVs(const edm::Handle< TrackingVertexCollection > &)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:796
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
edm::View
Definition: CaloClusterFwd.h:14
funct::true
true
Definition: Factorize.h:173
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
edm::ParameterSet
Definition: ParameterSet.h:47
PrimaryVertexAnalyzer4PUSlimmed::s2r_
const reco::SimToRecoCollection * s2r_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:172
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex::DUPLICATE
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:99
Event.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PrimaryVertexAnalyzer4PUSlimmed::reco_vertex_collection_tokens_
std::vector< edm::EDGetTokenT< edm::View< reco::Vertex > > > reco_vertex_collection_tokens_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:175
edm::AssociationMap< edm::OneToManyWithQuality< TrackingVertexCollection, edm::View< reco::Vertex >, double > >
TrackingVertex
Definition: TrackingVertex.h:22
PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex::pt
double pt
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:115
edmPickEvents.event
event
Definition: edmPickEvents.py:273
PrimaryVertexAnalyzer4PUSlimmed::IS_ASSOC2ANY_RECO
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:64
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:98
calculateVertexSharedTracks.h
universalConfigTemplate.collection
collection
Definition: universalConfigTemplate.py:81
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
PrimaryVertexAnalyzer4PUSlimmed::r2s_
const reco::RecoToSimCollection * r2s_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:171
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:117
edm::EventSetup
Definition: EventSetup.h:58
HLT_FULL_cff.pt2
pt2
Definition: HLT_FULL_cff.py:9895
TrackAssociatorRecord.h
reco::VertexToTrackingVertexAssociator
Definition: VertexToTrackingVertexAssociator.h:9
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PrimaryVertexAnalyzer4PUSlimmed::matchSim2RecoVertices
void matchSim2RecoVertices(std::vector< simPrimaryVertex > &, const reco::VertexSimToRecoCollection &)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:1045
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
PrimaryVertexAnalyzer4PUSlimmed::getRecoPVs
std::vector< PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex > getRecoPVs(const edm::Handle< edm::View< reco::Vertex >> &)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:953
PrimaryVertexAnalyzer4PUSlimmed::matchReco2SimVertices
void matchReco2SimVertices(std::vector< recoPrimaryVertex > &, const reco::VertexRecoToSimCollection &, const std::vector< simPrimaryVertex > &)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:1074
TransientVertex.h
PrimaryVertexAnalyzer4PUSlimmed.h
std
Definition: JetResolutionObject.h:76
L1TOccupancyClient_cfi.ymin
ymin
Definition: L1TOccupancyClient_cfi.py:43
Vertex.h
TrackingParticleFwd.h
T
long double T
Definition: Basic3DVectorLD.h:48
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
edm::RefVectorIterator
Definition: EDProductfwd.h:33
PrimaryVertexAnalyzer4PUSlimmed::vertexAssociatorToken_
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:181
hgcal::SimToRecoCollection
edm::AssociationMap< edm::OneToManyWithQualityGeneric< CaloParticleCollection, reco::CaloClusterCollection, std::pair< float, float > > > SimToRecoCollection
Definition: LayerClusterToCaloParticleAssociatorBaseImpl.h:23
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition: TrackingParticleFwd.h:9
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< reco::Track >
VarParsing.mult
mult
Definition: VarParsing.py:658
PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex::num_matched_reco_tracks
int num_matched_reco_tracks
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:90
dqm::implementation::IBooker
Definition: DQMStore.h:43
PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex::average_match_quality
float average_match_quality
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:91
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
PrimaryVertexAnalyzer4PUSlimmed::errorPrintedForColl_
std::vector< bool > errorPrintedForColl_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:183
PrimaryVertexAnalyzer4PUSlimmed::bookHistograms
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:73
calculateVertexSharedTracks
unsigned int calculateVertexSharedTracks(const reco::Vertex &recoV, const TrackingVertex &simV, const reco::RecoToSimCollection &trackRecoToSimAssociation)
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
trigObjTnPSource_cfi.bins
bins
Definition: trigObjTnPSource_cfi.py:20
ParameterSet.h
combine.missing
missing
Definition: combine.py:5
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
PrimaryVertexAnalyzer4PUSlimmed::verbose_
bool verbose_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:165
PrimaryVertexAnalyzer4PUSlimmed::recoToSimAssociationToken_
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimAssociationToken_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:180
edm::Event
Definition: Event.h:73
HLT_FULL_cff.distance
distance
Definition: HLT_FULL_cff.py:7746
edm::Log
Definition: MessageLogger.h:70
PrimaryVertexAnalyzer4PUSlimmed::simToRecoAssociationToken_
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoAssociationToken_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:179
PrimaryVertexAnalyzer4PUSlimmed::resetSimPVAssociation
void resetSimPVAssociation(std::vector< simPrimaryVertex > &)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:1038
label
const char * label
Definition: PFTauDecayModeTools.cc:11
reco::Vertex
Definition: Vertex.h:35
hcallasereventfilter2012_cfi.prefix
prefix
Definition: hcallasereventfilter2012_cfi.py:10
PileupSummaryInfo
Definition: PileupSummaryInfo.h:22
vertexPlots.e4
e4
Definition: vertexPlots.py:64
PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:67
PrimaryVertexAnalyzer4PUSlimmed::fillGenAssociatedRecoVertexHistograms
void fillGenAssociatedRecoVertexHistograms(const std::string &, int, recoPrimaryVertex &v)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:553
PrimaryVertexAnalyzer4PUSlimmed::computePairDistance
void computePairDistance(const T &collection, MonitorElement *me)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:1364
reco::VertexBaseRef
edm::RefToBase< reco::Vertex > VertexBaseRef
persistent reference to a Vertex, using views
Definition: VertexFwd.h:21
PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex::MERGED
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:99
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
PrimaryVertexAnalyzer4PUSlimmed::fillRecoAssociatedGenPVHistograms
void fillRecoAssociatedGenPVHistograms(const std::string &label, const PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex &v, bool genPVMatchedToRecoPV)
Definition: PrimaryVertexAnalyzer4PUSlimmed.cc:541
PrimaryVertexAnalyzer4PUSlimmed::IS_ASSOC2FIRST_RECO
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:64
PrimaryVertexAnalyzer4PUSlimmed::root_folder_
std::string root_folder_
Definition: PrimaryVertexAnalyzer4PUSlimmed.h:168