24 minEta_(
pset.getParameter<double>(
"minEta")),
25 maxEta_(
pset.getParameter<double>(
"maxEta")),
26 nintEta_(
pset.getParameter<
int>(
"nintEta")),
27 useFabsEta_(
pset.getParameter<
bool>(
"useFabsEta")),
30 minEne_(
pset.getParameter<double>(
"minEne")),
31 maxEne_(
pset.getParameter<double>(
"maxEne")),
32 nintEne_(
pset.getParameter<
int>(
"nintEne")),
35 minPt_(
pset.getParameter<double>(
"minPt")),
36 maxPt_(
pset.getParameter<double>(
"maxPt")),
37 nintPt_(
pset.getParameter<
int>(
"nintPt")),
40 minPhi_(
pset.getParameter<double>(
"minPhi")),
41 maxPhi_(
pset.getParameter<double>(
"maxPhi")),
42 nintPhi_(
pset.getParameter<
int>(
"nintPhi")),
45 minMixedHitsSimCluster_(
pset.getParameter<double>(
"minMixedHitsSimCluster")),
46 maxMixedHitsSimCluster_(
pset.getParameter<double>(
"maxMixedHitsSimCluster")),
47 nintMixedHitsSimCluster_(
pset.getParameter<
int>(
"nintMixedHitsSimCluster")),
50 minMixedHitsCluster_(
pset.getParameter<double>(
"minMixedHitsCluster")),
51 maxMixedHitsCluster_(
pset.getParameter<double>(
"maxMixedHitsCluster")),
52 nintMixedHitsCluster_(
pset.getParameter<
int>(
"nintMixedHitsCluster")),
55 minEneCl_(
pset.getParameter<double>(
"minEneCl")),
56 maxEneCl_(
pset.getParameter<double>(
"maxEneCl")),
57 nintEneCl_(
pset.getParameter<
int>(
"nintEneCl")),
60 minLongDepBary_(
pset.getParameter<double>(
"minLongDepBary")),
61 maxLongDepBary_(
pset.getParameter<double>(
"maxLongDepBary")),
62 nintLongDepBary_(
pset.getParameter<
int>(
"nintLongDepBary")),
65 minZpos_(
pset.getParameter<double>(
"minZpos")),
66 maxZpos_(
pset.getParameter<double>(
"maxZpos")),
67 nintZpos_(
pset.getParameter<
int>(
"nintZpos")),
70 minTotNsimClsperlay_(
pset.getParameter<double>(
"minTotNsimClsperlay")),
71 maxTotNsimClsperlay_(
pset.getParameter<double>(
"maxTotNsimClsperlay")),
72 nintTotNsimClsperlay_(
pset.getParameter<
int>(
"nintTotNsimClsperlay")),
75 minTotNClsperlay_(
pset.getParameter<double>(
"minTotNClsperlay")),
76 maxTotNClsperlay_(
pset.getParameter<double>(
"maxTotNClsperlay")),
77 nintTotNClsperlay_(
pset.getParameter<
int>(
"nintTotNClsperlay")),
80 minEneClperlay_(
pset.getParameter<double>(
"minEneClperlay")),
81 maxEneClperlay_(
pset.getParameter<double>(
"maxEneClperlay")),
82 nintEneClperlay_(
pset.getParameter<
int>(
"nintEneClperlay")),
87 minScore_(
pset.getParameter<double>(
"minScore")),
88 maxScore_(
pset.getParameter<double>(
"maxScore")),
89 nintScore_(
pset.getParameter<
int>(
"nintScore")),
96 minSharedEneFrac_(
pset.getParameter<double>(
"minSharedEneFrac")),
97 maxSharedEneFrac_(
pset.getParameter<double>(
"maxSharedEneFrac")),
98 nintSharedEneFrac_(
pset.getParameter<
int>(
"nintSharedEneFrac")),
101 minMCLSharedEneFrac_(
pset.getParameter<double>(
"minMCLSharedEneFrac")),
102 maxMCLSharedEneFrac_(
pset.getParameter<double>(
"maxMCLSharedEneFrac")),
103 nintMCLSharedEneFrac_(
pset.getParameter<
int>(
"nintMCLSharedEneFrac")),
106 minTotNsimClsperthick_(
pset.getParameter<double>(
"minTotNsimClsperthick")),
107 maxTotNsimClsperthick_(
pset.getParameter<double>(
"maxTotNsimClsperthick")),
108 nintTotNsimClsperthick_(
pset.getParameter<
int>(
"nintTotNsimClsperthick")),
111 minTotNClsperthick_(
pset.getParameter<double>(
"minTotNClsperthick")),
112 maxTotNClsperthick_(
pset.getParameter<double>(
"maxTotNClsperthick")),
113 nintTotNClsperthick_(
pset.getParameter<
int>(
"nintTotNClsperthick")),
116 minTotNcellsperthickperlayer_(
pset.getParameter<double>(
"minTotNcellsperthickperlayer")),
117 maxTotNcellsperthickperlayer_(
pset.getParameter<double>(
"maxTotNcellsperthickperlayer")),
118 nintTotNcellsperthickperlayer_(
pset.getParameter<
int>(
"nintTotNcellsperthickperlayer")),
121 minDisToSeedperthickperlayer_(
pset.getParameter<double>(
"minDisToSeedperthickperlayer")),
122 maxDisToSeedperthickperlayer_(
pset.getParameter<double>(
"maxDisToSeedperthickperlayer")),
123 nintDisToSeedperthickperlayer_(
pset.getParameter<
int>(
"nintDisToSeedperthickperlayer")),
126 minDisToSeedperthickperlayerenewei_(
pset.getParameter<double>(
"minDisToSeedperthickperlayerenewei")),
127 maxDisToSeedperthickperlayerenewei_(
pset.getParameter<double>(
"maxDisToSeedperthickperlayerenewei")),
128 nintDisToSeedperthickperlayerenewei_(
pset.getParameter<
int>(
"nintDisToSeedperthickperlayerenewei")),
131 minDisToMaxperthickperlayer_(
pset.getParameter<double>(
"minDisToMaxperthickperlayer")),
132 maxDisToMaxperthickperlayer_(
pset.getParameter<double>(
"maxDisToMaxperthickperlayer")),
133 nintDisToMaxperthickperlayer_(
pset.getParameter<
int>(
"nintDisToMaxperthickperlayer")),
136 minDisToMaxperthickperlayerenewei_(
pset.getParameter<double>(
"minDisToMaxperthickperlayerenewei")),
137 maxDisToMaxperthickperlayerenewei_(
pset.getParameter<double>(
"maxDisToMaxperthickperlayerenewei")),
138 nintDisToMaxperthickperlayerenewei_(
pset.getParameter<
int>(
"nintDisToMaxperthickperlayerenewei")),
141 minDisSeedToMaxperthickperlayer_(
pset.getParameter<double>(
"minDisSeedToMaxperthickperlayer")),
142 maxDisSeedToMaxperthickperlayer_(
pset.getParameter<double>(
"maxDisSeedToMaxperthickperlayer")),
143 nintDisSeedToMaxperthickperlayer_(
pset.getParameter<
int>(
"nintDisSeedToMaxperthickperlayer")),
146 minClEneperthickperlayer_(
pset.getParameter<double>(
"minClEneperthickperlayer")),
147 maxClEneperthickperlayer_(
pset.getParameter<double>(
"maxClEneperthickperlayer")),
148 nintClEneperthickperlayer_(
pset.getParameter<
int>(
"nintClEneperthickperlayer")),
151 minCellsEneDensperthick_(
pset.getParameter<double>(
"minCellsEneDensperthick")),
152 maxCellsEneDensperthick_(
pset.getParameter<double>(
"maxCellsEneDensperthick")),
153 nintCellsEneDensperthick_(
pset.getParameter<
int>(
"nintCellsEneDensperthick")),
157 minTotNMCLs_(
pset.getParameter<double>(
"minTotNMCLs")),
158 maxTotNMCLs_(
pset.getParameter<double>(
"maxTotNMCLs")),
159 nintTotNMCLs_(
pset.getParameter<
int>(
"nintTotNMCLs")),
162 minTotNClsinMCLs_(
pset.getParameter<double>(
"minTotNClsinMCLs")),
163 maxTotNClsinMCLs_(
pset.getParameter<double>(
"maxTotNClsinMCLs")),
164 nintTotNClsinMCLs_(
pset.getParameter<
int>(
"nintTotNClsinMCLs")),
167 minTotNClsinMCLsperlayer_(
pset.getParameter<double>(
"minTotNClsinMCLsperlayer")),
168 maxTotNClsinMCLsperlayer_(
pset.getParameter<double>(
"maxTotNClsinMCLsperlayer")),
169 nintTotNClsinMCLsperlayer_(
pset.getParameter<
int>(
"nintTotNClsinMCLsperlayer")),
172 minMplofLCs_(
pset.getParameter<double>(
"minMplofLCs")),
173 maxMplofLCs_(
pset.getParameter<double>(
"maxMplofLCs")),
174 nintMplofLCs_(
pset.getParameter<
int>(
"nintMplofLCs")),
177 minSizeCLsinMCLs_(
pset.getParameter<double>(
"minSizeCLsinMCLs")),
178 maxSizeCLsinMCLs_(
pset.getParameter<double>(
"maxSizeCLsinMCLs")),
179 nintSizeCLsinMCLs_(
pset.getParameter<
int>(
"nintSizeCLsinMCLs")),
182 minClEnepermultiplicity_(
pset.getParameter<double>(
"minClEnepermultiplicity")),
183 maxClEnepermultiplicity_(
pset.getParameter<double>(
"maxClEnepermultiplicity")),
184 nintClEnepermultiplicity_(
pset.getParameter<
int>(
"nintClEnepermultiplicity")),
187 minX_(
pset.getParameter<double>(
"minX")),
188 maxX_(
pset.getParameter<double>(
"maxX")),
189 nintX_(
pset.getParameter<
int>(
"nintX")),
192 minY_(
pset.getParameter<double>(
"minY")),
193 maxY_(
pset.getParameter<double>(
"maxY")),
194 nintY_(
pset.getParameter<
int>(
"nintY")),
197 minZ_(
pset.getParameter<double>(
"minZ")),
198 maxZ_(
pset.getParameter<double>(
"maxZ")),
199 nintZ_(
pset.getParameter<
int>(
"nintZ")) {}
228 ibook.
book1D(
"EnergyDifference",
"(Energy-SelfEnergy)/Energy", 300., -5., 1.);
231 ibook.
book1D(
"Num Sim Clusters",
"Num Sim Clusters in caloparticle", 100, 0., 100.);
233 ibook.
book1D(
"Num Hits in Sim Clusters",
"Num Hits in Sim Clusters in caloparticle", 1000, 0., 1000.);
235 "Num Rec-matched Hits in Sim Clusters",
"Num Hits in Sim Clusters (matched) in caloparticle", 1000, 0., 1000.);
238 ibook.
book1D(
"Energy of Rec-matched Hits",
"Energy of Hits in Sim Clusters (matched)", 100, 0., 10.);
240 ibook.
book2D(
"Energy of Rec-matched Hits vs layer",
241 "Energy of Hits in Sim Clusters (matched) vs layer",
249 ibook.
book2D(
"Energy of Rec-matched Hits vs layer (1SC)",
250 "Energy of Hits only 1 Sim Clusters (matched) vs layer",
258 ibook.
book2D(
"Rec-matched Hits Sum Energy vs layer",
259 "Rescaled Sum Energy of Hits in Sim Clusters (matched) vs layer",
268 ibook.
book1D(
"First Layer",
"First layer of the caloparticle", 2 *
layers, 0., (
float)2 *
layers);
270 ibook.
book1D(
"Last Layer",
"Last layer of the caloparticle", 2 *
layers, 0., (
float)2 *
layers);
272 ibook.
book1D(
"Number of Layers",
"Number of layers of the caloparticle", 2 *
layers, 0., (
float)2 *
layers);
274 "First Layer (rec-matched hit)",
"First layer of the caloparticle (matched)", 2 *
layers, 0., (
float)2 *
layers);
276 "Last Layer (rec-matched hit)",
"Last layer of the caloparticle (matched)", 2 *
layers, 0., (
float)2 *
layers);
278 ibook.
book1D(
"Number of Layers (rec-matched hit)",
279 "Number of layers of the caloparticle (matched)",
288 std::vector<int> thicknesses) {
290 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
291 auto istr1 = std::to_string(ilayer);
292 while (istr1.size() < 2) {
293 istr1.insert(0,
"0");
299 istr2 = std::to_string(ilayer + 1) +
" in z-";
301 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
303 histograms.h_simclusternum_perlayer[ilayer] = ibook.
book1D(
"totsimclusternum_layer_" + istr1,
304 "total number of SimClusters for layer " + istr2,
311 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
312 auto istr = std::to_string(*it);
313 histograms.h_simclusternum_perthick[(*it)] = ibook.
book1D(
"totsimclusternum_thick_" + istr,
314 "total number of simclusters for thickness " + istr,
323 ibook.
book1D(
"mixedhitssimcluster_zminus",
324 "N of simclusters that contain hits of more than one kind in z-",
330 ibook.
book1D(
"mixedhitssimcluster_zplus",
331 "N of simclusters that contain hits of more than one kind in z+",
340 std::vector<int> thicknesses) {
341 std::unordered_map<int, dqm::reco::MonitorElement*> denom_layercl_in_simcl_eta_perlayer;
342 denom_layercl_in_simcl_eta_perlayer.clear();
343 std::unordered_map<int, dqm::reco::MonitorElement*> denom_layercl_in_simcl_phi_perlayer;
344 denom_layercl_in_simcl_phi_perlayer.clear();
345 std::unordered_map<int, dqm::reco::MonitorElement*> score_layercl2simcluster_perlayer;
346 score_layercl2simcluster_perlayer.clear();
347 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_layercl2simcluster_perlayer;
348 sharedenergy_layercl2simcluster_perlayer.clear();
349 std::unordered_map<int, dqm::reco::MonitorElement*> energy_vs_score_layercl2simcluster_perlayer;
350 energy_vs_score_layercl2simcluster_perlayer.clear();
351 std::unordered_map<int, dqm::reco::MonitorElement*> num_layercl_in_simcl_eta_perlayer;
352 num_layercl_in_simcl_eta_perlayer.clear();
353 std::unordered_map<int, dqm::reco::MonitorElement*> num_layercl_in_simcl_phi_perlayer;
354 num_layercl_in_simcl_phi_perlayer.clear();
355 std::unordered_map<int, dqm::reco::MonitorElement*> numMerge_layercl_in_simcl_eta_perlayer;
356 numMerge_layercl_in_simcl_eta_perlayer.clear();
357 std::unordered_map<int, dqm::reco::MonitorElement*> numMerge_layercl_in_simcl_phi_perlayer;
358 numMerge_layercl_in_simcl_phi_perlayer.clear();
359 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_layercl2simcluster_vs_eta_perlayer;
360 sharedenergy_layercl2simcluster_vs_eta_perlayer.clear();
361 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_layercl2simcluster_vs_phi_perlayer;
362 sharedenergy_layercl2simcluster_vs_phi_perlayer.clear();
363 std::unordered_map<int, dqm::reco::MonitorElement*> denom_simcluster_eta_perlayer;
364 denom_simcluster_eta_perlayer.clear();
365 std::unordered_map<int, dqm::reco::MonitorElement*> denom_simcluster_phi_perlayer;
366 denom_simcluster_phi_perlayer.clear();
367 std::unordered_map<int, dqm::reco::MonitorElement*> score_simcluster2layercl_perlayer;
368 score_simcluster2layercl_perlayer.clear();
369 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_simcluster2layercl_perlayer;
370 sharedenergy_simcluster2layercl_perlayer.clear();
371 std::unordered_map<int, dqm::reco::MonitorElement*> energy_vs_score_simcluster2layercl_perlayer;
372 energy_vs_score_simcluster2layercl_perlayer.clear();
373 std::unordered_map<int, dqm::reco::MonitorElement*> num_simcluster_eta_perlayer;
374 num_simcluster_eta_perlayer.clear();
375 std::unordered_map<int, dqm::reco::MonitorElement*> num_simcluster_phi_perlayer;
376 num_simcluster_phi_perlayer.clear();
377 std::unordered_map<int, dqm::reco::MonitorElement*> numDup_simcluster_eta_perlayer;
378 numDup_simcluster_eta_perlayer.clear();
379 std::unordered_map<int, dqm::reco::MonitorElement*> numDup_simcluster_phi_perlayer;
380 numDup_simcluster_phi_perlayer.clear();
381 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_simcluster2layercl_vs_eta_perlayer;
382 sharedenergy_simcluster2layercl_vs_eta_perlayer.clear();
383 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_simcluster2layercl_vs_phi_perlayer;
384 sharedenergy_simcluster2layercl_vs_phi_perlayer.clear();
387 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
388 auto istr1 = std::to_string(ilayer);
389 while (istr1.size() < 2) {
390 istr1.insert(0,
"0");
396 istr2 = std::to_string(ilayer + 1) +
" in z-";
398 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
401 denom_layercl_in_simcl_eta_perlayer[ilayer] =
402 ibook.
book1D(
"Denom_LayerCluster_in_SimCluster_Eta_perlayer" + istr1,
403 "Denom LayerCluster in SimCluster Eta per Layer Cluster for layer " + istr2,
408 denom_layercl_in_simcl_phi_perlayer[ilayer] =
409 ibook.
book1D(
"Denom_LayerCluster_in_SimCluster_Phi_perlayer" + istr1,
410 "Denom LayerCluster in SimCluster Phi per Layer Cluster for layer " + istr2,
415 score_layercl2simcluster_perlayer[ilayer] = ibook.
book1D(
"Score_layercl2simcluster_perlayer" + istr1,
416 "Score of Layer Cluster per SimCluster for layer " + istr2,
421 score_simcluster2layercl_perlayer[ilayer] = ibook.
book1D(
"Score_simcluster2layercl_perlayer" + istr1,
422 "Score of SimCluster per Layer Cluster for layer " + istr2,
427 energy_vs_score_simcluster2layercl_perlayer[ilayer] =
428 ibook.
book2D(
"Energy_vs_Score_simcluster2layer_perlayer" + istr1,
429 "Energy vs Score of SimCluster per Layer Cluster for layer " + istr2,
437 energy_vs_score_layercl2simcluster_perlayer[ilayer] =
438 ibook.
book2D(
"Energy_vs_Score_layer2simcluster_perlayer" + istr1,
439 "Energy vs Score of Layer Cluster per SimCluster for layer " + istr2,
447 sharedenergy_simcluster2layercl_perlayer[ilayer] =
448 ibook.
book1D(
"SharedEnergy_simcluster2layercl_perlayer" + istr1,
449 "Shared Energy of SimCluster per Layer Cluster for layer " + istr2,
454 sharedenergy_simcluster2layercl_vs_eta_perlayer[ilayer] =
455 ibook.
bookProfile(
"SharedEnergy_simcluster2layercl_vs_eta_perlayer" + istr1,
456 "Shared Energy of SimCluster vs #eta per best Layer Cluster for layer " + istr2,
463 sharedenergy_simcluster2layercl_vs_phi_perlayer[ilayer] =
464 ibook.
bookProfile(
"SharedEnergy_simcluster2layercl_vs_phi_perlayer" + istr1,
465 "Shared Energy of SimCluster vs #phi per best Layer Cluster for layer " + istr2,
472 sharedenergy_layercl2simcluster_perlayer[ilayer] =
473 ibook.
book1D(
"SharedEnergy_layercluster2simcluster_perlayer" + istr1,
474 "Shared Energy of Layer Cluster per SimCluster for layer " + istr2,
479 sharedenergy_layercl2simcluster_vs_eta_perlayer[ilayer] =
480 ibook.
bookProfile(
"SharedEnergy_layercl2simcluster_vs_eta_perlayer" + istr1,
481 "Shared Energy of LayerCluster vs #eta per best SimCluster for layer " + istr2,
488 sharedenergy_layercl2simcluster_vs_phi_perlayer[ilayer] =
489 ibook.
bookProfile(
"SharedEnergy_layercl2simcluster_vs_phi_perlayer" + istr1,
490 "Shared Energy of LayerCluster vs #phi per best SimCluster for layer " + istr2,
497 num_simcluster_eta_perlayer[ilayer] = ibook.
book1D(
"Num_SimCluster_Eta_perlayer" + istr1,
498 "Num SimCluster Eta per Layer Cluster for layer " + istr2,
503 numDup_simcluster_eta_perlayer[ilayer] =
504 ibook.
book1D(
"NumDup_SimCluster_Eta_perlayer" + istr1,
505 "Num Duplicate SimCluster Eta per Layer Cluster for layer " + istr2,
510 denom_simcluster_eta_perlayer[ilayer] = ibook.
book1D(
"Denom_SimCluster_Eta_perlayer" + istr1,
511 "Denom SimCluster Eta per Layer Cluster for layer " + istr2,
516 num_simcluster_phi_perlayer[ilayer] = ibook.
book1D(
"Num_SimCluster_Phi_perlayer" + istr1,
517 "Num SimCluster Phi per Layer Cluster for layer " + istr2,
522 numDup_simcluster_phi_perlayer[ilayer] =
523 ibook.
book1D(
"NumDup_SimCluster_Phi_perlayer" + istr1,
524 "Num Duplicate SimCluster Phi per Layer Cluster for layer " + istr2,
529 denom_simcluster_phi_perlayer[ilayer] = ibook.
book1D(
"Denom_SimCluster_Phi_perlayer" + istr1,
530 "Denom SimCluster Phi per Layer Cluster for layer " + istr2,
535 num_layercl_in_simcl_eta_perlayer[ilayer] =
536 ibook.
book1D(
"Num_LayerCluster_in_SimCluster_Eta_perlayer" + istr1,
537 "Num LayerCluster Eta per Layer Cluster in SimCluster for layer " + istr2,
542 numMerge_layercl_in_simcl_eta_perlayer[ilayer] =
543 ibook.
book1D(
"NumMerge_LayerCluster_in_SimCluster_Eta_perlayer" + istr1,
544 "Num Merge LayerCluster Eta per Layer Cluster in SimCluster for layer " + istr2,
549 num_layercl_in_simcl_phi_perlayer[ilayer] =
550 ibook.
book1D(
"Num_LayerCluster_in_SimCluster_Phi_perlayer" + istr1,
551 "Num LayerCluster Phi per Layer Cluster in SimCluster for layer " + istr2,
556 numMerge_layercl_in_simcl_phi_perlayer[ilayer] =
557 ibook.
book1D(
"NumMerge_LayerCluster_in_SimCluster_Phi_perlayer" + istr1,
558 "Num Merge LayerCluster Phi per Layer Cluster in SimCluster for layer " + istr2,
565 histograms.h_denom_layercl_in_simcl_eta_perlayer.push_back(
std::move(denom_layercl_in_simcl_eta_perlayer));
566 histograms.h_denom_layercl_in_simcl_phi_perlayer.push_back(
std::move(denom_layercl_in_simcl_phi_perlayer));
567 histograms.h_score_layercl2simcluster_perlayer.push_back(
std::move(score_layercl2simcluster_perlayer));
568 histograms.h_sharedenergy_layercl2simcluster_perlayer.push_back(
std::move(sharedenergy_layercl2simcluster_perlayer));
569 histograms.h_energy_vs_score_layercl2simcluster_perlayer.push_back(
570 std::move(energy_vs_score_layercl2simcluster_perlayer));
571 histograms.h_num_layercl_in_simcl_eta_perlayer.push_back(
std::move(num_layercl_in_simcl_eta_perlayer));
572 histograms.h_num_layercl_in_simcl_phi_perlayer.push_back(
std::move(num_layercl_in_simcl_phi_perlayer));
573 histograms.h_numMerge_layercl_in_simcl_eta_perlayer.push_back(
std::move(numMerge_layercl_in_simcl_eta_perlayer));
574 histograms.h_numMerge_layercl_in_simcl_phi_perlayer.push_back(
std::move(numMerge_layercl_in_simcl_phi_perlayer));
575 histograms.h_sharedenergy_layercl2simcluster_vs_eta_perlayer.push_back(
576 std::move(sharedenergy_layercl2simcluster_vs_eta_perlayer));
577 histograms.h_sharedenergy_layercl2simcluster_vs_phi_perlayer.push_back(
578 std::move(sharedenergy_layercl2simcluster_vs_phi_perlayer));
579 histograms.h_denom_simcluster_eta_perlayer.push_back(
std::move(denom_simcluster_eta_perlayer));
580 histograms.h_denom_simcluster_phi_perlayer.push_back(
std::move(denom_simcluster_phi_perlayer));
581 histograms.h_score_simcluster2layercl_perlayer.push_back(
std::move(score_simcluster2layercl_perlayer));
582 histograms.h_sharedenergy_simcluster2layercl_perlayer.push_back(
std::move(sharedenergy_simcluster2layercl_perlayer));
583 histograms.h_energy_vs_score_simcluster2layercl_perlayer.push_back(
584 std::move(energy_vs_score_simcluster2layercl_perlayer));
585 histograms.h_num_simcluster_eta_perlayer.push_back(
std::move(num_simcluster_eta_perlayer));
586 histograms.h_num_simcluster_phi_perlayer.push_back(
std::move(num_simcluster_phi_perlayer));
587 histograms.h_numDup_simcluster_eta_perlayer.push_back(
std::move(numDup_simcluster_eta_perlayer));
588 histograms.h_numDup_simcluster_phi_perlayer.push_back(
std::move(numDup_simcluster_phi_perlayer));
589 histograms.h_sharedenergy_simcluster2layercl_vs_eta_perlayer.push_back(
590 std::move(sharedenergy_simcluster2layercl_vs_eta_perlayer));
591 histograms.h_sharedenergy_simcluster2layercl_vs_phi_perlayer.push_back(
592 std::move(sharedenergy_simcluster2layercl_vs_phi_perlayer));
597 std::vector<int> thicknesses,
605 histograms.h_mixedhitscluster_zminus.push_back(
606 ibook.
book1D(
"mixedhitscluster_zminus",
607 "N of reco clusters that contain hits of more than one kind in z-",
612 histograms.h_mixedhitscluster_zplus.push_back(
613 ibook.
book1D(
"mixedhitscluster_zplus",
614 "N of reco clusters that contain hits of more than one kind in z+",
621 histograms.h_energyclustered_zminus.push_back(
622 ibook.
book1D(
"energyclustered_zminus",
623 "percent of total energy clustered by all layer clusters over caloparticles energy in z-",
629 ibook.
book1D(
"energyclustered_zplus",
630 "percent of total energy clustered by all layer clusters over caloparticles energy in z+",
637 std::string subpathtomat = pathtomatbudfile.substr(pathtomatbudfile.find(
"Validation"));
638 histograms.h_longdepthbarycentre_zminus.push_back(
639 ibook.
book1D(
"longdepthbarycentre_zminus",
640 "The longitudinal depth barycentre in z- for " + subpathtomat,
645 histograms.h_longdepthbarycentre_zplus.push_back(
646 ibook.
book1D(
"longdepthbarycentre_zplus",
647 "The longitudinal depth barycentre in z+ for " + subpathtomat,
653 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
654 auto istr1 = std::to_string(ilayer);
655 while (istr1.size() < 2) {
656 istr1.insert(0,
"0");
662 istr2 = std::to_string(ilayer + 1) +
" in z-";
664 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
666 histograms.h_clusternum_perlayer[ilayer] = ibook.
book1D(
"totclusternum_layer_" + istr1,
667 "total number of layer clusters for layer " + istr2,
671 histograms.h_energyclustered_perlayer[ilayer] =
672 ibook.
book1D(
"energyclustered_perlayer" + istr1,
673 "percent of total energy clustered by layer clusters over caloparticles energy for layer " + istr2,
680 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
681 auto istr = std::to_string(*it);
682 histograms.h_clusternum_perthick[(*it)] = ibook.
book1D(
"totclusternum_thick_" + istr,
683 "total number of layer clusters for thickness " + istr,
695 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
696 auto istr1 = std::to_string(ilayer);
697 while (istr1.size() < 2) {
698 istr1.insert(0,
"0");
704 istr2 = std::to_string(ilayer + 1) +
" in z-";
706 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
708 histograms.h_score_layercl2caloparticle_perlayer[ilayer] =
709 ibook.
book1D(
"Score_layercl2caloparticle_perlayer" + istr1,
710 "Score of Layer Cluster per CaloParticle for layer " + istr2,
714 histograms.h_score_caloparticle2layercl_perlayer[ilayer] =
715 ibook.
book1D(
"Score_caloparticle2layercl_perlayer" + istr1,
716 "Score of CaloParticle per Layer Cluster for layer " + istr2,
720 histograms.h_energy_vs_score_caloparticle2layercl_perlayer[ilayer] =
721 ibook.
book2D(
"Energy_vs_Score_caloparticle2layer_perlayer" + istr1,
722 "Energy vs Score of CaloParticle per Layer Cluster for layer " + istr2,
729 histograms.h_energy_vs_score_layercl2caloparticle_perlayer[ilayer] =
730 ibook.
book2D(
"Energy_vs_Score_layer2caloparticle_perlayer" + istr1,
731 "Energy vs Score of Layer Cluster per CaloParticle Layer for layer " + istr2,
738 histograms.h_sharedenergy_caloparticle2layercl_perlayer[ilayer] =
739 ibook.
book1D(
"SharedEnergy_caloparticle2layercl_perlayer" + istr1,
740 "Shared Energy of CaloParticle per Layer Cluster for layer " + istr2,
744 histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer[ilayer] =
745 ibook.
bookProfile(
"SharedEnergy_caloparticle2layercl_vs_eta_perlayer" + istr1,
746 "Shared Energy of CaloParticle vs #eta per best Layer Cluster for layer " + istr2,
752 histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer[ilayer] =
753 ibook.
bookProfile(
"SharedEnergy_caloparticle2layercl_vs_phi_perlayer" + istr1,
754 "Shared Energy of CaloParticle vs #phi per best Layer Cluster for layer " + istr2,
760 histograms.h_sharedenergy_layercl2caloparticle_perlayer[ilayer] =
761 ibook.
book1D(
"SharedEnergy_layercluster2caloparticle_perlayer" + istr1,
762 "Shared Energy of Layer Cluster per Layer Calo Particle for layer " + istr2,
766 histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer[ilayer] =
767 ibook.
bookProfile(
"SharedEnergy_layercl2caloparticle_vs_eta_perlayer" + istr1,
768 "Shared Energy of LayerCluster vs #eta per best Calo Particle for layer " + istr2,
774 histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer[ilayer] =
775 ibook.
bookProfile(
"SharedEnergy_layercl2caloparticle_vs_phi_perlayer" + istr1,
776 "Shared Energy of LayerCluster vs #phi per best Calo Particle for layer " + istr2,
782 histograms.h_num_caloparticle_eta_perlayer[ilayer] =
783 ibook.
book1D(
"Num_CaloParticle_Eta_perlayer" + istr1,
784 "Num CaloParticle Eta per Layer Cluster for layer " + istr2,
788 histograms.h_numDup_caloparticle_eta_perlayer[ilayer] =
789 ibook.
book1D(
"NumDup_CaloParticle_Eta_perlayer" + istr1,
790 "Num Duplicate CaloParticle Eta per Layer Cluster for layer " + istr2,
794 histograms.h_denom_caloparticle_eta_perlayer[ilayer] =
795 ibook.
book1D(
"Denom_CaloParticle_Eta_perlayer" + istr1,
796 "Denom CaloParticle Eta per Layer Cluster for layer " + istr2,
800 histograms.h_num_caloparticle_phi_perlayer[ilayer] =
801 ibook.
book1D(
"Num_CaloParticle_Phi_perlayer" + istr1,
802 "Num CaloParticle Phi per Layer Cluster for layer " + istr2,
806 histograms.h_numDup_caloparticle_phi_perlayer[ilayer] =
807 ibook.
book1D(
"NumDup_CaloParticle_Phi_perlayer" + istr1,
808 "Num Duplicate CaloParticle Phi per Layer Cluster for layer " + istr2,
812 histograms.h_denom_caloparticle_phi_perlayer[ilayer] =
813 ibook.
book1D(
"Denom_CaloParticle_Phi_perlayer" + istr1,
814 "Denom CaloParticle Phi per Layer Cluster for layer " + istr2,
818 histograms.h_num_layercl_eta_perlayer[ilayer] =
819 ibook.
book1D(
"Num_LayerCluster_Eta_perlayer" + istr1,
820 "Num LayerCluster Eta per Layer Cluster for layer " + istr2,
824 histograms.h_numMerge_layercl_eta_perlayer[ilayer] =
825 ibook.
book1D(
"NumMerge_LayerCluster_Eta_perlayer" + istr1,
826 "Num Merge LayerCluster Eta per Layer Cluster for layer " + istr2,
830 histograms.h_denom_layercl_eta_perlayer[ilayer] =
831 ibook.
book1D(
"Denom_LayerCluster_Eta_perlayer" + istr1,
832 "Denom LayerCluster Eta per Layer Cluster for layer " + istr2,
836 histograms.h_num_layercl_phi_perlayer[ilayer] =
837 ibook.
book1D(
"Num_LayerCluster_Phi_perlayer" + istr1,
838 "Num LayerCluster Phi per Layer Cluster for layer " + istr2,
842 histograms.h_numMerge_layercl_phi_perlayer[ilayer] =
843 ibook.
book1D(
"NumMerge_LayerCluster_Phi_perlayer" + istr1,
844 "Num Merge LayerCluster Phi per Layer Cluster for layer " + istr2,
848 histograms.h_denom_layercl_phi_perlayer[ilayer] =
849 ibook.
book1D(
"Denom_LayerCluster_Phi_perlayer" + istr1,
850 "Denom LayerCluster Phi per Layer Cluster for layer " + istr2,
861 std::vector<int> thicknesses) {
863 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
864 auto istr1 = std::to_string(ilayer);
865 while (istr1.size() < 2) {
866 istr1.insert(0,
"0");
872 istr2 = std::to_string(ilayer + 1) +
" in z-";
874 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
876 histograms.h_cellAssociation_perlayer[ilayer] =
877 ibook.
book1D(
"cellAssociation_perlayer" + istr1,
"Cell Association for layer " + istr2, 5, -4., 1.);
878 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(2,
"TN(purity)");
879 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(3,
"FN(ineff.)");
880 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(4,
"FP(fake)");
881 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(5,
"TP(eff.)");
884 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
885 auto istr = std::to_string(*it);
886 histograms.h_cellsenedens_perthick[(*it)] = ibook.
book1D(
"cellsenedens_thick_" + istr,
887 "energy density of cluster cells for thickness " + istr,
894 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
895 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
896 auto istr1 = std::to_string(*it);
897 auto istr2 = std::to_string(ilayer);
898 while (istr2.size() < 2)
899 istr2.insert(0,
"0");
900 auto istr = istr1 +
"_" + istr2;
905 istr3 = std::to_string(ilayer + 1) +
" in z- ";
907 istr3 = std::to_string(ilayer - (
layers - 1)) +
" in z+ ";
910 histograms.h_cellsnum_perthickperlayer[istr] =
911 ibook.
book1D(
"cellsnum_perthick_perlayer_" + istr,
912 "total number of cells for layer " + istr3 +
" for thickness " + istr1,
917 histograms.h_distancetoseedcell_perthickperlayer[istr] =
918 ibook.
book1D(
"distancetoseedcell_perthickperlayer_" + istr,
919 "distance of cluster cells to seed cell for layer " + istr3 +
" for thickness " + istr1,
924 histograms.h_distancetoseedcell_perthickperlayer_eneweighted[istr] = ibook.
book1D(
925 "distancetoseedcell_perthickperlayer_eneweighted_" + istr,
926 "energy weighted distance of cluster cells to seed cell for layer " + istr3 +
" for thickness " + istr1,
931 histograms.h_distancetomaxcell_perthickperlayer[istr] =
932 ibook.
book1D(
"distancetomaxcell_perthickperlayer_" + istr,
933 "distance of cluster cells to max cell for layer " + istr3 +
" for thickness " + istr1,
938 histograms.h_distancetomaxcell_perthickperlayer_eneweighted[istr] = ibook.
book1D(
939 "distancetomaxcell_perthickperlayer_eneweighted_" + istr,
940 "energy weighted distance of cluster cells to max cell for layer " + istr3 +
" for thickness " + istr1,
945 histograms.h_distancebetseedandmaxcell_perthickperlayer[istr] =
946 ibook.
book1D(
"distancebetseedandmaxcell_perthickperlayer_" + istr,
947 "distance of seed cell to max cell for layer " + istr3 +
" for thickness " + istr1,
952 histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer[istr] = ibook.
book2D(
953 "distancebetseedandmaxcellvsclusterenergy_perthickperlayer_" + istr,
954 "distance of seed cell to max cell vs cluster energy for layer " + istr3 +
" for thickness " + istr1,
973 histograms.h_energy_vs_score_multicl2caloparticle.push_back(
974 ibook.
book2D(
"Energy_vs_Score_multi2caloparticle",
975 "Energy vs Score of Multi Cluster per CaloParticle",
982 histograms.h_energy_vs_score_caloparticle2multicl.push_back(
983 ibook.
book2D(
"Energy_vs_Score_caloparticle2multi",
984 "Energy vs Score of CaloParticle per Multi Cluster",
996 "NumMerge_MultiCluster_Eta",
"Num Merge MultiCluster Eta per Multi Cluster ",
nintEta_,
minEta_,
maxEta_));
1002 "NumMerge_MultiCluster_Phi",
"Num Merge MultiCluster Phi per Multi Cluster",
nintPhi_,
minPhi_,
maxPhi_));
1005 histograms.h_sharedenergy_multicl2caloparticle.push_back(
1006 ibook.
book1D(
"SharedEnergy_multicluster2caloparticle",
1007 "Shared Energy of Multi Cluster per Calo Particle in each layer",
1011 histograms.h_sharedenergy_multicl2caloparticle_vs_eta.push_back(
1012 ibook.
bookProfile(
"SharedEnergy_multicl2caloparticle_vs_eta",
1013 "Shared Energy of MultiCluster vs #eta per best Calo Particle in each layer",
1019 histograms.h_sharedenergy_multicl2caloparticle_vs_phi.push_back(
1020 ibook.
bookProfile(
"SharedEnergy_multicl2caloparticle_vs_phi",
1021 "Shared Energy of MultiCluster vs #phi per best Calo Particle in each layer",
1027 histograms.h_sharedenergy_caloparticle2multicl.push_back(
1028 ibook.
book1D(
"SharedEnergy_caloparticle2multicl",
1029 "Shared Energy of CaloParticle per Multi Cluster",
1033 histograms.h_sharedenergy_caloparticle2multicl_assoc.push_back(
1034 ibook.
book1D(
"SharedEnergy_caloparticle2multicl_assoc",
1035 "Shared Energy of Associated CaloParticle per Multi Cluster",
1039 histograms.h_sharedenergy_caloparticle2multicl_vs_eta.push_back(
1040 ibook.
bookProfile(
"SharedEnergy_caloparticle2multicl_vs_eta",
1041 "Shared Energy of CaloParticle vs #eta per best Multi Cluster",
1047 histograms.h_sharedenergy_caloparticle2multicl_vs_phi.push_back(
1048 ibook.
bookProfile(
"SharedEnergy_caloparticle2multicl_vs_phi",
1049 "Shared Energy of CaloParticle vs #phi per best Multi Cluster",
1059 histograms.h_denom_caloparticle_eta.push_back(
1065 histograms.h_denom_caloparticle_phi.push_back(
1068 std::unordered_map<int, dqm::reco::MonitorElement*> clusternum_in_multicluster_perlayer;
1069 clusternum_in_multicluster_perlayer.clear();
1071 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
1072 auto istr1 = std::to_string(ilayer);
1073 while (istr1.size() < 2) {
1074 istr1.insert(0,
"0");
1080 istr2 = std::to_string(ilayer + 1) +
" in z-";
1082 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
1085 clusternum_in_multicluster_perlayer[ilayer] =
1086 ibook.
book1D(
"clusternum_in_multicluster_perlayer" + istr1,
1087 "Number of layer clusters in multicluster for layer " + istr2,
1093 histograms.h_clusternum_in_multicluster_perlayer.push_back(
std::move(clusternum_in_multicluster_perlayer));
1098 histograms.h_contmulticlusternum.push_back(ibook.
book1D(
"contmulticlusternum",
1099 "number of multiclusters with 3 contiguous layers",
1104 histograms.h_noncontmulticlusternum.push_back(ibook.
book1D(
"noncontmulticlusternum",
1105 "number of multiclusters without 3 contiguous layers",
1110 histograms.h_clusternum_in_multicluster.push_back(ibook.
book1D(
"clusternum_in_multicluster",
1111 "total number of layer clusters in multicluster",
1116 histograms.h_clusternum_in_multicluster_vs_layer.push_back(
1117 ibook.
bookProfile(
"clusternum_in_multicluster_vs_layer",
1118 "Profile of 2d layer clusters in multicluster vs layer number",
1125 histograms.h_multiplicityOfLCinMCL.push_back(ibook.
book2D(
"multiplicityOfLCinMCL",
1126 "Multiplicity vs Layer cluster size in Multiclusters",
1134 histograms.h_multiplicity_numberOfEventsHistogram.push_back(ibook.
book1D(
"multiplicity_numberOfEventsHistogram",
1135 "multiplicity numberOfEventsHistogram",
1140 histograms.h_multiplicity_zminus_numberOfEventsHistogram.push_back(
1141 ibook.
book1D(
"multiplicity_zminus_numberOfEventsHistogram",
1142 "multiplicity numberOfEventsHistogram in z-",
1147 histograms.h_multiplicity_zplus_numberOfEventsHistogram.push_back(
1148 ibook.
book1D(
"multiplicity_zplus_numberOfEventsHistogram",
1149 "multiplicity numberOfEventsHistogram in z+",
1154 histograms.h_multiplicityOfLCinMCL_vs_layercluster_zminus.push_back(
1155 ibook.
book2D(
"multiplicityOfLCinMCL_vs_layercluster_zminus",
1156 "Multiplicity vs Layer number in z-",
1164 histograms.h_multiplicityOfLCinMCL_vs_layercluster_zplus.push_back(
1165 ibook.
book2D(
"multiplicityOfLCinMCL_vs_layercluster_zplus",
1166 "Multiplicity vs Layer number in z+",
1174 histograms.h_multiplicityOfLCinMCL_vs_layerclusterenergy.push_back(
1175 ibook.
book2D(
"multiplicityOfLCinMCL_vs_layerclusterenergy",
1176 "Multiplicity vs Layer cluster energy",
1198 histograms.h_multicluster_firstlayer.push_back(
1199 ibook.
book1D(
"multicluster_firstlayer",
"First layer of the multicluster", 2 *
layers, 0., (
float)2 *
layers));
1200 histograms.h_multicluster_lastlayer.push_back(
1201 ibook.
book1D(
"multicluster_lastlayer",
"Last layer of the multicluster", 2 *
layers, 0., (
float)2 *
layers));
1203 "multicluster_layersnum",
"Number of layers of the multicluster", 2 *
layers, 0., (
float)2 *
layers));
1224 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap)
const {
1248 int minLayerId = 999;
1251 int simHits_matched = 0;
1252 int minLayerId_matched = 999;
1253 int maxLayerId_matched = 0;
1256 std::map<int, double> totenergy_layer;
1258 for (
auto const& sc : caloparticle.
simClusters()) {
1259 LogDebug(
"HGCalValidator") <<
" This sim cluster has " << sc->hits_and_fractions().size() <<
" simHits and "
1260 << sc->energy() <<
" energy. " << std::endl;
1261 simHits += sc->hits_and_fractions().size();
1262 for (
auto const& h_and_f : sc->hits_and_fractions()) {
1263 const auto hitDetId = h_and_f.first;
1267 int layerId_matched_min = 999;
1268 int layerId_matched_max = 0;
1269 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitDetId);
1270 if (itcheck != hitMap.end()) {
1271 layerId_matched_min = layerId;
1272 layerId_matched_max = layerId;
1276 energy +=
hit->energy() * h_and_f.second;
1277 histograms.h_caloparticle_nHits_matched_energy.at(
pdgid)->Fill(
hit->energy() * h_and_f.second);
1278 histograms.h_caloparticle_nHits_matched_energy_layer.at(
pdgid)->Fill(layerId,
hit->energy() * h_and_f.second);
1280 if (totenergy_layer.find(layerId) != totenergy_layer.end()) {
1281 totenergy_layer[layerId] = totenergy_layer.at(layerId) +
hit->energy();
1283 totenergy_layer.emplace(layerId,
hit->energy());
1286 histograms.h_caloparticle_nHits_matched_energy_layer_1SimCl.at(
pdgid)->Fill(layerId,
1287 hit->energy() * h_and_f.second);
1289 LogDebug(
"HGCalValidator") <<
" matched to RecHit NOT found !" << std::endl;
1292 minLayerId =
std::min(minLayerId, layerId);
1293 maxLayerId =
std::max(maxLayerId, layerId);
1294 minLayerId_matched =
std::min(minLayerId_matched, layerId_matched_min);
1295 maxLayerId_matched =
std::max(maxLayerId_matched, layerId_matched_max);
1297 LogDebug(
"HGCalValidator") << std::endl;
1301 histograms.h_caloparticle_layersnum.at(
pdgid)->Fill(
int(maxLayerId - minLayerId));
1303 histograms.h_caloparticle_firstlayer_matchedtoRecHit.at(
pdgid)->Fill(minLayerId_matched);
1304 histograms.h_caloparticle_lastlayer_matchedtoRecHit.at(
pdgid)->Fill(maxLayerId_matched);
1305 histograms.h_caloparticle_layersnum_matchedtoRecHit.at(
pdgid)->Fill(
int(maxLayerId_matched - minLayerId_matched));
1308 histograms.h_caloparticle_nHitsInSimClusters_matchedtoRecHit.at(
pdgid)->Fill((
float)simHits_matched);
1313 auto i = totenergy_layer.begin();
1314 double sum_energy = 0.0;
1315 while (
i != totenergy_layer.end()) {
1316 sum_energy +=
i->second;
1317 histograms.h_caloparticle_sum_energy_layer.at(
pdgid)->Fill(
i->first, sum_energy / caloparticle.
energy() * 100.);
1323 void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simcluster_histos(
const Histograms&
histograms,
1326 std::vector<int> thicknesses)
const {
1335 std::vector<int> tnscpl(1000, 0);
1338 std::map<std::string, int> tnscpthplus;
1339 tnscpthplus.clear();
1340 std::map<std::string, int> tnscpthminus;
1341 tnscpthminus.clear();
1343 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
1344 tnscpthplus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1345 tnscpthminus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1348 tnscpthplus.insert(std::pair<std::string, int>(
"mixed", 0));
1349 tnscpthminus.insert(std::pair<std::string, int>(
"mixed", 0));
1352 for (
unsigned int ic = 0; ic <
simclusters.size(); ++ic) {
1354 const auto& hitsAndFractions = sc.hits_and_fractions();
1357 int nthhits120p = 0;
1358 int nthhits200p = 0;
1359 int nthhits300p = 0;
1360 int nthhitsscintp = 0;
1361 int nthhits120m = 0;
1362 int nthhits200m = 0;
1363 int nthhits300m = 0;
1364 int nthhitsscintm = 0;
1368 std::vector<int> occurenceSCinlayer(1000, 0);
1371 for (
const auto& hAndF : hitsAndFractions) {
1372 const DetId sh_detid = hAndF.first;
1376 recHitTools_->getLayerWithOffset(sh_detid) +
layers * ((recHitTools_->zside(sh_detid) + 1) >> 1) - 1;
1378 int zside = recHitTools_->zside(sh_detid);
1381 if (occurenceSCinlayer[layerid] == 0) {
1384 occurenceSCinlayer[layerid]++;
1387 thickness = recHitTools_->getSiThickness(sh_detid);
1391 LogDebug(
"HGCalValidator") <<
"These are HGCal simclusters, you shouldn't be here !!! " << layerid <<
"\n";
1413 <<
" You are running a geometry that contains thicknesses different than the normal ones. "
1420 if ((nthhits120p != 0 && nthhits200p != 0) || (nthhits120p != 0 && nthhits300p != 0) ||
1421 (nthhits120p != 0 && nthhitsscintp != 0) || (nthhits200p != 0 && nthhits300p != 0) ||
1422 (nthhits200p != 0 && nthhitsscintp != 0) || (nthhits300p != 0 && nthhitsscintp != 0)) {
1423 tnscpthplus[
"mixed"]++;
1424 }
else if ((nthhits120p != 0 || nthhits200p != 0 || nthhits300p != 0 || nthhitsscintp != 0)) {
1426 tnscpthplus[std::to_string((
int)
thickness)]++;
1428 if ((nthhits120m != 0 && nthhits200m != 0) || (nthhits120m != 0 && nthhits300m != 0) ||
1429 (nthhits120m != 0 && nthhitsscintm != 0) || (nthhits200m != 0 && nthhits300m != 0) ||
1430 (nthhits200m != 0 && nthhitsscintm != 0) || (nthhits300m != 0 && nthhitsscintm != 0)) {
1431 tnscpthminus[
"mixed"]++;
1432 }
else if ((nthhits120m != 0 || nthhits200m != 0 || nthhits300m != 0 || nthhitsscintm != 0)) {
1434 tnscpthminus[std::to_string((
int)
thickness)]++;
1440 for (
unsigned ilayer = 0; ilayer <
layers * 2; ++ilayer) {
1441 if (
histograms.h_simclusternum_perlayer.count(ilayer)) {
1442 histograms.h_simclusternum_perlayer.at(ilayer)->Fill(tnscpl[ilayer]);
1447 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
1448 if (
histograms.h_simclusternum_perthick.count(*it)) {
1449 histograms.h_simclusternum_perthick.at(*it)->Fill(tnscpthplus[std::to_string(*it)]);
1450 histograms.h_simclusternum_perthick.at(*it)->Fill(tnscpthminus[std::to_string(*it)]);
1454 histograms.h_mixedhitssimcluster_zplus->Fill(tnscpthplus[
"mixed"]);
1455 histograms.h_mixedhitssimcluster_zminus->Fill(tnscpthminus[
"mixed"]);
1458 void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simclusterassosiation_histos(
1463 edm::Handle<std::vector<SimCluster>> simClusterHandle,
1465 std::vector<size_t>
const& sCIndices,
1466 const std::vector<float>& mask,
1467 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
1489 scsInLayerClusterMap,
1490 lcsInSimClusterMap);
1503 edm::Handle<std::vector<CaloParticle>> caloParticleHandle,
1504 std::vector<CaloParticle>
const& cP,
1505 std::vector<size_t>
const& cPIndices,
1506 std::vector<size_t>
const& cPSelectedIndices,
1507 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
1511 auto nLayerClusters =
clusters.size();
1513 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToCaloParticleId_Map;
1514 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToLayerClusterId_Map;
1518 for (
const auto& cpId : cPIndices) {
1520 for (
const auto& it_sc : simClusterRefVector) {
1523 for (
const auto& it_haf : hits_and_fractions) {
1524 DetId hitid = (it_haf.first);
1525 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
1526 if (itcheck != hitMap.end()) {
1527 auto hit_find_it = detIdToCaloParticleId_Map.find(hitid);
1528 if (hit_find_it == detIdToCaloParticleId_Map.end()) {
1529 detIdToCaloParticleId_Map[hitid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
1530 detIdToCaloParticleId_Map[hitid].emplace_back(
1533 auto findHitIt =
std::find(detIdToCaloParticleId_Map[hitid].begin(),
1534 detIdToCaloParticleId_Map[hitid].
end(),
1536 if (findHitIt != detIdToCaloParticleId_Map[hitid].
end()) {
1537 findHitIt->fraction += it_haf.second;
1539 detIdToCaloParticleId_Map[hitid].emplace_back(
1548 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
1549 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1550 unsigned int numberOfHitsInLC = hits_and_fractions.size();
1560 std::vector<int> hitsToCaloParticleId(numberOfHitsInLC);
1561 const auto firstHitDetId = hits_and_fractions[0].first;
1566 std::unordered_map<unsigned, float> CPEnergyInLC;
1568 for (
unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) {
1569 DetId rh_detid = hits_and_fractions[hitId].first;
1570 auto rhFraction = hits_and_fractions[hitId].second;
1572 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
1575 auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid);
1576 if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) {
1577 detIdToLayerClusterId_Map[rh_detid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
1581 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
1589 if (rhFraction == 0.) {
1590 hitsToCaloParticleId[hitId] = -2;
1592 if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) {
1593 hitsToCaloParticleId[hitId] -= 1;
1595 auto maxCPEnergyInLC = 0.f;
1597 for (
auto&
h : hit_find_in_CP->second) {
1598 CPEnergyInLC[
h.clusterId] +=
h.fraction *
hit->energy();
1601 if (CPEnergyInLC[
h.clusterId] > maxCPEnergyInLC) {
1602 maxCPEnergyInLC = CPEnergyInLC[
h.clusterId];
1603 maxCPId =
h.clusterId;
1606 hitsToCaloParticleId[hitId] = maxCPId;
1608 histograms.h_cellAssociation_perlayer.at(lcLayerId)->Fill(
1609 hitsToCaloParticleId[hitId] > 0. ? 0. : hitsToCaloParticleId[hitId]);
1617 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
1618 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1619 const auto firstHitDetId = hits_and_fractions[0].first;
1620 const int lcLayerId =
1626 const auto& cpsIt = cpsInLayerClusterMap.
find(lcRef);
1627 if (cpsIt == cpsInLayerClusterMap.
end())
1630 const auto& cps = cpsIt->
val;
1632 for (
const auto& cpPair : cps) {
1633 histograms.h_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(cpPair.second);
1637 for (
const auto& cpPair : cps) {
1638 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId <<
"\t CP id: \t" << cpPair.first.index()
1639 <<
"\t score \t" << cpPair.second << std::endl;
1640 histograms.h_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(cpPair.second);
1641 auto const& cp_linked =
1642 std::find_if(std::begin(cPOnLayerMap[cpPair.first]),
1643 std::end(cPOnLayerMap[cpPair.first]),
1645 return p.first == lcRef;
1648 cPOnLayerMap[cpPair.first].
end())
1650 histograms.h_sharedenergy_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(
1651 cp_linked->second.first /
clusters[lcId].energy(),
clusters[lcId].energy());
1652 histograms.h_energy_vs_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(
1653 cpPair.second, cp_linked->second.first /
clusters[lcId].energy());
1664 const auto& best = std::min_element(
1665 std::begin(cps),
std::end(cps), [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
1666 const auto& best_cp_linked =
1667 std::find_if(std::begin(cPOnLayerMap[best->first]),
1668 std::end(cPOnLayerMap[best->first]),
1670 return p.first == lcRef;
1672 if (best_cp_linked ==
1673 cPOnLayerMap[best->first].
end())
1675 histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer.at(lcLayerId)->Fill(
1677 histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer.at(lcLayerId)->Fill(
1685 for (
const auto& cpId : cPSelectedIndices) {
1687 const auto& lcsIt = cPOnLayerMap.
find(cpRef);
1689 std::map<unsigned int, float> cPEnergyOnLayer;
1690 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId)
1691 cPEnergyOnLayer[layerId] = 0;
1694 for (
const auto& it_sc : simClusterRefVector) {
1697 for (
const auto& it_haf : hits_and_fractions) {
1698 const DetId hitid = (it_haf.first);
1699 const int cpLayerId =
1701 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
1702 if (itcheck != hitMap.end()) {
1704 cPEnergyOnLayer[cpLayerId] += it_haf.second *
hit->energy();
1709 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId) {
1710 if (!cPEnergyOnLayer[layerId])
1713 histograms.h_denom_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1714 histograms.h_denom_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1716 if (lcsIt == cPOnLayerMap.
end())
1718 const auto& lcs = lcsIt->val;
1720 auto getLCLayerId = [&](
const unsigned int lcId) {
1721 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1722 const auto firstHitDetId = hits_and_fractions[0].first;
1723 const unsigned int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) +
1728 for (
const auto& lcPair : lcs) {
1729 if (getLCLayerId(lcPair.first.index()) != layerId)
1731 histograms.h_score_caloparticle2layercl_perlayer.at(layerId)->Fill(lcPair.second.second);
1732 histograms.h_sharedenergy_caloparticle2layercl_perlayer.at(layerId)->Fill(
1733 lcPair.second.first / cPEnergyOnLayer[layerId], cPEnergyOnLayer[layerId]);
1734 histograms.h_energy_vs_score_caloparticle2layercl_perlayer.at(layerId)->Fill(
1735 lcPair.second.second, lcPair.second.first / cPEnergyOnLayer[layerId]);
1737 const auto assoc = std::count_if(std::begin(lcs),
std::end(lcs), [&](
const auto&
obj) {
1738 if (getLCLayerId(
obj.first.index()) != layerId)
1744 histograms.h_num_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1745 histograms.h_num_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1747 histograms.h_numDup_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1748 histograms.h_numDup_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1750 const auto best = std::min_element(std::begin(lcs),
std::end(lcs), [&](
const auto& obj1,
const auto& obj2) {
1751 if (getLCLayerId(obj1.first.index()) != layerId)
1753 else if (getLCLayerId(obj2.first.index()) == layerId)
1754 return obj1.second.second < obj2.second.second;
1758 histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer.at(layerId)->Fill(
1759 cP[cpId].g4Tracks()[0].momentum().
eta(), best->second.first / cPEnergyOnLayer[layerId]);
1760 histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer.at(layerId)->Fill(
1761 cP[cpId].g4Tracks()[0].momentum().
phi(), best->second.first / cPEnergyOnLayer[layerId]);
1772 edm::Handle<std::vector<SimCluster>> simClusterHandle,
1773 std::vector<SimCluster>
const& sC,
1774 std::vector<size_t>
const& sCIndices,
1775 const std::vector<float>& mask,
1776 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
1780 auto nLayerClusters =
clusters.size();
1785 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
1786 if (mask[lcId] != 0.) {
1787 LogDebug(
"HGCalValidator") <<
"Skipping layer cluster " << lcId <<
" not belonging to mask" << std::endl;
1790 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1791 const auto firstHitDetId = hits_and_fractions[0].first;
1792 const int lcLayerId =
1800 const auto& scsIt = scsInLayerClusterMap.
find(lcRef);
1801 if (scsIt == scsInLayerClusterMap.
end())
1804 const auto& scs = scsIt->
val;
1808 for (
const auto& scPair : scs) {
1809 histograms.h_score_layercl2simcluster_perlayer[
count].at(lcLayerId)->Fill(scPair.second);
1814 for (
const auto& scPair : scs) {
1815 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId <<
"\t SC id: \t" << scPair.first.index()
1816 <<
"\t score \t" << scPair.second << std::endl;
1818 histograms.h_score_layercl2simcluster_perlayer[
count].at(lcLayerId)->Fill(scPair.second);
1819 auto const& sc_linked =
1820 std::find_if(std::begin(lcsInSimClusterMap[scPair.first]),
1821 std::end(lcsInSimClusterMap[scPair.first]),
1823 return p.first == lcRef;
1826 lcsInSimClusterMap[scPair.first].
end())
1828 histograms.h_sharedenergy_layercl2simcluster_perlayer[
count].at(lcLayerId)->Fill(
1829 sc_linked->second.first /
clusters[lcId].energy(),
clusters[lcId].energy());
1830 histograms.h_energy_vs_score_layercl2simcluster_perlayer[
count].at(lcLayerId)->Fill(
1831 scPair.second, sc_linked->second.first /
clusters[lcId].energy());
1843 const auto& best = std::min_element(
1844 std::begin(scs),
std::end(scs), [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
1846 const auto& best_sc_linked =
1847 std::find_if(std::begin(lcsInSimClusterMap[best->first]),
1848 std::end(lcsInSimClusterMap[best->first]),
1850 return p.first == lcRef;
1852 if (best_sc_linked ==
1853 lcsInSimClusterMap[best->first].
end())
1855 histograms.h_sharedenergy_layercl2simcluster_vs_eta_perlayer[
count].at(lcLayerId)->Fill(
1857 histograms.h_sharedenergy_layercl2simcluster_vs_phi_perlayer[
count].at(lcLayerId)->Fill(
1865 for (
const auto& scId : sCIndices) {
1867 const auto& lcsIt = lcsInSimClusterMap.
find(scRef);
1869 std::map<unsigned int, float> sCEnergyOnLayer;
1870 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId)
1871 sCEnergyOnLayer[layerId] = 0;
1873 const auto& hits_and_fractions = sC[scId].hits_and_fractions();
1874 for (
const auto& it_haf : hits_and_fractions) {
1875 const DetId hitid = (it_haf.first);
1876 const int scLayerId =
1878 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
1879 if (itcheck != hitMap.end()) {
1881 sCEnergyOnLayer[scLayerId] += it_haf.second *
hit->energy();
1885 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId) {
1886 if (!sCEnergyOnLayer[layerId])
1892 if (lcsIt == lcsInSimClusterMap.
end())
1894 const auto& lcs = lcsIt->val;
1896 auto getLCLayerId = [&](
const unsigned int lcId) {
1897 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1898 const auto firstHitDetId = hits_and_fractions[0].first;
1899 const unsigned int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) +
1905 for (
const auto& lcPair : lcs) {
1906 auto lcId = lcPair.first.index();
1907 if (mask[lcId] != 0.) {
1908 LogDebug(
"HGCalValidator") <<
"Skipping layer cluster " << lcId <<
" not belonging to mask" << std::endl;
1912 if (getLCLayerId(lcId) != layerId)
1914 histograms.h_score_simcluster2layercl_perlayer[
count].at(layerId)->Fill(lcPair.second.second);
1915 histograms.h_sharedenergy_simcluster2layercl_perlayer[
count].at(layerId)->Fill(
1916 lcPair.second.first / sCEnergyOnLayer[layerId], sCEnergyOnLayer[layerId]);
1917 histograms.h_energy_vs_score_simcluster2layercl_perlayer[
count].at(layerId)->Fill(
1918 lcPair.second.second, lcPair.second.first / sCEnergyOnLayer[layerId]);
1920 const auto assoc = std::count_if(std::begin(lcs),
std::end(lcs), [&](
const auto&
obj) {
1921 if (getLCLayerId(
obj.first.index()) != layerId)
1930 histograms.h_numDup_simcluster_eta_perlayer[
count].at(layerId)->Fill(sC[scId].
eta());
1931 histograms.h_numDup_simcluster_phi_perlayer[
count].at(layerId)->Fill(sC[scId].
phi());
1933 const auto best = std::min_element(std::begin(lcs),
std::end(lcs), [&](
const auto& obj1,
const auto& obj2) {
1934 if (getLCLayerId(obj1.first.index()) != layerId)
1936 else if (getLCLayerId(obj2.first.index()) == layerId)
1937 return obj1.second.second < obj2.second.second;
1941 histograms.h_sharedenergy_simcluster2layercl_vs_eta_perlayer[
count].at(layerId)->Fill(
1942 sC[scId].
eta(), best->second.first / sCEnergyOnLayer[layerId]);
1943 histograms.h_sharedenergy_simcluster2layercl_vs_phi_perlayer[
count].at(layerId)->Fill(
1944 sC[scId].
phi(), best->second.first / sCEnergyOnLayer[layerId]);
1955 edm::Handle<std::vector<CaloParticle>> caloParticleHandle,
1956 std::vector<CaloParticle>
const& cP,
1957 std::vector<size_t>
const& cPIndices,
1958 std::vector<size_t>
const& cPSelectedIndices,
1959 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
1960 std::map<double, double> cummatbudg,
1962 std::vector<int> thicknesses,
1973 std::vector<int> tnlcpl(1000, 0);
1976 std::map<std::string, int> tnlcpthplus;
1977 tnlcpthplus.clear();
1978 std::map<std::string, int> tnlcpthminus;
1979 tnlcpthminus.clear();
1981 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
1982 tnlcpthplus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1983 tnlcpthminus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1986 tnlcpthplus.insert(std::pair<std::string, int>(
"mixed", 0));
1987 tnlcpthminus.insert(std::pair<std::string, int>(
"mixed", 0));
1998 cpsInLayerClusterMap,
2003 std::vector<double> tecpl(1000, 0.0);
2005 std::vector<double> ldbar(1000, 0.0);
2008 double caloparteneplus = 0.;
2009 double caloparteneminus = 0.;
2010 for (
const auto& cpId : cPIndices) {
2011 if (cP[cpId].
eta() >= 0.) {
2012 caloparteneplus = caloparteneplus + cP[cpId].energy();
2014 if (cP[cpId].
eta() < 0.) {
2015 caloparteneminus = caloparteneminus + cP[cpId].energy();
2020 for (
unsigned int layerclusterIndex = 0; layerclusterIndex <
clusters.size(); layerclusterIndex++) {
2021 const std::vector<std::pair<DetId, float>> hits_and_fractions =
clusters[layerclusterIndex].hitsAndFractions();
2024 const double seedx =
recHitTools_->getPosition(seedid).x();
2025 const double seedy =
recHitTools_->getPosition(seedid).y();
2033 int nthhits120p = 0;
2034 int nthhits200p = 0;
2035 int nthhits300p = 0;
2036 int nthhitsscintp = 0;
2037 int nthhits120m = 0;
2038 int nthhits200m = 0;
2039 int nthhits300m = 0;
2040 int nthhitsscintm = 0;
2051 bool cluslay =
true;
2055 for (
std::vector<std::pair<DetId, float>>::const_iterator it_haf = hits_and_fractions.begin();
2056 it_haf != hits_and_fractions.end();
2058 const DetId rh_detid = it_haf->first;
2068 LogDebug(
"HGCalValidator") <<
"These are HGCal layer clusters, you shouldn't be here !!! " << layerid <<
"\n";
2075 while (lay_string.size() < 2)
2076 lay_string.insert(0,
"0");
2077 curistr +=
"_" + lay_string;
2102 <<
" You are running a geometry that contains thicknesses different than the normal ones. "
2106 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
2107 if (itcheck == hitMap.end()) {
2108 LogDebug(
"HGCalValidator") <<
" You shouldn't be here - Unable to find a hit " << rh_detid.
rawId() <<
" "
2117 const double hit_x =
recHitTools_->getPosition(rh_detid).x();
2118 const double hit_y =
recHitTools_->getPosition(rh_detid).y();
2119 double distancetoseed =
distance(seedx, seedy, hit_x, hit_y);
2120 double distancetomax =
distance(maxx, maxy, hit_x, hit_y);
2121 if (distancetoseed != 0. &&
histograms.h_distancetoseedcell_perthickperlayer.count(curistr)) {
2122 histograms.h_distancetoseedcell_perthickperlayer.at(curistr)->Fill(distancetoseed);
2125 if (distancetoseed != 0. &&
histograms.h_distancetoseedcell_perthickperlayer_eneweighted.count(curistr)) {
2126 histograms.h_distancetoseedcell_perthickperlayer_eneweighted.at(curistr)->Fill(distancetoseed,
hit->energy());
2129 if (distancetomax != 0. &&
histograms.h_distancetomaxcell_perthickperlayer.count(curistr)) {
2130 histograms.h_distancetomaxcell_perthickperlayer.at(curistr)->Fill(distancetomax);
2133 if (distancetomax != 0. &&
histograms.h_distancetomaxcell_perthickperlayer_eneweighted.count(curistr)) {
2134 histograms.h_distancetomaxcell_perthickperlayer_eneweighted.at(curistr)->Fill(distancetomax,
hit->energy());
2138 std::map<DetId, float>::const_iterator dit = densities.find(rh_detid);
2139 if (dit == densities.end()) {
2140 LogDebug(
"HGCalValidator") <<
" You shouldn't be here - Unable to find a density " << rh_detid.
rawId() <<
" "
2152 if ((nthhits120p != 0 && nthhits200p != 0) || (nthhits120p != 0 && nthhits300p != 0) ||
2153 (nthhits120p != 0 && nthhitsscintp != 0) || (nthhits200p != 0 && nthhits300p != 0) ||
2154 (nthhits200p != 0 && nthhitsscintp != 0) || (nthhits300p != 0 && nthhitsscintp != 0)) {
2155 tnlcpthplus[
"mixed"]++;
2156 }
else if ((nthhits120p != 0 || nthhits200p != 0 || nthhits300p != 0 || nthhitsscintp != 0)) {
2158 tnlcpthplus[std::to_string((
int)
thickness)]++;
2160 if ((nthhits120m != 0 && nthhits200m != 0) || (nthhits120m != 0 && nthhits300m != 0) ||
2161 (nthhits120m != 0 && nthhitsscintm != 0) || (nthhits200m != 0 && nthhits300m != 0) ||
2162 (nthhits200m != 0 && nthhitsscintm != 0) || (nthhits300m != 0 && nthhitsscintm != 0)) {
2163 tnlcpthminus[
"mixed"]++;
2164 }
else if ((nthhits120m != 0 || nthhits200m != 0 || nthhits300m != 0 || nthhitsscintm != 0)) {
2166 tnlcpthminus[std::to_string((
int)
thickness)]++;
2170 std::vector<int> bigamoth;
2173 bigamoth.push_back(nthhits120p);
2174 bigamoth.push_back(nthhits200p);
2175 bigamoth.push_back(nthhits300p);
2176 bigamoth.push_back(nthhitsscintp);
2179 bigamoth.push_back(nthhits120m);
2180 bigamoth.push_back(nthhits200m);
2181 bigamoth.push_back(nthhits300m);
2182 bigamoth.push_back(nthhitsscintm);
2184 auto bgth = std::max_element(bigamoth.begin(), bigamoth.end());
2185 istr = std::to_string(thicknesses[
std::distance(bigamoth.begin(), bgth)]);
2187 while (lay_string.size() < 2)
2188 lay_string.insert(0,
"0");
2189 istr +=
"_" + lay_string;
2192 if (
histograms.h_cellsnum_perthickperlayer.count(istr)) {
2193 histograms.h_cellsnum_perthickperlayer.at(istr)->Fill(hits_and_fractions.size());
2197 double distancebetseedandmax =
distance(seedx, seedy, maxx, maxy);
2199 std::string seedstr = std::to_string((
int)
recHitTools_->getSiThickness(seedid)) +
"_" + std::to_string(layerid);
2200 seedstr +=
"_" + lay_string;
2201 if (
histograms.h_distancebetseedandmaxcell_perthickperlayer.count(seedstr)) {
2202 histograms.h_distancebetseedandmaxcell_perthickperlayer.at(seedstr)->Fill(distancebetseedandmax);
2204 if (
histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer.count(seedstr)) {
2205 histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer.at(seedstr)->Fill(
2210 tecpl[layerid] = tecpl[layerid] +
clusters[layerclusterIndex].energy();
2211 ldbar[layerid] = ldbar[layerid] +
clusters[layerclusterIndex].energy() * cummatbudg[(double)lay];
2217 double sumeneallcluspl = 0.;
2218 double sumeneallclusmi = 0.;
2220 double sumldbarpl = 0.;
2221 double sumldbarmi = 0.;
2223 for (
unsigned ilayer = 0; ilayer <
layers * 2; ++ilayer) {
2224 if (
histograms.h_clusternum_perlayer.count(ilayer)) {
2225 histograms.h_clusternum_perlayer.at(ilayer)->Fill(tnlcpl[ilayer]);
2230 if (
histograms.h_energyclustered_perlayer.count(ilayer)) {
2231 if (caloparteneminus != 0.) {
2232 histograms.h_energyclustered_perlayer.at(ilayer)->Fill(100. * tecpl[ilayer] / caloparteneminus);
2236 sumeneallclusmi = sumeneallclusmi + tecpl[ilayer];
2238 sumldbarmi = sumldbarmi + ldbar[ilayer];
2240 if (
histograms.h_energyclustered_perlayer.count(ilayer)) {
2241 if (caloparteneplus != 0.) {
2242 histograms.h_energyclustered_perlayer.at(ilayer)->Fill(100. * tecpl[ilayer] / caloparteneplus);
2246 sumeneallcluspl = sumeneallcluspl + tecpl[ilayer];
2248 sumldbarpl = sumldbarpl + ldbar[ilayer];
2254 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
2255 if (
histograms.h_clusternum_perthick.count(*it)) {
2256 histograms.h_clusternum_perthick.at(*it)->Fill(tnlcpthplus[std::to_string(*it)]);
2257 histograms.h_clusternum_perthick.at(*it)->Fill(tnlcpthminus[std::to_string(*it)]);
2261 histograms.h_mixedhitscluster_zplus[
count]->Fill(tnlcpthplus[
"mixed"]);
2262 histograms.h_mixedhitscluster_zminus[
count]->Fill(tnlcpthminus[
"mixed"]);
2265 if (caloparteneplus != 0.) {
2266 histograms.h_energyclustered_zplus[
count]->Fill(100. * sumeneallcluspl / caloparteneplus);
2268 if (caloparteneminus != 0.) {
2269 histograms.h_energyclustered_zminus[
count]->Fill(100. * sumeneallclusmi / caloparteneminus);
2273 histograms.h_longdepthbarycentre_zplus[
count]->Fill(sumldbarpl / sumeneallcluspl);
2274 histograms.h_longdepthbarycentre_zminus[
count]->Fill(sumldbarmi / sumeneallclusmi);
2279 const std::vector<reco::HGCalMultiCluster>& multiClusters,
2280 std::vector<CaloParticle>
const& cP,
2281 std::vector<size_t>
const& cPIndices,
2282 std::vector<size_t>
const& cPSelectedIndices,
2283 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
2284 unsigned int layers)
const {
2285 auto nMultiClusters = multiClusters.size();
2287 auto nCaloParticles = cPIndices.size();
2289 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToCaloParticleId_Map;
2290 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInMultiCluster>> detIdToMultiClusterId_Map;
2291 std::vector<int> tracksters_fakemerge(nMultiClusters, 0);
2292 std::vector<int> tracksters_duplicate(nMultiClusters, 0);
2297 std::vector<std::vector<std::pair<unsigned int, float>>> cpsInMultiCluster;
2298 cpsInMultiCluster.resize(nMultiClusters);
2307 std::unordered_map<int, std::vector<caloParticleOnLayer>> cPOnLayer;
2308 for (
unsigned int i = 0;
i < nCaloParticles; ++
i) {
2309 auto cpIndex = cPIndices[
i];
2310 cPOnLayer[cpIndex].resize(
layers * 2);
2311 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2312 cPOnLayer[cpIndex][
j].caloParticleId = cpIndex;
2313 cPOnLayer[cpIndex][
j].energy = 0.f;
2314 cPOnLayer[cpIndex][
j].hits_and_fractions.clear();
2318 for (
const auto& cpId : cPIndices) {
2322 for (
const auto& it_sc : simClusterRefVector) {
2325 for (
const auto& it_haf : hits_and_fractions) {
2326 DetId hitid = (it_haf.first);
2330 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
2332 if (itcheck != hitMap.end()) {
2341 auto hit_find_it = detIdToCaloParticleId_Map.find(hitid);
2342 if (hit_find_it == detIdToCaloParticleId_Map.end()) {
2343 detIdToCaloParticleId_Map[hitid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
2344 detIdToCaloParticleId_Map[hitid].emplace_back(
2347 auto findHitIt =
std::find(detIdToCaloParticleId_Map[hitid].begin(),
2348 detIdToCaloParticleId_Map[hitid].
end(),
2350 if (findHitIt != detIdToCaloParticleId_Map[hitid].
end()) {
2351 findHitIt->fraction += it_haf.second;
2353 detIdToCaloParticleId_Map[hitid].emplace_back(
2360 cPOnLayer[cpId][cpLayerId].energy += it_haf.second *
hit->energy();
2367 auto& haf = cPOnLayer[cpId][cpLayerId].hits_and_fractions;
2368 auto found = std::find_if(
2369 std::begin(haf),
std::end(haf), [&hitid](
const std::pair<DetId, float>&
v) {
return v.first == hitid; });
2370 if (
found != haf.end()) {
2371 found->second += it_haf.second;
2373 cPOnLayer[cpId][cpLayerId].hits_and_fractions.emplace_back(hitid, it_haf.second);
2381 for (
unsigned int mclId = 0; mclId < nMultiClusters; ++mclId) {
2382 const auto& hits_and_fractions = multiClusters[mclId].hitsAndFractions();
2383 if (!hits_and_fractions.empty()) {
2384 std::unordered_map<unsigned, float> CPEnergyInMCL;
2385 int maxCPId_byNumberOfHits = -1;
2386 unsigned int maxCPNumberOfHitsInMCL = 0;
2387 int maxCPId_byEnergy = -1;
2388 float maxEnergySharedMCLandCP = 0.f;
2389 float energyFractionOfMCLinCP = 0.f;
2390 float energyFractionOfCPinMCL = 0.f;
2397 std::unordered_map<unsigned, unsigned> occurrencesCPinMCL;
2398 unsigned int numberOfNoiseHitsInMCL = 0;
2399 unsigned int numberOfHaloHitsInMCL = 0;
2400 unsigned int numberOfHitsInMCL = 0;
2403 unsigned int numberOfHitsInLC = hits_and_fractions.size();
2404 numberOfHitsInMCL += numberOfHitsInLC;
2405 std::unordered_map<unsigned, float> CPEnergyInLC;
2424 std::vector<int> hitsToCaloParticleId(numberOfHitsInLC);
2427 const auto firstHitDetId = hits_and_fractions[0].first;
2428 int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) +
2432 for (
unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) {
2433 DetId rh_detid = hits_and_fractions[hitId].first;
2434 auto rhFraction = hits_and_fractions[hitId].second;
2437 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
2447 auto hit_find_in_LC = detIdToMultiClusterId_Map.find(rh_detid);
2448 if (hit_find_in_LC == detIdToMultiClusterId_Map.end()) {
2449 detIdToMultiClusterId_Map[rh_detid] = std::vector<HGVHistoProducerAlgo::detIdInfoInMultiCluster>();
2451 detIdToMultiClusterId_Map[rh_detid].emplace_back(
2455 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
2463 if (rhFraction == 0.) {
2464 hitsToCaloParticleId[hitId] = -2;
2465 numberOfHaloHitsInMCL++;
2467 if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) {
2468 hitsToCaloParticleId[hitId] -= 1;
2470 auto maxCPEnergyInLC = 0.f;
2472 for (
auto&
h : hit_find_in_CP->second) {
2473 auto shared_fraction =
std::min(rhFraction,
h.fraction);
2478 CPEnergyInMCL[
h.clusterId] += shared_fraction *
hit->energy();
2480 CPEnergyInLC[
h.clusterId] += shared_fraction *
hit->energy();
2483 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[mclId].first +=
2484 shared_fraction *
hit->energy();
2485 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[mclId].second = FLT_MAX;
2488 cpsInMultiCluster[mclId].emplace_back(
h.clusterId, FLT_MAX);
2491 if (shared_fraction > maxCPEnergyInLC) {
2493 maxCPEnergyInLC = CPEnergyInLC[
h.clusterId];
2494 maxCPId =
h.clusterId;
2498 hitsToCaloParticleId[hitId] = maxCPId;
2505 for (
auto c : hitsToCaloParticleId) {
2507 numberOfNoiseHitsInMCL++;
2509 occurrencesCPinMCL[
c]++;
2515 for (
auto&
c : occurrencesCPinMCL) {
2516 if (
c.second > maxCPNumberOfHitsInMCL) {
2517 maxCPId_byNumberOfHits =
c.first;
2518 maxCPNumberOfHitsInMCL =
c.second;
2523 for (
auto&
c : CPEnergyInMCL) {
2524 if (
c.second > maxEnergySharedMCLandCP) {
2525 maxCPId_byEnergy =
c.first;
2526 maxEnergySharedMCLandCP =
c.second;
2530 float totalCPEnergyFromLayerCP = 0.f;
2531 if (maxCPId_byEnergy >= 0) {
2533 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2534 totalCPEnergyFromLayerCP = totalCPEnergyFromLayerCP + cPOnLayer[maxCPId_byEnergy][
j].energy;
2536 energyFractionOfCPinMCL = maxEnergySharedMCLandCP / totalCPEnergyFromLayerCP;
2537 if (multiClusters[mclId].
energy() > 0.
f) {
2538 energyFractionOfMCLinCP = maxEnergySharedMCLandCP / multiClusters[mclId].energy();
2542 LogDebug(
"HGCalValidator") << std::setw(12) <<
"multiCluster"
2544 << std::setw(10) <<
"mulcl energy"
2545 <<
"\t" << std::setw(5) <<
"nhits"
2546 <<
"\t" << std::setw(12) <<
"noise hits"
2547 <<
"\t" << std::setw(22) <<
"maxCPId_byNumberOfHits"
2548 <<
"\t" << std::setw(8) <<
"nhitsCP"
2549 <<
"\t" << std::setw(16) <<
"maxCPId_byEnergy"
2550 <<
"\t" << std::setw(23) <<
"maxEnergySharedMCLandCP"
2551 <<
"\t" << std::setw(22) <<
"totalCPEnergyFromAllLayerCP"
2552 <<
"\t" << std::setw(22) <<
"energyFractionOfMCLinCP"
2553 <<
"\t" << std::setw(25) <<
"energyFractionOfCPinMCL"
2554 <<
"\t" << std::endl;
2555 LogDebug(
"HGCalValidator") << std::setw(12) << mclId <<
"\t"
2556 << std::setw(10) << multiClusters[mclId].energy() <<
"\t" << std::setw(5)
2557 << numberOfHitsInMCL <<
"\t" << std::setw(12) << numberOfNoiseHitsInMCL <<
"\t"
2558 << std::setw(22) << maxCPId_byNumberOfHits <<
"\t" << std::setw(8)
2559 << maxCPNumberOfHitsInMCL <<
"\t" << std::setw(16) << maxCPId_byEnergy <<
"\t"
2560 << std::setw(23) << maxEnergySharedMCLandCP <<
"\t" << std::setw(22)
2561 << totalCPEnergyFromLayerCP <<
"\t" << std::setw(22) << energyFractionOfMCLinCP <<
"\t"
2562 << std::setw(25) << energyFractionOfCPinMCL << std::endl;
2567 for (
unsigned int mclId = 0; mclId < nMultiClusters; ++mclId) {
2568 const auto& hits_and_fractions = multiClusters[mclId].hitsAndFractions();
2569 if (!hits_and_fractions.empty()) {
2572 std::sort(cpsInMultiCluster[mclId].begin(), cpsInMultiCluster[mclId].
end());
2573 auto last =
std::unique(cpsInMultiCluster[mclId].begin(), cpsInMultiCluster[mclId].
end());
2574 cpsInMultiCluster[mclId].erase(
last, cpsInMultiCluster[mclId].
end());
2576 if (multiClusters[mclId].
energy() == 0. && !cpsInMultiCluster[mclId].
empty()) {
2578 for (
auto& cpPair : cpsInMultiCluster[mclId]) {
2581 LogDebug(
"HGCalValidator") <<
"multiCluster Id: \t" << mclId <<
"\t CP id: \t" << cpPair.first
2582 <<
"\t score \t" << cpPair.second << std::endl;
2589 float invMultiClusterEnergyWeight = 0.f;
2590 for (
auto const& haf : multiClusters[mclId].hitsAndFractions()) {
2591 invMultiClusterEnergyWeight +=
2592 (haf.second * hitMap.at(haf.first)->energy()) * (haf.second * hitMap.at(haf.first)->energy());
2594 invMultiClusterEnergyWeight = 1.f / invMultiClusterEnergyWeight;
2596 unsigned int numberOfHitsInLC = hits_and_fractions.size();
2597 for (
unsigned int i = 0;
i < numberOfHitsInLC; ++
i) {
2598 DetId rh_detid = hits_and_fractions[
i].first;
2599 float rhFraction = hits_and_fractions[
i].second;
2600 bool hitWithNoCP =
false;
2602 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
2603 if (hit_find_in_CP == detIdToCaloParticleId_Map.end())
2605 auto itcheck = hitMap.find(rh_detid);
2607 float hitEnergyWeight =
hit->energy() *
hit->energy();
2609 for (
auto& cpPair : cpsInMultiCluster[mclId]) {
2610 float cpFraction = 0.f;
2612 auto findHitIt =
std::find(detIdToCaloParticleId_Map[rh_detid].begin(),
2613 detIdToCaloParticleId_Map[rh_detid].
end(),
2615 if (findHitIt != detIdToCaloParticleId_Map[rh_detid].
end()) {
2616 cpFraction = findHitIt->fraction;
2619 if (cpPair.second == FLT_MAX) {
2620 cpPair.second = 0.f;
2623 (rhFraction - cpFraction) * (rhFraction - cpFraction) * hitEnergyWeight * invMultiClusterEnergyWeight;
2628 if (cpsInMultiCluster[mclId].
empty())
2629 LogDebug(
"HGCalValidator") <<
"multiCluster Id: \t" << mclId <<
"\tCP id:\t-1 "
2633 auto score = std::min_element(std::begin(cpsInMultiCluster[mclId]),
2634 std::end(cpsInMultiCluster[mclId]),
2635 [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
2636 for (
auto& cpPair : cpsInMultiCluster[mclId]) {
2641 LogDebug(
"HGCalValidator") <<
"multiCluster Id: \t" << mclId <<
"\t CP id: \t" << cpPair.first <<
"\t score \t"
2642 << cpPair.second << std::endl;
2643 if (cpPair.first ==
score->first) {
2646 float sharedeneCPallLayers = 0.;
2648 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2649 auto const& cp_linked = cPOnLayer[cpPair.first][
j].layerClusterIdToEnergyAndScore[mclId];
2650 sharedeneCPallLayers += cp_linked.first;
2652 LogDebug(
"HGCalValidator") <<
"sharedeneCPallLayers " << sharedeneCPallLayers << std::endl;
2653 if (cpPair.first ==
score->first) {
2654 histograms.h_sharedenergy_multicl2caloparticle[
count]->Fill(sharedeneCPallLayers /
2655 multiClusters[mclId].
energy());
2657 score->second, sharedeneCPallLayers / multiClusters[mclId].energy());
2660 auto assocFakeMerge = std::count_if(std::begin(cpsInMultiCluster[mclId]),
2661 std::end(cpsInMultiCluster[mclId]),
2663 tracksters_fakemerge[mclId] = assocFakeMerge;
2667 std::unordered_map<int, std::vector<float>> score3d;
2668 std::unordered_map<int, std::vector<float>> mclsharedenergy;
2669 std::unordered_map<int, std::vector<float>> mclsharedenergyfrac;
2671 for (
unsigned int i = 0;
i < nCaloParticles; ++
i) {
2672 auto cpIndex = cPIndices[
i];
2673 score3d[cpIndex].resize(nMultiClusters);
2674 mclsharedenergy[cpIndex].resize(nMultiClusters);
2675 mclsharedenergyfrac[cpIndex].resize(nMultiClusters);
2676 for (
unsigned int j = 0;
j < nMultiClusters; ++
j) {
2677 score3d[cpIndex][
j] = FLT_MAX;
2678 mclsharedenergy[cpIndex][
j] = 0.f;
2679 mclsharedenergyfrac[cpIndex][
j] = 0.f;
2686 for (
const auto& cpId : cPSelectedIndices) {
2689 std::vector<unsigned int> cpId_mclId_related;
2690 cpId_mclId_related.clear();
2692 float CPenergy = 0.f;
2693 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId) {
2694 unsigned int CPNumberOfHits = cPOnLayer[cpId][layerId].hits_and_fractions.size();
2696 CPenergy += cPOnLayer[cpId][layerId].energy;
2697 if (CPNumberOfHits == 0)
2699 int mclWithMaxEnergyInCP = -1;
2701 float maxEnergyMCLperlayerinCP = 0.f;
2702 float CPEnergyFractionInMCLperlayer = 0.f;
2704 for (
const auto& mcl : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2705 if (mcl.second.first > maxEnergyMCLperlayerinCP) {
2706 maxEnergyMCLperlayerinCP = mcl.second.first;
2707 mclWithMaxEnergyInCP = mcl.first;
2711 CPEnergyFractionInMCLperlayer = maxEnergyMCLperlayerinCP / CPenergy;
2713 LogDebug(
"HGCalValidator") << std::setw(8) <<
"LayerId:\t" << std::setw(12) <<
"caloparticle\t" << std::setw(15)
2714 <<
"cp total energy\t" << std::setw(15) <<
"cpEnergyOnLayer\t" << std::setw(14)
2715 <<
"CPNhitsOnLayer\t" << std::setw(18) <<
"mclWithMaxEnergyInCP\t" << std::setw(15)
2716 <<
"maxEnergyMCLinCP\t" << std::setw(20) <<
"CPEnergyFractionInMCL"
2718 LogDebug(
"HGCalValidator") << std::setw(8) << layerId <<
"\t" << std::setw(12) << cpId <<
"\t" << std::setw(15)
2719 << cP[cpId].energy() <<
"\t" << std::setw(15) << CPenergy <<
"\t" << std::setw(14)
2720 << CPNumberOfHits <<
"\t" << std::setw(18) << mclWithMaxEnergyInCP <<
"\t"
2721 << std::setw(15) << maxEnergyMCLperlayerinCP <<
"\t" << std::setw(20)
2722 << CPEnergyFractionInMCLperlayer <<
"\n";
2724 for (
unsigned int i = 0;
i < CPNumberOfHits; ++
i) {
2725 auto& cp_hitDetId = cPOnLayer[cpId][layerId].hits_and_fractions[
i].first;
2726 auto& cpFraction = cPOnLayer[cpId][layerId].hits_and_fractions[
i].second;
2728 bool hitWithNoMCL =
false;
2729 if (cpFraction == 0.
f)
2731 auto hit_find_in_MCL = detIdToMultiClusterId_Map.find(cp_hitDetId);
2732 if (hit_find_in_MCL == detIdToMultiClusterId_Map.end())
2733 hitWithNoMCL =
true;
2734 auto itcheck = hitMap.find(cp_hitDetId);
2736 float hitEnergyWeight =
hit->energy() *
hit->energy();
2737 for (
auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2738 unsigned int multiClusterId = lcPair.first;
2739 if (
std::find(std::begin(cpId_mclId_related),
std::end(cpId_mclId_related), multiClusterId) ==
2741 cpId_mclId_related.push_back(multiClusterId);
2743 float mclFraction = 0.f;
2745 if (!hitWithNoMCL) {
2746 auto findHitIt =
std::find(detIdToMultiClusterId_Map[cp_hitDetId].begin(),
2747 detIdToMultiClusterId_Map[cp_hitDetId].
end(),
2749 if (findHitIt != detIdToMultiClusterId_Map[cp_hitDetId].
end())
2750 mclFraction = findHitIt->fraction;
2754 if (lcPair.second.second == FLT_MAX) {
2755 lcPair.second.second = 0.f;
2757 lcPair.second.second += (mclFraction - cpFraction) * (mclFraction - cpFraction) * hitEnergyWeight;
2758 LogDebug(
"HGCalValidator") <<
"multiClusterId:\t" << multiClusterId <<
"\t"
2759 <<
"mclfraction,cpfraction:\t" << mclFraction <<
", " << cpFraction <<
"\t"
2760 <<
"hitEnergyWeight:\t" << hitEnergyWeight <<
"\t"
2761 <<
"currect score numerator:\t" << lcPair.second.second <<
"\n";
2765 if (cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore.empty())
2766 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\t MCL id:\t-1 "
2767 <<
"\t layer \t " << layerId <<
" Sub score in \t -1"
2770 for (
const auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2772 if (score3d[cpId][lcPair.first] == FLT_MAX) {
2773 score3d[cpId][lcPair.first] = 0.f;
2775 score3d[cpId][lcPair.first] += lcPair.second.second;
2776 mclsharedenergy[cpId][lcPair.first] += lcPair.second.first;
2784 float invCPEnergyWeight = 0.f;
2785 for (
const auto&
layer : cPOnLayer[cpId]) {
2786 for (
const auto& haf :
layer.hits_and_fractions) {
2787 invCPEnergyWeight +=
2788 (haf.second * hitMap.at(haf.first)->energy()) * (haf.second * hitMap.at(haf.first)->energy());
2791 invCPEnergyWeight = 1.f / invCPEnergyWeight;
2795 std::vector<int> cpId_mclId_related_vec(cpId_mclId_related.begin(), cpId_mclId_related.end());
2796 for (
unsigned int i = 0;
i < cpId_mclId_related_vec.size(); ++
i) {
2797 auto mclId = cpId_mclId_related_vec[
i];
2799 score3d[cpId][mclId] = score3d[cpId][mclId] * invCPEnergyWeight;
2800 mclsharedenergyfrac[cpId][mclId] = (mclsharedenergy[cpId][mclId] / CPenergy);
2802 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\t MCL id: \t" << mclId <<
"\t score \t"
2803 << score3d[cpId][mclId] <<
"\t"
2804 <<
"invCPEnergyWeight \t" << invCPEnergyWeight <<
"\t"
2805 <<
"shared energy:\t" << mclsharedenergy[cpId][mclId] <<
"\t"
2806 <<
"shared energy fraction:\t" << mclsharedenergyfrac[cpId][mclId] <<
"\n";
2808 histograms.h_score_caloparticle2multicl[
count]->Fill(score3d[cpId][mclId]);
2810 histograms.h_sharedenergy_caloparticle2multicl[
count]->Fill(mclsharedenergyfrac[cpId][mclId]);
2811 histograms.h_energy_vs_score_caloparticle2multicl[
count]->Fill(score3d[cpId][mclId],
2812 mclsharedenergyfrac[cpId][mclId]);
2817 auto assocDup = std::count_if(std::begin(score3d[cpId]),
std::end(score3d[cpId]), is_assoc);
2820 histograms.h_num_caloparticle_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
2821 histograms.h_num_caloparticle_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
2822 auto best = std::min_element(std::begin(score3d[cpId]),
std::end(score3d[cpId]));
2823 auto bestmclId =
std::distance(std::begin(score3d[cpId]), best);
2825 histograms.h_sharedenergy_caloparticle2multicl_vs_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta(),
2826 multiClusters[bestmclId].
energy() / CPenergy);
2827 histograms.h_sharedenergy_caloparticle2multicl_vs_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi(),
2828 multiClusters[bestmclId].
energy() / CPenergy);
2829 histograms.h_sharedenergy_caloparticle2multicl_assoc[
count]->Fill(mclsharedenergyfrac[cpId][bestmclId]);
2831 if (assocDup >= 2) {
2832 auto match = std::find_if(std::begin(score3d[cpId]),
std::end(score3d[cpId]), is_assoc);
2833 while (
match != score3d[cpId].
end()) {
2838 histograms.h_denom_caloparticle_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
2839 histograms.h_denom_caloparticle_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
2846 for (
unsigned int mclId = 0; mclId < nMultiClusters; ++mclId) {
2847 const auto& hits_and_fractions = multiClusters[mclId].hitsAndFractions();
2848 if (!hits_and_fractions.empty()) {
2849 auto assocFakeMerge = tracksters_fakemerge[mclId];
2850 auto assocDuplicate = tracksters_duplicate[mclId];
2851 if (assocDuplicate) {
2855 if (assocFakeMerge > 0) {
2858 auto best = std::min_element(std::begin(cpsInMultiCluster[mclId]),
2859 std::end(cpsInMultiCluster[mclId]),
2860 [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
2863 float sharedeneCPallLayers = 0.;
2865 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2866 auto const& best_cp_linked = cPOnLayer[best->first][
j].layerClusterIdToEnergyAndScore[mclId];
2867 sharedeneCPallLayers += best_cp_linked.first;
2870 multiClusters[mclId].
eta(), sharedeneCPallLayers / multiClusters[mclId].
energy());
2872 multiClusters[mclId].
phi(), sharedeneCPallLayers / multiClusters[mclId].
energy());
2874 if (assocFakeMerge >= 2) {
2886 const std::vector<reco::HGCalMultiCluster>& multiClusters,
2887 std::vector<CaloParticle>
const& cP,
2888 std::vector<size_t>
const& cPIndices,
2889 std::vector<size_t>
const& cPSelectedIndices,
2890 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
2891 unsigned int layers)
const {
2899 int tncontmclpz = 0;
2900 int tncontmclmz = 0;
2902 int tnnoncontmclpz = 0;
2903 int tnnoncontmclmz = 0;
2905 std::vector<bool> contmulti;
2909 std::unordered_map<unsigned int, std::vector<unsigned int>> multiplicity;
2911 std::unordered_map<unsigned int, std::vector<unsigned int>> multiplicity_vs_layer;
2918 auto nMultiClusters = multiClusters.size();
2920 for (
unsigned int mclId = 0; mclId < nMultiClusters; ++mclId) {
2924 if (nLayerClusters == 0)
2927 if (multiClusters[mclId].
z() < 0.) {
2930 if (multiClusters[mclId].
z() > 0.) {
2939 std::vector<int> tnlcinmclperlay(1000, 0);
2943 std::set<int> multicluster_layers;
2945 bool multiclusterInZplus =
false;
2946 bool multiclusterInZminus =
false;
2949 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
2951 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
layerClusters[lcId]->hitsAndFractions();
2954 multiplicity[mclId].emplace_back(hits_and_fractions.size());
2956 const auto firstHitDetId = hits_and_fractions[0].first;
2958 int layerid =
recHitTools_->getLayerWithOffset(firstHitDetId) +
2960 multicluster_layers.insert(layerid);
2961 multiplicity_vs_layer[mclId].emplace_back(layerid);
2963 tnlcinmclperlay[layerid]++;
2967 multiclusterInZplus =
true;
2970 multiclusterInZminus =
true;
2976 for (
unsigned ilayer = 0; ilayer <
layers * 2; ++ilayer) {
2977 if (
histograms.h_clusternum_in_multicluster_perlayer[
count].count(ilayer) && tnlcinmclperlay[ilayer] != 0) {
2978 histograms.h_clusternum_in_multicluster_perlayer[
count].at(ilayer)->Fill((
float)tnlcinmclperlay[ilayer]);
2981 if (tnlcinmclperlay[ilayer] != 0) {
2982 histograms.h_clusternum_in_multicluster_vs_layer[
count]->Fill((
float)ilayer, (
float)tnlcinmclperlay[ilayer]);
2987 std::vector<int> multicluster_layers_vec(multicluster_layers.begin(), multicluster_layers.end());
2989 bool contimulti =
false;
2991 if (multicluster_layers_vec.size() >= 3) {
2992 for (
unsigned int i = 1;
i < multicluster_layers_vec.size() - 1; ++
i) {
2993 if ((multicluster_layers_vec[
i - 1] + 1 == multicluster_layers_vec[
i]) &&
2994 (multicluster_layers_vec[
i + 1] - 1 == multicluster_layers_vec[
i])) {
2996 if (multiclusterInZplus) {
2999 if (multiclusterInZminus) {
3009 if (multiclusterInZplus) {
3012 if (multiclusterInZminus) {
3018 contmulti.push_back(contimulti);
3022 for (
unsigned int lc = 0; lc < multiplicity[mclId].size(); ++lc) {
3024 float mlp =
std::count(std::begin(multiplicity[mclId]),
std::end(multiplicity[mclId]), multiplicity[mclId][lc]);
3027 histograms.h_multiplicityOfLCinMCL[
count]->Fill(mlp, multiplicity[mclId][lc]);
3033 if (multiplicity_vs_layer[mclId][lc] <
layers) {
3034 histograms.h_multiplicityOfLCinMCL_vs_layercluster_zminus[
count]->Fill(mlp, multiplicity_vs_layer[mclId][lc]);
3035 histograms.h_multiplicity_zminus_numberOfEventsHistogram[
count]->Fill(mlp);
3037 histograms.h_multiplicityOfLCinMCL_vs_layercluster_zplus[
count]->Fill(
3038 mlp, multiplicity_vs_layer[mclId][lc] -
layers);
3039 histograms.h_multiplicity_zplus_numberOfEventsHistogram[
count]->Fill(mlp);
3045 if (!multicluster_layers.empty()) {
3052 histograms.h_multicluster_firstlayer[
count]->Fill((
float)*multicluster_layers.begin());
3053 histograms.h_multicluster_lastlayer[
count]->Fill((
float)*multicluster_layers.rbegin());
3054 histograms.h_multicluster_layersnum[
count]->Fill((
float)multicluster_layers.size());
3064 histograms.h_contmulticlusternum[
count]->Fill(tncontmclpz + tncontmclmz);
3065 histograms.h_noncontmulticlusternum[
count]->Fill(tnnoncontmclpz + tnnoncontmclmz);
3073 const double y2)
const {
3074 const double dx =
x1 -
x2;
3075 const double dy =
y1 -
y2;
3081 const double y2)
const {
3090 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap)
const {
3092 const std::vector<std::pair<DetId, float>>& hits_and_fractions = cluster.
hitsAndFractions();
3095 for (
std::vector<std::pair<DetId, float>>::const_iterator it_haf = hits_and_fractions.begin();
3096 it_haf != hits_and_fractions.end();
3098 DetId rh_detid = it_haf->first;
3100 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
3103 if (maxene < hit->
energy()) {
3104 maxene =
hit->energy();
3105 themaxid = rh_detid;