25 template <
typename T,
size_t N>
27 const double minLog10 = std::log10(
min);
28 const double maxLog10 = std::log10(
max);
29 const double width = (maxLog10 - minLog10) /
N;
30 std::array<T, N + 1>
ret;
33 for (
size_t i = 1;
i <=
N; ++
i) {
44 : verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose",
false)),
45 use_only_charged_tracks_(iConfig.getUntrackedParameter<
bool>(
"use_only_charged_tracks",
true)),
46 do_generic_sim_plots_(iConfig.getUntrackedParameter<
bool>(
"do_generic_sim_plots")),
47 root_folder_(iConfig.getUntrackedParameter<
std::
string>(
"root_folder",
"Validation/Vertices")),
50 iConfig.getUntrackedParameter<
edm::
InputTag>(
"trackingParticleCollection"))),
51 trackingVertexCollectionToken_(
53 simToRecoAssociationToken_(
55 recoToSimAssociationToken_(
57 vertexAssociatorToken_(consumes<
reco::VertexToTrackingVertexAssociator>(
58 iConfig.getUntrackedParameter<
edm::
InputTag>(
"vertexAssociator"))),
59 nPUbins_(iConfig.getParameter<unsigned
int>(
"nPUbins")) {
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>(1
e-4, 1);
84 auto const log_pt_bins = makeLogBins<float, 100>(0.1, 1
e4);
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};
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};
99 mes_[
"root_folder"][
"GenVtx_vs_BX"] =
100 i.book2D(
"GenVtx_vs_BX",
"GenVtx_vs_BX", 16, -12.5, 3.5,
nPUbins_, 0.,
double(
nPUbins_));
102 mes_[
"root_folder"][
"GenPV_X"] =
i.book1D(
"GenPV_X",
"GeneratedPV_X", 120, -0.6, 0.6);
103 mes_[
"root_folder"][
"GenPV_Y"] =
i.book1D(
"GenPV_Y",
"GeneratedPV_Y", 120, -0.6, 0.6);
104 mes_[
"root_folder"][
"GenPV_Z"] =
i.book1D(
"GenPV_Z",
"GeneratedPV_Z", 120, -60., 60.);
105 mes_[
"root_folder"][
"GenPV_R"] =
i.book1D(
"GenPV_R",
"GeneratedPV_R", 120, 0, 0.6);
106 mes_[
"root_folder"][
"GenPV_Pt2"] =
i.book1D(
"GenPV_Pt2",
"GeneratedPV_Sum-pt2", 15, &log_pt2_bins[0]);
107 mes_[
"root_folder"][
"GenPV_NumTracks"] =
108 i.book1D(
"GenPV_NumTracks",
"GeneratedPV_NumTracks", 24, &log_ntrk_bins[0]);
109 mes_[
"root_folder"][
"GenPV_ClosestDistanceZ"] =
110 i.book1D(
"GenPV_ClosestDistanceZ",
"GeneratedPV_ClosestDistanceZ", 30, &log_bins[0]);
113 mes_[
"root_folder"][
"GenAllV_NumVertices"] =
114 i.book1D(
"GenAllV_NumVertices",
"GeneratedAllV_NumVertices",
int(
nPUbins_ / 2), 0.,
double(
nPUbins_));
115 mes_[
"root_folder"][
"GenAllV_X"] =
i.book1D(
"GenAllV_X",
"GeneratedAllV_X", 120, -0.6, 0.6);
116 mes_[
"root_folder"][
"GenAllV_Y"] =
i.book1D(
"GenAllV_Y",
"GeneratedAllV_Y", 120, -0.6, 0.6);
117 mes_[
"root_folder"][
"GenAllV_Z"] =
i.book1D(
"GenAllV_Z",
"GeneratedAllV_Z", 120, -60, 60);
118 mes_[
"root_folder"][
"GenAllV_R"] =
i.book1D(
"GenAllV_R",
"GeneratedAllV_R", 120, 0, 0.6);
119 mes_[
"root_folder"][
"GenAllV_Pt2"] =
i.book1D(
"GenAllV_Pt2",
"GeneratedAllV_Sum-pt2", 15, &log_pt2_bins[0]);
120 mes_[
"root_folder"][
"GenAllV_NumTracks"] =
121 i.book1D(
"GenAllV_NumTracks",
"GeneratedAllV_NumTracks", 24, &log_ntrk_bins[0]);
122 mes_[
"root_folder"][
"GenAllV_ClosestDistanceZ"] =
123 i.book1D(
"GenAllV_ClosestDistanceZ",
"GeneratedAllV_ClosestDistanceZ", 30, &log_bins[0]);
124 mes_[
"root_folder"][
"GenAllV_PairDistanceZ"] =
125 i.book1D(
"GenAllV_PairDistanceZ",
"GeneratedAllV_PairDistanceZ", 1000, 0, 20);
126 mes_[
"root_folder"][
"SignalIsHighestPt2"] =
i.book1D(
"SignalIsHighestPt2",
"SignalIsHighestPt2", 2, -0.5, 1.5);
132 i.setCurrentFolder(current_folder);
134 auto book1d = [&](
const char*
name,
int bins,
double min,
double max) {
137 auto book1dlogx = [&](
const char*
name,
int bins,
const float* xbinedges) {
143 auto book2dlogx = [&](
const char*
name,
int xbins,
const float* xbinedges,
int ybins,
double ymin,
double ymax) {
145 me->getTH2F()->GetXaxis()->Set(
xbins, xbinedges);
149 mes_[
label][
"RecoVtx_vs_GenVtx"] =
i.bookProfile(
151 mes_[
label][
"MatchedRecoVtx_vs_GenVtx"] =
i.bookProfile(
"MatchedRecoVtx_vs_GenVtx",
152 "MatchedRecoVtx_vs_GenVtx",
159 mes_[
label][
"KindOfSignalPV"] =
i.book1D(
"KindOfSignalPV",
"KindOfSignalPV", 9, -0.5, 8.5);
160 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(1,
"!Highest!Assoc2Any");
161 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(2,
"Highest!Assoc2Any");
162 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(3,
"!HighestAssoc2First");
163 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(4,
"HighestAssoc2First");
164 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(5,
"!HighestAssoc2!First");
165 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(6,
"HighestAssoc2!First");
166 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(7,
"!HighestAssoc2First");
167 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(8,
"HighestAssoc2First");
168 mes_[
label][
"MisTagRate"] =
i.book1D(
"MisTagRate",
"MisTagRate", 2, -0.5, 1.5);
170 i.bookProfile(
"MisTagRate_vs_PU",
"MisTagRate_vs_PU",
int(
nPUbins_ / 2), 0.,
double(
nPUbins_), 2, 0., 1.);
172 i.bookProfile(
"MisTagRate_vs_sum-pt2",
"MisTagRate_vs_sum-pt2", 15, &log_pt2_bins_double[0], 2, 0., 1.);
173 mes_[
label][
"MisTagRate_vs_Z"] =
i.bookProfile(
"MisTagRate_vs_Z",
"MisTagRate_vs_Z", 120, -60., 60., 2, 0., 1.);
174 mes_[
label][
"MisTagRate_vs_R"] =
i.bookProfile(
"MisTagRate_vs_R",
"MisTagRate_vs_R", 120, 0., 0.6, 2, 0., 1.);
175 mes_[
label][
"MisTagRate_vs_NumTracks"] =
i.bookProfile(
176 "MisTagRate_vs_NumTracks",
"MisTagRate_vs_NumTracks",
int(
nPUbins_ / 2), 0.,
double(
nPUbins_), 2, 0., 1.);
177 mes_[
label][
"MisTagRateSignalIsHighest"] =
178 i.book1D(
"MisTagRateSignalIsHighest",
"MisTagRateSignalIsHighest", 2, -0.5, 1.5);
179 mes_[
label][
"MisTagRateSignalIsHighest_vs_PU"] =
i.bookProfile(
180 "MisTagRateSignalIsHighest_vs_PU",
"MisTagRateSignalIsHighest_vs_PU",
nPUbins_, 0.,
double(
nPUbins_), 2, 0., 1.);
181 mes_[
label][
"MisTagRateSignalIsHighest_vs_sum-pt2"] =
i.bookProfile(
"MisTagRateSignalIsHighest_vs_sum-pt2",
182 "MisTagRateSignalIsHighest_vs_sum-pt2",
184 &log_pt2_bins_double[0],
188 mes_[
label][
"MisTagRateSignalIsHighest_vs_Z"] =
189 i.bookProfile(
"MisTagRateSignalIsHighest_vs_Z",
"MisTagRateSignalIsHighest_vs_Z", 120, -60., 60., 2, 0., 1.);
190 mes_[
label][
"MisTagRateSignalIsHighest_vs_R"] =
191 i.bookProfile(
"MisTagRateSignalIsHighest_vs_R",
"MisTagRateSignalIsHighest_vs_R", 120, 0., 0.6, 2, 0., 1.);
192 mes_[
label][
"MisTagRateSignalIsHighest_vs_NumTracks"] =
i.bookProfile(
"MisTagRateSignalIsHighest_vs_NumTracks",
193 "MisTagRateSignalIsHighest_vs_NumTracks",
200 mes_[
label][
"MisTagRateSignalIsNotHighest"] =
201 i.book1D(
"MisTagRateSignalIsNotHighest",
"MisTagRateSignalIsNotHighest", 2, -0.5, 1.5);
202 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_PU"] =
i.bookProfile(
"MisTagRateSignalIsNotHighest_vs_PU",
203 "MisTagRateSignalIsNotHighest_vs_PU",
210 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_sum-pt2"] =
i.bookProfile(
"MisTagRateSignalIsNotHighest_vs_sum-pt2",
211 "MisTagRateSignalIsNotHighest_vs_sum-pt2",
213 &log_pt2_bins_double[0],
217 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_Z"] =
i.bookProfile(
218 "MisTagRateSignalIsNotHighest_vs_Z",
"MisTagRateSignalIsNotHighest_vs_Z", 120, -60., 60., 2, 0., 1.);
219 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_R"] =
i.bookProfile(
220 "MisTagRateSignalIsNotHighest_vs_R",
"MisTagRateSignalIsNotHighest_vs_R", 120, 0., 0.6, 2, 0., 1.);
221 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_NumTracks"] =
222 i.bookProfile(
"MisTagRateSignalIsNotHighest_vs_NumTracks",
223 "MisTagRateSignalIsNotHighest_vs_NumTracks",
231 i.book1D(
"TruePVLocationIndex",
"TruePVLocationIndexInRecoVertexCollection", 12, -1.5, 10.5);
232 mes_[
label][
"TruePVLocationIndexCumulative"] =
233 i.book1D(
"TruePVLocationIndexCumulative",
"TruePVLocationIndexInRecoVertexCollectionCumulative", 3, -1.5, 1.5);
234 mes_[
label][
"TruePVLocationIndexSignalIsHighest"] =
235 i.book1D(
"TruePVLocationIndexSignalIsHighest",
236 "TruePVLocationIndexSignalIsHighestInRecoVertexCollection",
240 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"] =
241 i.book1D(
"TruePVLocationIndexSignalIsNotHighest",
242 "TruePVLocationIndexSignalIsNotHighestInRecoVertexCollection",
249 mes_[
label][
"GenAllAssoc2Reco_NumVertices"] =
i.book1D(
250 "GenAllAssoc2Reco_NumVertices",
"GeneratedAllAssoc2Reco_NumVertices",
int(
nPUbins_ / 2), 0.,
double(
nPUbins_));
251 mes_[
label][
"GenAllAssoc2Reco_X"] =
i.book1D(
"GenAllAssoc2Reco_X",
"GeneratedAllAssoc2Reco_X", 120, -0.6, 0.6);
252 mes_[
label][
"GenAllAssoc2Reco_Y"] =
i.book1D(
"GenAllAssoc2Reco_Y",
"GeneratedAllAssoc2Reco_Y", 120, -0.6, 0.6);
253 mes_[
label][
"GenAllAssoc2Reco_Z"] =
i.book1D(
"GenAllAssoc2Reco_Z",
"GeneratedAllAssoc2Reco_Z", 120, -60, 60);
254 mes_[
label][
"GenAllAssoc2Reco_R"] =
i.book1D(
"GenAllAssoc2Reco_R",
"GeneratedAllAssoc2Reco_R", 120, 0, 0.6);
256 i.book1D(
"GenAllAssoc2Reco_Pt2",
"GeneratedAllAssoc2Reco_Sum-pt2", 15, &log_pt2_bins[0]);
257 mes_[
label][
"GenAllAssoc2Reco_NumTracks"] =
258 i.book1D(
"GenAllAssoc2Reco_NumTracks",
"GeneratedAllAssoc2Reco_NumTracks", 24, &log_ntrk_bins[0]);
259 mes_[
label][
"GenAllAssoc2Reco_ClosestDistanceZ"] =
260 i.book1D(
"GenAllAssoc2Reco_ClosestDistanceZ",
"GeneratedAllAssoc2Reco_ClosestDistanceZ", 30, &log_bins[0]);
261 book1d(
"GenPVAssoc2RecoPV_X", 120, -0.6, 0.6);
262 book1d(
"GenPVAssoc2RecoPV_Y", 120, -0.6, 0.6);
263 book1d(
"GenPVAssoc2RecoPV_Z", 120, -60, 60);
267 mes_[
label][
"GenAllAssoc2RecoMatched_NumVertices"] =
i.book1D(
"GenAllAssoc2RecoMatched_NumVertices",
268 "GeneratedAllAssoc2RecoMatched_NumVertices",
272 mes_[
label][
"GenAllAssoc2RecoMatched_X"] =
273 i.book1D(
"GenAllAssoc2RecoMatched_X",
"GeneratedAllAssoc2RecoMatched_X", 120, -0.6, 0.6);
274 mes_[
label][
"GenAllAssoc2RecoMatched_Y"] =
275 i.book1D(
"GenAllAssoc2RecoMatched_Y",
"GeneratedAllAssoc2RecoMatched_Y", 120, -0.6, 0.6);
276 mes_[
label][
"GenAllAssoc2RecoMatched_Z"] =
277 i.book1D(
"GenAllAssoc2RecoMatched_Z",
"GeneratedAllAssoc2RecoMatched_Z", 120, -60, 60);
278 mes_[
label][
"GenAllAssoc2RecoMatched_R"] =
279 i.book1D(
"GenAllAssoc2RecoMatched_R",
"GeneratedAllAssoc2RecoMatched_R", 120, 0, 0.6);
280 mes_[
label][
"GenAllAssoc2RecoMatched_Pt2"] =
281 i.book1D(
"GenAllAssoc2RecoMatched_Pt2",
"GeneratedAllAssoc2RecoMatched_Sum-pt2", 15, &log_pt2_bins[0]);
282 mes_[
label][
"GenAllAssoc2RecoMatched_NumTracks"] =
283 i.book1D(
"GenAllAssoc2RecoMatched_NumTracks",
"GeneratedAllAssoc2RecoMatched_NumTracks", 24, &log_ntrk_bins[0]);
284 mes_[
label][
"GenAllAssoc2RecoMatched_ClosestDistanceZ"] =
i.book1D(
285 "GenAllAssoc2RecoMatched_ClosestDistanceZ",
"GeneratedAllAssoc2RecoMatched_ClosestDistanceZ", 30, &log_bins[0]);
286 book1d(
"GenPVAssoc2RecoPVMatched_X", 120, -0.6, 0.6);
287 book1d(
"GenPVAssoc2RecoPVMatched_Y", 120, -0.6, 0.6);
288 book1d(
"GenPVAssoc2RecoPVMatched_Z", 120, -60, 60);
292 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumVertices"] =
i.book1D(
"GenAllAssoc2RecoMultiMatched_NumVertices",
293 "GeneratedAllAssoc2RecoMultiMatched_NumVertices",
297 mes_[
label][
"GenAllAssoc2RecoMultiMatched_X"] =
298 i.book1D(
"GenAllAssoc2RecoMultiMatched_X",
"GeneratedAllAssoc2RecoMultiMatched_X", 120, -0.6, 0.6);
299 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Y"] =
300 i.book1D(
"GenAllAssoc2RecoMultiMatched_Y",
"GeneratedAllAssoc2RecoMultiMatched_Y", 120, -0.6, 0.6);
301 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Z"] =
302 i.book1D(
"GenAllAssoc2RecoMultiMatched_Z",
"GeneratedAllAssoc2RecoMultiMatched_Z", 120, -60, 60);
303 mes_[
label][
"GenAllAssoc2RecoMultiMatched_R"] =
304 i.book1D(
"GenAllAssoc2RecoMultiMatched_R",
"GeneratedAllAssoc2RecoMultiMatched_R", 120, 0, 0.6);
305 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Pt2"] =
i.book1D(
306 "GenAllAssoc2RecoMultiMatched_Pt2",
"GeneratedAllAssoc2RecoMultiMatched_Sum-pt2", 15, &log_pt2_bins[0]);
307 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumTracks"] =
i.book1D(
"GenAllAssoc2RecoMultiMatched_NumTracks",
308 "GeneratedAllAssoc2RecoMultiMatched_NumTracks",
311 mes_[
label][
"GenAllAssoc2RecoMultiMatched_ClosestDistanceZ"] =
312 i.book1D(
"GenAllAssoc2RecoMultiMatched_ClosestDistanceZ",
313 "GeneratedAllAssoc2RecoMultiMatched_ClosestDistanceZ",
318 mes_[
label][
"RecoAllAssoc2Gen_NumVertices"] =
i.book1D(
"RecoAllAssoc2Gen_NumVertices",
319 "ReconstructedAllAssoc2Gen_NumVertices",
323 mes_[
label][
"RecoAllAssoc2Gen_X"] =
i.book1D(
"RecoAllAssoc2Gen_X",
"ReconstructedAllAssoc2Gen_X", 120, -0.6, 0.6);
324 mes_[
label][
"RecoAllAssoc2Gen_Y"] =
i.book1D(
"RecoAllAssoc2Gen_Y",
"ReconstructedAllAssoc2Gen_Y", 120, -0.6, 0.6);
325 mes_[
label][
"RecoAllAssoc2Gen_Z"] =
i.book1D(
"RecoAllAssoc2Gen_Z",
"ReconstructedAllAssoc2Gen_Z", 120, -60, 60);
326 mes_[
label][
"RecoAllAssoc2Gen_R"] =
i.book1D(
"RecoAllAssoc2Gen_R",
"ReconstructedAllAssoc2Gen_R", 120, 0, 0.6);
328 i.book1D(
"RecoAllAssoc2Gen_Pt2",
"ReconstructedAllAssoc2Gen_Sum-pt2", 15, &log_pt2_bins[0]);
330 i.book1D(
"RecoAllAssoc2Gen_Ndof",
"ReconstructedAllAssoc2Gen_Ndof", 120, 0., 240.);
331 mes_[
label][
"RecoAllAssoc2Gen_NumTracks"] =
332 i.book1D(
"RecoAllAssoc2Gen_NumTracks",
"ReconstructedAllAssoc2Gen_NumTracks", 24, &log_ntrk_bins[0]);
334 i.book1D(
"RecoAllAssoc2Gen_PU",
"ReconstructedAllAssoc2Gen_PU",
int(
nPUbins_ / 2), 0.,
double(
nPUbins_));
335 mes_[
label][
"RecoAllAssoc2Gen_ClosestDistanceZ"] =
336 i.book1D(
"RecoAllAssoc2Gen_ClosestDistanceZ",
"ReconstructedAllAssoc2Gen_ClosestDistanceZ", 30, &log_bins[0]);
337 mes_[
label][
"RecoAllAssoc2GenProperties"] =
338 i.book1D(
"RecoAllAssoc2GenProperties",
"ReconstructedAllAssoc2Gen_Properties", 8, -0.5, 7.5);
339 mes_[
label][
"RecoAllAssoc2Gen_PairDistanceZ"] =
340 i.book1D(
"RecoAllAssoc2Gen_PairDistanceZ",
"RecoAllAssoc2Gen_PairDistanceZ", 1000, 0, 20);
344 mes_[
label][
"RecoAllAssoc2GenMatched_NumVertices"] =
i.book1D(
"RecoAllAssoc2GenMatched_NumVertices",
345 "ReconstructedAllAssoc2GenMatched_NumVertices",
349 mes_[
label][
"RecoAllAssoc2GenMatched_X"] =
350 i.book1D(
"RecoAllAssoc2GenMatched_X",
"ReconstructedAllAssoc2GenMatched_X", 120, -0.6, 0.6);
351 mes_[
label][
"RecoAllAssoc2GenMatched_Y"] =
352 i.book1D(
"RecoAllAssoc2GenMatched_Y",
"ReconstructedAllAssoc2GenMatched_Y", 120, -0.6, 0.6);
353 mes_[
label][
"RecoAllAssoc2GenMatched_Z"] =
354 i.book1D(
"RecoAllAssoc2GenMatched_Z",
"ReconstructedAllAssoc2GenMatched_Z", 120, -60, 60);
355 mes_[
label][
"RecoAllAssoc2GenMatched_R"] =
356 i.book1D(
"RecoAllAssoc2GenMatched_R",
"ReconstructedAllAssoc2GenMatched_R", 120, 0, 0.6);
357 mes_[
label][
"RecoAllAssoc2GenMatched_Pt2"] =
358 i.book1D(
"RecoAllAssoc2GenMatched_Pt2",
"ReconstructedAllAssoc2GenMatched_Sum-pt2", 15, &log_pt2_bins[0]);
359 mes_[
label][
"RecoAllAssoc2GenMatched_Ndof"] =
360 i.book1D(
"RecoAllAssoc2GenMatched_Ndof",
"ReconstructedAllAssoc2GenMatched_Ndof", 120, 0., 240.);
361 mes_[
label][
"RecoAllAssoc2GenMatched_NumTracks"] =
i.book1D(
362 "RecoAllAssoc2GenMatched_NumTracks",
"ReconstructedAllAssoc2GenMatched_NumTracks", 24, &log_ntrk_bins[0]);
363 mes_[
label][
"RecoAllAssoc2GenMatched_PU"] =
i.book1D(
364 "RecoAllAssoc2GenMatched_PU",
"ReconstructedAllAssoc2GenMatched_PU",
int(
nPUbins_ / 2), 0.,
double(
nPUbins_));
365 mes_[
label][
"RecoAllAssoc2GenMatched_ClosestDistanceZ"] =
366 i.book1D(
"RecoAllAssoc2GenMatched_ClosestDistanceZ",
367 "ReconstructedAllAssoc2GenMatched_ClosestDistanceZ",
373 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumVertices"] =
374 i.book1D(
"RecoAllAssoc2GenMultiMatched_NumVertices",
375 "ReconstructedAllAssoc2GenMultiMatched_NumVertices",
379 mes_[
label][
"RecoAllAssoc2GenMultiMatched_X"] =
380 i.book1D(
"RecoAllAssoc2GenMultiMatched_X",
"ReconstructedAllAssoc2GenMultiMatched_X", 120, -0.6, 0.6);
381 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Y"] =
382 i.book1D(
"RecoAllAssoc2GenMultiMatched_Y",
"ReconstructedAllAssoc2GenMultiMatched_Y", 120, -0.6, 0.6);
383 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Z"] =
384 i.book1D(
"RecoAllAssoc2GenMultiMatched_Z",
"ReconstructedAllAssoc2GenMultiMatched_Z", 120, -60, 60);
385 mes_[
label][
"RecoAllAssoc2GenMultiMatched_R"] =
386 i.book1D(
"RecoAllAssoc2GenMultiMatched_R",
"ReconstructedAllAssoc2GenMultiMatched_R", 120, 0, 0.6);
387 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Pt2"] =
i.book1D(
388 "RecoAllAssoc2GenMultiMatched_Pt2",
"ReconstructedAllAssoc2GenMultiMatched_Sum-pt2", 15, &log_pt2_bins[0]);
389 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumTracks"] =
i.book1D(
"RecoAllAssoc2GenMultiMatched_NumTracks",
390 "ReconstructedAllAssoc2GenMultiMatched_NumTracks",
393 mes_[
label][
"RecoAllAssoc2GenMultiMatched_PU"] =
i.book1D(
"RecoAllAssoc2GenMultiMatched_PU",
394 "ReconstructedAllAssoc2GenMultiMatched_PU",
398 mes_[
label][
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ"] =
399 i.book1D(
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ",
400 "ReconstructedAllAssoc2GenMultiMatched_ClosestDistanceZ",
401 log_mergez_bins.size() - 1,
402 &log_mergez_bins[0]);
410 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumVertices"] =
i.book1D(
"RecoAllAssoc2MultiMatchedGen_NumVertices",
411 "RecoAllAssoc2MultiMatchedGen_NumVertices",
415 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_X"] =
416 i.book1D(
"RecoAllAssoc2MultiMatchedGen_X",
"RecoAllAssoc2MultiMatchedGen_X", 120, -0.6, 0.6);
417 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Y"] =
418 i.book1D(
"RecoAllAssoc2MultiMatchedGen_Y",
"RecoAllAssoc2MultiMatchedGen_Y", 120, -0.6, 0.6);
419 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Z"] =
420 i.book1D(
"RecoAllAssoc2MultiMatchedGen_Z",
"RecoAllAssoc2MultiMatchedGen_Z", 120, -60, 60);
421 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_R"] =
422 i.book1D(
"RecoAllAssoc2MultiMatchedGen_R",
"RecoAllAssoc2MultiMatchedGen_R", 120, 0, 0.6);
423 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Pt2"] =
424 i.book1D(
"RecoAllAssoc2MultiMatchedGen_Pt2",
"RecoAllAssoc2MultiMatchedGen_Sum-pt2", 15, &log_pt2_bins[0]);
425 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumTracks"] =
i.book1D(
426 "RecoAllAssoc2MultiMatchedGen_NumTracks",
"RecoAllAssoc2MultiMatchedGen_NumTracks", 24, &log_ntrk_bins[0]);
427 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_PU"] =
i.book1D(
428 "RecoAllAssoc2MultiMatchedGen_PU",
"RecoAllAssoc2MultiMatchedGen_PU",
int(
nPUbins_ / 2), 0.,
double(
nPUbins_));
429 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ"] =
430 i.book1D(
"RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ",
431 "RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ",
434 mes_[
label][
"RecoAllAssoc2GenSimForMerge_ClosestDistanceZ"] =
435 i.book1D(
"RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
436 "RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
437 log_mergez_bins.size() - 1,
438 &log_mergez_bins[0]);
441 const double resolpt2 = 10;
443 const double minPull = -10;
444 const double maxPull = 10;
445 const double nPull = 100;
447 auto bookResolPull = [&](
const std::string&
prefix,
const double resolx,
const double resoly,
const double resolz) {
448 book1d((
prefix +
"_ResolX").c_str(), 100, -resolx, resolx);
449 book1d((
prefix +
"_ResolY").c_str(), 100, -resoly, resoly);
450 book1d((
prefix +
"_ResolZ").c_str(), 100, -resolz, resolz);
451 book1d((
prefix +
"_ResolPt2").c_str(), 100, -resolpt2, resolpt2);
452 book1d((
prefix +
"_PullX").c_str(), 250, -25, 25);
453 book1d((
prefix +
"_PullY").c_str(), 250, -25, 25);
454 book1d((
prefix +
"_PullZ").c_str(), 250, -25, 25);
457 book2d((
prefix +
"_ResolY_vs_PU").c_str(),
int(
nPUbins_ / 2), 0.,
double(
nPUbins_), 100, -resoly, resoly);
458 book2d((
prefix +
"_ResolZ_vs_PU").c_str(),
int(
nPUbins_ / 2), 0.,
double(
nPUbins_), 100, -resolz, resolz);
459 book2d((
prefix +
"_ResolPt2_vs_PU").c_str(),
int(
nPUbins_ / 2), 0.,
double(
nPUbins_), 100, -resolpt2, resolpt2);
460 book2d((
prefix +
"_PullX_vs_PU").c_str(),
int(
nPUbins_ / 2), 0.,
double(
nPUbins_), nPull, minPull, maxPull);
461 book2d((
prefix +
"_PullY_vs_PU").c_str(),
int(
nPUbins_ / 2), 0.,
double(
nPUbins_), nPull, minPull, maxPull);
462 book2d((
prefix +
"_PullZ_vs_PU").c_str(),
int(
nPUbins_ / 2), 0.,
double(
nPUbins_), nPull, minPull, maxPull);
464 book2dlogx((
prefix +
"_ResolX_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolx, resolx);
465 book2dlogx((
prefix +
"_ResolY_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resoly, resoly);
466 book2dlogx((
prefix +
"_ResolZ_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolz, resolz);
467 book2dlogx((
prefix +
"_ResolPt2_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolpt2, resolpt2);
468 book2dlogx((
prefix +
"_PullX_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
469 book2dlogx((
prefix +
"_PullY_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
470 book2dlogx((
prefix +
"_PullZ_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
472 book2d((
prefix +
"_ResolX_vs_Z").c_str(), 120, -60, 60, 100, -resolx, resolx);
473 book2d((
prefix +
"_ResolY_vs_Z").c_str(), 120, -60, 60, 100, -resoly, resoly);
474 book2d((
prefix +
"_ResolZ_vs_Z").c_str(), 120, -60, 60, 100, -resolz, resolz);
475 book2d((
prefix +
"_ResolPt2_vs_Z").c_str(), 120, -60, 60, 100, -resolpt2, resolpt2);
476 book2d((
prefix +
"_PullX_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
477 book2d((
prefix +
"_PullY_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
478 book2d((
prefix +
"_PullZ_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
480 book2dlogx((
prefix +
"_ResolX_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolx, resolx);
481 book2dlogx((
prefix +
"_ResolY_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resoly, resoly);
482 book2dlogx((
prefix +
"_ResolZ_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolz, resolz);
484 (
prefix +
"_ResolPt2_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolpt2, resolpt2);
485 book2dlogx((
prefix +
"_PullX_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
486 book2dlogx((
prefix +
"_PullY_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
487 book2dlogx((
prefix +
"_PullZ_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
490 bookResolPull(
"RecoAllAssoc2GenMatched", 0.1, 0.1, 0.1);
491 bookResolPull(
"RecoAllAssoc2GenMatchedMerged", 0.1, 0.1, 0.1);
493 "RecoPVAssoc2GenPVMatched", 0.01, 0.01, 0.01);
497 book1d(
"RecoPVAssoc2GenPVMatched_Purity", 50, 0, 1);
498 book1d(
"RecoPVAssoc2GenPVMatched_Missing", 50, 0, 1);
499 book2d(
"RecoPVAssoc2GenPVMatched_Purity_vs_Index", 100, 0, 100, 50, 0, 1);
502 book1d(
"RecoPVAssoc2GenPVNotMatched_Purity", 50, 0, 1);
503 book1d(
"RecoPVAssoc2GenPVNotMatched_Missing", 50, 0, 1);
504 book2d(
"RecoPVAssoc2GenPVNotMatched_Purity_vs_Index", 100, 0, 100, 50, 0, 1);
507 book1d(
"RecoAllAssoc2Gen_Purity", 50, 0, 1);
508 book1d(
"RecoAllAssoc2GenMatched_Purity", 50, 0, 1);
512 book1dlogx(
"RecoAssoc2GenPVMatched_Pt2", 15, &log_pt2_bins[0]);
513 book1dlogx(
"RecoAssoc2GenPVNotMatched_Pt2", 15, &log_pt2_bins[0]);
515 book1dlogx(
"RecoAssoc2GenPVMatchedNotHighest_Pt2", 15, &log_pt2_bins[0]);
516 book1dlogx(
"RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2", 15, &log_pt2_bins[0]);
519 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionReco", 50, 0, 1);
520 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionReco", 50, 0, 1);
521 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionRecoMatched", 50, 0, 1);
522 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionRecoMatched", 50, 0, 1);
524 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionSim", 50, 0, 1);
525 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionSim", 50, 0, 1);
526 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionSimMatched", 50, 0, 1);
527 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionSimMatched", 50, 0, 1);
532 if (
v.eventId.event() == 0) {
533 mes_[
"root_folder"][
"GenPV_X"]->Fill(
v.x);
534 mes_[
"root_folder"][
"GenPV_Y"]->Fill(
v.y);
535 mes_[
"root_folder"][
"GenPV_Z"]->Fill(
v.z);
536 mes_[
"root_folder"][
"GenPV_R"]->Fill(
v.r);
537 mes_[
"root_folder"][
"GenPV_Pt2"]->Fill(
v.ptsq);
538 mes_[
"root_folder"][
"GenPV_NumTracks"]->Fill(
v.nGenTrk);
539 if (
v.closest_vertex_distance_z > 0.)
540 mes_[
"root_folder"][
"GenPV_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
542 mes_[
"root_folder"][
"GenAllV_X"]->Fill(
v.x);
543 mes_[
"root_folder"][
"GenAllV_Y"]->Fill(
v.y);
544 mes_[
"root_folder"][
"GenAllV_Z"]->Fill(
v.z);
545 mes_[
"root_folder"][
"GenAllV_R"]->Fill(
v.r);
546 mes_[
"root_folder"][
"GenAllV_Pt2"]->Fill(
v.ptsq);
547 mes_[
"root_folder"][
"GenAllV_NumTracks"]->Fill(
v.nGenTrk);
548 if (
v.closest_vertex_distance_z > 0.)
549 mes_[
"root_folder"][
"GenAllV_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
558 mes_[
label][
"GenAllAssoc2Reco_Pt2"]->Fill(
v.ptsq);
559 mes_[
label][
"GenAllAssoc2Reco_NumTracks"]->Fill(
v.nGenTrk);
560 if (
v.closest_vertex_distance_z > 0.)
561 mes_[
label][
"GenAllAssoc2Reco_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
562 if (!
v.rec_vertices.empty()) {
563 mes_[
label][
"GenAllAssoc2RecoMatched_X"]->Fill(
v.x);
564 mes_[
label][
"GenAllAssoc2RecoMatched_Y"]->Fill(
v.y);
565 mes_[
label][
"GenAllAssoc2RecoMatched_Z"]->Fill(
v.z);
566 mes_[
label][
"GenAllAssoc2RecoMatched_R"]->Fill(
v.r);
567 mes_[
label][
"GenAllAssoc2RecoMatched_Pt2"]->Fill(
v.ptsq);
568 mes_[
label][
"GenAllAssoc2RecoMatched_NumTracks"]->Fill(
v.nGenTrk);
569 if (
v.closest_vertex_distance_z > 0.)
570 mes_[
label][
"GenAllAssoc2RecoMatched_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
572 if (
v.rec_vertices.size() > 1) {
573 mes_[
label][
"GenAllAssoc2RecoMultiMatched_X"]->Fill(
v.x);
574 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Y"]->Fill(
v.y);
575 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Z"]->Fill(
v.z);
576 mes_[
label][
"GenAllAssoc2RecoMultiMatched_R"]->Fill(
v.r);
577 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Pt2"]->Fill(
v.ptsq);
578 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumTracks"]->Fill(
v.nGenTrk);
579 if (
v.closest_vertex_distance_z > 0.)
580 mes_[
label][
"GenAllAssoc2RecoMultiMatched_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
586 mes_[
label][
"GenPVAssoc2RecoPV_X"]->Fill(
v.x);
587 mes_[
label][
"GenPVAssoc2RecoPV_Y"]->Fill(
v.y);
588 mes_[
label][
"GenPVAssoc2RecoPV_Z"]->Fill(
v.z);
589 if (genPVMatchedToRecoPV) {
590 mes_[
label][
"GenPVAssoc2RecoPVMatched_X"]->Fill(
v.x);
591 mes_[
label][
"GenPVAssoc2RecoPVMatched_Y"]->Fill(
v.y);
592 mes_[
label][
"GenPVAssoc2RecoPVMatched_Z"]->Fill(
v.z);
602 mes_[
label][
"RecoAllAssoc2Gen_Pt2"]->Fill(
v.ptsq);
603 mes_[
label][
"RecoAllAssoc2Gen_Ndof"]->Fill(
v.recVtx->ndof());
604 mes_[
label][
"RecoAllAssoc2Gen_NumTracks"]->Fill(
v.nRecoTrk);
605 mes_[
label][
"RecoAllAssoc2Gen_PU"]->Fill(num_pileup_vertices);
606 mes_[
label][
"RecoAllAssoc2Gen_Purity"]->Fill(
v.purity);
607 if (
v.closest_vertex_distance_z > 0.)
608 mes_[
label][
"RecoAllAssoc2Gen_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
609 if (!
v.sim_vertices.empty()) {
611 mes_[
label][
"RecoAllAssoc2GenMatched_X"]->Fill(
v.x);
612 mes_[
label][
"RecoAllAssoc2GenMatched_Y"]->Fill(
v.y);
613 mes_[
label][
"RecoAllAssoc2GenMatched_Z"]->Fill(
v.z);
614 mes_[
label][
"RecoAllAssoc2GenMatched_R"]->Fill(
v.r);
615 mes_[
label][
"RecoAllAssoc2GenMatched_Pt2"]->Fill(
v.ptsq);
616 mes_[
label][
"RecoAllAssoc2GenMatched_Ndof"]->Fill(
v.recVtx->ndof());
617 mes_[
label][
"RecoAllAssoc2GenMatched_NumTracks"]->Fill(
v.nRecoTrk);
618 mes_[
label][
"RecoAllAssoc2GenMatched_PU"]->Fill(num_pileup_vertices);
619 mes_[
label][
"RecoAllAssoc2GenMatched_Purity"]->Fill(
v.purity);
620 if (
v.closest_vertex_distance_z > 0.)
621 mes_[
label][
"RecoAllAssoc2GenMatched_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
629 if (
v.sim_vertices_internal[0]->rec_vertices.size() > 1) {
631 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_X"]->Fill(
v.x);
632 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Y"]->Fill(
v.y);
633 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Z"]->Fill(
v.z);
634 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_R"]->Fill(
v.r);
635 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Pt2"]->Fill(
v.ptsq);
636 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumTracks"]->Fill(
v.nRecoTrk);
637 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_PU"]->Fill(num_pileup_vertices);
638 if (
v.closest_vertex_distance_z > 0.)
639 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
647 if (
v.sim_vertices_internal[0]->closest_vertex_distance_z > 0.)
648 mes_[
label][
"RecoAllAssoc2GenSimForMerge_ClosestDistanceZ"]->Fill(
649 v.sim_vertices_internal[0]->closest_vertex_distance_z);
652 if (
v.sim_vertices.size() > 1) {
654 mes_[
label][
"RecoAllAssoc2GenMultiMatched_X"]->Fill(
v.x);
655 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Y"]->Fill(
v.y);
656 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Z"]->Fill(
v.z);
657 mes_[
label][
"RecoAllAssoc2GenMultiMatched_R"]->Fill(
v.r);
658 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Pt2"]->Fill(
v.ptsq);
659 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumTracks"]->Fill(
v.nRecoTrk);
660 mes_[
label][
"RecoAllAssoc2GenMultiMatched_PU"]->Fill(num_pileup_vertices);
661 if (
v.sim_vertices_internal[0]->closest_vertex_distance_z > 0.)
662 mes_[
label][
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ"]->Fill(
663 v.sim_vertices_internal[0]->closest_vertex_distance_z);
665 mes_[
label][
"RecoAllAssoc2GenProperties"]->Fill(
v.kind_of_vertex);
668 if (
v.sim_vertices.size() == 1) {
669 prefix =
"RecoAllAssoc2GenSingleMatched_SharedTrackFraction";
670 }
else if (
v.sim_vertices.size() > 1) {
671 prefix =
"RecoAllAssoc2GenMultiMatched_SharedTrackFraction";
674 for (
size_t i = 0;
i <
v.sim_vertices.size(); ++
i) {
675 const double sharedTracks =
v.sim_vertices_num_shared_tracks[
i];
678 mes_[
label][
prefix +
"RecoMatched"]->Fill(sharedTracks /
v.num_matched_sim_tracks);
686 int num_pileup_vertices,
690 if (
v.sim_vertices_internal.size() > 1) {
694 prefix =
"RecoPVAssoc2GenPVMatched";
703 const double pt2res =
v.ptsq -
bestMatch.ptsq;
705 const double xresol = xres;
706 const double yresol = yres;
707 const double zresol = zres;
708 const double pt2resol = pt2res /
v.ptsq;
709 const double xpull = xres /
v.recVtx->xError();
710 const double ypull = yres /
v.recVtx->yError();
711 const double zpull = zres /
v.recVtx->zError();
721 mes_[
label][
prefix +
"_ResolX_vs_PU"]->Fill(num_pileup_vertices, xresol);
722 mes_[
label][
prefix +
"_ResolY_vs_PU"]->Fill(num_pileup_vertices, yresol);
723 mes_[
label][
prefix +
"_ResolZ_vs_PU"]->Fill(num_pileup_vertices, zresol);
724 mes_[
label][
prefix +
"_ResolPt2_vs_PU"]->Fill(num_pileup_vertices, pt2resol);
725 mes_[
label][
prefix +
"_PullX_vs_PU"]->Fill(num_pileup_vertices, xpull);
726 mes_[
label][
prefix +
"_PullY_vs_PU"]->Fill(num_pileup_vertices, ypull);
727 mes_[
label][
prefix +
"_PullZ_vs_PU"]->Fill(num_pileup_vertices, zpull);
762 for (
const auto&
tp :
found->val) {
763 if (
tp.first->eventId().bunchCrossing() == 0 &&
tp.first->eventId().event() == 0)
772 std::vector<recoPrimaryVertex>& recopvs,
773 int genpv_position_in_reco_collection,
774 bool signal_is_highest_pt) {
778 std::vector<double> vtx_sumpt_sigmatched;
779 std::vector<double> vtx_sumpt2_sigmatched;
781 vtx_sumpt_sigmatched.reserve(recopvs.size());
782 vtx_sumpt2_sigmatched.reserve(recopvs.size());
785 for (
auto&
v : recopvs) {
786 double sumpt_all = 0;
787 double sumpt_sigmatched = 0;
788 double sumpt2_sigmatched = 0;
790 for (
auto iTrack =
vertex->tracks_begin(); iTrack !=
vertex->tracks_end(); ++iTrack) {
791 double pt = (*iTrack)->pt();
794 sumpt_sigmatched +=
pt;
795 sumpt2_sigmatched +=
pt *
pt;
798 v.purity = sumpt_sigmatched / sumpt_all;
800 vtx_sumpt_sigmatched.push_back(sumpt_sigmatched);
801 vtx_sumpt2_sigmatched.push_back(sumpt2_sigmatched);
804 const double vtxAll_sumpt_sigmatched = std::accumulate(vtx_sumpt_sigmatched.begin(), vtx_sumpt_sigmatched.end(), 0.0);
805 const double vtxNot0_sumpt_sigmatched = vtxAll_sumpt_sigmatched - vtx_sumpt_sigmatched[0];
806 const double missing = vtxNot0_sumpt_sigmatched / vtxAll_sumpt_sigmatched;
810 if (genpv_position_in_reco_collection == 0)
811 prefix =
"RecoPVAssoc2GenPVMatched_";
816 for (
size_t i = 0;
i < recopvs.size(); ++
i) {
817 hpurity->Fill(
i, recopvs[
i].purity);
821 for (
size_t i = 0;
i < recopvs.size(); ++
i) {
822 if (static_cast<int>(
i) == genpv_position_in_reco_collection) {
823 mes_[
label][
"RecoAssoc2GenPVMatched_Pt2"]->Fill(recopvs[
i].ptsq);
825 double pt2 = recopvs[
i].ptsq;
826 mes_[
label][
"RecoAssoc2GenPVNotMatched_Pt2"]->Fill(
pt2);
828 double pt2_pu =
pt2 - vtx_sumpt2_sigmatched[
i];
829 mes_[
label][
"RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2"]->Fill(pt2_pu);
832 if (!signal_is_highest_pt && genpv_position_in_reco_collection >= 0)
833 mes_[
label][
"RecoAssoc2GenPVMatchedNotHighest_Pt2"]->Fill(recopvs[genpv_position_in_reco_collection].ptsq);
841 std::vector<PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex> simpv;
842 int current_event = -1;
845 std::cout <<
"getSimPVs TrackingVertexCollection " << std::endl;
848 for (TrackingVertexCollection::const_iterator
v = tVC->begin();
v != tVC->end(); ++
v) {
850 std::cout <<
"BunchX.EventId: " <<
v->eventId().bunchCrossing() <<
"." << (
v->eventId()).
event()
851 <<
" Position: " <<
v->position() <<
" G4/HepMC Vertices: " <<
v->g4Vertices().size() <<
"/" 852 <<
v->genVertices().size() <<
" t = " <<
v->position().t() * 1.e12
853 <<
" == 0:" << (
v->position().t() > 0) << std::endl;
864 if (
v->eventId().bunchCrossing() != 0)
866 if (
v->eventId().event() != current_event) {
867 current_event =
v->eventId().event();
872 if (fabs(
v->position().z()) > 1000)
878 sv.eventId =
v->eventId();
886 assert((**iTrack).eventId().bunchCrossing() == 0);
891 for (std::vector<simPrimaryVertex>::iterator
v0 = simpv.begin();
v0 != simpv.end();
v0++) {
892 if ((
sv.eventId ==
v0->eventId) && (fabs(
sv.x -
v0->x) < 1
e-5) && (fabs(
sv.y -
v0->y) < 1
e-5) &&
893 (fabs(
sv.z -
v0->z) < 1
e-5)) {
903 std::cout <<
"this is a new vertex " <<
sv.eventId.event() <<
" " <<
sv.x <<
" " <<
sv.y <<
" " <<
sv.z
908 std::cout <<
"this is not a new vertex" <<
sv.x <<
" " <<
sv.y <<
" " <<
sv.z << std::endl;
914 auto momentum = (*(*iTP)).momentum();
915 const reco::Track* matched_best_reco_track =
nullptr;
916 double match_quality = -1;
920 matched_best_reco_track = (*s2r_)[*iTP][0].first.get();
921 match_quality = (*s2r_)[*iTP][0].second;
924 std::cout <<
" Daughter momentum: " << momentum;
926 std::cout <<
" matched: " << (matched_best_reco_track !=
nullptr);
927 std::cout <<
" match-quality: " << match_quality;
930 vp->
ptot.setPx(vp->
ptot.x() + momentum.x());
931 vp->
ptot.setPy(vp->
ptot.y() + momentum.y());
932 vp->
ptot.setPz(vp->
ptot.z() + momentum.z());
933 vp->
ptot.setE(vp->
ptot.e() + (**iTP).energy());
934 vp->
ptsq += ((**iTP).pt() * (**iTP).pt());
937 if (matched_best_reco_track) {
945 if (((**iTP).pt() > 0.2) && (fabs((**iTP).eta()) < 2.5) && (**iTP).charge() != 0) {
952 std::cout <<
"average number of associated tracks: " 959 std::cout <<
"------- PrimaryVertexAnalyzer4PUSlimmed simPVs from " 963 for (std::vector<simPrimaryVertex>::iterator
v0 = simpv.begin();
v0 != simpv.end();
v0++) {
964 std::cout <<
"z=" <<
v0->z <<
" event=" <<
v0->eventId.event() << std::endl;
966 std::cout <<
"-----------------------------------------------" << std::endl;
975 auto prev_z = simpv.back().z;
977 vsim.closest_vertex_distance_z =
std::abs(vsim.z - prev_z);
981 for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin(); vsim != simpv.end(); vsim++) {
982 std::vector<simPrimaryVertex>::iterator vsim2 = vsim;
984 for (; vsim2 != simpv.end(); vsim2++) {
987 vsim->closest_vertex_distance_z =
std::min(vsim->closest_vertex_distance_z,
distance);
988 vsim2->closest_vertex_distance_z =
std::min(vsim2->closest_vertex_distance_z,
distance);
998 std::vector<PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex> recopv;
1001 std::cout <<
"getRecoPVs TrackingVertexCollection " << std::endl;
1004 for (
auto v = tVC->begin();
v != tVC->end(); ++
v) {
1006 std::cout <<
" Position: " <<
v->position() << std::endl;
1010 if (fabs(
v->z()) > 1000)
1012 if (
v->isFake() || !
v->isValid())
1019 recopv.push_back(
sv);
1023 for (
auto iTrack =
v->tracks_begin(); iTrack !=
v->tracks_end(); ++iTrack) {
1024 auto momentum = (*(*iTrack)).innerMomentum();
1028 if (momentum.mag2() == 0)
1029 momentum = (*(*iTrack)).momentum();
1031 std::cout <<
" Daughter momentum: " << momentum;
1035 vp->
ptsq += (momentum.perp2());
1047 std::cout <<
"------- PrimaryVertexAnalyzer4PUSlimmed recoPVs from " 1051 for (std::vector<recoPrimaryVertex>::iterator
v0 = recopv.begin();
v0 != recopv.end();
v0++) {
1054 std::cout <<
"-----------------------------------------------" << std::endl;
1063 auto prev_z = recopv.back().z;
1065 vreco.closest_vertex_distance_z =
std::abs(vreco.z - prev_z);
1068 for (std::vector<recoPrimaryVertex>::iterator vreco = recopv.begin(); vreco != recopv.end(); vreco++) {
1069 std::vector<recoPrimaryVertex>::iterator vreco2 = vreco;
1071 for (; vreco2 != recopv.end(); vreco2++) {
1074 vreco->closest_vertex_distance_z =
std::min(vreco->closest_vertex_distance_z,
distance);
1075 vreco2->closest_vertex_distance_z =
std::min(vreco2->closest_vertex_distance_z,
distance);
1082 for (
auto&
v : simpv) {
1083 v.rec_vertices.clear();
1091 std::cout <<
"PrimaryVertexAnalyzer4PUSlimmed::matchSim2RecoVertices " << std::endl;
1093 for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin(); vsim != simpv.end(); vsim++) {
1096 for (
const auto& vertexRefQuality :
matched->val) {
1097 vsim->rec_vertices.push_back(&(*(vertexRefQuality.first)));
1102 if (!vsim->rec_vertices.empty()) {
1103 for (
auto const&
v : vsim->rec_vertices) {
1104 std::cout <<
"Found a matching vertex for genVtx " << vsim->z <<
" at " <<
v->z()
1105 <<
" with sign: " << fabs(
v->z() - vsim->z) /
v->zError() << std::endl;
1108 std::cout <<
"No matching vertex for " << vsim->z << std::endl;
1113 std::cout <<
"Done with matching sim vertices" << std::endl;
1119 const std::vector<simPrimaryVertex>& simpv) {
1120 for (std::vector<recoPrimaryVertex>::iterator vrec = recopv.begin(); vrec != recopv.end(); vrec++) {
1123 for (
const auto& vertexRefQuality :
matched->val) {
1124 const auto tvPtr = &(*(vertexRefQuality.first));
1125 vrec->sim_vertices.push_back(tvPtr);
1130 for (
const auto& vv : simpv) {
1131 if (&(*(vv.sim_vertex)) == tv) {
1132 vrec->sim_vertices_internal.push_back(&vv);
1143 for (
auto v : vrec->sim_vertices) {
1144 std::cout <<
"Found a matching vertex for reco: " << vrec->z <<
" at gen:" <<
v->position().z()
1145 <<
" with sign: " << fabs(vrec->z -
v->position().z()) / vrec->recVtx->zError() << std::endl;
1157 using namespace reco;
1159 std::vector<float> pileUpInfo_z;
1164 for (
auto const& pu_info : *puinfoH.
product()) {
1166 mes_[
"root_folder"][
"GenVtx_vs_BX"]->Fill(pu_info.getBunchCrossing(), pu_info.getPU_NumInteractions());
1168 if (pu_info.getBunchCrossing() == 0) {
1169 pileUpInfo_z = pu_info.getPU_zpositions();
1171 for (
auto const&
p : pileUpInfo_z) {
1172 std::cout <<
"PileUpInfo on Z vertex: " <<
p << std::endl;
1183 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"TPCollectionH is not valid";
1188 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"TVCollectionH is not valid";
1200 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"simToRecoH is not valid";
1207 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"recoToSimH is not valid";
1212 if (!vertexAssociatorH.
isValid()) {
1213 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"vertexAssociatorH is not valid";
1218 std::vector<simPrimaryVertex> simpv;
1224 int kind_of_signal_vertex = 0;
1225 int num_pileup_vertices = simpv.size();
1227 mes_[
"root_folder"][
"GenAllV_NumVertices"]->Fill(simpv.size());
1228 bool signal_is_highest_pt =
1230 return lhs.
ptsq < rhs.ptsq;
1231 }) == simpv.begin();
1232 kind_of_signal_vertex |= (signal_is_highest_pt <<
HIGHEST_PT);
1234 mes_[
"root_folder"][
"SignalIsHighestPt2"]->Fill(signal_is_highest_pt ? 1. : 0.);
1238 int label_index = -1;
1241 std::vector<recoPrimaryVertex> recopv;
1245 if (!
iEvent.getByToken(vertex_token, recVtxs)) {
1248 <<
"Skipping vertex collection: " <<
label <<
" since it is missing.";
1257 for (
const auto&
v : *recVtxs) {
1258 if (
v.tracksSize() > 0) {
1259 const auto& ref =
v.trackRefAt(0);
1260 if (ref.isNull() || !ref.isAvailable()) {
1263 <<
"Skipping vertex collection: " <<
label 1264 <<
" since likely the track collection the vertex has refs pointing to is missing (at least the " 1265 "first TrackBaseRef is null or not available)";
1285 int num_total_gen_vertices_assoc2reco = 0;
1286 int num_total_reco_vertices_assoc2gen = 0;
1287 int num_total_gen_vertices_multiassoc2reco = 0;
1288 int num_total_reco_vertices_multiassoc2gen = 0;
1289 int num_total_reco_vertices_duplicate = 0;
1290 int genpv_position_in_reco_collection = -1;
1291 for (
auto const&
v : simpv) {
1294 if (
v.eventId.event() == 0) {
1295 if (!recVtxs->empty() &&
std::find(
v.rec_vertices.begin(),
v.rec_vertices.end(), &((*recVtxs.
product())[0])) !=
1296 v.rec_vertices.end()) {
1300 if (!
v.rec_vertices.empty()) {
1304 mes_[
label][
"KindOfSignalPV"]->Fill(kind_of_signal_vertex);
1305 mes_[
label][
"MisTagRate"]->Fill(mistag);
1306 mes_[
label][
"MisTagRate_vs_PU"]->Fill(simpv.size(), mistag);
1307 mes_[
label][
"MisTagRate_vs_sum-pt2"]->Fill(
v.ptsq, mistag);
1308 mes_[
label][
"MisTagRate_vs_Z"]->Fill(
v.z, mistag);
1309 mes_[
label][
"MisTagRate_vs_R"]->Fill(
v.r, mistag);
1310 mes_[
label][
"MisTagRate_vs_NumTracks"]->Fill(
v.nGenTrk, mistag);
1311 if (signal_is_highest_pt) {
1312 mes_[
label][
"MisTagRateSignalIsHighest"]->Fill(mistag);
1313 mes_[
label][
"MisTagRateSignalIsHighest_vs_PU"]->Fill(simpv.size(), mistag);
1314 mes_[
label][
"MisTagRateSignalIsHighest_vs_sum-pt2"]->Fill(
v.ptsq, mistag);
1315 mes_[
label][
"MisTagRateSignalIsHighest_vs_Z"]->Fill(
v.z, mistag);
1316 mes_[
label][
"MisTagRateSignalIsHighest_vs_R"]->Fill(
v.r, mistag);
1317 mes_[
label][
"MisTagRateSignalIsHighest_vs_NumTracks"]->Fill(
v.nGenTrk, mistag);
1319 mes_[
label][
"MisTagRateSignalIsNotHighest"]->Fill(mistag);
1320 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_PU"]->Fill(simpv.size(), mistag);
1321 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_sum-pt2"]->Fill(
v.ptsq, mistag);
1322 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_Z"]->Fill(
v.z, mistag);
1323 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_R"]->Fill(
v.r, mistag);
1324 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_NumTracks"]->Fill(
v.nGenTrk, mistag);
1332 for (
int pv_position_in_reco_collection = 0;
iv != (*recVtxs.
product()).
end();
1333 ++pv_position_in_reco_collection, ++
iv) {
1334 if (
std::find(
v.rec_vertices.begin(),
v.rec_vertices.end(), &(*iv)) !=
v.rec_vertices.end()) {
1335 mes_[
label][
"TruePVLocationIndex"]->Fill(pv_position_in_reco_collection);
1336 const bool genPVMatchedToRecoPV = (pv_position_in_reco_collection == 0);
1337 mes_[
label][
"TruePVLocationIndexCumulative"]->Fill(genPVMatchedToRecoPV ? 0 : 1);
1339 if (signal_is_highest_pt) {
1340 mes_[
label][
"TruePVLocationIndexSignalIsHighest"]->Fill(pv_position_in_reco_collection);
1342 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"]->Fill(pv_position_in_reco_collection);
1346 if (genPVMatchedToRecoPV) {
1347 auto pv = recopv[0];
1351 genpv_position_in_reco_collection = pv_position_in_reco_collection;
1361 mes_[
label][
"TruePVLocationIndex"]->Fill(-1.);
1362 mes_[
label][
"TruePVLocationIndexCumulative"]->Fill(-1.);
1363 if (signal_is_highest_pt)
1364 mes_[
label][
"TruePVLocationIndexSignalIsHighest"]->Fill(-1.);
1366 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"]->Fill(-1.);
1370 if (!
v.rec_vertices.empty())
1371 num_total_gen_vertices_assoc2reco++;
1372 if (
v.rec_vertices.size() > 1)
1373 num_total_gen_vertices_multiassoc2reco++;
1382 mes_[
label][
"GenAllAssoc2Reco_NumVertices"]->Fill(simpv.size(), simpv.size());
1383 mes_[
label][
"GenAllAssoc2RecoMatched_NumVertices"]->Fill(simpv.size(), num_total_gen_vertices_assoc2reco);
1384 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumVertices"]->Fill(simpv.size(), num_total_gen_vertices_multiassoc2reco);
1385 for (
auto&
v : recopv) {
1387 if (!
v.sim_vertices.empty()) {
1388 num_total_reco_vertices_assoc2gen++;
1389 if (
v.sim_vertices_internal[0]->rec_vertices.size() > 1) {
1390 num_total_reco_vertices_duplicate++;
1393 if (
v.sim_vertices.size() > 1)
1394 num_total_reco_vertices_multiassoc2gen++;
1396 mes_[
label][
"RecoAllAssoc2Gen_NumVertices"]->Fill(recopv.size(), recopv.size());
1397 mes_[
label][
"RecoAllAssoc2GenMatched_NumVertices"]->Fill(recopv.size(), num_total_reco_vertices_assoc2gen);
1398 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumVertices"]->Fill(recopv.size(),
1399 num_total_reco_vertices_multiassoc2gen);
1400 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumVertices"]->Fill(recopv.size(), num_total_reco_vertices_duplicate);
1401 mes_[
label][
"RecoVtx_vs_GenVtx"]->Fill(simpv.size(), recopv.size());
1402 mes_[
label][
"MatchedRecoVtx_vs_GenVtx"]->Fill(simpv.size(), num_total_reco_vertices_assoc2gen);
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 >> &)
T getParameter(std::string const &) const
bool matchRecoTrack2SimSignal(const reco::TrackBaseRef &)
void resetSimPVAssociation(std::vector< simPrimaryVertex > &)
edm::EDGetTokenT< reco::SimToRecoCollection > simToRecoAssociationToken_
void fillRecoAssociatedGenPVHistograms(const std::string &label, const PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex &v, bool genPVMatchedToRecoPV)
void computePairDistance(const T &collection, MonitorElement *me)
std::vector< SimVertex >::const_iterator g4v_iterator
ret
prodAgent to be discontinued
bool use_only_charged_tracks_
tuple isPV
JSON lumifiles checks.
edm::RefToBase< reco::Vertex > VertexBaseRef
persistent reference to a Vertex, using views
T const * product() const
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
int num_matched_sim_tracks
PrimaryVertexAnalyzer4PUSlimmed(const edm::ParameterSet &)
edm::AssociationMap< edm::OneToManyWithQualityGeneric< CaloParticleCollection, reco::CaloClusterCollection, std::pair< float, float > > > SimToRecoCollection
edm::EDGetTokenT< TrackingVertexCollection > trackingVertexCollectionToken_
edm::EDGetTokenT< std::vector< PileupSummaryInfo > > vecPileupSummaryInfoToken_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const bool do_generic_sim_plots_
const_iterator find(const key_type &k) const
find element with specified reference key
const_iterator end() const
last iterator over the map (read only)
void analyze(const edm::Event &, const edm::EventSetup &) override
std::vector< PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex > getSimPVs(const edm::Handle< TrackingVertexCollection > &)
std::vector< edm::InputTag > reco_vertex_collections_
void fillResolutionAndPullHistograms(const std::string &, int, recoPrimaryVertex &v, bool)
Abs< T >::type abs(const T &t)
std::vector< bool > errorPrintedForColl_
void calculatePurityAndFillHistograms(const std::string &, std::vector< recoPrimaryVertex > &, int, bool)
const reco::SimToRecoCollection * s2r_
std::vector< edm::EDGetTokenT< edm::View< reco::Vertex > > > reco_vertex_collection_tokens_
void fillGenericGenVertexHistograms(const simPrimaryVertex &v)
edm::Ref< TrackingVertexCollection > TrackingVertexRef
def bestMatch(object, matchCollection)
std::vector< TrackingVertex > TrackingVertexCollection
std::array< T, N+1 > makeLogBins(const T &min, const T &max)
std::map< std::string, std::map< std::string, MonitorElement * > > mes_
void fillRecoAssociatedGenVertexHistograms(const std::string &, const simPrimaryVertex &v)
void matchReco2SimVertices(std::vector< recoPrimaryVertex > &, const reco::VertexRecoToSimCollection &, const std::vector< simPrimaryVertex > &)
edm::EDGetTokenT< reco::VertexToTrackingVertexAssociator > vertexAssociatorToken_
edm::EDGetTokenT< reco::RecoToSimCollection > recoToSimAssociationToken_
unsigned int calculateVertexSharedTracks(const reco::Vertex &recoV, const TrackingVertex &simV, const reco::RecoToSimCollection &trackRecoToSimAssociation)
float average_match_quality
std::vector< TrackingParticle > TrackingParticleCollection
Log< level::Warning, false > LogWarning
int num_matched_reco_tracks
Power< A, B >::type pow(const A &a, const B &b)
const reco::RecoToSimCollection * r2s_
edm::AssociationMap< edm::OneToManyWithQualityGeneric< reco::CaloClusterCollection, CaloParticleCollection, float > > RecoToSimCollection
edm::EDGetTokenT< TrackingParticleCollection > trackingParticleCollectionToken_
~PrimaryVertexAnalyzer4PUSlimmed() override