26 template <
typename T,
size_t N>
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;
34 for (
size_t i = 1;
i <=
N; ++
i) {
45 : verbose_(iConfig.getUntrackedParameter<
bool>(
"verbose",
false)),
46 use_only_charged_tracks_(iConfig.getUntrackedParameter<
bool>(
"use_only_charged_tracks",
true)),
47 do_generic_sim_plots_(iConfig.getUntrackedParameter<
bool>(
"do_generic_sim_plots")),
48 root_folder_(iConfig.getUntrackedParameter<
std::
string>(
"root_folder",
"Validation/Vertices")),
51 iConfig.getUntrackedParameter<
edm::
InputTag>(
"trackingParticleCollection"))),
52 trackingVertexCollectionToken_(
54 simToRecoAssociationToken_(
56 recoToSimAssociationToken_(
58 vertexAssociatorToken_(consumes<
reco::VertexToTrackingVertexAssociator>(
59 iConfig.getUntrackedParameter<
edm::
InputTag>(
"vertexAssociator"))) {
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"] =
i.book2D(
"GenVtx_vs_BX",
"GenVtx_vs_BX", 16, -12.5, 3.5, 200, 0., 200.);
101 mes_[
"root_folder"][
"GenPV_X"] =
i.book1D(
"GenPV_X",
"GeneratedPV_X", 120, -0.6, 0.6);
102 mes_[
"root_folder"][
"GenPV_Y"] =
i.book1D(
"GenPV_Y",
"GeneratedPV_Y", 120, -0.6, 0.6);
103 mes_[
"root_folder"][
"GenPV_Z"] =
i.book1D(
"GenPV_Z",
"GeneratedPV_Z", 120, -60., 60.);
104 mes_[
"root_folder"][
"GenPV_R"] =
i.book1D(
"GenPV_R",
"GeneratedPV_R", 120, 0, 0.6);
105 mes_[
"root_folder"][
"GenPV_Pt2"] =
i.book1D(
"GenPV_Pt2",
"GeneratedPV_Sum-pt2", 15, &log_pt2_bins[0]);
106 mes_[
"root_folder"][
"GenPV_NumTracks"] =
107 i.book1D(
"GenPV_NumTracks",
"GeneratedPV_NumTracks", 24, &log_ntrk_bins[0]);
108 mes_[
"root_folder"][
"GenPV_ClosestDistanceZ"] =
109 i.book1D(
"GenPV_ClosestDistanceZ",
"GeneratedPV_ClosestDistanceZ", 30, &log_bins[0]);
112 mes_[
"root_folder"][
"GenAllV_NumVertices"] =
113 i.book1D(
"GenAllV_NumVertices",
"GeneratedAllV_NumVertices", 100, 0., 200.);
114 mes_[
"root_folder"][
"GenAllV_X"] =
i.book1D(
"GenAllV_X",
"GeneratedAllV_X", 120, -0.6, 0.6);
115 mes_[
"root_folder"][
"GenAllV_Y"] =
i.book1D(
"GenAllV_Y",
"GeneratedAllV_Y", 120, -0.6, 0.6);
116 mes_[
"root_folder"][
"GenAllV_Z"] =
i.book1D(
"GenAllV_Z",
"GeneratedAllV_Z", 120, -60, 60);
117 mes_[
"root_folder"][
"GenAllV_R"] =
i.book1D(
"GenAllV_R",
"GeneratedAllV_R", 120, 0, 0.6);
118 mes_[
"root_folder"][
"GenAllV_Pt2"] =
i.book1D(
"GenAllV_Pt2",
"GeneratedAllV_Sum-pt2", 15, &log_pt2_bins[0]);
119 mes_[
"root_folder"][
"GenAllV_NumTracks"] =
120 i.book1D(
"GenAllV_NumTracks",
"GeneratedAllV_NumTracks", 24, &log_ntrk_bins[0]);
121 mes_[
"root_folder"][
"GenAllV_ClosestDistanceZ"] =
122 i.book1D(
"GenAllV_ClosestDistanceZ",
"GeneratedAllV_ClosestDistanceZ", 30, &log_bins[0]);
123 mes_[
"root_folder"][
"GenAllV_PairDistanceZ"] =
124 i.book1D(
"GenAllV_PairDistanceZ",
"GeneratedAllV_PairDistanceZ", 1000, 0, 20);
125 mes_[
"root_folder"][
"SignalIsHighestPt2"] =
i.book1D(
"SignalIsHighestPt2",
"SignalIsHighestPt2", 2, -0.5, 1.5);
131 i.setCurrentFolder(current_folder);
133 auto book1d = [&](
const char*
name,
int bins,
double min,
double max) {
136 auto book1dlogx = [&](
const char*
name,
int bins,
const float* xbinedges) {
142 auto book2dlogx = [&](
const char*
name,
int xbins,
const float* xbinedges,
int ybins,
double ymin,
double ymax) {
144 me->getTH2F()->GetXaxis()->Set(
xbins, xbinedges);
149 i.bookProfile(
"RecoVtx_vs_GenVtx",
"RecoVtx_vs_GenVtx", 125, 0., 250., 250, 0., 250.);
150 mes_[
label][
"MatchedRecoVtx_vs_GenVtx"] =
151 i.bookProfile(
"MatchedRecoVtx_vs_GenVtx",
"MatchedRecoVtx_vs_GenVtx", 125, 0., 250., 250, 0., 250.);
152 mes_[
label][
"KindOfSignalPV"] =
i.book1D(
"KindOfSignalPV",
"KindOfSignalPV", 9, -0.5, 8.5);
153 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(1,
"!Highest!Assoc2Any");
154 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(2,
"Highest!Assoc2Any");
155 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(3,
"!HighestAssoc2First");
156 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(4,
"HighestAssoc2First");
157 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(5,
"!HighestAssoc2!First");
158 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(6,
"HighestAssoc2!First");
159 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(7,
"!HighestAssoc2First");
160 mes_[
label][
"KindOfSignalPV"]->getTH1()->GetXaxis()->SetBinLabel(8,
"HighestAssoc2First");
161 mes_[
label][
"MisTagRate"] =
i.book1D(
"MisTagRate",
"MisTagRate", 2, -0.5, 1.5);
162 mes_[
label][
"MisTagRate_vs_PU"] =
i.bookProfile(
"MisTagRate_vs_PU",
"MisTagRate_vs_PU", 125, 0., 250., 2, 0., 1.);
164 i.bookProfile(
"MisTagRate_vs_sum-pt2",
"MisTagRate_vs_sum-pt2", 15, &log_pt2_bins_double[0], 2, 0., 1.);
165 mes_[
label][
"MisTagRate_vs_Z"] =
i.bookProfile(
"MisTagRate_vs_Z",
"MisTagRate_vs_Z", 120, -60., 60., 2, 0., 1.);
166 mes_[
label][
"MisTagRate_vs_R"] =
i.bookProfile(
"MisTagRate_vs_R",
"MisTagRate_vs_R", 120, 0., 0.6, 2, 0., 1.);
168 i.bookProfile(
"MisTagRate_vs_NumTracks",
"MisTagRate_vs_NumTracks", 100, 0., 200, 2, 0., 1.);
169 mes_[
label][
"MisTagRateSignalIsHighest"] =
170 i.book1D(
"MisTagRateSignalIsHighest",
"MisTagRateSignalIsHighest", 2, -0.5, 1.5);
171 mes_[
label][
"MisTagRateSignalIsHighest_vs_PU"] =
172 i.bookProfile(
"MisTagRateSignalIsHighest_vs_PU",
"MisTagRateSignalIsHighest_vs_PU", 125, 0., 250., 2, 0., 1.);
173 mes_[
label][
"MisTagRateSignalIsHighest_vs_sum-pt2"] =
i.bookProfile(
"MisTagRateSignalIsHighest_vs_sum-pt2",
174 "MisTagRateSignalIsHighest_vs_sum-pt2",
176 &log_pt2_bins_double[0],
180 mes_[
label][
"MisTagRateSignalIsHighest_vs_Z"] =
181 i.bookProfile(
"MisTagRateSignalIsHighest_vs_Z",
"MisTagRateSignalIsHighest_vs_Z", 120, -60., 60., 2, 0., 1.);
182 mes_[
label][
"MisTagRateSignalIsHighest_vs_R"] =
183 i.bookProfile(
"MisTagRateSignalIsHighest_vs_R",
"MisTagRateSignalIsHighest_vs_R", 120, 0., 0.6, 2, 0., 1.);
184 mes_[
label][
"MisTagRateSignalIsHighest_vs_NumTracks"] =
i.bookProfile(
185 "MisTagRateSignalIsHighest_vs_NumTracks",
"MisTagRateSignalIsHighest_vs_NumTracks", 100, 0., 200, 2, 0., 1.);
186 mes_[
label][
"MisTagRateSignalIsNotHighest"] =
187 i.book1D(
"MisTagRateSignalIsNotHighest",
"MisTagRateSignalIsNotHighest", 2, -0.5, 1.5);
188 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_PU"] =
i.bookProfile(
189 "MisTagRateSignalIsNotHighest_vs_PU",
"MisTagRateSignalIsNotHighest_vs_PU", 125, 0., 250., 2, 0., 1.);
190 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_sum-pt2"] =
i.bookProfile(
"MisTagRateSignalIsNotHighest_vs_sum-pt2",
191 "MisTagRateSignalIsNotHighest_vs_sum-pt2",
193 &log_pt2_bins_double[0],
197 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_Z"] =
i.bookProfile(
198 "MisTagRateSignalIsNotHighest_vs_Z",
"MisTagRateSignalIsNotHighest_vs_Z", 120, -60., 60., 2, 0., 1.);
199 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_R"] =
i.bookProfile(
200 "MisTagRateSignalIsNotHighest_vs_R",
"MisTagRateSignalIsNotHighest_vs_R", 120, 0., 0.6, 2, 0., 1.);
201 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_NumTracks"] =
202 i.bookProfile(
"MisTagRateSignalIsNotHighest_vs_NumTracks",
203 "MisTagRateSignalIsNotHighest_vs_NumTracks",
211 i.book1D(
"TruePVLocationIndex",
"TruePVLocationIndexInRecoVertexCollection", 12, -1.5, 10.5);
212 mes_[
label][
"TruePVLocationIndexCumulative"] =
213 i.book1D(
"TruePVLocationIndexCumulative",
"TruePVLocationIndexInRecoVertexCollectionCumulative", 3, -1.5, 1.5);
214 mes_[
label][
"TruePVLocationIndexSignalIsHighest"] =
215 i.book1D(
"TruePVLocationIndexSignalIsHighest",
216 "TruePVLocationIndexSignalIsHighestInRecoVertexCollection",
220 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"] =
221 i.book1D(
"TruePVLocationIndexSignalIsNotHighest",
222 "TruePVLocationIndexSignalIsNotHighestInRecoVertexCollection",
229 mes_[
label][
"GenAllAssoc2Reco_NumVertices"] =
230 i.book1D(
"GenAllAssoc2Reco_NumVertices",
"GeneratedAllAssoc2Reco_NumVertices", 100, 0., 200.);
231 mes_[
label][
"GenAllAssoc2Reco_X"] =
i.book1D(
"GenAllAssoc2Reco_X",
"GeneratedAllAssoc2Reco_X", 120, -0.6, 0.6);
232 mes_[
label][
"GenAllAssoc2Reco_Y"] =
i.book1D(
"GenAllAssoc2Reco_Y",
"GeneratedAllAssoc2Reco_Y", 120, -0.6, 0.6);
233 mes_[
label][
"GenAllAssoc2Reco_Z"] =
i.book1D(
"GenAllAssoc2Reco_Z",
"GeneratedAllAssoc2Reco_Z", 120, -60, 60);
234 mes_[
label][
"GenAllAssoc2Reco_R"] =
i.book1D(
"GenAllAssoc2Reco_R",
"GeneratedAllAssoc2Reco_R", 120, 0, 0.6);
236 i.book1D(
"GenAllAssoc2Reco_Pt2",
"GeneratedAllAssoc2Reco_Sum-pt2", 15, &log_pt2_bins[0]);
237 mes_[
label][
"GenAllAssoc2Reco_NumTracks"] =
238 i.book1D(
"GenAllAssoc2Reco_NumTracks",
"GeneratedAllAssoc2Reco_NumTracks", 24, &log_ntrk_bins[0]);
239 mes_[
label][
"GenAllAssoc2Reco_ClosestDistanceZ"] =
240 i.book1D(
"GenAllAssoc2Reco_ClosestDistanceZ",
"GeneratedAllAssoc2Reco_ClosestDistanceZ", 30, &log_bins[0]);
241 book1d(
"GenPVAssoc2RecoPV_X", 120, -0.6, 0.6);
242 book1d(
"GenPVAssoc2RecoPV_Y", 120, -0.6, 0.6);
243 book1d(
"GenPVAssoc2RecoPV_Z", 120, -60, 60);
247 mes_[
label][
"GenAllAssoc2RecoMatched_NumVertices"] =
248 i.book1D(
"GenAllAssoc2RecoMatched_NumVertices",
"GeneratedAllAssoc2RecoMatched_NumVertices", 100, 0., 200.);
249 mes_[
label][
"GenAllAssoc2RecoMatched_X"] =
250 i.book1D(
"GenAllAssoc2RecoMatched_X",
"GeneratedAllAssoc2RecoMatched_X", 120, -0.6, 0.6);
251 mes_[
label][
"GenAllAssoc2RecoMatched_Y"] =
252 i.book1D(
"GenAllAssoc2RecoMatched_Y",
"GeneratedAllAssoc2RecoMatched_Y", 120, -0.6, 0.6);
253 mes_[
label][
"GenAllAssoc2RecoMatched_Z"] =
254 i.book1D(
"GenAllAssoc2RecoMatched_Z",
"GeneratedAllAssoc2RecoMatched_Z", 120, -60, 60);
255 mes_[
label][
"GenAllAssoc2RecoMatched_R"] =
256 i.book1D(
"GenAllAssoc2RecoMatched_R",
"GeneratedAllAssoc2RecoMatched_R", 120, 0, 0.6);
257 mes_[
label][
"GenAllAssoc2RecoMatched_Pt2"] =
258 i.book1D(
"GenAllAssoc2RecoMatched_Pt2",
"GeneratedAllAssoc2RecoMatched_Sum-pt2", 15, &log_pt2_bins[0]);
259 mes_[
label][
"GenAllAssoc2RecoMatched_NumTracks"] =
260 i.book1D(
"GenAllAssoc2RecoMatched_NumTracks",
"GeneratedAllAssoc2RecoMatched_NumTracks", 24, &log_ntrk_bins[0]);
261 mes_[
label][
"GenAllAssoc2RecoMatched_ClosestDistanceZ"] =
i.book1D(
262 "GenAllAssoc2RecoMatched_ClosestDistanceZ",
"GeneratedAllAssoc2RecoMatched_ClosestDistanceZ", 30, &log_bins[0]);
263 book1d(
"GenPVAssoc2RecoPVMatched_X", 120, -0.6, 0.6);
264 book1d(
"GenPVAssoc2RecoPVMatched_Y", 120, -0.6, 0.6);
265 book1d(
"GenPVAssoc2RecoPVMatched_Z", 120, -60, 60);
269 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumVertices"] =
i.book1D(
270 "GenAllAssoc2RecoMultiMatched_NumVertices",
"GeneratedAllAssoc2RecoMultiMatched_NumVertices", 100, 0., 200.);
271 mes_[
label][
"GenAllAssoc2RecoMultiMatched_X"] =
272 i.book1D(
"GenAllAssoc2RecoMultiMatched_X",
"GeneratedAllAssoc2RecoMultiMatched_X", 120, -0.6, 0.6);
273 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Y"] =
274 i.book1D(
"GenAllAssoc2RecoMultiMatched_Y",
"GeneratedAllAssoc2RecoMultiMatched_Y", 120, -0.6, 0.6);
275 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Z"] =
276 i.book1D(
"GenAllAssoc2RecoMultiMatched_Z",
"GeneratedAllAssoc2RecoMultiMatched_Z", 120, -60, 60);
277 mes_[
label][
"GenAllAssoc2RecoMultiMatched_R"] =
278 i.book1D(
"GenAllAssoc2RecoMultiMatched_R",
"GeneratedAllAssoc2RecoMultiMatched_R", 120, 0, 0.6);
279 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Pt2"] =
i.book1D(
280 "GenAllAssoc2RecoMultiMatched_Pt2",
"GeneratedAllAssoc2RecoMultiMatched_Sum-pt2", 15, &log_pt2_bins[0]);
281 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumTracks"] =
i.book1D(
"GenAllAssoc2RecoMultiMatched_NumTracks",
282 "GeneratedAllAssoc2RecoMultiMatched_NumTracks",
285 mes_[
label][
"GenAllAssoc2RecoMultiMatched_ClosestDistanceZ"] =
286 i.book1D(
"GenAllAssoc2RecoMultiMatched_ClosestDistanceZ",
287 "GeneratedAllAssoc2RecoMultiMatched_ClosestDistanceZ",
292 mes_[
label][
"RecoAllAssoc2Gen_NumVertices"] =
293 i.book1D(
"RecoAllAssoc2Gen_NumVertices",
"ReconstructedAllAssoc2Gen_NumVertices", 100, 0., 200.);
294 mes_[
label][
"RecoAllAssoc2Gen_X"] =
i.book1D(
"RecoAllAssoc2Gen_X",
"ReconstructedAllAssoc2Gen_X", 120, -0.6, 0.6);
295 mes_[
label][
"RecoAllAssoc2Gen_Y"] =
i.book1D(
"RecoAllAssoc2Gen_Y",
"ReconstructedAllAssoc2Gen_Y", 120, -0.6, 0.6);
296 mes_[
label][
"RecoAllAssoc2Gen_Z"] =
i.book1D(
"RecoAllAssoc2Gen_Z",
"ReconstructedAllAssoc2Gen_Z", 120, -60, 60);
297 mes_[
label][
"RecoAllAssoc2Gen_R"] =
i.book1D(
"RecoAllAssoc2Gen_R",
"ReconstructedAllAssoc2Gen_R", 120, 0, 0.6);
299 i.book1D(
"RecoAllAssoc2Gen_Pt2",
"ReconstructedAllAssoc2Gen_Sum-pt2", 15, &log_pt2_bins[0]);
301 i.book1D(
"RecoAllAssoc2Gen_Ndof",
"ReconstructedAllAssoc2Gen_Ndof", 120, 0., 240.);
302 mes_[
label][
"RecoAllAssoc2Gen_NumTracks"] =
303 i.book1D(
"RecoAllAssoc2Gen_NumTracks",
"ReconstructedAllAssoc2Gen_NumTracks", 24, &log_ntrk_bins[0]);
304 mes_[
label][
"RecoAllAssoc2Gen_PU"] =
i.book1D(
"RecoAllAssoc2Gen_PU",
"ReconstructedAllAssoc2Gen_PU", 125, 0., 250.);
305 mes_[
label][
"RecoAllAssoc2Gen_ClosestDistanceZ"] =
306 i.book1D(
"RecoAllAssoc2Gen_ClosestDistanceZ",
"ReconstructedAllAssoc2Gen_ClosestDistanceZ", 30, &log_bins[0]);
307 mes_[
label][
"RecoAllAssoc2GenProperties"] =
308 i.book1D(
"RecoAllAssoc2GenProperties",
"ReconstructedAllAssoc2Gen_Properties", 8, -0.5, 7.5);
309 mes_[
label][
"RecoAllAssoc2Gen_PairDistanceZ"] =
310 i.book1D(
"RecoAllAssoc2Gen_PairDistanceZ",
"RecoAllAssoc2Gen_PairDistanceZ", 1000, 0, 20);
314 mes_[
label][
"RecoAllAssoc2GenMatched_NumVertices"] =
315 i.book1D(
"RecoAllAssoc2GenMatched_NumVertices",
"ReconstructedAllAssoc2GenMatched_NumVertices", 100, 0., 200.);
316 mes_[
label][
"RecoAllAssoc2GenMatched_X"] =
317 i.book1D(
"RecoAllAssoc2GenMatched_X",
"ReconstructedAllAssoc2GenMatched_X", 120, -0.6, 0.6);
318 mes_[
label][
"RecoAllAssoc2GenMatched_Y"] =
319 i.book1D(
"RecoAllAssoc2GenMatched_Y",
"ReconstructedAllAssoc2GenMatched_Y", 120, -0.6, 0.6);
320 mes_[
label][
"RecoAllAssoc2GenMatched_Z"] =
321 i.book1D(
"RecoAllAssoc2GenMatched_Z",
"ReconstructedAllAssoc2GenMatched_Z", 120, -60, 60);
322 mes_[
label][
"RecoAllAssoc2GenMatched_R"] =
323 i.book1D(
"RecoAllAssoc2GenMatched_R",
"ReconstructedAllAssoc2GenMatched_R", 120, 0, 0.6);
324 mes_[
label][
"RecoAllAssoc2GenMatched_Pt2"] =
325 i.book1D(
"RecoAllAssoc2GenMatched_Pt2",
"ReconstructedAllAssoc2GenMatched_Sum-pt2", 15, &log_pt2_bins[0]);
326 mes_[
label][
"RecoAllAssoc2GenMatched_Ndof"] =
327 i.book1D(
"RecoAllAssoc2GenMatched_Ndof",
"ReconstructedAllAssoc2GenMatched_Ndof", 120, 0., 240.);
328 mes_[
label][
"RecoAllAssoc2GenMatched_NumTracks"] =
i.book1D(
329 "RecoAllAssoc2GenMatched_NumTracks",
"ReconstructedAllAssoc2GenMatched_NumTracks", 24, &log_ntrk_bins[0]);
330 mes_[
label][
"RecoAllAssoc2GenMatched_PU"] =
331 i.book1D(
"RecoAllAssoc2GenMatched_PU",
"ReconstructedAllAssoc2GenMatched_PU", 125, 0., 250.);
332 mes_[
label][
"RecoAllAssoc2GenMatched_ClosestDistanceZ"] =
333 i.book1D(
"RecoAllAssoc2GenMatched_ClosestDistanceZ",
334 "ReconstructedAllAssoc2GenMatched_ClosestDistanceZ",
340 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumVertices"] =
i.book1D(
341 "RecoAllAssoc2GenMultiMatched_NumVertices",
"ReconstructedAllAssoc2GenMultiMatched_NumVertices", 100, 0., 200.);
342 mes_[
label][
"RecoAllAssoc2GenMultiMatched_X"] =
343 i.book1D(
"RecoAllAssoc2GenMultiMatched_X",
"ReconstructedAllAssoc2GenMultiMatched_X", 120, -0.6, 0.6);
344 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Y"] =
345 i.book1D(
"RecoAllAssoc2GenMultiMatched_Y",
"ReconstructedAllAssoc2GenMultiMatched_Y", 120, -0.6, 0.6);
346 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Z"] =
347 i.book1D(
"RecoAllAssoc2GenMultiMatched_Z",
"ReconstructedAllAssoc2GenMultiMatched_Z", 120, -60, 60);
348 mes_[
label][
"RecoAllAssoc2GenMultiMatched_R"] =
349 i.book1D(
"RecoAllAssoc2GenMultiMatched_R",
"ReconstructedAllAssoc2GenMultiMatched_R", 120, 0, 0.6);
350 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Pt2"] =
i.book1D(
351 "RecoAllAssoc2GenMultiMatched_Pt2",
"ReconstructedAllAssoc2GenMultiMatched_Sum-pt2", 15, &log_pt2_bins[0]);
352 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumTracks"] =
i.book1D(
"RecoAllAssoc2GenMultiMatched_NumTracks",
353 "ReconstructedAllAssoc2GenMultiMatched_NumTracks",
356 mes_[
label][
"RecoAllAssoc2GenMultiMatched_PU"] =
357 i.book1D(
"RecoAllAssoc2GenMultiMatched_PU",
"ReconstructedAllAssoc2GenMultiMatched_PU", 125, 0., 250.);
358 mes_[
label][
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ"] =
359 i.book1D(
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ",
360 "ReconstructedAllAssoc2GenMultiMatched_ClosestDistanceZ",
361 log_mergez_bins.size() - 1,
362 &log_mergez_bins[0]);
370 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumVertices"] =
371 i.book1D(
"RecoAllAssoc2MultiMatchedGen_NumVertices",
"RecoAllAssoc2MultiMatchedGen_NumVertices", 100, 0., 200.);
372 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_X"] =
373 i.book1D(
"RecoAllAssoc2MultiMatchedGen_X",
"RecoAllAssoc2MultiMatchedGen_X", 120, -0.6, 0.6);
374 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Y"] =
375 i.book1D(
"RecoAllAssoc2MultiMatchedGen_Y",
"RecoAllAssoc2MultiMatchedGen_Y", 120, -0.6, 0.6);
376 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Z"] =
377 i.book1D(
"RecoAllAssoc2MultiMatchedGen_Z",
"RecoAllAssoc2MultiMatchedGen_Z", 120, -60, 60);
378 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_R"] =
379 i.book1D(
"RecoAllAssoc2MultiMatchedGen_R",
"RecoAllAssoc2MultiMatchedGen_R", 120, 0, 0.6);
380 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Pt2"] =
381 i.book1D(
"RecoAllAssoc2MultiMatchedGen_Pt2",
"RecoAllAssoc2MultiMatchedGen_Sum-pt2", 15, &log_pt2_bins[0]);
382 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumTracks"] =
i.book1D(
383 "RecoAllAssoc2MultiMatchedGen_NumTracks",
"RecoAllAssoc2MultiMatchedGen_NumTracks", 24, &log_ntrk_bins[0]);
384 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_PU"] =
385 i.book1D(
"RecoAllAssoc2MultiMatchedGen_PU",
"RecoAllAssoc2MultiMatchedGen_PU", 125, 0., 250.);
386 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ"] =
387 i.book1D(
"RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ",
388 "RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ",
391 mes_[
label][
"RecoAllAssoc2GenSimForMerge_ClosestDistanceZ"] =
392 i.book1D(
"RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
393 "RecoAllAssoc2GenSimForMerge_ClosestDistanceZ",
394 log_mergez_bins.size() - 1,
395 &log_mergez_bins[0]);
398 const double resolpt2 = 10;
400 const double minPull = -10;
401 const double maxPull = 10;
402 const double nPull = 100;
404 auto bookResolPull = [&](
const std::string&
prefix,
const double resolx,
const double resoly,
const double resolz) {
405 book1d((
prefix +
"_ResolX").c_str(), 100, -resolx, resolx);
406 book1d((
prefix +
"_ResolY").c_str(), 100, -resoly, resoly);
407 book1d((
prefix +
"_ResolZ").c_str(), 100, -resolz, resolz);
408 book1d((
prefix +
"_ResolPt2").c_str(), 100, -resolpt2, resolpt2);
409 book1d((
prefix +
"_PullX").c_str(), 250, -25, 25);
410 book1d((
prefix +
"_PullY").c_str(), 250, -25, 25);
411 book1d((
prefix +
"_PullZ").c_str(), 250, -25, 25);
413 book2d((
prefix +
"_ResolX_vs_PU").c_str(), 125, 0., 250., 100, -resolx, resolx);
414 book2d((
prefix +
"_ResolY_vs_PU").c_str(), 125, 0., 250., 100, -resoly, resoly);
415 book2d((
prefix +
"_ResolZ_vs_PU").c_str(), 125, 0., 250., 100, -resolz, resolz);
416 book2d((
prefix +
"_ResolPt2_vs_PU").c_str(), 125, 0., 250., 100, -resolpt2, resolpt2);
417 book2d((
prefix +
"_PullX_vs_PU").c_str(), 125, 0., 250., nPull, minPull, maxPull);
418 book2d((
prefix +
"_PullY_vs_PU").c_str(), 125, 0., 250., nPull, minPull, maxPull);
419 book2d((
prefix +
"_PullZ_vs_PU").c_str(), 125, 0., 250., nPull, minPull, maxPull);
421 book2dlogx((
prefix +
"_ResolX_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolx, resolx);
422 book2dlogx((
prefix +
"_ResolY_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resoly, resoly);
423 book2dlogx((
prefix +
"_ResolZ_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolz, resolz);
424 book2dlogx((
prefix +
"_ResolPt2_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], 100, -resolpt2, resolpt2);
425 book2dlogx((
prefix +
"_PullX_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
426 book2dlogx((
prefix +
"_PullY_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
427 book2dlogx((
prefix +
"_PullZ_vs_NumTracks").c_str(), 24, &log_ntrk_bins[0], nPull, minPull, maxPull);
429 book2d((
prefix +
"_ResolX_vs_Z").c_str(), 120, -60, 60, 100, -resolx, resolx);
430 book2d((
prefix +
"_ResolY_vs_Z").c_str(), 120, -60, 60, 100, -resoly, resoly);
431 book2d((
prefix +
"_ResolZ_vs_Z").c_str(), 120, -60, 60, 100, -resolz, resolz);
432 book2d((
prefix +
"_ResolPt2_vs_Z").c_str(), 120, -60, 60, 100, -resolpt2, resolpt2);
433 book2d((
prefix +
"_PullX_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
434 book2d((
prefix +
"_PullY_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
435 book2d((
prefix +
"_PullZ_vs_Z").c_str(), 120, -60, 60, nPull, minPull, maxPull);
437 book2dlogx((
prefix +
"_ResolX_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolx, resolx);
438 book2dlogx((
prefix +
"_ResolY_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resoly, resoly);
439 book2dlogx((
prefix +
"_ResolZ_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolz, resolz);
441 (
prefix +
"_ResolPt2_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], 100, -resolpt2, resolpt2);
442 book2dlogx((
prefix +
"_PullX_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
443 book2dlogx((
prefix +
"_PullY_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
444 book2dlogx((
prefix +
"_PullZ_vs_Pt").c_str(), log_pt_bins.size() - 1, &log_pt_bins[0], nPull, minPull, maxPull);
447 bookResolPull(
"RecoAllAssoc2GenMatched", 0.1, 0.1, 0.1);
448 bookResolPull(
"RecoAllAssoc2GenMatchedMerged", 0.1, 0.1, 0.1);
450 "RecoPVAssoc2GenPVMatched", 0.01, 0.01, 0.01);
454 book1d(
"RecoPVAssoc2GenPVMatched_Purity", 50, 0, 1);
455 book1d(
"RecoPVAssoc2GenPVMatched_Missing", 50, 0, 1);
456 book2d(
"RecoPVAssoc2GenPVMatched_Purity_vs_Index", 100, 0, 100, 50, 0, 1);
459 book1d(
"RecoPVAssoc2GenPVNotMatched_Purity", 50, 0, 1);
460 book1d(
"RecoPVAssoc2GenPVNotMatched_Missing", 50, 0, 1);
461 book2d(
"RecoPVAssoc2GenPVNotMatched_Purity_vs_Index", 100, 0, 100, 50, 0, 1);
464 book1d(
"RecoAllAssoc2Gen_Purity", 50, 0, 1);
465 book1d(
"RecoAllAssoc2GenMatched_Purity", 50, 0, 1);
469 book1dlogx(
"RecoAssoc2GenPVMatched_Pt2", 15, &log_pt2_bins[0]);
470 book1dlogx(
"RecoAssoc2GenPVNotMatched_Pt2", 15, &log_pt2_bins[0]);
472 book1dlogx(
"RecoAssoc2GenPVMatchedNotHighest_Pt2", 15, &log_pt2_bins[0]);
473 book1dlogx(
"RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2", 15, &log_pt2_bins[0]);
476 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionReco", 50, 0, 1);
477 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionReco", 50, 0, 1);
478 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionRecoMatched", 50, 0, 1);
479 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionRecoMatched", 50, 0, 1);
481 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionSim", 50, 0, 1);
482 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionSim", 50, 0, 1);
483 book1d(
"RecoAllAssoc2GenSingleMatched_SharedTrackFractionSimMatched", 50, 0, 1);
484 book1d(
"RecoAllAssoc2GenMultiMatched_SharedTrackFractionSimMatched", 50, 0, 1);
489 if (
v.eventId.event() == 0) {
490 mes_[
"root_folder"][
"GenPV_X"]->Fill(
v.x);
491 mes_[
"root_folder"][
"GenPV_Y"]->Fill(
v.y);
492 mes_[
"root_folder"][
"GenPV_Z"]->Fill(
v.z);
493 mes_[
"root_folder"][
"GenPV_R"]->Fill(
v.r);
494 mes_[
"root_folder"][
"GenPV_Pt2"]->Fill(
v.ptsq);
495 mes_[
"root_folder"][
"GenPV_NumTracks"]->Fill(
v.nGenTrk);
496 if (
v.closest_vertex_distance_z > 0.)
497 mes_[
"root_folder"][
"GenPV_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
499 mes_[
"root_folder"][
"GenAllV_X"]->Fill(
v.x);
500 mes_[
"root_folder"][
"GenAllV_Y"]->Fill(
v.y);
501 mes_[
"root_folder"][
"GenAllV_Z"]->Fill(
v.z);
502 mes_[
"root_folder"][
"GenAllV_R"]->Fill(
v.r);
503 mes_[
"root_folder"][
"GenAllV_Pt2"]->Fill(
v.ptsq);
504 mes_[
"root_folder"][
"GenAllV_NumTracks"]->Fill(
v.nGenTrk);
505 if (
v.closest_vertex_distance_z > 0.)
506 mes_[
"root_folder"][
"GenAllV_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
515 mes_[
label][
"GenAllAssoc2Reco_Pt2"]->Fill(
v.ptsq);
516 mes_[
label][
"GenAllAssoc2Reco_NumTracks"]->Fill(
v.nGenTrk);
517 if (
v.closest_vertex_distance_z > 0.)
518 mes_[
label][
"GenAllAssoc2Reco_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
519 if (!
v.rec_vertices.empty()) {
520 mes_[
label][
"GenAllAssoc2RecoMatched_X"]->Fill(
v.x);
521 mes_[
label][
"GenAllAssoc2RecoMatched_Y"]->Fill(
v.y);
522 mes_[
label][
"GenAllAssoc2RecoMatched_Z"]->Fill(
v.z);
523 mes_[
label][
"GenAllAssoc2RecoMatched_R"]->Fill(
v.r);
524 mes_[
label][
"GenAllAssoc2RecoMatched_Pt2"]->Fill(
v.ptsq);
525 mes_[
label][
"GenAllAssoc2RecoMatched_NumTracks"]->Fill(
v.nGenTrk);
526 if (
v.closest_vertex_distance_z > 0.)
527 mes_[
label][
"GenAllAssoc2RecoMatched_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
529 if (
v.rec_vertices.size() > 1) {
530 mes_[
label][
"GenAllAssoc2RecoMultiMatched_X"]->Fill(
v.x);
531 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Y"]->Fill(
v.y);
532 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Z"]->Fill(
v.z);
533 mes_[
label][
"GenAllAssoc2RecoMultiMatched_R"]->Fill(
v.r);
534 mes_[
label][
"GenAllAssoc2RecoMultiMatched_Pt2"]->Fill(
v.ptsq);
535 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumTracks"]->Fill(
v.nGenTrk);
536 if (
v.closest_vertex_distance_z > 0.)
537 mes_[
label][
"GenAllAssoc2RecoMultiMatched_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
543 mes_[
label][
"GenPVAssoc2RecoPV_X"]->Fill(
v.x);
544 mes_[
label][
"GenPVAssoc2RecoPV_Y"]->Fill(
v.y);
545 mes_[
label][
"GenPVAssoc2RecoPV_Z"]->Fill(
v.z);
546 if (genPVMatchedToRecoPV) {
547 mes_[
label][
"GenPVAssoc2RecoPVMatched_X"]->Fill(
v.x);
548 mes_[
label][
"GenPVAssoc2RecoPVMatched_Y"]->Fill(
v.y);
549 mes_[
label][
"GenPVAssoc2RecoPVMatched_Z"]->Fill(
v.z);
559 mes_[
label][
"RecoAllAssoc2Gen_Pt2"]->Fill(
v.ptsq);
560 mes_[
label][
"RecoAllAssoc2Gen_Ndof"]->Fill(
v.recVtx->ndof());
561 mes_[
label][
"RecoAllAssoc2Gen_NumTracks"]->Fill(
v.nRecoTrk);
562 mes_[
label][
"RecoAllAssoc2Gen_PU"]->Fill(num_pileup_vertices);
563 mes_[
label][
"RecoAllAssoc2Gen_Purity"]->Fill(
v.purity);
564 if (
v.closest_vertex_distance_z > 0.)
565 mes_[
label][
"RecoAllAssoc2Gen_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
566 if (!
v.sim_vertices.empty()) {
568 mes_[
label][
"RecoAllAssoc2GenMatched_X"]->Fill(
v.x);
569 mes_[
label][
"RecoAllAssoc2GenMatched_Y"]->Fill(
v.y);
570 mes_[
label][
"RecoAllAssoc2GenMatched_Z"]->Fill(
v.z);
571 mes_[
label][
"RecoAllAssoc2GenMatched_R"]->Fill(
v.r);
572 mes_[
label][
"RecoAllAssoc2GenMatched_Pt2"]->Fill(
v.ptsq);
573 mes_[
label][
"RecoAllAssoc2GenMatched_Ndof"]->Fill(
v.recVtx->ndof());
574 mes_[
label][
"RecoAllAssoc2GenMatched_NumTracks"]->Fill(
v.nRecoTrk);
575 mes_[
label][
"RecoAllAssoc2GenMatched_PU"]->Fill(num_pileup_vertices);
576 mes_[
label][
"RecoAllAssoc2GenMatched_Purity"]->Fill(
v.purity);
577 if (
v.closest_vertex_distance_z > 0.)
578 mes_[
label][
"RecoAllAssoc2GenMatched_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
586 if (
v.sim_vertices_internal[0]->rec_vertices.size() > 1) {
588 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_X"]->Fill(
v.x);
589 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Y"]->Fill(
v.y);
590 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Z"]->Fill(
v.z);
591 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_R"]->Fill(
v.r);
592 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_Pt2"]->Fill(
v.ptsq);
593 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumTracks"]->Fill(
v.nRecoTrk);
594 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_PU"]->Fill(num_pileup_vertices);
595 if (
v.closest_vertex_distance_z > 0.)
596 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_ClosestDistanceZ"]->Fill(
v.closest_vertex_distance_z);
604 if (
v.sim_vertices_internal[0]->closest_vertex_distance_z > 0.)
605 mes_[
label][
"RecoAllAssoc2GenSimForMerge_ClosestDistanceZ"]->Fill(
606 v.sim_vertices_internal[0]->closest_vertex_distance_z);
609 if (
v.sim_vertices.size() > 1) {
611 mes_[
label][
"RecoAllAssoc2GenMultiMatched_X"]->Fill(
v.x);
612 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Y"]->Fill(
v.y);
613 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Z"]->Fill(
v.z);
614 mes_[
label][
"RecoAllAssoc2GenMultiMatched_R"]->Fill(
v.r);
615 mes_[
label][
"RecoAllAssoc2GenMultiMatched_Pt2"]->Fill(
v.ptsq);
616 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumTracks"]->Fill(
v.nRecoTrk);
617 mes_[
label][
"RecoAllAssoc2GenMultiMatched_PU"]->Fill(num_pileup_vertices);
618 if (
v.sim_vertices_internal[0]->closest_vertex_distance_z > 0.)
619 mes_[
label][
"RecoAllAssoc2GenMultiMatched_ClosestDistanceZ"]->Fill(
620 v.sim_vertices_internal[0]->closest_vertex_distance_z);
622 mes_[
label][
"RecoAllAssoc2GenProperties"]->Fill(
v.kind_of_vertex);
625 if (
v.sim_vertices.size() == 1) {
626 prefix =
"RecoAllAssoc2GenSingleMatched_SharedTrackFraction";
627 }
else if (
v.sim_vertices.size() > 1) {
628 prefix =
"RecoAllAssoc2GenMultiMatched_SharedTrackFraction";
631 for (
size_t i = 0;
i <
v.sim_vertices.size(); ++
i) {
632 const double sharedTracks =
v.sim_vertices_num_shared_tracks[
i];
635 mes_[
label][
prefix +
"RecoMatched"]->Fill(sharedTracks /
v.num_matched_sim_tracks);
643 int num_pileup_vertices,
647 if (
v.sim_vertices_internal.size() > 1) {
651 prefix =
"RecoPVAssoc2GenPVMatched";
660 const double pt2res =
v.ptsq -
bestMatch.ptsq;
662 const double xresol = xres;
663 const double yresol = yres;
664 const double zresol = zres;
665 const double pt2resol = pt2res /
v.ptsq;
666 const double xpull = xres /
v.recVtx->xError();
667 const double ypull = yres /
v.recVtx->yError();
668 const double zpull = zres /
v.recVtx->zError();
678 mes_[
label][
prefix +
"_ResolX_vs_PU"]->Fill(num_pileup_vertices, xresol);
679 mes_[
label][
prefix +
"_ResolY_vs_PU"]->Fill(num_pileup_vertices, yresol);
680 mes_[
label][
prefix +
"_ResolZ_vs_PU"]->Fill(num_pileup_vertices, zresol);
681 mes_[
label][
prefix +
"_ResolPt2_vs_PU"]->Fill(num_pileup_vertices, pt2resol);
682 mes_[
label][
prefix +
"_PullX_vs_PU"]->Fill(num_pileup_vertices, xpull);
683 mes_[
label][
prefix +
"_PullY_vs_PU"]->Fill(num_pileup_vertices, ypull);
684 mes_[
label][
prefix +
"_PullZ_vs_PU"]->Fill(num_pileup_vertices, zpull);
719 for (
const auto&
tp :
found->val) {
720 if (
tp.first->eventId().bunchCrossing() == 0 &&
tp.first->eventId().event() == 0)
729 std::vector<recoPrimaryVertex>& recopvs,
730 int genpv_position_in_reco_collection,
731 bool signal_is_highest_pt) {
735 std::vector<double> vtx_sumpt_sigmatched;
736 std::vector<double> vtx_sumpt2_sigmatched;
738 vtx_sumpt_sigmatched.reserve(recopvs.size());
739 vtx_sumpt2_sigmatched.reserve(recopvs.size());
742 for (
auto&
v : recopvs) {
743 double sumpt_all = 0;
744 double sumpt_sigmatched = 0;
745 double sumpt2_sigmatched = 0;
747 for (
auto iTrack =
vertex->tracks_begin(); iTrack !=
vertex->tracks_end(); ++iTrack) {
748 double pt = (*iTrack)->pt();
751 sumpt_sigmatched +=
pt;
752 sumpt2_sigmatched +=
pt *
pt;
755 v.purity = sumpt_sigmatched / sumpt_all;
757 vtx_sumpt_sigmatched.push_back(sumpt_sigmatched);
758 vtx_sumpt2_sigmatched.push_back(sumpt2_sigmatched);
761 const double vtxAll_sumpt_sigmatched = std::accumulate(vtx_sumpt_sigmatched.begin(), vtx_sumpt_sigmatched.end(), 0.0);
762 const double vtxNot0_sumpt_sigmatched = vtxAll_sumpt_sigmatched - vtx_sumpt_sigmatched[0];
763 const double missing = vtxNot0_sumpt_sigmatched / vtxAll_sumpt_sigmatched;
767 if (genpv_position_in_reco_collection == 0)
768 prefix =
"RecoPVAssoc2GenPVMatched_";
773 for (
size_t i = 0;
i < recopvs.size(); ++
i) {
774 hpurity->Fill(
i, recopvs[
i].purity);
778 for (
size_t i = 0;
i < recopvs.size(); ++
i) {
779 if (static_cast<int>(
i) == genpv_position_in_reco_collection) {
780 mes_[
label][
"RecoAssoc2GenPVMatched_Pt2"]->Fill(recopvs[
i].ptsq);
782 double pt2 = recopvs[
i].ptsq;
783 mes_[
label][
"RecoAssoc2GenPVNotMatched_Pt2"]->Fill(
pt2);
785 double pt2_pu =
pt2 - vtx_sumpt2_sigmatched[
i];
786 mes_[
label][
"RecoAssoc2GenPVNotMatched_GenPVTracksRemoved_Pt2"]->Fill(pt2_pu);
789 if (!signal_is_highest_pt && genpv_position_in_reco_collection >= 0)
790 mes_[
label][
"RecoAssoc2GenPVMatchedNotHighest_Pt2"]->Fill(recopvs[genpv_position_in_reco_collection].ptsq);
798 std::vector<PrimaryVertexAnalyzer4PUSlimmed::simPrimaryVertex> simpv;
799 int current_event = -1;
802 std::cout <<
"getSimPVs TrackingVertexCollection " << std::endl;
805 for (TrackingVertexCollection::const_iterator
v = tVC->begin();
v != tVC->end(); ++
v) {
807 std::cout <<
"BunchX.EventId: " <<
v->eventId().bunchCrossing() <<
"." << (
v->eventId()).
event()
808 <<
" Position: " <<
v->position() <<
" G4/HepMC Vertices: " <<
v->g4Vertices().size() <<
"/"
809 <<
v->genVertices().size() <<
" t = " <<
v->position().t() * 1.e12
810 <<
" == 0:" << (
v->position().t() > 0) << std::endl;
821 if (
v->eventId().bunchCrossing() != 0)
823 if (
v->eventId().event() != current_event) {
824 current_event =
v->eventId().event();
829 if (fabs(
v->position().z()) > 1000)
835 sv.eventId =
v->eventId();
843 assert((**iTrack).eventId().bunchCrossing() == 0);
848 for (std::vector<simPrimaryVertex>::iterator
v0 = simpv.begin();
v0 != simpv.end();
v0++) {
849 if ((
sv.eventId ==
v0->eventId) && (fabs(
sv.x -
v0->x) < 1
e-5) && (fabs(
sv.y -
v0->y) < 1
e-5) &&
850 (fabs(
sv.z -
v0->z) < 1
e-5)) {
860 std::cout <<
"this is a new vertex " <<
sv.eventId.event() <<
" " <<
sv.x <<
" " <<
sv.y <<
" " <<
sv.z
865 std::cout <<
"this is not a new vertex" <<
sv.x <<
" " <<
sv.y <<
" " <<
sv.z << std::endl;
871 auto momentum = (*(*iTP)).momentum();
872 const reco::Track* matched_best_reco_track =
nullptr;
873 double match_quality = -1;
877 matched_best_reco_track = (*s2r_)[*iTP][0].first.get();
878 match_quality = (*s2r_)[*iTP][0].second;
881 std::cout <<
" Daughter momentum: " << momentum;
883 std::cout <<
" matched: " << (matched_best_reco_track !=
nullptr);
884 std::cout <<
" match-quality: " << match_quality;
887 vp->
ptot.setPx(vp->
ptot.x() + momentum.x());
888 vp->
ptot.setPy(vp->
ptot.y() + momentum.y());
889 vp->
ptot.setPz(vp->
ptot.z() + momentum.z());
890 vp->
ptot.setE(vp->
ptot.e() + (**iTP).energy());
891 vp->
ptsq += ((**iTP).pt() * (**iTP).pt());
894 if (matched_best_reco_track) {
902 if (((**iTP).pt() > 0.2) && (fabs((**iTP).eta()) < 2.5) && (**iTP).charge() != 0) {
909 std::cout <<
"average number of associated tracks: "
916 std::cout <<
"------- PrimaryVertexAnalyzer4PUSlimmed simPVs from "
920 for (std::vector<simPrimaryVertex>::iterator
v0 = simpv.begin();
v0 != simpv.end();
v0++) {
921 std::cout <<
"z=" <<
v0->z <<
" event=" <<
v0->eventId.event() << std::endl;
923 std::cout <<
"-----------------------------------------------" << std::endl;
932 auto prev_z = simpv.back().z;
934 vsim.closest_vertex_distance_z =
std::abs(vsim.z - prev_z);
938 for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin(); vsim != simpv.end(); vsim++) {
939 std::vector<simPrimaryVertex>::iterator vsim2 = vsim;
941 for (; vsim2 != simpv.end(); vsim2++) {
944 vsim->closest_vertex_distance_z =
std::min(vsim->closest_vertex_distance_z,
distance);
945 vsim2->closest_vertex_distance_z =
std::min(vsim2->closest_vertex_distance_z,
distance);
955 std::vector<PrimaryVertexAnalyzer4PUSlimmed::recoPrimaryVertex> recopv;
958 std::cout <<
"getRecoPVs TrackingVertexCollection " << std::endl;
961 for (
auto v = tVC->begin();
v != tVC->end(); ++
v) {
963 std::cout <<
" Position: " <<
v->position() << std::endl;
967 if (fabs(
v->z()) > 1000)
969 if (
v->isFake() || !
v->isValid())
976 recopv.push_back(
sv);
980 for (
auto iTrack =
v->tracks_begin(); iTrack !=
v->tracks_end(); ++iTrack) {
981 auto momentum = (*(*iTrack)).innerMomentum();
985 if (momentum.mag2() == 0)
986 momentum = (*(*iTrack)).momentum();
988 std::cout <<
" Daughter momentum: " << momentum;
992 vp->
ptsq += (momentum.perp2());
1004 std::cout <<
"------- PrimaryVertexAnalyzer4PUSlimmed recoPVs from "
1008 for (std::vector<recoPrimaryVertex>::iterator
v0 = recopv.begin();
v0 != recopv.end();
v0++) {
1011 std::cout <<
"-----------------------------------------------" << std::endl;
1020 auto prev_z = recopv.back().z;
1022 vreco.closest_vertex_distance_z =
std::abs(vreco.z - prev_z);
1025 for (std::vector<recoPrimaryVertex>::iterator vreco = recopv.begin(); vreco != recopv.end(); vreco++) {
1026 std::vector<recoPrimaryVertex>::iterator vreco2 = vreco;
1028 for (; vreco2 != recopv.end(); vreco2++) {
1031 vreco->closest_vertex_distance_z =
std::min(vreco->closest_vertex_distance_z,
distance);
1032 vreco2->closest_vertex_distance_z =
std::min(vreco2->closest_vertex_distance_z,
distance);
1039 for (
auto&
v : simpv) {
1040 v.rec_vertices.clear();
1048 std::cout <<
"PrimaryVertexAnalyzer4PUSlimmed::matchSim2RecoVertices " << std::endl;
1050 for (std::vector<simPrimaryVertex>::iterator vsim = simpv.begin(); vsim != simpv.end(); vsim++) {
1053 for (
const auto& vertexRefQuality :
matched->val) {
1054 vsim->rec_vertices.push_back(&(*(vertexRefQuality.first)));
1059 if (!vsim->rec_vertices.empty()) {
1060 for (
auto const&
v : vsim->rec_vertices) {
1061 std::cout <<
"Found a matching vertex for genVtx " << vsim->z <<
" at " <<
v->z()
1062 <<
" with sign: " << fabs(
v->z() - vsim->z) /
v->zError() << std::endl;
1065 std::cout <<
"No matching vertex for " << vsim->z << std::endl;
1070 std::cout <<
"Done with matching sim vertices" << std::endl;
1076 const std::vector<simPrimaryVertex>& simpv) {
1077 for (std::vector<recoPrimaryVertex>::iterator vrec = recopv.begin(); vrec != recopv.end(); vrec++) {
1080 for (
const auto& vertexRefQuality :
matched->val) {
1081 const auto tvPtr = &(*(vertexRefQuality.first));
1082 vrec->sim_vertices.push_back(tvPtr);
1087 for (
const auto& vv : simpv) {
1088 if (&(*(vv.sim_vertex)) == tv) {
1089 vrec->sim_vertices_internal.push_back(&vv);
1100 for (
auto v : vrec->sim_vertices) {
1101 std::cout <<
"Found a matching vertex for reco: " << vrec->z <<
" at gen:" <<
v->position().z()
1102 <<
" with sign: " << fabs(vrec->z -
v->position().z()) / vrec->recVtx->zError() << std::endl;
1114 using namespace reco;
1116 std::vector<float> pileUpInfo_z;
1121 for (
auto const& pu_info : *puinfoH.
product()) {
1123 mes_[
"root_folder"][
"GenVtx_vs_BX"]->Fill(pu_info.getBunchCrossing(), pu_info.getPU_NumInteractions());
1125 if (pu_info.getBunchCrossing() == 0) {
1126 pileUpInfo_z = pu_info.getPU_zpositions();
1128 for (
auto const&
p : pileUpInfo_z) {
1129 std::cout <<
"PileUpInfo on Z vertex: " <<
p << std::endl;
1140 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"TPCollectionH is not valid";
1145 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"TVCollectionH is not valid";
1157 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"simToRecoH is not valid";
1164 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"recoToSimH is not valid";
1169 if (!vertexAssociatorH.
isValid()) {
1170 edm::LogWarning(
"PrimaryVertexAnalyzer4PUSlimmed") <<
"vertexAssociatorH is not valid";
1175 std::vector<simPrimaryVertex> simpv;
1181 int kind_of_signal_vertex = 0;
1182 int num_pileup_vertices = simpv.size();
1184 mes_[
"root_folder"][
"GenAllV_NumVertices"]->Fill(simpv.size());
1185 bool signal_is_highest_pt =
1187 return lhs.
ptsq < rhs.ptsq;
1188 }) == simpv.begin();
1189 kind_of_signal_vertex |= (signal_is_highest_pt <<
HIGHEST_PT);
1191 mes_[
"root_folder"][
"SignalIsHighestPt2"]->Fill(signal_is_highest_pt ? 1. : 0.);
1195 int label_index = -1;
1198 std::vector<recoPrimaryVertex> recopv;
1202 if (!
iEvent.getByToken(vertex_token, recVtxs)) {
1205 <<
"Skipping vertex collection: " <<
label <<
" since it is missing.";
1214 for (
const auto&
v : *recVtxs) {
1215 if (
v.tracksSize() > 0) {
1216 const auto& ref =
v.trackRefAt(0);
1217 if (ref.isNull() || !ref.isAvailable()) {
1220 <<
"Skipping vertex collection: " <<
label
1221 <<
" since likely the track collection the vertex has refs pointing to is missing (at least the "
1222 "first TrackBaseRef is null or not available)";
1242 int num_total_gen_vertices_assoc2reco = 0;
1243 int num_total_reco_vertices_assoc2gen = 0;
1244 int num_total_gen_vertices_multiassoc2reco = 0;
1245 int num_total_reco_vertices_multiassoc2gen = 0;
1246 int num_total_reco_vertices_duplicate = 0;
1247 int genpv_position_in_reco_collection = -1;
1248 for (
auto const&
v : simpv) {
1251 if (
v.eventId.event() == 0) {
1252 if (!recVtxs->empty() &&
std::find(
v.rec_vertices.begin(),
v.rec_vertices.end(), &((*recVtxs.
product())[0])) !=
1253 v.rec_vertices.end()) {
1257 if (!
v.rec_vertices.empty()) {
1261 mes_[
label][
"KindOfSignalPV"]->Fill(kind_of_signal_vertex);
1262 mes_[
label][
"MisTagRate"]->Fill(mistag);
1263 mes_[
label][
"MisTagRate_vs_PU"]->Fill(simpv.size(), mistag);
1264 mes_[
label][
"MisTagRate_vs_sum-pt2"]->Fill(
v.ptsq, mistag);
1265 mes_[
label][
"MisTagRate_vs_Z"]->Fill(
v.z, mistag);
1266 mes_[
label][
"MisTagRate_vs_R"]->Fill(
v.r, mistag);
1267 mes_[
label][
"MisTagRate_vs_NumTracks"]->Fill(
v.nGenTrk, mistag);
1268 if (signal_is_highest_pt) {
1269 mes_[
label][
"MisTagRateSignalIsHighest"]->Fill(mistag);
1270 mes_[
label][
"MisTagRateSignalIsHighest_vs_PU"]->Fill(simpv.size(), mistag);
1271 mes_[
label][
"MisTagRateSignalIsHighest_vs_sum-pt2"]->Fill(
v.ptsq, mistag);
1272 mes_[
label][
"MisTagRateSignalIsHighest_vs_Z"]->Fill(
v.z, mistag);
1273 mes_[
label][
"MisTagRateSignalIsHighest_vs_R"]->Fill(
v.r, mistag);
1274 mes_[
label][
"MisTagRateSignalIsHighest_vs_NumTracks"]->Fill(
v.nGenTrk, mistag);
1276 mes_[
label][
"MisTagRateSignalIsNotHighest"]->Fill(mistag);
1277 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_PU"]->Fill(simpv.size(), mistag);
1278 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_sum-pt2"]->Fill(
v.ptsq, mistag);
1279 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_Z"]->Fill(
v.z, mistag);
1280 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_R"]->Fill(
v.r, mistag);
1281 mes_[
label][
"MisTagRateSignalIsNotHighest_vs_NumTracks"]->Fill(
v.nGenTrk, mistag);
1289 for (
int pv_position_in_reco_collection = 0;
iv != (*recVtxs.
product()).
end();
1290 ++pv_position_in_reco_collection, ++
iv) {
1291 if (
std::find(
v.rec_vertices.begin(),
v.rec_vertices.end(), &(*iv)) !=
v.rec_vertices.end()) {
1292 mes_[
label][
"TruePVLocationIndex"]->Fill(pv_position_in_reco_collection);
1293 const bool genPVMatchedToRecoPV = (pv_position_in_reco_collection == 0);
1294 mes_[
label][
"TruePVLocationIndexCumulative"]->Fill(genPVMatchedToRecoPV ? 0 : 1);
1296 if (signal_is_highest_pt) {
1297 mes_[
label][
"TruePVLocationIndexSignalIsHighest"]->Fill(pv_position_in_reco_collection);
1299 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"]->Fill(pv_position_in_reco_collection);
1303 if (genPVMatchedToRecoPV) {
1304 auto pv = recopv[0];
1308 genpv_position_in_reco_collection = pv_position_in_reco_collection;
1318 mes_[
label][
"TruePVLocationIndex"]->Fill(-1.);
1319 mes_[
label][
"TruePVLocationIndexCumulative"]->Fill(-1.);
1320 if (signal_is_highest_pt)
1321 mes_[
label][
"TruePVLocationIndexSignalIsHighest"]->Fill(-1.);
1323 mes_[
label][
"TruePVLocationIndexSignalIsNotHighest"]->Fill(-1.);
1327 if (!
v.rec_vertices.empty())
1328 num_total_gen_vertices_assoc2reco++;
1329 if (
v.rec_vertices.size() > 1)
1330 num_total_gen_vertices_multiassoc2reco++;
1339 mes_[
label][
"GenAllAssoc2Reco_NumVertices"]->Fill(simpv.size(), simpv.size());
1340 mes_[
label][
"GenAllAssoc2RecoMatched_NumVertices"]->Fill(simpv.size(), num_total_gen_vertices_assoc2reco);
1341 mes_[
label][
"GenAllAssoc2RecoMultiMatched_NumVertices"]->Fill(simpv.size(), num_total_gen_vertices_multiassoc2reco);
1342 for (
auto&
v : recopv) {
1344 if (!
v.sim_vertices.empty()) {
1345 num_total_reco_vertices_assoc2gen++;
1346 if (
v.sim_vertices_internal[0]->rec_vertices.size() > 1) {
1347 num_total_reco_vertices_duplicate++;
1350 if (
v.sim_vertices.size() > 1)
1351 num_total_reco_vertices_multiassoc2gen++;
1353 mes_[
label][
"RecoAllAssoc2Gen_NumVertices"]->Fill(recopv.size(), recopv.size());
1354 mes_[
label][
"RecoAllAssoc2GenMatched_NumVertices"]->Fill(recopv.size(), num_total_reco_vertices_assoc2gen);
1355 mes_[
label][
"RecoAllAssoc2GenMultiMatched_NumVertices"]->Fill(recopv.size(),
1356 num_total_reco_vertices_multiassoc2gen);
1357 mes_[
label][
"RecoAllAssoc2MultiMatchedGen_NumVertices"]->Fill(recopv.size(), num_total_reco_vertices_duplicate);
1358 mes_[
label][
"RecoVtx_vs_GenVtx"]->Fill(simpv.size(), recopv.size());
1359 mes_[
label][
"MatchedRecoVtx_vs_GenVtx"]->Fill(simpv.size(), num_total_reco_vertices_assoc2gen);