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;
33 const double mult =
std::pow(10, width);
34 for(
size_t i=1;
i<=
N; ++
i) {
35 ret[
i] = ret[
i-1]*mult;
46 : verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose",
false)),
47 use_only_charged_tracks_(iConfig.getUntrackedParameter<
bool>(
48 "use_only_charged_tracks",
true)),
49 do_generic_sim_plots_(iConfig.getUntrackedParameter<
bool>(
"do_generic_sim_plots")),
51 iConfig.getUntrackedParameter<
std::
string>(
"root_folder",
52 "Validation/Vertices")),
56 iConfig.getUntrackedParameter<
edm::InputTag>(
"trackingParticleCollection"))),
58 iConfig.getUntrackedParameter<
edm::InputTag>(
"trackingVertexCollection"))),
60 iConfig.getUntrackedParameter<
edm::InputTag>(
"trackAssociatorMap"))),
62 iConfig.getUntrackedParameter<
edm::InputTag>(
"trackAssociatorMap"))),
63 vertexAssociatorToken_(consumes<
reco::VertexToTrackingVertexAssociator>(
64 iConfig.getUntrackedParameter<
edm::InputTag>(
"vertexAssociator"))) {
66 "vertexRecoCollections");
85 float log_bins[31] = {
86 0.0, 0.0002, 0.0004, 0.0006, 0.0008, 0.001, 0.002,
87 0.004, 0.006, 0.008, 0.01, 0.02,
88 0.04, 0.06, 0.08, 0.1, 0.2,
89 0.4, 0.6, 0.8, 1.0, 2.0,
90 4.0, 6.0, 8.0, 10.0, 20.0,
91 40.0, 60.0, 80.0, 100.0
93 auto const log_mergez_bins = makeLogBins<float, 16>(1
e-4, 1);
95 auto const log_pt_bins = makeLogBins<float, 100>(0.1, 1
e4);
96 float log_pt2_bins[16] = {
101 1000.0, 2000.0, 5000.0,10000.0
103 float log_ntrk_bins[25] = {
104 0., 2.0, 4.0, 6.0, 8.0, 10.,
105 12.0, 14.0, 16.0, 18.0, 22.0,
106 26.0, 30.0, 35.0, 40.0,
107 45.0, 50.0, 55.0, 60.0, 70.0,
108 80.0, 90.0, 100.0, 150.0, 200.0
115 double log_pt2_bins_double[16] = {
120 1000.0, 2000.0, 5000.0,10000.0
125 mes_[
"root_folder"][
"GenVtx_vs_BX"] =
126 i.
book2D(
"GenVtx_vs_BX",
"GenVtx_vs_BX", 16, -12.5, 3.5, 200, 0., 200.);
128 mes_[
"root_folder"][
"GenPV_X"] =
129 i.
book1D(
"GenPV_X",
"GeneratedPV_X", 120, -0.6, 0.6);
130 mes_[
"root_folder"][
"GenPV_Y"] =
131 i.
book1D(
"GenPV_Y",
"GeneratedPV_Y", 120, -0.6, 0.6);
132 mes_[
"root_folder"][
"GenPV_Z"] =
133 i.
book1D(
"GenPV_Z",
"GeneratedPV_Z", 120, -60., 60.);
134 mes_[
"root_folder"][
"GenPV_R"] =
135 i.
book1D(
"GenPV_R",
"GeneratedPV_R", 120, 0, 0.6);
136 mes_[
"root_folder"][
"GenPV_Pt2"] =
137 i.
book1D(
"GenPV_Pt2",
"GeneratedPV_Sum-pt2", 15, &log_pt2_bins[0]);
138 mes_[
"root_folder"][
"GenPV_NumTracks"] =
139 i.
book1D(
"GenPV_NumTracks",
"GeneratedPV_NumTracks", 24, &log_ntrk_bins[0]);
140 mes_[
"root_folder"][
"GenPV_ClosestDistanceZ"] =
141 i.
book1D(
"GenPV_ClosestDistanceZ",
"GeneratedPV_ClosestDistanceZ", 30,
145 mes_[
"root_folder"][
"GenAllV_NumVertices"] = i.
book1D(
146 "GenAllV_NumVertices",
"GeneratedAllV_NumVertices", 100, 0., 200.);
147 mes_[
"root_folder"][
"GenAllV_X"] =
148 i.
book1D(
"GenAllV_X",
"GeneratedAllV_X", 120, -0.6, 0.6);
149 mes_[
"root_folder"][
"GenAllV_Y"] =
150 i.
book1D(
"GenAllV_Y",
"GeneratedAllV_Y", 120, -0.6, 0.6);
151 mes_[
"root_folder"][
"GenAllV_Z"] =
152 i.
book1D(
"GenAllV_Z",
"GeneratedAllV_Z", 120, -60, 60);
153 mes_[
"root_folder"][
"GenAllV_R"] =
154 i.
book1D(
"GenAllV_R",
"GeneratedAllV_R", 120, 0, 0.6);
155 mes_[
"root_folder"][
"GenAllV_Pt2"] =
156 i.
book1D(
"GenAllV_Pt2",
"GeneratedAllV_Sum-pt2", 15, &log_pt2_bins[0]);
157 mes_[
"root_folder"][
"GenAllV_NumTracks"] =
158 i.
book1D(
"GenAllV_NumTracks",
"GeneratedAllV_NumTracks", 24, &log_ntrk_bins[0]);
159 mes_[
"root_folder"][
"GenAllV_ClosestDistanceZ"] =
160 i.
book1D(
"GenAllV_ClosestDistanceZ",
"GeneratedAllV_ClosestDistanceZ", 30,
162 mes_[
"root_folder"][
"GenAllV_PairDistanceZ"] =
163 i.
book1D(
"GenAllV_PairDistanceZ",
"GeneratedAllV_PairDistanceZ",
165 mes_[
"root_folder"][
"SignalIsHighestPt2"] =
166 i.
book1D(
"SignalIsHighestPt2",
"SignalIsHighestPt2", 2, -0.5, 1.5);
174 auto book1d = [&](
const char *
name,
int bins,
double min,
double max) {
177 auto book1dlogx = [&](
const char *
name,
int bins,
const float *xbinedges) {
180 auto book2d = [&](
const char *
name,
182 int ybins,
double ymin,
double ymax) {
185 auto book2dlogx = [&](
const char *
name,
186 int xbins,
const float *xbinedges,
187 int ybins,
double ymin,
double ymax) {
188 auto me = i.
book2D(name, name, xbins,xbinedges[0],xbinedges[xbins], ybins,ymin,
ymax);
189 me->
getTH2F()->GetXaxis()->Set(xbins, xbinedges);
195 "RecoVtx_vs_GenVtx",
"RecoVtx_vs_GenVtx", 125, 0., 250., 250, 0., 250.);
196 mes_[
label][
"MatchedRecoVtx_vs_GenVtx"] =
197 i.
bookProfile(
"MatchedRecoVtx_vs_GenVtx",
"MatchedRecoVtx_vs_GenVtx",
198 125, 0., 250., 250, 0., 250.);
200 i.
book1D(
"KindOfSignalPV",
"KindOfSignalPV", 9, -0.5, 8.5);
201 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(1,
"!Highest!Assoc2Any");
202 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(2,
"Highest!Assoc2Any");
203 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(3,
"!HighestAssoc2First");
204 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(4,
"HighestAssoc2First");
205 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(5,
"!HighestAssoc2!First");
206 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(6,
"HighestAssoc2!First");
207 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(7,
"!HighestAssoc2First");
208 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(8,
"HighestAssoc2First");
210 i.
book1D(
"MisTagRate",
"MisTagRate", 2, -0.5, 1.5);
212 i.
bookProfile(
"MisTagRate_vs_PU",
"MisTagRate_vs_PU", 125, 0., 250.,
215 i.
bookProfile(
"MisTagRate_vs_sum-pt2",
"MisTagRate_vs_sum-pt2",
216 15, &log_pt2_bins_double[0], 2, 0., 1.);
218 i.
bookProfile(
"MisTagRate_vs_Z",
"MisTagRate_vs_Z",
219 120, -60., 60., 2, 0., 1.);
221 i.
bookProfile(
"MisTagRate_vs_R",
"MisTagRate_vs_R",
222 120, 0., 0.6, 2, 0., 1.);
224 i.
bookProfile(
"MisTagRate_vs_NumTracks",
"MisTagRate_vs_NumTracks",
225 100, 0., 200, 2, 0., 1.);
226 mes_[
label][
"MisTagRateSignalIsHighest"] =
227 i.
book1D(
"MisTagRateSignalIsHighest",
228 "MisTagRateSignalIsHighest", 2, -0.5, 1.5);
229 mes_[
label][
"MisTagRateSignalIsHighest_vs_PU"] =
231 "MisTagRateSignalIsHighest_vs_PU", 125, 0., 250.,
233 mes_[
label][
"MisTagRateSignalIsHighest_vs_sum-pt2"] =
234 i.
bookProfile(
"MisTagRateSignalIsHighest_vs_sum-pt2",
235 "MisTagRateSignalIsHighest_vs_sum-pt2",
236 15, &log_pt2_bins_double[0], 2, 0., 1.);
237 mes_[
label][
"MisTagRateSignalIsHighest_vs_Z"] =
239 "MisTagRateSignalIsHighest_vs_Z",
240 120, -60., 60., 2, 0., 1.);
241 mes_[
label][
"MisTagRateSignalIsHighest_vs_R"] =
243 "MisTagRateSignalIsHighest_vs_R",
244 120, 0., 0.6, 2, 0., 1.);
245 mes_[
label][
"MisTagRateSignalIsHighest_vs_NumTracks"] =
246 i.
bookProfile(
"MisTagRateSignalIsHighest_vs_NumTracks",
247 "MisTagRateSignalIsHighest_vs_NumTracks",
248 100, 0., 200, 2, 0., 1.);
249 mes_[
label][
"MisTagRateSignalIsNotHighest"] =
250 i.
book1D(
"MisTagRateSignalIsNotHighest",
251 "MisTagRateSignalIsNotHighest", 2, -0.5, 1.5);
252 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_PU"] =
253 i.
bookProfile(
"MisTagRateSignalIsNotHighest_vs_PU",
254 "MisTagRateSignalIsNotHighest_vs_PU", 125, 0., 250.,
256 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_sum-pt2"] =
257 i.
bookProfile(
"MisTagRateSignalIsNotHighest_vs_sum-pt2",
258 "MisTagRateSignalIsNotHighest_vs_sum-pt2",
259 15, &log_pt2_bins_double[0], 2, 0., 1.);
260 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_Z"] =
262 "MisTagRateSignalIsNotHighest_vs_Z",
263 120, -60., 60., 2, 0., 1.);
264 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_R"] =
266 "MisTagRateSignalIsNotHighest_vs_R",
267 120, 0., 0.6, 2, 0., 1.);
268 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_NumTracks"] =
269 i.
bookProfile(
"MisTagRateSignalIsNotHighest_vs_NumTracks",
270 "MisTagRateSignalIsNotHighest_vs_NumTracks",
271 100, 0., 200, 2, 0., 1.);
273 i.
book1D(
"TruePVLocationIndex",
274 "TruePVLocationIndexInRecoVertexCollection", 12, -1.5, 10.5);
275 mes_[
label][
"TruePVLocationIndexCumulative"] =
276 i.
book1D(
"TruePVLocationIndexCumulative",
277 "TruePVLocationIndexInRecoVertexCollectionCumulative",
279 mes_[
label][
"TruePVLocationIndexSignalIsHighest"] =
280 i.
book1D(
"TruePVLocationIndexSignalIsHighest",
281 "TruePVLocationIndexSignalIsHighestInRecoVertexCollection",
283 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"] =
284 i.
book1D(
"TruePVLocationIndexSignalIsNotHighest",
285 "TruePVLocationIndexSignalIsNotHighestInRecoVertexCollection",
290 mes_[
label][
"GenAllAssoc2Reco_NumVertices"] =
291 i.
book1D(
"GenAllAssoc2Reco_NumVertices",
292 "GeneratedAllAssoc2Reco_NumVertices", 100, 0., 200.);
294 "GenAllAssoc2Reco_X",
"GeneratedAllAssoc2Reco_X", 120, -0.6, 0.6);
296 "GenAllAssoc2Reco_Y",
"GeneratedAllAssoc2Reco_Y", 120, -0.6, 0.6);
298 "GenAllAssoc2Reco_Z",
"GeneratedAllAssoc2Reco_Z", 120, -60, 60);
300 i.
book1D(
"GenAllAssoc2Reco_R",
"GeneratedAllAssoc2Reco_R", 120, 0, 0.6);
302 i.
book1D(
"GenAllAssoc2Reco_Pt2",
"GeneratedAllAssoc2Reco_Sum-pt2", 15,
304 mes_[
label][
"GenAllAssoc2Reco_NumTracks"] =
305 i.
book1D(
"GenAllAssoc2Reco_NumTracks",
306 "GeneratedAllAssoc2Reco_NumTracks", 24, &log_ntrk_bins[0]);
307 mes_[
label][
"GenAllAssoc2Reco_ClosestDistanceZ"] =
308 i.
book1D(
"GenAllAssoc2Reco_ClosestDistanceZ",
309 "GeneratedAllAssoc2Reco_ClosestDistanceZ", 30, &log_bins[0]);
310 book1d(
"GenPVAssoc2RecoPV_X", 120, -0.6, 0.6);
311 book1d(
"GenPVAssoc2RecoPV_Y", 120, -0.6, 0.6);
312 book1d(
"GenPVAssoc2RecoPV_Z", 120, -60, 60);
316 mes_[
label][
"GenAllAssoc2RecoMatched_NumVertices"] =
317 i.
book1D(
"GenAllAssoc2RecoMatched_NumVertices",
318 "GeneratedAllAssoc2RecoMatched_NumVertices", 100, 0., 200.);
319 mes_[
label][
"GenAllAssoc2RecoMatched_X"] =
320 i.
book1D(
"GenAllAssoc2RecoMatched_X",
"GeneratedAllAssoc2RecoMatched_X",
322 mes_[
label][
"GenAllAssoc2RecoMatched_Y"] =
323 i.
book1D(
"GenAllAssoc2RecoMatched_Y",
"GeneratedAllAssoc2RecoMatched_Y",
325 mes_[
label][
"GenAllAssoc2RecoMatched_Z"] =
326 i.
book1D(
"GenAllAssoc2RecoMatched_Z",
"GeneratedAllAssoc2RecoMatched_Z",
328 mes_[
label][
"GenAllAssoc2RecoMatched_R"] =
329 i.
book1D(
"GenAllAssoc2RecoMatched_R",
"GeneratedAllAssoc2RecoMatched_R",
331 mes_[
label][
"GenAllAssoc2RecoMatched_Pt2"] =
332 i.
book1D(
"GenAllAssoc2RecoMatched_Pt2",
333 "GeneratedAllAssoc2RecoMatched_Sum-pt2", 15, &log_pt2_bins[0]);
334 mes_[
label][
"GenAllAssoc2RecoMatched_NumTracks"] =
335 i.
book1D(
"GenAllAssoc2RecoMatched_NumTracks",
336 "GeneratedAllAssoc2RecoMatched_NumTracks", 24, &log_ntrk_bins[0]);
338 "GenAllAssoc2RecoMatched_ClosestDistanceZ",
339 "GeneratedAllAssoc2RecoMatched_ClosestDistanceZ", 30, &log_bins[0]);
340 book1d(
"GenPVAssoc2RecoPVMatched_X", 120, -0.6, 0.6);
341 book1d(
"GenPVAssoc2RecoPVMatched_Y", 120, -0.6, 0.6);
342 book1d(
"GenPVAssoc2RecoPVMatched_Z", 120, -60, 60);
347 "GenAllAssoc2RecoMultiMatched_NumVertices",
348 "GeneratedAllAssoc2RecoMultiMatched_NumVertices", 100, 0., 200.);
349 mes_[
label][
"GenAllAssoc2RecoMultiMatched_X"] =
350 i.
book1D(
"GenAllAssoc2RecoMultiMatched_X",
351 "GeneratedAllAssoc2RecoMultiMatched_X", 120, -0.6, 0.6);
352 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Y"] =
353 i.
book1D(
"GenAllAssoc2RecoMultiMatched_Y",
354 "GeneratedAllAssoc2RecoMultiMatched_Y", 120, -0.6, 0.6);
355 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Z"] =
356 i.
book1D(
"GenAllAssoc2RecoMultiMatched_Z",
357 "GeneratedAllAssoc2RecoMultiMatched_Z", 120, -60, 60);
358 mes_[
label][
"GenAllAssoc2RecoMultiMatched_R"] =
359 i.
book1D(
"GenAllAssoc2RecoMultiMatched_R",
360 "GeneratedAllAssoc2RecoMultiMatched_R", 120, 0, 0.6);
361 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Pt2"] =
362 i.
book1D(
"GenAllAssoc2RecoMultiMatched_Pt2",
363 "GeneratedAllAssoc2RecoMultiMatched_Sum-pt2",
364 15, &log_pt2_bins[0]);
365 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumTracks"] =
366 i.
book1D(
"GenAllAssoc2RecoMultiMatched_NumTracks",
367 "GeneratedAllAssoc2RecoMultiMatched_NumTracks", 24, &log_ntrk_bins[0]);
368 mes_[
label][
"GenAllAssoc2RecoMultiMatched_ClosestDistanceZ"] = i.
book1D(
369 "GenAllAssoc2RecoMultiMatched_ClosestDistanceZ",
370 "GeneratedAllAssoc2RecoMultiMatched_ClosestDistanceZ",
374 mes_[
label][
"RecoAllAssoc2Gen_NumVertices"] =
375 i.
book1D(
"RecoAllAssoc2Gen_NumVertices",
376 "ReconstructedAllAssoc2Gen_NumVertices", 100, 0., 200.);
378 "RecoAllAssoc2Gen_X",
"ReconstructedAllAssoc2Gen_X", 120, -0.6, 0.6);
380 "RecoAllAssoc2Gen_Y",
"ReconstructedAllAssoc2Gen_Y", 120, -0.6, 0.6);
382 "RecoAllAssoc2Gen_Z",
"ReconstructedAllAssoc2Gen_Z", 120, -60, 60);
384 "RecoAllAssoc2Gen_R",
"ReconstructedAllAssoc2Gen_R", 120, 0, 0.6);
386 i.
book1D(
"RecoAllAssoc2Gen_Pt2",
"ReconstructedAllAssoc2Gen_Sum-pt2",
387 15, &log_pt2_bins[0]);
389 i.
book1D(
"RecoAllAssoc2Gen_Ndof",
390 "ReconstructedAllAssoc2Gen_Ndof", 120, 0., 240.);
391 mes_[
label][
"RecoAllAssoc2Gen_NumTracks"] =
392 i.
book1D(
"RecoAllAssoc2Gen_NumTracks",
393 "ReconstructedAllAssoc2Gen_NumTracks", 24, &log_ntrk_bins[0]);
395 i.
book1D(
"RecoAllAssoc2Gen_PU",
396 "ReconstructedAllAssoc2Gen_PU", 125, 0., 250.);
397 mes_[
label][
"RecoAllAssoc2Gen_ClosestDistanceZ"] =
398 i.
book1D(
"RecoAllAssoc2Gen_ClosestDistanceZ",
399 "ReconstructedAllAssoc2Gen_ClosestDistanceZ",
401 mes_[
label][
"RecoAllAssoc2GenProperties"] =
402 i.
book1D(
"RecoAllAssoc2GenProperties",
403 "ReconstructedAllAssoc2Gen_Properties", 8, -0.5, 7.5);
404 mes_[
label][
"RecoAllAssoc2Gen_PairDistanceZ"] =
405 i.
book1D(
"RecoAllAssoc2Gen_PairDistanceZ",
406 "RecoAllAssoc2Gen_PairDistanceZ", 1000, 0, 20);
410 mes_[
label][
"RecoAllAssoc2GenMatched_NumVertices"] =
411 i.
book1D(
"RecoAllAssoc2GenMatched_NumVertices",
412 "ReconstructedAllAssoc2GenMatched_NumVertices", 100, 0., 200.);
413 mes_[
label][
"RecoAllAssoc2GenMatched_X"] =
414 i.
book1D(
"RecoAllAssoc2GenMatched_X",
415 "ReconstructedAllAssoc2GenMatched_X", 120, -0.6, 0.6);
416 mes_[
label][
"RecoAllAssoc2GenMatched_Y"] =
417 i.
book1D(
"RecoAllAssoc2GenMatched_Y",
418 "ReconstructedAllAssoc2GenMatched_Y", 120, -0.6, 0.6);
419 mes_[
label][
"RecoAllAssoc2GenMatched_Z"] =
420 i.
book1D(
"RecoAllAssoc2GenMatched_Z",
421 "ReconstructedAllAssoc2GenMatched_Z", 120, -60, 60);
422 mes_[
label][
"RecoAllAssoc2GenMatched_R"] =
423 i.
book1D(
"RecoAllAssoc2GenMatched_R",
424 "ReconstructedAllAssoc2GenMatched_R", 120, 0, 0.6);
425 mes_[
label][
"RecoAllAssoc2GenMatched_Pt2"] =
426 i.
book1D(
"RecoAllAssoc2GenMatched_Pt2",
427 "ReconstructedAllAssoc2GenMatched_Sum-pt2",
428 15, &log_pt2_bins[0]);
429 mes_[
label][
"RecoAllAssoc2GenMatched_Ndof"] =
430 i.
book1D(
"RecoAllAssoc2GenMatched_Ndof",
431 "ReconstructedAllAssoc2GenMatched_Ndof", 120, 0., 240.);
432 mes_[
label][
"RecoAllAssoc2GenMatched_NumTracks"] =
433 i.
book1D(
"RecoAllAssoc2GenMatched_NumTracks",
434 "ReconstructedAllAssoc2GenMatched_NumTracks", 24, &log_ntrk_bins[0]);
435 mes_[
label][
"RecoAllAssoc2GenMatched_PU"] =
436 i.
book1D(
"RecoAllAssoc2GenMatched_PU",
437 "ReconstructedAllAssoc2GenMatched_PU", 125, 0., 250.);
439 "RecoAllAssoc2GenMatched_ClosestDistanceZ",
440 "ReconstructedAllAssoc2GenMatched_ClosestDistanceZ", 30, &log_bins[0]);
445 "RecoAllAssoc2GenMultiMatched_NumVertices",
446 "ReconstructedAllAssoc2GenMultiMatched_NumVertices", 100, 0., 200.);
447 mes_[
label][
"RecoAllAssoc2GenMultiMatched_X"] =
448 i.
book1D(
"RecoAllAssoc2GenMultiMatched_X",
449 "ReconstructedAllAssoc2GenMultiMatched_X", 120, -0.6, 0.6);
450 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Y"] =
451 i.
book1D(
"RecoAllAssoc2GenMultiMatched_Y",
452 "ReconstructedAllAssoc2GenMultiMatched_Y", 120, -0.6, 0.6);
453 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Z"] =
454 i.
book1D(
"RecoAllAssoc2GenMultiMatched_Z",
455 "ReconstructedAllAssoc2GenMultiMatched_Z", 120, -60, 60);
456 mes_[
label][
"RecoAllAssoc2GenMultiMatched_R"] =
457 i.
book1D(
"RecoAllAssoc2GenMultiMatched_R",
458 "ReconstructedAllAssoc2GenMultiMatched_R", 120, 0, 0.6);
460 "RecoAllAssoc2GenMultiMatched_Pt2",
461 "ReconstructedAllAssoc2GenMultiMatched_Sum-pt2", 15, &log_pt2_bins[0]);
463 "RecoAllAssoc2GenMultiMatched_NumTracks",
464 "ReconstructedAllAssoc2GenMultiMatched_NumTracks", 24, &log_ntrk_bins[0]);
465 mes_[
label][
"RecoAllAssoc2GenMultiMatched_PU"] =
466 i.
book1D(
"RecoAllAssoc2GenMultiMatched_PU",
467 "ReconstructedAllAssoc2GenMultiMatched_PU", 125, 0., 250.);
468 mes_[
label][
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ"] =
469 i.
book1D(
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ",
470 "ReconstructedAllAssoc2GenMultiMatched_ClosestDistanceZ",
471 log_mergez_bins.size()-1, &log_mergez_bins[0]);
480 "RecoAllAssoc2MultiMatchedGen_NumVertices",
481 "RecoAllAssoc2MultiMatchedGen_NumVertices", 100, 0., 200.);
482 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_X"] =
483 i.
book1D(
"RecoAllAssoc2MultiMatchedGen_X",
484 "RecoAllAssoc2MultiMatchedGen_X", 120, -0.6, 0.6);
485 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Y"] =
486 i.
book1D(
"RecoAllAssoc2MultiMatchedGen_Y",
487 "RecoAllAssoc2MultiMatchedGen_Y", 120, -0.6, 0.6);
488 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Z"] =
489 i.
book1D(
"RecoAllAssoc2MultiMatchedGen_Z",
490 "RecoAllAssoc2MultiMatchedGen_Z", 120, -60, 60);
491 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_R"] =
492 i.
book1D(
"RecoAllAssoc2MultiMatchedGen_R",
493 "RecoAllAssoc2MultiMatchedGen_R", 120, 0, 0.6);
494 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Pt2"] =
495 i.
book1D(
"RecoAllAssoc2MultiMatchedGen_Pt2",
496 "RecoAllAssoc2MultiMatchedGen_Sum-pt2", 15, &log_pt2_bins[0]);
497 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumTracks"] =
498 i.
book1D(
"RecoAllAssoc2MultiMatchedGen_NumTracks",
499 "RecoAllAssoc2MultiMatchedGen_NumTracks", 24, &log_ntrk_bins[0]);
500 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_PU"] =
501 i.
book1D(
"RecoAllAssoc2MultiMatchedGen_PU",
502 "RecoAllAssoc2MultiMatchedGen_PU", 125, 0., 250.);
503 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ"] = i.
book1D(
504 "RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ",
505 "RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ", 30, &log_bins[0]);
506 mes_[
label][
"RecoAllAssoc2GenSimForMerge_ClosestDistanceZ"] = i.
book1D(
507 "RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
508 "RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
509 log_mergez_bins.size()-1, &log_mergez_bins[0]);
513 const double resolpt2 = 10;
515 const double minPull = -10;
516 const double maxPull = 10;
517 const double nPull = 100;
519 auto bookResolPull = [&](
const std::string&
prefix,
const double resolx,
const double resoly,
const double resolz) {
520 book1d((prefix+
"_ResolX" ).c_str(), 100,-resolx,resolx);
521 book1d((prefix+
"_ResolY" ).c_str(), 100,-resoly,resoly);
522 book1d((prefix+
"_ResolZ" ).c_str(), 100,-resolz,resolz);
523 book1d((prefix+
"_ResolPt2").c_str(), 100,-resolpt2,resolpt2);
524 book1d((prefix+
"_PullX" ).c_str(), 250,-25,25);
525 book1d((prefix+
"_PullY" ).c_str(), 250,-25,25);
526 book1d((prefix+
"_PullZ" ).c_str(), 250,-25,25);
528 book2d((prefix+
"_ResolX_vs_PU" ).c_str(), 125,0.,250., 100,-resolx,resolx);
529 book2d((prefix+
"_ResolY_vs_PU" ).c_str(), 125,0.,250., 100,-resoly,resoly);
530 book2d((prefix+
"_ResolZ_vs_PU" ).c_str(), 125,0.,250., 100,-resolz,resolz);
531 book2d((prefix+
"_ResolPt2_vs_PU").c_str(), 125,0.,250., 100,-resolpt2,resolpt2);
532 book2d((prefix+
"_PullX_vs_PU" ).c_str(), 125,0.,250., nPull,minPull,maxPull);
533 book2d((prefix+
"_PullY_vs_PU" ).c_str(), 125,0.,250., nPull,minPull,maxPull);
534 book2d((prefix+
"_PullZ_vs_PU" ).c_str(), 125,0.,250., nPull,minPull,maxPull);
536 book2dlogx((prefix+
"_ResolX_vs_NumTracks" ).c_str(), 24,&log_ntrk_bins[0], 100,-resolx,resolx);
537 book2dlogx((prefix+
"_ResolY_vs_NumTracks" ).c_str(), 24,&log_ntrk_bins[0], 100,-resoly,resoly);
538 book2dlogx((prefix+
"_ResolZ_vs_NumTracks" ).c_str(), 24,&log_ntrk_bins[0], 100,-resolz,resolz);
539 book2dlogx((prefix+
"_ResolPt2_vs_NumTracks").c_str(), 24,&log_ntrk_bins[0], 100,-resolpt2,resolpt2);
540 book2dlogx((prefix+
"_PullX_vs_NumTracks" ).c_str(), 24,&log_ntrk_bins[0], nPull,minPull,maxPull);
541 book2dlogx((prefix+
"_PullY_vs_NumTracks" ).c_str(), 24,&log_ntrk_bins[0], nPull,minPull,maxPull);
542 book2dlogx((prefix+
"_PullZ_vs_NumTracks" ).c_str(), 24,&log_ntrk_bins[0], nPull,minPull,maxPull);
544 book2d((prefix+
"_ResolX_vs_Z" ).c_str(), 120,-60,60, 100,-resolx,resolx);
545 book2d((prefix+
"_ResolY_vs_Z" ).c_str(), 120,-60,60, 100,-resoly,resoly);
546 book2d((prefix+
"_ResolZ_vs_Z" ).c_str(), 120,-60,60, 100,-resolz,resolz);
547 book2d((prefix+
"_ResolPt2_vs_Z").c_str(), 120,-60,60, 100,-resolpt2,resolpt2);
548 book2d((prefix+
"_PullX_vs_Z" ).c_str(), 120,-60,60, nPull,minPull,maxPull);
549 book2d((prefix+
"_PullY_vs_Z" ).c_str(), 120,-60,60, nPull,minPull,maxPull);
550 book2d((prefix+
"_PullZ_vs_Z" ).c_str(), 120,-60,60, nPull,minPull,maxPull);
552 book2dlogx((prefix+
"_ResolX_vs_Pt" ).c_str(), log_pt_bins.size()-1,&log_pt_bins[0], 100,-resolx,resolx);
553 book2dlogx((prefix+
"_ResolY_vs_Pt" ).c_str(), log_pt_bins.size()-1,&log_pt_bins[0], 100,-resoly,resoly);
554 book2dlogx((prefix+
"_ResolZ_vs_Pt" ).c_str(), log_pt_bins.size()-1,&log_pt_bins[0], 100,-resolz,resolz);
555 book2dlogx((prefix+
"_ResolPt2_vs_Pt").c_str(), log_pt_bins.size()-1,&log_pt_bins[0], 100,-resolpt2,resolpt2);
556 book2dlogx((prefix+
"_PullX_vs_Pt" ).c_str(), log_pt_bins.size()-1,&log_pt_bins[0], nPull,minPull,maxPull);
557 book2dlogx((prefix+
"_PullY_vs_Pt" ).c_str(), log_pt_bins.size()-1,&log_pt_bins[0], nPull,minPull,maxPull);
558 book2dlogx((prefix+
"_PullZ_vs_Pt" ).c_str(), log_pt_bins.size()-1,&log_pt_bins[0], nPull,minPull,maxPull);
561 bookResolPull(
"RecoAllAssoc2GenMatched" , 0.1 , 0.1 , 0.1 );
562 bookResolPull(
"RecoAllAssoc2GenMatchedMerged", 0.1 , 0.1 , 0.1 );
563 bookResolPull(
"RecoPVAssoc2GenPVMatched" , 0.01, 0.01, 0.01);
567 book1d(
"RecoPVAssoc2GenPVMatched_Purity", 50, 0, 1);
568 book1d(
"RecoPVAssoc2GenPVMatched_Missing", 50, 0, 1);
569 book2d(
"RecoPVAssoc2GenPVMatched_Purity_vs_Index", 100,0,100, 50,0,1);
572 book1d(
"RecoPVAssoc2GenPVNotMatched_Purity", 50, 0, 1);
573 book1d(
"RecoPVAssoc2GenPVNotMatched_Missing", 50, 0, 1);
574 book2d(
"RecoPVAssoc2GenPVNotMatched_Purity_vs_Index", 100,0,100, 50,0,1);
577 book1d(
"RecoAllAssoc2Gen_Purity", 50, 0, 1);
578 book1d(
"RecoAllAssoc2GenMatched_Purity", 50, 0, 1);
582 book1dlogx(
"RecoAssoc2GenPVMatched_Pt2", 15, &log_pt2_bins[0]);
583 book1dlogx(
"RecoAssoc2GenPVNotMatched_Pt2", 15, &log_pt2_bins[0]);
585 book1dlogx(
"RecoAssoc2GenPVMatchedNotHighest_Pt2", 15, &log_pt2_bins[0]);
586 book1dlogx(
"RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2", 15, &log_pt2_bins[0]);
589 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionReco", 50, 0, 1);
590 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionReco", 50, 0, 1);
591 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionRecoMatched", 50, 0, 1);
592 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionRecoMatched", 50, 0, 1);
594 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionSim", 50, 0, 1);
595 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionSim", 50, 0, 1);
596 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionSimMatched", 50, 0, 1);
597 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionSimMatched", 50, 0, 1);
604 mes_[
"root_folder"][
"GenPV_X"]->Fill(v.
x);
605 mes_[
"root_folder"][
"GenPV_Y"]->Fill(v.
y);
606 mes_[
"root_folder"][
"GenPV_Z"]->Fill(v.
z);
607 mes_[
"root_folder"][
"GenPV_R"]->Fill(v.
r);
608 mes_[
"root_folder"][
"GenPV_Pt2"]->Fill(v.
ptsq);
609 mes_[
"root_folder"][
"GenPV_NumTracks"]->Fill(v.
nGenTrk);
611 mes_[
"root_folder"][
"GenPV_ClosestDistanceZ"]
614 mes_[
"root_folder"][
"GenAllV_X"]->Fill(v.
x);
615 mes_[
"root_folder"][
"GenAllV_Y"]->Fill(v.
y);
616 mes_[
"root_folder"][
"GenAllV_Z"]->Fill(v.
z);
617 mes_[
"root_folder"][
"GenAllV_R"]->Fill(v.
r);
618 mes_[
"root_folder"][
"GenAllV_Pt2"]->Fill(v.
ptsq);
619 mes_[
"root_folder"][
"GenAllV_NumTracks"]->Fill(v.
nGenTrk);
621 mes_[
"root_folder"][
"GenAllV_ClosestDistanceZ"]
635 mes_[
label][
"GenAllAssoc2Reco_ClosestDistanceZ"]
638 mes_[
label][
"GenAllAssoc2RecoMatched_X"]->Fill(v.
x);
639 mes_[
label][
"GenAllAssoc2RecoMatched_Y"]->Fill(v.
y);
640 mes_[
label][
"GenAllAssoc2RecoMatched_Z"]->Fill(v.
z);
641 mes_[
label][
"GenAllAssoc2RecoMatched_R"]->Fill(v.
r);
645 mes_[
label][
"GenAllAssoc2RecoMatched_ClosestDistanceZ"]
649 mes_[
label][
"GenAllAssoc2RecoMultiMatched_X"]->Fill(v.
x);
650 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Y"]->Fill(v.
y);
651 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Z"]->Fill(v.
z);
652 mes_[
label][
"GenAllAssoc2RecoMultiMatched_R"]->Fill(v.
r);
653 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Pt2"]->Fill(v.
ptsq);
656 mes_[
label][
"GenAllAssoc2RecoMultiMatched_ClosestDistanceZ"]
664 bool genPVMatchedToRecoPV) {
665 mes_[
label][
"GenPVAssoc2RecoPV_X"]->Fill(v.
x);
666 mes_[
label][
"GenPVAssoc2RecoPV_Y"]->Fill(v.
y);
667 mes_[
label][
"GenPVAssoc2RecoPV_Z"]->Fill(v.
z);
668 if (genPVMatchedToRecoPV) {
669 mes_[
label][
"GenPVAssoc2RecoPVMatched_X"]->Fill(v.
x);
670 mes_[
label][
"GenPVAssoc2RecoPVMatched_Y"]->Fill(v.
y);
671 mes_[
label][
"GenPVAssoc2RecoPVMatched_Z"]->Fill(v.
z);
677 int num_pileup_vertices,
686 mes_[
label][
"RecoAllAssoc2Gen_PU"]->Fill(num_pileup_vertices);
689 mes_[
label][
"RecoAllAssoc2Gen_ClosestDistanceZ"]
693 mes_[
label][
"RecoAllAssoc2GenMatched_X"]->Fill(v.
x);
694 mes_[
label][
"RecoAllAssoc2GenMatched_Y"]->Fill(v.
y);
695 mes_[
label][
"RecoAllAssoc2GenMatched_Z"]->Fill(v.
z);
696 mes_[
label][
"RecoAllAssoc2GenMatched_R"]->Fill(v.
r);
700 mes_[
label][
"RecoAllAssoc2GenMatched_PU"]->Fill(num_pileup_vertices);
703 mes_[
label][
"RecoAllAssoc2GenMatched_ClosestDistanceZ"]
714 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_X"]->Fill(v.
x);
715 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Y"]->Fill(v.
y);
716 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Z"]->Fill(v.
z);
717 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_R"]->Fill(v.
r);
718 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Pt2"]->Fill(v.
ptsq);
720 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_PU"]->Fill(num_pileup_vertices);
722 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ"]
732 mes_[
label][
"RecoAllAssoc2GenSimForMerge_ClosestDistanceZ"]
738 mes_[
label][
"RecoAllAssoc2GenMultiMatched_X"]->Fill(v.
x);
739 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Y"]->Fill(v.
y);
740 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Z"]->Fill(v.
z);
741 mes_[
label][
"RecoAllAssoc2GenMultiMatched_R"]->Fill(v.
r);
742 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Pt2"]->Fill(v.
ptsq);
744 mes_[
label][
"RecoAllAssoc2GenMultiMatched_PU"]->Fill(num_pileup_vertices);
746 mes_[
label][
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ"]
754 prefix =
"RecoAllAssoc2GenSingleMatched_SharedTrackFraction";
757 prefix =
"RecoAllAssoc2GenMultiMatched_SharedTrackFraction";
772 int num_pileup_vertices,
781 prefix =
"RecoPVAssoc2GenPVMatched";
787 const double xres = v.
x - bestMatch.
x;
788 const double yres = v.
y - bestMatch.
y;
789 const double zres = v.
z - bestMatch.
z;
790 const double pt2res = v.
ptsq - bestMatch.
ptsq;
792 const double xresol = xres;
793 const double yresol = yres;
794 const double zresol = zres;
795 const double pt2resol = pt2res/v.
ptsq;
800 mes_[
label][prefix+
"_ResolX"]->Fill(xresol);
801 mes_[
label][prefix+
"_ResolY"]->Fill(yresol);
802 mes_[
label][prefix+
"_ResolZ"]->Fill(zresol);
803 mes_[
label][prefix+
"_ResolPt2"]->Fill(pt2resol);
804 mes_[
label][prefix+
"_PullX"]->Fill(xpull);
805 mes_[
label][prefix+
"_PullY"]->Fill(ypull);
806 mes_[
label][prefix+
"_PullZ"]->Fill(zpull);
808 mes_[
label][prefix+
"_ResolX_vs_PU"]->Fill(num_pileup_vertices, xresol);
809 mes_[
label][prefix+
"_ResolY_vs_PU"]->Fill(num_pileup_vertices, yresol);
810 mes_[
label][prefix+
"_ResolZ_vs_PU"]->Fill(num_pileup_vertices, zresol);
811 mes_[
label][prefix+
"_ResolPt2_vs_PU"]->Fill(num_pileup_vertices, pt2resol);
812 mes_[
label][prefix+
"_PullX_vs_PU"]->Fill(num_pileup_vertices, xpull);
813 mes_[
label][prefix+
"_PullY_vs_PU"]->Fill(num_pileup_vertices, ypull);
814 mes_[
label][prefix+
"_PullZ_vs_PU"]->Fill(num_pileup_vertices, zpull);
824 mes_[
label][prefix+
"_ResolX_vs_Z"]->Fill(v.
z, xresol);
825 mes_[
label][prefix+
"_ResolY_vs_Z"]->Fill(v.
z, yresol);
826 mes_[
label][prefix+
"_ResolZ_vs_Z"]->Fill(v.
z, zresol);
827 mes_[
label][prefix+
"_ResolPt2_vs_Z"]->Fill(v.
z, pt2resol);
828 mes_[
label][prefix+
"_PullX_vs_Z"]->Fill(v.
z, xpull);
829 mes_[
label][prefix+
"_PullY_vs_Z"]->Fill(v.
z, ypull);
830 mes_[
label][prefix+
"_PullZ_vs_Z"]->Fill(v.
z, zpull);
832 mes_[
label][prefix+
"_ResolX_vs_Pt"]->Fill(v.
pt, xresol);
833 mes_[
label][prefix+
"_ResolY_vs_Pt"]->Fill(v.
pt, yresol);
834 mes_[
label][prefix+
"_ResolZ_vs_Pt"]->Fill(v.
pt, zresol);
835 mes_[
label][prefix+
"_ResolPt2_vs_Pt"]->Fill(v.
pt, pt2resol);
836 mes_[
label][prefix+
"_PullX_vs_Pt"]->Fill(v.
pt, xpull);
837 mes_[
label][prefix+
"_PullY_vs_Pt"]->Fill(v.
pt, ypull);
838 mes_[
label][prefix+
"_PullZ_vs_Pt"]->Fill(v.
pt, zpull);
849 for(
const auto& tp:
found->val) {
850 if(tp.first->eventId().bunchCrossing() == 0 && tp.first->eventId().event() == 0)
860 std::vector<recoPrimaryVertex>& recopvs,
861 int genpv_position_in_reco_collection,
862 bool signal_is_highest_pt) {
863 if(recopvs.empty())
return;
865 std::vector<double> vtx_sumpt_sigmatched;
866 std::vector<double> vtx_sumpt2_sigmatched;
868 vtx_sumpt_sigmatched.reserve(recopvs.size());
869 vtx_sumpt2_sigmatched.reserve(recopvs.size());
872 for(
auto&
v: recopvs) {
873 double sumpt_all = 0;
874 double sumpt_sigmatched = 0;
875 double sumpt2_sigmatched = 0;
878 double pt = (*iTrack)->pt();
881 sumpt_sigmatched +=
pt;
882 sumpt2_sigmatched += pt*
pt;
885 v.purity = sumpt_sigmatched / sumpt_all;
887 vtx_sumpt_sigmatched.push_back(sumpt_sigmatched);
888 vtx_sumpt2_sigmatched.push_back(sumpt2_sigmatched);
891 const double vtxAll_sumpt_sigmatched = std::accumulate(vtx_sumpt_sigmatched.begin(), vtx_sumpt_sigmatched.end(), 0.0);
892 const double vtxNot0_sumpt_sigmatched = vtxAll_sumpt_sigmatched - vtx_sumpt_sigmatched[0];
893 const double missing = vtxNot0_sumpt_sigmatched / vtxAll_sumpt_sigmatched;
897 if(genpv_position_in_reco_collection == 0)
898 prefix =
"RecoPVAssoc2GenPVMatched_";
900 mes_[
label][prefix+
"Purity"]->Fill(recopvs[0].purity);
901 mes_[
label][prefix+
"Missing"]->Fill(missing);
902 auto hpurity =
mes_[
label][prefix+
"Purity_vs_Index"];
903 for(
size_t i=0;
i<recopvs.size(); ++
i) {
904 hpurity->Fill(
i, recopvs[
i].purity);
908 for(
size_t i=0;
i<recopvs.size(); ++
i) {
909 if(static_cast<int>(
i) == genpv_position_in_reco_collection) {
910 mes_[
label][
"RecoAssoc2GenPVMatched_Pt2"]->Fill(recopvs[
i].ptsq);
913 double pt2 = recopvs[
i].ptsq;
914 mes_[
label][
"RecoAssoc2GenPVNotMatched_Pt2"]->Fill(pt2);
916 double pt2_pu = pt2-vtx_sumpt2_sigmatched[
i];
917 mes_[
label][
"RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2"]->Fill(pt2_pu);
920 if(!signal_is_highest_pt && genpv_position_in_reco_collection >= 0)
921 mes_[
label][
"RecoAssoc2GenPVMatchedNotHighest_Pt2"]->Fill(recopvs[genpv_position_in_reco_collection].ptsq);
927 std::vector<PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex>
930 std::vector<PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex> simpv;
931 int current_event = -1;
934 std::cout <<
"getSimPVs TrackingVertexCollection " << std::endl;
937 for (TrackingVertexCollection::const_iterator
v = tVC->begin();
938 v != tVC->end(); ++
v) {
940 std::cout <<
"BunchX.EventId: " <<
v->eventId().bunchCrossing() <<
"." 941 << (
v->eventId()).
event() <<
" Position: " <<
v->position()
942 <<
" G4/HepMC Vertices: " <<
v->g4Vertices().size() <<
"/" 943 <<
v->genVertices().size()
944 <<
" t = " <<
v->position().t() * 1.e12
945 <<
" == 0:" << (
v->position().t() > 0) << std::endl;
947 gv !=
v->g4Vertices_end(); gv++) {
957 if (
v->eventId().bunchCrossing() != 0)
continue;
958 if (
v->eventId().event() != current_event) {
959 current_event =
v->eventId().event();
964 if (fabs(
v->position().z()) > 1000)
continue;
970 sv.eventId =
v->eventId();
974 iTrack !=
v->daughterTracks_end(); ++iTrack) {
978 assert((**iTrack).eventId().bunchCrossing() == 0);
983 for (std::vector<simPrimaryVertex>::iterator v0 = simpv.begin();
984 v0 != simpv.end(); v0++) {
985 if ((
sv.eventId == v0->eventId) && (fabs(
sv.x - v0->x) < 1
e-5) &&
986 (fabs(
sv.y - v0->y) < 1
e-5) && (fabs(
sv.z - v0->z) < 1
e-5)) {
996 std::cout <<
"this is a new vertex " <<
sv.eventId.event() <<
" " 997 <<
sv.x <<
" " <<
sv.y <<
" " <<
sv.z << std::endl;
1001 std::cout <<
"this is not a new vertex" <<
sv.x <<
" " <<
sv.y <<
" " 1002 <<
sv.z << std::endl;
1008 iTP !=
v->daughterTracks_end(); ++iTP) {
1009 auto momentum = (*(*iTP)).momentum();
1010 const reco::Track* matched_best_reco_track =
nullptr;
1011 double match_quality = -1;
1015 matched_best_reco_track = (*s2r_)[*iTP][0].first.get();
1016 match_quality = (*s2r_)[*iTP][0].second;
1019 std::cout <<
" Daughter momentum: " << momentum;
1021 std::cout <<
" matched: " << (matched_best_reco_track !=
nullptr);
1022 std::cout <<
" match-quality: " << match_quality;
1025 vp->ptot.setPx(vp->ptot.x() + momentum.x());
1026 vp->ptot.setPy(vp->ptot.y() + momentum.y());
1027 vp->ptot.setPz(vp->ptot.z() + momentum.z());
1028 vp->ptot.setE(vp->ptot.e() + (**iTP).energy());
1029 vp->ptsq += ((**iTP).pt() * (**iTP).pt());
1032 if (matched_best_reco_track) {
1033 vp->num_matched_reco_tracks++;
1034 vp->average_match_quality += match_quality;
1040 if (((**iTP).pt() > 0.2) && (fabs((**iTP).eta()) < 2.5) &&
1041 (**iTP).charge() != 0) {
1045 if (vp->num_matched_reco_tracks)
1046 vp->average_match_quality /=
1047 static_cast<float>(vp->num_matched_reco_tracks);
1049 std::cout <<
"average number of associated tracks: " 1050 << vp->num_matched_reco_tracks /
static_cast<float>(vp->nGenTrk)
1051 <<
" with average quality: " << vp->average_match_quality
1057 std::cout <<
"------- PrimaryVertexAnalyzer4PUSlimmed simPVs from " 1059 "-------" << std::endl;
1060 for (std::vector<simPrimaryVertex>::iterator v0 = simpv.begin();
1061 v0 != simpv.end(); v0++) {
1062 std::cout <<
"z=" << v0->z <<
" event=" << v0->eventId.event()
1065 std::cout <<
"-----------------------------------------------" << std::endl;
1074 auto prev_z = simpv.back().z;
1076 vsim.closest_vertex_distance_z =
std::abs(vsim.z - prev_z);
1080 for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin();
1081 vsim != simpv.end(); vsim++) {
1082 std::vector<simPrimaryVertex>::iterator vsim2 = vsim;
1084 for (; vsim2 != simpv.end(); vsim2++) {
1087 vsim->closest_vertex_distance_z =
std::min(vsim->closest_vertex_distance_z, distance);
1088 vsim2->closest_vertex_distance_z =
std::min(vsim2->closest_vertex_distance_z, distance);
1096 std::vector<PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex>
1099 std::vector<PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex> recopv;
1102 std::cout <<
"getRecoPVs TrackingVertexCollection " << std::endl;
1105 for (
auto v = tVC->begin();
v != tVC->end(); ++
v) {
1107 std::cout <<
" Position: " <<
v->position() << std::endl;
1111 if (fabs(
v->z()) > 1000)
continue;
1112 if (
v->isFake() || !
v->isValid())
continue;
1119 recopv.push_back(
sv);
1123 for (
auto iTrack =
v->tracks_begin(); iTrack !=
v->tracks_end(); ++iTrack) {
1124 auto momentum = (*(*iTrack)).innerMomentum();
1128 if (momentum.mag2() == 0)
1129 momentum = (*(*iTrack)).momentum();
1131 std::cout <<
" Daughter momentum: " << momentum;
1135 vp->
ptsq += (momentum.perp2());
1147 std::cout <<
"------- PrimaryVertexAnalyzer4PUSlimmed recoPVs from " 1149 "-------" << std::endl;
1150 for (std::vector<recoPrimaryVertex>::iterator v0 = recopv.begin();
1151 v0 != recopv.end(); v0++) {
1152 std::cout <<
"z=" << v0->z << std::endl;
1154 std::cout <<
"-----------------------------------------------" << std::endl;
1163 auto prev_z = recopv.back().z;
1165 vreco.closest_vertex_distance_z =
std::abs(vreco.z - prev_z);
1168 for (std::vector<recoPrimaryVertex>::iterator vreco = recopv.begin();
1169 vreco != recopv.end(); vreco++) {
1170 std::vector<recoPrimaryVertex>::iterator vreco2 = vreco;
1172 for (; vreco2 != recopv.end(); vreco2++) {
1175 vreco->closest_vertex_distance_z =
std::min(vreco->closest_vertex_distance_z, distance);
1176 vreco2->closest_vertex_distance_z =
std::min(vreco2->closest_vertex_distance_z, distance);
1183 std::vector<simPrimaryVertex> & simpv) {
1184 for (
auto &
v : simpv) {
1185 v.rec_vertices.clear();
1191 std::vector<simPrimaryVertex>& simpv,
1194 std::cout <<
"PrimaryVertexAnalyzer4PUSlimmed::matchSim2RecoVertices " << std::endl;
1196 for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin();
1197 vsim != simpv.end(); vsim++) {
1201 for(
const auto vertexRefQuality:
matched->val) {
1202 vsim->rec_vertices.push_back(&(*(vertexRefQuality.first)));
1207 if (vsim->rec_vertices.size()) {
1208 for (
auto const&
v : vsim->rec_vertices) {
1209 std::cout <<
"Found a matching vertex for genVtx " 1210 << vsim->z <<
" at " <<
v->z()
1211 <<
" with sign: " << fabs(
v->z() - vsim->z) /
v->zError()
1215 std::cout <<
"No matching vertex for " << vsim->z << std::endl;
1220 std::cout <<
"Done with matching sim vertices" << std::endl;
1225 std::vector<recoPrimaryVertex>& recopv,
1227 const std::vector<simPrimaryVertex>& simpv) {
1228 for (std::vector<recoPrimaryVertex>::iterator vrec = recopv.begin();
1229 vrec != recopv.end(); vrec++) {
1233 for(
const auto vertexRefQuality:
matched->val) {
1234 const auto tvPtr = &(*(vertexRefQuality.first));
1235 vrec->sim_vertices.push_back(tvPtr);
1240 for(
const auto& vv: simpv) {
1241 if (&(*(vv.sim_vertex)) == tv) {
1242 vrec->sim_vertices_internal.push_back(&vv);
1253 for (
auto v : vrec->sim_vertices) {
1254 std::cout <<
"Found a matching vertex for reco: " << vrec->z
1255 <<
" at gen:" <<
v->position().z() <<
" with sign: " 1256 << fabs(vrec->z -
v->position().z()) / vrec->recVtx->zError()
1270 using namespace reco;
1272 std::vector<float> pileUpInfo_z;
1277 for (
auto const& pu_info : *puinfoH.
product()) {
1279 mes_[
"root_folder"][
"GenVtx_vs_BX"]
1280 ->Fill(pu_info.getBunchCrossing(), pu_info.getPU_NumInteractions());
1282 if (pu_info.getBunchCrossing() == 0) {
1283 pileUpInfo_z = pu_info.getPU_zpositions();
1285 for (
auto const&
p : pileUpInfo_z) {
1286 std::cout <<
"PileUpInfo on Z vertex: " <<
p << std::endl;
1298 <<
"TPCollectionH is not valid";
1304 <<
"TVCollectionH is not valid";
1317 <<
"simToRecoH is not valid";
1325 <<
"recoToSimH is not valid";
1330 if (!vertexAssociatorH.
isValid()) {
1332 <<
"vertexAssociatorH is not valid";
1337 std::vector<simPrimaryVertex> simpv;
1343 int kind_of_signal_vertex = 0;
1344 int num_pileup_vertices = simpv.size();
1346 bool signal_is_highest_pt = std::max_element(simpv.begin(), simpv.end(),
1349 return lhs.
ptsq < rhs.ptsq;
1350 }) == simpv.begin();
1351 kind_of_signal_vertex |= (signal_is_highest_pt <<
HIGHEST_PT);
1353 mes_[
"root_folder"][
"SignalIsHighestPt2"]->Fill(signal_is_highest_pt ? 1. : 0.);
1357 int label_index = -1;
1360 std::vector<recoPrimaryVertex> recopv;
1364 if (!iEvent.
getByToken(vertex_token, recVtxs)) {
1367 <<
"Skipping vertex collection: " << label <<
" since it is missing.";
1376 for(
const auto&
v: *recVtxs) {
1377 if(
v.tracksSize() > 0) {
1378 const auto& ref =
v.trackRefAt(0);
1379 if(ref.isNull() || !ref.isAvailable()) {
1382 <<
"Skipping vertex collection: " << label <<
" since likely the track collection the vertex has refs pointing to is missing (at least the first TrackBaseRef is null or not available)";
1400 mes_[label][
"RecoAllAssoc2Gen_PairDistanceZ"]);
1403 int num_total_gen_vertices_assoc2reco = 0;
1404 int num_total_reco_vertices_assoc2gen = 0;
1405 int num_total_gen_vertices_multiassoc2reco = 0;
1406 int num_total_reco_vertices_multiassoc2gen = 0;
1407 int num_total_reco_vertices_duplicate = 0;
1408 int genpv_position_in_reco_collection = -1;
1409 for (
auto const&
v : simpv) {
1412 if (
v.eventId.event() == 0) {
1413 if (!recVtxs->empty() &&
1414 std::find(
v.rec_vertices.begin(),
v.rec_vertices.end(),
1415 &((*recVtxs.
product())[0])) !=
v.rec_vertices.end()) {
1419 if (
v.rec_vertices.size()) {
1423 mes_[
label][
"KindOfSignalPV"]->Fill(kind_of_signal_vertex);
1424 mes_[
label][
"MisTagRate"]->Fill(mistag);
1425 mes_[
label][
"MisTagRate_vs_PU"]->Fill(simpv.size(), mistag);
1426 mes_[
label][
"MisTagRate_vs_sum-pt2"]->Fill(
v.ptsq, mistag);
1427 mes_[
label][
"MisTagRate_vs_Z"]->Fill(
v.z, mistag);
1428 mes_[
label][
"MisTagRate_vs_R"]->Fill(
v.r, mistag);
1429 mes_[
label][
"MisTagRate_vs_NumTracks"]->Fill(
v.nGenTrk, mistag);
1430 if (signal_is_highest_pt) {
1431 mes_[
label][
"MisTagRateSignalIsHighest"]->Fill(mistag);
1432 mes_[
label][
"MisTagRateSignalIsHighest_vs_PU"]->Fill(simpv.size(),
1434 mes_[
label][
"MisTagRateSignalIsHighest_vs_sum-pt2"]->Fill(
v.ptsq,
1436 mes_[
label][
"MisTagRateSignalIsHighest_vs_Z"]->Fill(
v.z, mistag);
1437 mes_[
label][
"MisTagRateSignalIsHighest_vs_R"]->Fill(
v.r, mistag);
1438 mes_[
label][
"MisTagRateSignalIsHighest_vs_NumTracks"]->Fill(
v.nGenTrk,
1441 mes_[
label][
"MisTagRateSignalIsNotHighest"]->Fill(mistag);
1442 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_PU"]->Fill(simpv.size(),
1444 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_sum-pt2"]->Fill(
v.ptsq,
1446 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_Z"]->Fill(
v.z, mistag);
1447 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_R"]->Fill(
v.r, mistag);
1448 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_NumTracks"]->
1449 Fill(
v.nGenTrk, mistag);
1457 for (
int pv_position_in_reco_collection = 0;
1459 ++pv_position_in_reco_collection, ++iv) {
1460 if (
std::find(
v.rec_vertices.begin(),
v.rec_vertices.end(),
1461 &(*iv)) !=
v.rec_vertices.end()) {
1463 ->Fill(pv_position_in_reco_collection);
1464 const bool genPVMatchedToRecoPV = (pv_position_in_reco_collection == 0);
1465 mes_[
label][
"TruePVLocationIndexCumulative"]
1466 ->Fill(genPVMatchedToRecoPV ? 0 : 1);
1468 if (signal_is_highest_pt) {
1469 mes_[
label][
"TruePVLocationIndexSignalIsHighest"]
1470 ->Fill(pv_position_in_reco_collection);
1472 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"]
1473 ->Fill(pv_position_in_reco_collection);
1477 if(genPVMatchedToRecoPV) {
1478 auto pv = recopv[0];
1479 assert(
pv.recVtx == &(*iv));
1482 genpv_position_in_reco_collection = pv_position_in_reco_collection;
1492 mes_[
label][
"TruePVLocationIndex"]->Fill(-1.);
1493 mes_[
label][
"TruePVLocationIndexCumulative"]->Fill(-1.);
1494 if (signal_is_highest_pt)
1495 mes_[
label][
"TruePVLocationIndexSignalIsHighest"]->Fill(-1.);
1497 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"]->Fill(-1.);
1501 if (
v.rec_vertices.size()) num_total_gen_vertices_assoc2reco++;
1502 if (
v.rec_vertices.size() > 1) num_total_gen_vertices_multiassoc2reco++;
1510 mes_[
label][
"GenAllAssoc2Reco_NumVertices"]
1511 ->Fill(simpv.size(), simpv.size());
1512 mes_[
label][
"GenAllAssoc2RecoMatched_NumVertices"]
1513 ->Fill(simpv.size(), num_total_gen_vertices_assoc2reco);
1514 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumVertices"]
1515 ->Fill(simpv.size(), num_total_gen_vertices_multiassoc2reco);
1516 for (
auto &
v : recopv) {
1518 if (
v.sim_vertices.size()) {
1519 num_total_reco_vertices_assoc2gen++;
1520 if (
v.sim_vertices_internal[0]->rec_vertices.size() > 1) {
1521 num_total_reco_vertices_duplicate++;
1524 if (
v.sim_vertices.size() > 1) num_total_reco_vertices_multiassoc2gen++;
1526 mes_[
label][
"RecoAllAssoc2Gen_NumVertices"]
1527 ->Fill(recopv.size(), recopv.size());
1528 mes_[
label][
"RecoAllAssoc2GenMatched_NumVertices"]
1529 ->Fill(recopv.size(), num_total_reco_vertices_assoc2gen);
1530 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumVertices"]
1531 ->Fill(recopv.size(), num_total_reco_vertices_multiassoc2gen);
1532 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumVertices"]
1533 ->Fill(recopv.size(), num_total_reco_vertices_duplicate);
1534 mes_[
label][
"RecoVtx_vs_GenVtx"]->Fill(simpv.size(), recopv.size());
1536 ->Fill(simpv.size(), num_total_reco_vertices_assoc2gen);
1544 for (
unsigned int i = 0;
i < collection.size(); ++
i) {
1545 for (
unsigned int j =
i+1; j < collection.size(); ++j) {
T getParameter(std::string const &) const
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 >> &)
double closest_vertex_distance_z
int event() const
get the contents of the subdetector field (should be protected?)
bool matchRecoTrack2SimSignal(const reco::TrackBaseRef &)
void resetSimPVAssociation(std::vector< simPrimaryVertex > &)
std::vector< const simPrimaryVertex * > sim_vertices_internal
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoAssociationToken_
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > vecPileupSummaryInfoToken_
std::vector< TrackingParticle > TrackingParticleCollection
void fillRecoAssociatedGenPVHistograms(const std::string &label, const PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex &v, bool genPVMatchedToRecoPV)
trackRef_iterator tracks_end() const
last iterator over tracks
void computePairDistance(const T &collection, MonitorElement *me)
const_iterator end() const
last iterator over the map (read only)
MonitorElement * bookProfile(Args &&...args)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double zError() const
error on z
std::vector< SimVertex >::const_iterator g4v_iterator
std::vector< const TrackingVertex * > sim_vertices
bool use_only_charged_tracks_
edm::RefToBase< reco::Vertex > VertexBaseRef
persistent reference to a Vertex, using views
const_iterator find(const key_type &k) const
find element with specified reference key
virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
int num_matched_sim_tracks
PrimaryVertexAnalyzer4PUSlimmed(const edm::ParameterSet &)
edm::EDGetTokenT< TrackingVertexCollection > trackingVertexCollectionToken_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const bool do_generic_sim_plots_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex > getSimPVs(const edm::Handle< TrackingVertexCollection > &)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
void fillResolutionAndPullHistograms(const std::string &, int, recoPrimaryVertex &v, bool)
MonitorElement * book1D(Args &&...args)
Abs< T >::type abs(const T &t)
std::vector< bool > errorPrintedForColl_
void calculatePurityAndFillHistograms(const std::string &, std::vector< recoPrimaryVertex > &, int, bool)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
double closest_vertex_distance_z
const reco::SimToRecoCollection * s2r_
std::vector< edm::EDGetTokenT< edm::View< reco::Vertex > > > reco_vertex_collection_tokens_
void fillGenericGenVertexHistograms(const simPrimaryVertex &v)
edm::Ref< TrackingVertexCollection > TrackingVertexRef
double xError() const
error on x
void setCurrentFolder(const std::string &fullpath)
T const * product() const
MonitorElement * book2D(Args &&...args)
def bestMatch(object, matchCollection)
std::vector< TrackingVertex > TrackingVertexCollection
~PrimaryVertexAnalyzer4PUSlimmed()
edm::AssociationMap< edm::OneToManyWithQualityGeneric< edm::View< reco::Track >, TrackingParticleCollection, double > > RecoToSimCollection
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_
std::vector< edm::InputTag > reco_vertex_collections_
std::map< std::string, std::map< std::string, MonitorElement * > > mes_
const reco::Vertex * recVtx
edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > > SimToRecoCollection
unsigned int calculateVertexSharedTracks(const reco::Vertex &recoV, const TrackingVertex &simV, const reco::RecoToSimCollection &trackRecoToSimAssociation)
trackRef_iterator tracks_begin() const
first iterator over tracks
int num_matched_reco_tracks
TH2F * getTH2F(void) const
reco::VertexRecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
compare reco to sim the handle of reco::Vertex and TrackingVertex collections
std::vector< const reco::Vertex * > rec_vertices
reco::VertexSimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Vertex > > &vCH, const edm::Handle< TrackingVertexCollection > &tVCH) const
compare reco to sim the handle of reco::Vertex and TrackingVertex collections
std::vector< unsigned int > sim_vertices_num_shared_tracks
Power< A, B >::type pow(const A &a, const B &b)
double yError() const
error on y
const reco::RecoToSimCollection * r2s_
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleCollectionToken_