22 minEta_(
pset.getParameter<double>(
"minEta")),
23 maxEta_(
pset.getParameter<double>(
"maxEta")),
24 nintEta_(
pset.getParameter<
int>(
"nintEta")),
25 useFabsEta_(
pset.getParameter<
bool>(
"useFabsEta")),
28 minEne_(
pset.getParameter<double>(
"minEne")),
29 maxEne_(
pset.getParameter<double>(
"maxEne")),
30 nintEne_(
pset.getParameter<
int>(
"nintEne")),
33 minPt_(
pset.getParameter<double>(
"minPt")),
34 maxPt_(
pset.getParameter<double>(
"maxPt")),
35 nintPt_(
pset.getParameter<
int>(
"nintPt")),
38 minPhi_(
pset.getParameter<double>(
"minPhi")),
39 maxPhi_(
pset.getParameter<double>(
"maxPhi")),
40 nintPhi_(
pset.getParameter<
int>(
"nintPhi")),
43 minMixedHitsCluster_(
pset.getParameter<double>(
"minMixedHitsCluster")),
44 maxMixedHitsCluster_(
pset.getParameter<double>(
"maxMixedHitsCluster")),
45 nintMixedHitsCluster_(
pset.getParameter<
int>(
"nintMixedHitsCluster")),
48 minEneCl_(
pset.getParameter<double>(
"minEneCl")),
49 maxEneCl_(
pset.getParameter<double>(
"maxEneCl")),
50 nintEneCl_(
pset.getParameter<
int>(
"nintEneCl")),
53 minLongDepBary_(
pset.getParameter<double>(
"minLongDepBary")),
54 maxLongDepBary_(
pset.getParameter<double>(
"maxLongDepBary")),
55 nintLongDepBary_(
pset.getParameter<
int>(
"nintLongDepBary")),
58 minZpos_(
pset.getParameter<double>(
"minZpos")),
59 maxZpos_(
pset.getParameter<double>(
"maxZpos")),
60 nintZpos_(
pset.getParameter<
int>(
"nintZpos")),
63 minTotNClsperlay_(
pset.getParameter<double>(
"minTotNClsperlay")),
64 maxTotNClsperlay_(
pset.getParameter<double>(
"maxTotNClsperlay")),
65 nintTotNClsperlay_(
pset.getParameter<
int>(
"nintTotNClsperlay")),
68 minEneClperlay_(
pset.getParameter<double>(
"minEneClperlay")),
69 maxEneClperlay_(
pset.getParameter<double>(
"maxEneClperlay")),
70 nintEneClperlay_(
pset.getParameter<
int>(
"nintEneClperlay")),
75 minScore_(
pset.getParameter<double>(
"minScore")),
76 maxScore_(
pset.getParameter<double>(
"maxScore")),
77 nintScore_(
pset.getParameter<
int>(
"nintScore")),
84 minSharedEneFrac_(
pset.getParameter<double>(
"minSharedEneFrac")),
85 maxSharedEneFrac_(
pset.getParameter<double>(
"maxSharedEneFrac")),
86 nintSharedEneFrac_(
pset.getParameter<
int>(
"nintSharedEneFrac")),
89 minMCLSharedEneFrac_(
pset.getParameter<double>(
"minMCLSharedEneFrac")),
90 maxMCLSharedEneFrac_(
pset.getParameter<double>(
"maxMCLSharedEneFrac")),
91 nintMCLSharedEneFrac_(
pset.getParameter<
int>(
"nintMCLSharedEneFrac")),
94 minTotNClsperthick_(
pset.getParameter<double>(
"minTotNClsperthick")),
95 maxTotNClsperthick_(
pset.getParameter<double>(
"maxTotNClsperthick")),
96 nintTotNClsperthick_(
pset.getParameter<
int>(
"nintTotNClsperthick")),
99 minTotNcellsperthickperlayer_(
pset.getParameter<double>(
"minTotNcellsperthickperlayer")),
100 maxTotNcellsperthickperlayer_(
pset.getParameter<double>(
"maxTotNcellsperthickperlayer")),
101 nintTotNcellsperthickperlayer_(
pset.getParameter<
int>(
"nintTotNcellsperthickperlayer")),
104 minDisToSeedperthickperlayer_(
pset.getParameter<double>(
"minDisToSeedperthickperlayer")),
105 maxDisToSeedperthickperlayer_(
pset.getParameter<double>(
"maxDisToSeedperthickperlayer")),
106 nintDisToSeedperthickperlayer_(
pset.getParameter<
int>(
"nintDisToSeedperthickperlayer")),
109 minDisToSeedperthickperlayerenewei_(
pset.getParameter<double>(
"minDisToSeedperthickperlayerenewei")),
110 maxDisToSeedperthickperlayerenewei_(
pset.getParameter<double>(
"maxDisToSeedperthickperlayerenewei")),
111 nintDisToSeedperthickperlayerenewei_(
pset.getParameter<
int>(
"nintDisToSeedperthickperlayerenewei")),
114 minDisToMaxperthickperlayer_(
pset.getParameter<double>(
"minDisToMaxperthickperlayer")),
115 maxDisToMaxperthickperlayer_(
pset.getParameter<double>(
"maxDisToMaxperthickperlayer")),
116 nintDisToMaxperthickperlayer_(
pset.getParameter<
int>(
"nintDisToMaxperthickperlayer")),
119 minDisToMaxperthickperlayerenewei_(
pset.getParameter<double>(
"minDisToMaxperthickperlayerenewei")),
120 maxDisToMaxperthickperlayerenewei_(
pset.getParameter<double>(
"maxDisToMaxperthickperlayerenewei")),
121 nintDisToMaxperthickperlayerenewei_(
pset.getParameter<
int>(
"nintDisToMaxperthickperlayerenewei")),
124 minDisSeedToMaxperthickperlayer_(
pset.getParameter<double>(
"minDisSeedToMaxperthickperlayer")),
125 maxDisSeedToMaxperthickperlayer_(
pset.getParameter<double>(
"maxDisSeedToMaxperthickperlayer")),
126 nintDisSeedToMaxperthickperlayer_(
pset.getParameter<
int>(
"nintDisSeedToMaxperthickperlayer")),
129 minClEneperthickperlayer_(
pset.getParameter<double>(
"minClEneperthickperlayer")),
130 maxClEneperthickperlayer_(
pset.getParameter<double>(
"maxClEneperthickperlayer")),
131 nintClEneperthickperlayer_(
pset.getParameter<
int>(
"nintClEneperthickperlayer")),
134 minCellsEneDensperthick_(
pset.getParameter<double>(
"minCellsEneDensperthick")),
135 maxCellsEneDensperthick_(
pset.getParameter<double>(
"maxCellsEneDensperthick")),
136 nintCellsEneDensperthick_(
pset.getParameter<
int>(
"nintCellsEneDensperthick")),
140 minTotNMCLs_(
pset.getParameter<double>(
"minTotNMCLs")),
141 maxTotNMCLs_(
pset.getParameter<double>(
"maxTotNMCLs")),
142 nintTotNMCLs_(
pset.getParameter<
int>(
"nintTotNMCLs")),
145 minTotNClsinMCLs_(
pset.getParameter<double>(
"minTotNClsinMCLs")),
146 maxTotNClsinMCLs_(
pset.getParameter<double>(
"maxTotNClsinMCLs")),
147 nintTotNClsinMCLs_(
pset.getParameter<
int>(
"nintTotNClsinMCLs")),
150 minTotNClsinMCLsperlayer_(
pset.getParameter<double>(
"minTotNClsinMCLsperlayer")),
151 maxTotNClsinMCLsperlayer_(
pset.getParameter<double>(
"maxTotNClsinMCLsperlayer")),
152 nintTotNClsinMCLsperlayer_(
pset.getParameter<
int>(
"nintTotNClsinMCLsperlayer")),
155 minMplofLCs_(
pset.getParameter<double>(
"minMplofLCs")),
156 maxMplofLCs_(
pset.getParameter<double>(
"maxMplofLCs")),
157 nintMplofLCs_(
pset.getParameter<
int>(
"nintMplofLCs")),
160 minSizeCLsinMCLs_(
pset.getParameter<double>(
"minSizeCLsinMCLs")),
161 maxSizeCLsinMCLs_(
pset.getParameter<double>(
"maxSizeCLsinMCLs")),
162 nintSizeCLsinMCLs_(
pset.getParameter<
int>(
"nintSizeCLsinMCLs")),
165 minClEnepermultiplicity_(
pset.getParameter<double>(
"minClEnepermultiplicity")),
166 maxClEnepermultiplicity_(
pset.getParameter<double>(
"maxClEnepermultiplicity")),
167 nintClEnepermultiplicity_(
pset.getParameter<
int>(
"nintClEnepermultiplicity")),
170 minX_(
pset.getParameter<double>(
"minX")),
171 maxX_(
pset.getParameter<double>(
"maxX")),
172 nintX_(
pset.getParameter<
int>(
"nintX")),
175 minY_(
pset.getParameter<double>(
"minY")),
176 maxY_(
pset.getParameter<double>(
"maxY")),
177 nintY_(
pset.getParameter<
int>(
"nintY")),
180 minZ_(
pset.getParameter<double>(
"minZ")),
181 maxZ_(
pset.getParameter<double>(
"maxZ")),
182 nintZ_(
pset.getParameter<
int>(
"nintZ")) {}
211 std::vector<int> thicknesses,
219 histograms.h_mixedhitscluster_zminus.push_back(
220 ibook.
book1D(
"mixedhitscluster_zminus",
221 "N of reco clusters that contain hits of more than one kind in z-",
226 histograms.h_mixedhitscluster_zplus.push_back(
227 ibook.
book1D(
"mixedhitscluster_zplus",
228 "N of reco clusters that contain hits of more than one kind in z+",
235 histograms.h_energyclustered_zminus.push_back(
236 ibook.
book1D(
"energyclustered_zminus",
237 "percent of total energy clustered by all layer clusters over caloparticles energy in z-",
243 ibook.
book1D(
"energyclustered_zplus",
244 "percent of total energy clustered by all layer clusters over caloparticles energy in z+",
251 std::string subpathtomat = pathtomatbudfile.substr(pathtomatbudfile.find(
"Validation"));
252 histograms.h_longdepthbarycentre_zminus.push_back(
253 ibook.
book1D(
"longdepthbarycentre_zminus",
254 "The longitudinal depth barycentre in z- for " + subpathtomat,
259 histograms.h_longdepthbarycentre_zplus.push_back(
260 ibook.
book1D(
"longdepthbarycentre_zplus",
261 "The longitudinal depth barycentre in z+ for " + subpathtomat,
267 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
268 auto istr1 = std::to_string(ilayer);
269 while (istr1.size() < 2) {
270 istr1.insert(0,
"0");
276 istr2 = std::to_string(ilayer + 1) +
" in z-";
278 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
280 histograms.h_clusternum_perlayer[ilayer] = ibook.
book1D(
"totclusternum_layer_" + istr1,
281 "total number of layer clusters for layer " + istr2,
285 histograms.h_energyclustered_perlayer[ilayer] =
286 ibook.
book1D(
"energyclustered_perlayer" + istr1,
287 "percent of total energy clustered by layer clusters over caloparticles energy for layer " + istr2,
291 histograms.h_score_layercl2caloparticle_perlayer[ilayer] =
292 ibook.
book1D(
"Score_layercl2caloparticle_perlayer" + istr1,
293 "Score of Layer Cluster per CaloParticle for layer " + istr2,
297 histograms.h_score_caloparticle2layercl_perlayer[ilayer] =
298 ibook.
book1D(
"Score_caloparticle2layercl_perlayer" + istr1,
299 "Score of CaloParticle per Layer Cluster for layer " + istr2,
303 histograms.h_energy_vs_score_caloparticle2layercl_perlayer[ilayer] =
304 ibook.
book2D(
"Energy_vs_Score_caloparticle2layer_perlayer" + istr1,
305 "Energy vs Score of CaloParticle per Layer Cluster for layer " + istr2,
312 histograms.h_energy_vs_score_layercl2caloparticle_perlayer[ilayer] =
313 ibook.
book2D(
"Energy_vs_Score_layer2caloparticle_perlayer" + istr1,
314 "Energy vs Score of Layer Cluster per CaloParticle Layer for layer " + istr2,
321 histograms.h_sharedenergy_caloparticle2layercl_perlayer[ilayer] =
322 ibook.
book1D(
"SharedEnergy_caloparticle2layercl_perlayer" + istr1,
323 "Shared Energy of CaloParticle per Layer Cluster for layer " + istr2,
327 histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer[ilayer] =
328 ibook.
bookProfile(
"SharedEnergy_caloparticle2layercl_vs_eta_perlayer" + istr1,
329 "Shared Energy of CaloParticle vs #eta per best Layer Cluster for layer " + istr2,
335 histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer[ilayer] =
336 ibook.
bookProfile(
"SharedEnergy_caloparticle2layercl_vs_phi_perlayer" + istr1,
337 "Shared Energy of CaloParticle vs #phi per best Layer Cluster for layer " + istr2,
343 histograms.h_sharedenergy_layercl2caloparticle_perlayer[ilayer] =
344 ibook.
book1D(
"SharedEnergy_layercluster2caloparticle_perlayer" + istr1,
345 "Shared Energy of Layer Cluster per Layer Calo Particle for layer " + istr2,
349 histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer[ilayer] =
350 ibook.
bookProfile(
"SharedEnergy_layercl2caloparticle_vs_eta_perlayer" + istr1,
351 "Shared Energy of LayerCluster vs #eta per best Calo Particle for layer " + istr2,
357 histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer[ilayer] =
358 ibook.
bookProfile(
"SharedEnergy_layercl2caloparticle_vs_phi_perlayer" + istr1,
359 "Shared Energy of LayerCluster vs #phi per best Calo Particle for layer " + istr2,
365 histograms.h_num_caloparticle_eta_perlayer[ilayer] =
366 ibook.
book1D(
"Num_CaloParticle_Eta_perlayer" + istr1,
367 "Num CaloParticle Eta per Layer Cluster for layer " + istr2,
371 histograms.h_numDup_caloparticle_eta_perlayer[ilayer] =
372 ibook.
book1D(
"NumDup_CaloParticle_Eta_perlayer" + istr1,
373 "Num Duplicate CaloParticle Eta per Layer Cluster for layer " + istr2,
377 histograms.h_denom_caloparticle_eta_perlayer[ilayer] =
378 ibook.
book1D(
"Denom_CaloParticle_Eta_perlayer" + istr1,
379 "Denom CaloParticle Eta per Layer Cluster for layer " + istr2,
383 histograms.h_num_caloparticle_phi_perlayer[ilayer] =
384 ibook.
book1D(
"Num_CaloParticle_Phi_perlayer" + istr1,
385 "Num CaloParticle Phi per Layer Cluster for layer " + istr2,
389 histograms.h_numDup_caloparticle_phi_perlayer[ilayer] =
390 ibook.
book1D(
"NumDup_CaloParticle_Phi_perlayer" + istr1,
391 "Num Duplicate CaloParticle Phi per Layer Cluster for layer " + istr2,
395 histograms.h_denom_caloparticle_phi_perlayer[ilayer] =
396 ibook.
book1D(
"Denom_CaloParticle_Phi_perlayer" + istr1,
397 "Denom CaloParticle Phi per Layer Cluster for layer " + istr2,
401 histograms.h_num_layercl_eta_perlayer[ilayer] =
402 ibook.
book1D(
"Num_LayerCluster_Eta_perlayer" + istr1,
403 "Num LayerCluster Eta per Layer Cluster for layer " + istr2,
407 histograms.h_numMerge_layercl_eta_perlayer[ilayer] =
408 ibook.
book1D(
"NumMerge_LayerCluster_Eta_perlayer" + istr1,
409 "Num Merge LayerCluster Eta per Layer Cluster for layer " + istr2,
413 histograms.h_denom_layercl_eta_perlayer[ilayer] =
414 ibook.
book1D(
"Denom_LayerCluster_Eta_perlayer" + istr1,
415 "Denom LayerCluster Eta per Layer Cluster for layer " + istr2,
419 histograms.h_num_layercl_phi_perlayer[ilayer] =
420 ibook.
book1D(
"Num_LayerCluster_Phi_perlayer" + istr1,
421 "Num LayerCluster Phi per Layer Cluster for layer " + istr2,
425 histograms.h_numMerge_layercl_phi_perlayer[ilayer] =
426 ibook.
book1D(
"NumMerge_LayerCluster_Phi_perlayer" + istr1,
427 "Num Merge LayerCluster Phi per Layer Cluster for layer " + istr2,
431 histograms.h_denom_layercl_phi_perlayer[ilayer] =
432 ibook.
book1D(
"Denom_LayerCluster_Phi_perlayer" + istr1,
433 "Denom LayerCluster Phi per Layer Cluster for layer " + istr2,
437 histograms.h_cellAssociation_perlayer[ilayer] =
438 ibook.
book1D(
"cellAssociation_perlayer" + istr1,
"Cell Association for layer " + istr2, 5, -4., 1.);
439 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(2,
"TN(purity)");
440 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(3,
"FN(ineff.)");
441 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(4,
"FP(fake)");
442 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(5,
"TP(eff.)");
446 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
447 auto istr = std::to_string(*it);
448 histograms.h_clusternum_perthick[(*it)] = ibook.
book1D(
"totclusternum_thick_" + istr,
449 "total number of layer clusters for thickness " + istr,
454 histograms.h_cellsenedens_perthick[(*it)] = ibook.
book1D(
"cellsenedens_thick_" + istr,
455 "energy density of cluster cells for thickness " + istr,
463 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
464 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
465 auto istr1 = std::to_string(*it);
466 auto istr2 = std::to_string(ilayer);
467 while (istr2.size() < 2)
468 istr2.insert(0,
"0");
469 auto istr = istr1 +
"_" + istr2;
474 istr3 = std::to_string(ilayer + 1) +
" in z- ";
476 istr3 = std::to_string(ilayer - (
layers - 1)) +
" in z+ ";
479 histograms.h_cellsnum_perthickperlayer[istr] =
480 ibook.
book1D(
"cellsnum_perthick_perlayer_" + istr,
481 "total number of cells for layer " + istr3 +
" for thickness " + istr1,
486 histograms.h_distancetoseedcell_perthickperlayer[istr] =
487 ibook.
book1D(
"distancetoseedcell_perthickperlayer_" + istr,
488 "distance of cluster cells to seed cell for layer " + istr3 +
" for thickness " + istr1,
493 histograms.h_distancetoseedcell_perthickperlayer_eneweighted[istr] = ibook.
book1D(
494 "distancetoseedcell_perthickperlayer_eneweighted_" + istr,
495 "energy weighted distance of cluster cells to seed cell for layer " + istr3 +
" for thickness " + istr1,
500 histograms.h_distancetomaxcell_perthickperlayer[istr] =
501 ibook.
book1D(
"distancetomaxcell_perthickperlayer_" + istr,
502 "distance of cluster cells to max cell for layer " + istr3 +
" for thickness " + istr1,
507 histograms.h_distancetomaxcell_perthickperlayer_eneweighted[istr] = ibook.
book1D(
508 "distancetomaxcell_perthickperlayer_eneweighted_" + istr,
509 "energy weighted distance of cluster cells to max cell for layer " + istr3 +
" for thickness " + istr1,
514 histograms.h_distancebetseedandmaxcell_perthickperlayer[istr] =
515 ibook.
book1D(
"distancebetseedandmaxcell_perthickperlayer_" + istr,
516 "distance of seed cell to max cell for layer " + istr3 +
" for thickness " + istr1,
521 histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer[istr] = ibook.
book2D(
522 "distancebetseedandmaxcellvsclusterenergy_perthickperlayer_" + istr,
523 "distance of seed cell to max cell vs cluster energy for layer " + istr3 +
" for thickness " + istr1,
540 histograms.h_energy_vs_score_multicl2caloparticle.push_back(
541 ibook.
book2D(
"Energy_vs_Score_multi2caloparticle",
542 "Energy vs Score of Multi Cluster per CaloParticle",
549 histograms.h_energy_vs_score_caloparticle2multicl.push_back(
550 ibook.
book2D(
"Energy_vs_Score_caloparticle2multi",
551 "Energy vs Score of CaloParticle per Multi Cluster",
563 "NumMerge_MultiCluster_Eta",
"Num Merge MultiCluster Eta per Multi Cluster ",
nintEta_,
minEta_,
maxEta_));
569 "NumMerge_MultiCluster_Phi",
"Num Merge MultiCluster Phi per Multi Cluster",
nintPhi_,
minPhi_,
maxPhi_));
572 histograms.h_sharedenergy_multicl2caloparticle.push_back(
573 ibook.
book1D(
"SharedEnergy_multicluster2caloparticle",
574 "Shared Energy of Multi Cluster per Calo Particle in each layer",
578 histograms.h_sharedenergy_multicl2caloparticle_vs_eta.push_back(
579 ibook.
bookProfile(
"SharedEnergy_multicl2caloparticle_vs_eta",
580 "Shared Energy of MultiCluster vs #eta per best Calo Particle in each layer",
586 histograms.h_sharedenergy_multicl2caloparticle_vs_phi.push_back(
587 ibook.
bookProfile(
"SharedEnergy_multicl2caloparticle_vs_phi",
588 "Shared Energy of MultiCluster vs #phi per best Calo Particle in each layer",
594 histograms.h_sharedenergy_caloparticle2multicl.push_back(
595 ibook.
book1D(
"SharedEnergy_caloparticle2multicl",
596 "Shared Energy of CaloParticle per Multi Cluster",
600 histograms.h_sharedenergy_caloparticle2multicl_vs_eta.push_back(
601 ibook.
bookProfile(
"SharedEnergy_caloparticle2multicl_vs_eta",
602 "Shared Energy of CaloParticle vs #eta per best Multi Cluster",
608 histograms.h_sharedenergy_caloparticle2multicl_vs_phi.push_back(
609 ibook.
bookProfile(
"SharedEnergy_caloparticle2multicl_vs_phi",
610 "Shared Energy of CaloParticle vs #phi per best Multi Cluster",
620 histograms.h_denom_caloparticle_eta.push_back(
626 histograms.h_denom_caloparticle_phi.push_back(
629 std::unordered_map<int, dqm::reco::MonitorElement*> clusternum_in_multicluster_perlayer;
630 clusternum_in_multicluster_perlayer.clear();
632 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
633 auto istr1 = std::to_string(ilayer);
634 while (istr1.size() < 2) {
635 istr1.insert(0,
"0");
641 istr2 = std::to_string(ilayer + 1) +
" in z-";
643 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
646 clusternum_in_multicluster_perlayer[ilayer] =
647 ibook.
book1D(
"clusternum_in_multicluster_perlayer" + istr1,
648 "Number of layer clusters in multicluster for layer " + istr2,
654 histograms.h_clusternum_in_multicluster_perlayer.push_back(
std::move(clusternum_in_multicluster_perlayer));
659 histograms.h_contmulticlusternum.push_back(ibook.
book1D(
"contmulticlusternum",
660 "number of multiclusters with 3 contiguous layers",
665 histograms.h_noncontmulticlusternum.push_back(ibook.
book1D(
"noncontmulticlusternum",
666 "number of multiclusters without 3 contiguous layers",
671 histograms.h_clusternum_in_multicluster.push_back(ibook.
book1D(
"clusternum_in_multicluster",
672 "total number of layer clusters in multicluster",
677 histograms.h_clusternum_in_multicluster_vs_layer.push_back(
678 ibook.
bookProfile(
"clusternum_in_multicluster_vs_layer",
679 "Profile of 2d layer clusters in multicluster vs layer number",
686 histograms.h_multiplicityOfLCinMCL.push_back(ibook.
book2D(
"multiplicityOfLCinMCL",
687 "Multiplicity vs Layer cluster size in Multiclusters",
695 histograms.h_multiplicity_numberOfEventsHistogram.push_back(ibook.
book1D(
"multiplicity_numberOfEventsHistogram",
696 "multiplicity numberOfEventsHistogram",
701 histograms.h_multiplicity_zminus_numberOfEventsHistogram.push_back(
702 ibook.
book1D(
"multiplicity_zminus_numberOfEventsHistogram",
703 "multiplicity numberOfEventsHistogram in z-",
708 histograms.h_multiplicity_zplus_numberOfEventsHistogram.push_back(
709 ibook.
book1D(
"multiplicity_zplus_numberOfEventsHistogram",
710 "multiplicity numberOfEventsHistogram in z+",
715 histograms.h_multiplicityOfLCinMCL_vs_layercluster_zminus.push_back(
716 ibook.
book2D(
"multiplicityOfLCinMCL_vs_layercluster_zminus",
717 "Multiplicity vs Layer number in z-",
725 histograms.h_multiplicityOfLCinMCL_vs_layercluster_zplus.push_back(
726 ibook.
book2D(
"multiplicityOfLCinMCL_vs_layercluster_zplus",
727 "Multiplicity vs Layer number in z+",
735 histograms.h_multiplicityOfLCinMCL_vs_layerclusterenergy.push_back(
736 ibook.
book2D(
"multiplicityOfLCinMCL_vs_layerclusterenergy",
737 "Multiplicity vs Layer cluster energy",
759 histograms.h_multicluster_firstlayer.push_back(
760 ibook.
book1D(
"multicluster_firstlayer",
"First layer of the multicluster", 2 *
layers, 0., (
float)2 *
layers));
761 histograms.h_multicluster_lastlayer.push_back(
762 ibook.
book1D(
"multicluster_lastlayer",
"Last layer of the multicluster", 2 *
layers, 0., (
float)2 *
layers));
764 "multicluster_layersnum",
"Number of layers of the multicluster", 2 *
layers, 0., (
float)2 *
layers));
813 std::vector<CaloParticle>
const& cP,
814 std::vector<size_t>
const& cPIndices,
815 std::vector<size_t>
const& cPSelectedIndices,
816 std::map<DetId, const HGCRecHit*>
const& hitMap,
818 auto nLayerClusters =
clusters.size();
820 auto nCaloParticles = cPIndices.size();
822 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToCaloParticleId_Map;
823 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToLayerClusterId_Map;
826 std::vector<std::vector<std::pair<unsigned int, float>>> cpsInLayerCluster;
827 cpsInLayerCluster.resize(nLayerClusters);
829 std::unordered_map<int, std::vector<caloParticleOnLayer>> cPOnLayer;
831 for (
unsigned int i = 0;
i < nCaloParticles; ++
i) {
832 auto cpIndex = cPIndices[
i];
833 cPOnLayer[cpIndex].resize(
layers * 2);
834 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
835 cPOnLayer[cpIndex][
j].caloParticleId = cpIndex;
836 cPOnLayer[cpIndex][
j].energy = 0.f;
837 cPOnLayer[cpIndex][
j].hits_and_fractions.clear();
843 for (
const auto& cpId : cPIndices) {
845 for (
const auto& it_sc : simClusterRefVector) {
848 for (
const auto& it_haf : hits_and_fractions) {
849 DetId hitid = (it_haf.first);
851 std::map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
852 if (itcheck != hitMap.end()) {
854 auto hit_find_it = detIdToCaloParticleId_Map.find(hitid);
855 if (hit_find_it == detIdToCaloParticleId_Map.end()) {
856 detIdToCaloParticleId_Map[hitid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
857 detIdToCaloParticleId_Map[hitid].emplace_back(
860 auto findHitIt =
std::find(detIdToCaloParticleId_Map[hitid].
begin(),
861 detIdToCaloParticleId_Map[hitid].
end(),
863 if (findHitIt != detIdToCaloParticleId_Map[hitid].
end()) {
864 findHitIt->fraction += it_haf.second;
866 detIdToCaloParticleId_Map[hitid].emplace_back(
870 cPOnLayer[cpId][cpLayerId].energy += it_haf.second *
hit->energy();
877 auto& haf = cPOnLayer[cpId][cpLayerId].hits_and_fractions;
878 auto found = std::find_if(
879 std::begin(haf),
std::end(haf), [&hitid](
const std::pair<DetId, float>&
v) {
return v.first == hitid; });
880 if (
found != haf.end()) {
881 found->second += it_haf.second;
883 cPOnLayer[cpId][cpLayerId].hits_and_fractions.emplace_back(hitid, it_haf.second);
890 LogDebug(
"HGCalValidator") <<
"cPOnLayer INFO" << std::endl;
891 for (
size_t cp = 0;
cp < cPOnLayer.size(); ++
cp) {
892 LogDebug(
"HGCalValidator") <<
"For CaloParticle Idx: " <<
cp <<
" we have: " << std::endl;
893 for (
size_t cpp = 0; cpp < cPOnLayer[
cp].size(); ++cpp) {
894 LogDebug(
"HGCalValidator") <<
" On Layer: " << cpp <<
" we have:" << std::endl;
895 LogDebug(
"HGCalValidator") <<
" CaloParticleIdx: " << cPOnLayer[
cp][cpp].caloParticleId << std::endl;
896 LogDebug(
"HGCalValidator") <<
" Energy: " << cPOnLayer[
cp][cpp].energy << std::endl;
897 double tot_energy = 0.;
898 for (
auto const& haf : cPOnLayer[
cp][cpp].hits_and_fractions) {
899 LogDebug(
"HGCalValidator") <<
" Hits/fraction/energy: " << (uint32_t)haf.first <<
"/" << haf.second <<
"/"
900 << haf.second * hitMap.at(haf.first)->energy() << std::endl;
901 tot_energy += haf.second * hitMap.at(haf.first)->energy();
903 LogDebug(
"HGCalValidator") <<
" Tot Sum haf: " << tot_energy << std::endl;
904 for (
auto const& lc : cPOnLayer[
cp][cpp].layerClusterIdToEnergyAndScore) {
905 LogDebug(
"HGCalValidator") <<
" lcIdx/energy/score: " << lc.first <<
"/" << lc.second.first <<
"/"
906 << lc.second.second << std::endl;
911 LogDebug(
"HGCalValidator") <<
"detIdToCaloParticleId_Map INFO" << std::endl;
912 for (
auto const&
cp : detIdToCaloParticleId_Map) {
913 LogDebug(
"HGCalValidator") <<
"For detId: " << (uint32_t)
cp.first
914 <<
" we have found the following connections with CaloParticles:" << std::endl;
915 for (
auto const& cpp :
cp.second) {
916 LogDebug(
"HGCalValidator") <<
" CaloParticle Id: " << cpp.clusterId <<
" with fraction: " << cpp.fraction
917 <<
" and energy: " << cpp.fraction * hitMap.at(
cp.first)->energy() << std::endl;
921 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
922 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
923 unsigned int numberOfHitsInLC = hits_and_fractions.size();
933 std::vector<int> hitsToCaloParticleId(numberOfHitsInLC);
934 const auto firstHitDetId = hits_and_fractions[0].first;
939 int maxCPId_byNumberOfHits = -1;
941 unsigned int maxCPNumberOfHitsInLC = 0;
944 int maxCPId_byEnergy = -1;
946 float maxEnergySharedLCandCP = 0.f;
948 float energyFractionOfLCinCP = 0.f;
950 float energyFractionOfCPinLC = 0.f;
951 std::unordered_map<unsigned, unsigned> occurrencesCPinLC;
952 std::unordered_map<unsigned, float> CPEnergyInLC;
953 unsigned int numberOfNoiseHitsInLC = 0;
954 unsigned int numberOfHaloHitsInLC = 0;
956 for (
unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) {
957 DetId rh_detid = hits_and_fractions[hitId].first;
958 auto rhFraction = hits_and_fractions[hitId].second;
960 std::map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
963 auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid);
964 if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) {
965 detIdToLayerClusterId_Map[rh_detid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
969 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
977 if (rhFraction == 0.) {
978 hitsToCaloParticleId[hitId] = -2;
979 numberOfHaloHitsInLC++;
981 if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) {
982 hitsToCaloParticleId[hitId] -= 1;
984 auto maxCPEnergyInLC = 0.f;
986 for (
auto&
h : hit_find_in_CP->second) {
987 CPEnergyInLC[
h.clusterId] +=
h.fraction *
hit->energy();
988 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[lcId].first +=
h.fraction *
hit->energy();
989 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[lcId].second = FLT_MAX;
990 cpsInLayerCluster[lcId].emplace_back(std::make_pair<int, float>(
h.clusterId, FLT_MAX));
993 if (CPEnergyInLC[
h.clusterId] > maxCPEnergyInLC) {
994 maxCPEnergyInLC = CPEnergyInLC[
h.clusterId];
995 maxCPId =
h.clusterId;
998 hitsToCaloParticleId[hitId] = maxCPId;
1000 histograms.h_cellAssociation_perlayer.at(lcLayerId)->Fill(
1001 hitsToCaloParticleId[hitId] > 0. ? 0. : hitsToCaloParticleId[hitId]);
1004 for (
auto&
c : hitsToCaloParticleId) {
1006 numberOfNoiseHitsInLC++;
1008 occurrencesCPinLC[
c]++;
1012 for (
auto&
c : occurrencesCPinLC) {
1013 if (
c.second > maxCPNumberOfHitsInLC) {
1014 maxCPId_byNumberOfHits =
c.first;
1015 maxCPNumberOfHitsInLC =
c.second;
1019 for (
auto&
c : CPEnergyInLC) {
1020 if (
c.second > maxEnergySharedLCandCP) {
1021 maxCPId_byEnergy =
c.first;
1022 maxEnergySharedLCandCP =
c.second;
1025 float totalCPEnergyOnLayer = 0.f;
1026 if (maxCPId_byEnergy >= 0) {
1027 totalCPEnergyOnLayer = cPOnLayer[maxCPId_byEnergy][lcLayerId].energy;
1028 energyFractionOfCPinLC = maxEnergySharedLCandCP / totalCPEnergyOnLayer;
1030 energyFractionOfLCinCP = maxEnergySharedLCandCP /
clusters[lcId].energy();
1033 LogDebug(
"HGCalValidator") << std::setw(10) <<
"LayerId:"
1034 <<
"\t" << std::setw(12) <<
"layerCluster"
1035 <<
"\t" << std::setw(10) <<
"lc energy"
1036 <<
"\t" << std::setw(5) <<
"nhits"
1037 <<
"\t" << std::setw(12) <<
"noise hits"
1038 <<
"\t" << std::setw(22) <<
"maxCPId_byNumberOfHits"
1039 <<
"\t" << std::setw(8) <<
"nhitsCP"
1040 <<
"\t" << std::setw(13) <<
"maxCPId_byEnergy"
1041 <<
"\t" << std::setw(20) <<
"maxEnergySharedLCandCP"
1042 <<
"\t" << std::setw(22) <<
"totalCPEnergyOnLayer"
1043 <<
"\t" << std::setw(22) <<
"energyFractionOfLCinCP"
1044 <<
"\t" << std::setw(25) <<
"energyFractionOfCPinLC"
1047 LogDebug(
"HGCalValidator") << std::setw(10) << lcLayerId <<
"\t" << std::setw(12) << lcId <<
"\t" << std::setw(10)
1048 <<
clusters[lcId].energy() <<
"\t" << std::setw(5) << numberOfHitsInLC <<
"\t"
1049 << std::setw(12) << numberOfNoiseHitsInLC <<
"\t" << std::setw(22)
1050 << maxCPId_byNumberOfHits <<
"\t" << std::setw(8) << maxCPNumberOfHitsInLC <<
"\t"
1051 << std::setw(13) << maxCPId_byEnergy <<
"\t" << std::setw(20) << maxEnergySharedLCandCP
1052 <<
"\t" << std::setw(22) << totalCPEnergyOnLayer <<
"\t" << std::setw(22)
1053 << energyFractionOfLCinCP <<
"\t" << std::setw(25) << energyFractionOfCPinLC <<
"\n";
1056 LogDebug(
"HGCalValidator") <<
"Improved cPOnLayer INFO" << std::endl;
1057 for (
size_t cp = 0;
cp < cPOnLayer.size(); ++
cp) {
1058 LogDebug(
"HGCalValidator") <<
"For CaloParticle Idx: " <<
cp <<
" we have: " << std::endl;
1059 for (
size_t cpp = 0; cpp < cPOnLayer[
cp].size(); ++cpp) {
1060 LogDebug(
"HGCalValidator") <<
" On Layer: " << cpp <<
" we have:" << std::endl;
1061 LogDebug(
"HGCalValidator") <<
" CaloParticleIdx: " << cPOnLayer[
cp][cpp].caloParticleId << std::endl;
1062 LogDebug(
"HGCalValidator") <<
" Energy: " << cPOnLayer[
cp][cpp].energy << std::endl;
1063 double tot_energy = 0.;
1064 for (
auto const& haf : cPOnLayer[
cp][cpp].hits_and_fractions) {
1065 LogDebug(
"HGCalValidator") <<
" Hits/fraction/energy: " << (uint32_t)haf.first <<
"/" << haf.second <<
"/"
1066 << haf.second * hitMap.at(haf.first)->energy() << std::endl;
1067 tot_energy += haf.second * hitMap.at(haf.first)->energy();
1069 LogDebug(
"HGCalValidator") <<
" Tot Sum haf: " << tot_energy << std::endl;
1070 for (
auto const& lc : cPOnLayer[
cp][cpp].layerClusterIdToEnergyAndScore) {
1071 LogDebug(
"HGCalValidator") <<
" lcIdx/energy/score: " << lc.first <<
"/" << lc.second.first <<
"/"
1072 << lc.second.second << std::endl;
1077 LogDebug(
"HGCalValidator") <<
"Improved detIdToCaloParticleId_Map INFO" << std::endl;
1078 for (
auto const&
cp : detIdToCaloParticleId_Map) {
1079 LogDebug(
"HGCalValidator") <<
"For detId: " << (uint32_t)
cp.first
1080 <<
" we have found the following connections with CaloParticles:" << std::endl;
1081 for (
auto const& cpp :
cp.second) {
1082 LogDebug(
"HGCalValidator") <<
" CaloParticle Id: " << cpp.clusterId <<
" with fraction: " << cpp.fraction
1083 <<
" and energy: " << cpp.fraction * hitMap.at(
cp.first)->energy() << std::endl;
1090 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
1092 std::sort(cpsInLayerCluster[lcId].
begin(), cpsInLayerCluster[lcId].
end());
1094 cpsInLayerCluster[lcId].erase(
last, cpsInLayerCluster[lcId].
end());
1095 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1096 unsigned int numberOfHitsInLC = hits_and_fractions.size();
1097 auto firstHitDetId = hits_and_fractions[0].first;
1101 if (
clusters[lcId].
energy() == 0. && !cpsInLayerCluster[lcId].empty()) {
1102 for (
auto& cpPair : cpsInLayerCluster[lcId]) {
1104 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId <<
"\t CP id: \t" << cpPair.first <<
"\t score \t"
1105 << cpPair.second <<
"\n";
1106 histograms.h_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(cpPair.second);
1112 float invLayerClusterEnergyWeight = 0.f;
1113 for (
auto const& haf :
clusters[lcId].hitsAndFractions()) {
1114 invLayerClusterEnergyWeight +=
1115 (haf.second * hitMap.at(haf.first)->energy()) * (haf.second * hitMap.at(haf.first)->energy());
1117 invLayerClusterEnergyWeight = 1.f / invLayerClusterEnergyWeight;
1119 for (
unsigned int i = 0;
i < numberOfHitsInLC; ++
i) {
1120 DetId rh_detid = hits_and_fractions[
i].first;
1121 float rhFraction = hits_and_fractions[
i].second;
1122 bool hitWithNoCP =
false;
1124 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
1125 if (hit_find_in_CP == detIdToCaloParticleId_Map.end())
1127 auto itcheck = hitMap.find(rh_detid);
1129 float hitEnergyWeight =
hit->energy() *
hit->energy();
1131 for (
auto& cpPair : cpsInLayerCluster[lcId]) {
1132 float cpFraction = 0.f;
1134 auto findHitIt =
std::find(detIdToCaloParticleId_Map[rh_detid].
begin(),
1135 detIdToCaloParticleId_Map[rh_detid].
end(),
1137 if (findHitIt != detIdToCaloParticleId_Map[rh_detid].
end())
1138 cpFraction = findHitIt->fraction;
1140 if (cpPair.second == FLT_MAX) {
1141 cpPair.second = 0.f;
1144 (rhFraction - cpFraction) * (rhFraction - cpFraction) * hitEnergyWeight * invLayerClusterEnergyWeight;
1148 if (cpsInLayerCluster[lcId].
empty())
1149 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId <<
"\tCP id:\t-1 "
1153 for (
auto& cpPair : cpsInLayerCluster[lcId]) {
1154 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId <<
"\t CP id: \t" << cpPair.first <<
"\t score \t"
1155 << cpPair.second <<
"\n";
1156 histograms.h_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(cpPair.second);
1157 auto const& cp_linked = cPOnLayer[cpPair.first][lcLayerId].layerClusterIdToEnergyAndScore[lcId];
1158 histograms.h_sharedenergy_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(
1160 histograms.h_energy_vs_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(
1161 cpPair.second, cp_linked.first /
clusters[lcId].energy());
1174 auto best = std::min_element(
std::begin(cpsInLayerCluster[lcId]),
1176 [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
1177 auto const& best_cp_linked = cPOnLayer[best->first][lcLayerId].layerClusterIdToEnergyAndScore[lcId];
1178 histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer.at(lcLayerId)->Fill(
1180 histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer.at(lcLayerId)->Fill(
1190 for (
const auto& cpId : cPSelectedIndices) {
1191 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId) {
1192 unsigned int CPNumberOfHits = cPOnLayer[cpId][layerId].hits_and_fractions.size();
1193 float CPenergy = cPOnLayer[cpId][layerId].energy;
1194 if (CPNumberOfHits == 0)
1196 int lcWithMaxEnergyInCP = -1;
1197 float maxEnergyLCinCP = 0.f;
1198 float CPEnergyFractionInLC = 0.f;
1199 for (
auto& lc : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
1200 if (lc.second.first > maxEnergyLCinCP) {
1201 maxEnergyLCinCP = lc.second.first;
1202 lcWithMaxEnergyInCP = lc.first;
1206 CPEnergyFractionInLC = maxEnergyLCinCP / CPenergy;
1208 LogDebug(
"HGCalValidator") << std::setw(8) <<
"LayerId:\t" << std::setw(12) <<
"caloparticle\t" << std::setw(15)
1209 <<
"cp total energy\t" << std::setw(15) <<
"cpEnergyOnLayer\t" << std::setw(14)
1210 <<
"CPNhitsOnLayer\t" << std::setw(18) <<
"lcWithMaxEnergyInCP\t" << std::setw(15)
1211 <<
"maxEnergyLCinCP\t" << std::setw(20) <<
"CPEnergyFractionInLC"
1213 LogDebug(
"HGCalValidator") << std::setw(8) << layerId <<
"\t" << std::setw(12) << cpId <<
"\t" << std::setw(15)
1214 << cP[cpId].energy() <<
"\t" << std::setw(15) << CPenergy <<
"\t" << std::setw(14)
1215 << CPNumberOfHits <<
"\t" << std::setw(18) << lcWithMaxEnergyInCP <<
"\t"
1216 << std::setw(15) << maxEnergyLCinCP <<
"\t" << std::setw(20) << CPEnergyFractionInLC
1220 float invCPEnergyWeight = 0.f;
1221 for (
auto const& haf : cPOnLayer[cpId][layerId].hits_and_fractions) {
1222 invCPEnergyWeight +=
1223 (haf.second * hitMap.at(haf.first)->energy()) * (haf.second * hitMap.at(haf.first)->energy());
1225 invCPEnergyWeight = 1.f / invCPEnergyWeight;
1227 for (
unsigned int i = 0;
i < CPNumberOfHits; ++
i) {
1228 auto& cp_hitDetId = cPOnLayer[cpId][layerId].hits_and_fractions[
i].first;
1229 auto& cpFraction = cPOnLayer[cpId][layerId].hits_and_fractions[
i].second;
1231 bool hitWithNoLC =
false;
1232 if (cpFraction == 0.
f)
1234 auto hit_find_in_LC = detIdToLayerClusterId_Map.find(cp_hitDetId);
1235 if (hit_find_in_LC == detIdToLayerClusterId_Map.end())
1237 auto itcheck = hitMap.find(cp_hitDetId);
1239 float hitEnergyWeight =
hit->energy() *
hit->energy();
1240 for (
auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
1241 unsigned int layerClusterId = lcPair.first;
1242 float lcFraction = 0.f;
1245 auto findHitIt =
std::find(detIdToLayerClusterId_Map[cp_hitDetId].
begin(),
1246 detIdToLayerClusterId_Map[cp_hitDetId].
end(),
1248 if (findHitIt != detIdToLayerClusterId_Map[cp_hitDetId].
end())
1249 lcFraction = findHitIt->fraction;
1254 if (lcPair.second.second == FLT_MAX) {
1255 lcPair.second.second = 0.f;
1257 lcPair.second.second +=
1258 (lcFraction - cpFraction) * (lcFraction - cpFraction) * hitEnergyWeight * invCPEnergyWeight;
1259 LogDebug(
"HGCalValidator") <<
"cpDetId:\t" << (uint32_t)cp_hitDetId <<
"\tlayerClusterId:\t" << layerClusterId
1261 <<
"lcfraction,cpfraction:\t" << lcFraction <<
", " << cpFraction <<
"\t"
1262 <<
"hitEnergyWeight:\t" << hitEnergyWeight <<
"\t"
1263 <<
"current score:\t" << lcPair.second.second <<
"\t"
1264 <<
"invCPEnergyWeight:\t" << invCPEnergyWeight <<
"\n";
1268 if (cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore.empty())
1269 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\tLC id:\t-1 "
1273 for (
auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
1274 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\t LC id: \t" << lcPair.first <<
"\t score \t"
1275 << lcPair.second.second <<
"\t"
1276 <<
"shared energy:\t" << lcPair.second.first <<
"\t"
1277 <<
"shared energy fraction:\t" << (lcPair.second.first / CPenergy) <<
"\n";
1278 histograms.h_score_caloparticle2layercl_perlayer.at(layerId)->Fill(lcPair.second.second);
1279 histograms.h_sharedenergy_caloparticle2layercl_perlayer.at(layerId)->Fill(lcPair.second.first / CPenergy,
1281 histograms.h_energy_vs_score_caloparticle2layercl_perlayer.at(layerId)->Fill(lcPair.second.second,
1282 lcPair.second.first / CPenergy);
1284 auto assoc = std::count_if(
std::begin(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore),
1285 std::end(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore),
1288 histograms.h_num_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1289 histograms.h_num_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1291 histograms.h_numDup_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1292 histograms.h_numDup_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1294 auto best = std::min_element(
1295 std::begin(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore),
1296 std::end(cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore),
1297 [](
const auto& obj1,
const auto& obj2) {
return obj1.second.second < obj2.second.second; });
1298 histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer.at(layerId)->Fill(
1299 cP[cpId].g4Tracks()[0].momentum().
eta(), best->second.first / CPenergy);
1300 histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer.at(layerId)->Fill(
1301 cP[cpId].g4Tracks()[0].momentum().
phi(), best->second.first / CPenergy);
1303 histograms.h_denom_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1304 histograms.h_denom_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1313 std::vector<CaloParticle>
const& cP,
1314 std::vector<size_t>
const& cPIndices,
1315 std::vector<size_t>
const& cPSelectedIndices,
1316 std::map<DetId, const HGCRecHit*>
const& hitMap,
1317 std::map<double, double> cummatbudg,
1319 std::vector<int> thicknesses)
const {
1328 std::vector<int> tnlcpl(1000, 0);
1331 std::map<std::string, int> tnlcpthplus;
1332 tnlcpthplus.clear();
1333 std::map<std::string, int> tnlcpthminus;
1334 tnlcpthminus.clear();
1336 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
1337 tnlcpthplus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1338 tnlcpthminus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1341 tnlcpthplus.insert(std::pair<std::string, int>(
"mixed", 0));
1342 tnlcpthminus.insert(std::pair<std::string, int>(
"mixed", 0));
1348 std::vector<double> tecpl(1000, 0.0);
1350 std::vector<double> ldbar(1000, 0.0);
1353 double caloparteneplus = 0.;
1354 double caloparteneminus = 0.;
1355 for (
const auto& cpId : cPIndices) {
1356 if (cP[cpId].
eta() >= 0.) {
1357 caloparteneplus = caloparteneplus + cP[cpId].energy();
1359 if (cP[cpId].
eta() < 0.) {
1360 caloparteneminus = caloparteneminus + cP[cpId].energy();
1365 for (
unsigned int layerclusterIndex = 0; layerclusterIndex <
clusters.size(); layerclusterIndex++) {
1366 const std::vector<std::pair<DetId, float>> hits_and_fractions =
clusters[layerclusterIndex].hitsAndFractions();
1369 const double seedx =
recHitTools_->getPosition(seedid).x();
1370 const double seedy =
recHitTools_->getPosition(seedid).y();
1378 int nthhits120p = 0;
1379 int nthhits200p = 0;
1380 int nthhits300p = 0;
1381 int nthhitsscintp = 0;
1382 int nthhits120m = 0;
1383 int nthhits200m = 0;
1384 int nthhits300m = 0;
1385 int nthhitsscintm = 0;
1396 bool cluslay =
true;
1400 for (std::vector<std::pair<DetId, float>>::const_iterator it_haf = hits_and_fractions.begin();
1401 it_haf != hits_and_fractions.end();
1403 const DetId rh_detid = it_haf->first;
1413 LogDebug(
"HGCalValidator") <<
"These are HGCal layer clusters, you shouldn't be here !!! " << layerid <<
"\n";
1420 while (lay_string.size() < 2)
1421 lay_string.insert(0,
"0");
1422 curistr +=
"_" + lay_string;
1447 <<
" You are running a geometry that contains thicknesses different than the normal ones. "
1451 std::map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
1452 if (itcheck == hitMap.end()) {
1453 LogDebug(
"HGCalValidator") <<
" You shouldn't be here - Unable to find a hit " << rh_detid.
rawId() <<
" "
1462 const double hit_x =
recHitTools_->getPosition(rh_detid).x();
1463 const double hit_y =
recHitTools_->getPosition(rh_detid).y();
1464 double distancetoseed =
distance(seedx, seedy, hit_x, hit_y);
1465 double distancetomax =
distance(maxx, maxy, hit_x, hit_y);
1466 if (distancetoseed != 0. &&
histograms.h_distancetoseedcell_perthickperlayer.count(curistr)) {
1467 histograms.h_distancetoseedcell_perthickperlayer.at(curistr)->Fill(distancetoseed);
1470 if (distancetoseed != 0. &&
histograms.h_distancetoseedcell_perthickperlayer_eneweighted.count(curistr)) {
1471 histograms.h_distancetoseedcell_perthickperlayer_eneweighted.at(curistr)->Fill(distancetoseed,
hit->energy());
1474 if (distancetomax != 0. &&
histograms.h_distancetomaxcell_perthickperlayer.count(curistr)) {
1475 histograms.h_distancetomaxcell_perthickperlayer.at(curistr)->Fill(distancetomax);
1478 if (distancetomax != 0. &&
histograms.h_distancetomaxcell_perthickperlayer_eneweighted.count(curistr)) {
1479 histograms.h_distancetomaxcell_perthickperlayer_eneweighted.at(curistr)->Fill(distancetomax,
hit->energy());
1483 std::map<DetId, float>::const_iterator dit = densities.find(rh_detid);
1484 if (dit == densities.end()) {
1485 LogDebug(
"HGCalValidator") <<
" You shouldn't be here - Unable to find a density " << rh_detid.
rawId() <<
" "
1497 if ((nthhits120p != 0 && nthhits200p != 0) || (nthhits120p != 0 && nthhits300p != 0) ||
1498 (nthhits120p != 0 && nthhitsscintp != 0) || (nthhits200p != 0 && nthhits300p != 0) ||
1499 (nthhits200p != 0 && nthhitsscintp != 0) || (nthhits300p != 0 && nthhitsscintp != 0)) {
1500 tnlcpthplus[
"mixed"]++;
1501 }
else if ((nthhits120p != 0 || nthhits200p != 0 || nthhits300p != 0 || nthhitsscintp != 0)) {
1503 tnlcpthplus[std::to_string((
int)
thickness)]++;
1505 if ((nthhits120m != 0 && nthhits200m != 0) || (nthhits120m != 0 && nthhits300m != 0) ||
1506 (nthhits120m != 0 && nthhitsscintm != 0) || (nthhits200m != 0 && nthhits300m != 0) ||
1507 (nthhits200m != 0 && nthhitsscintm != 0) || (nthhits300m != 0 && nthhitsscintm != 0)) {
1508 tnlcpthminus[
"mixed"]++;
1509 }
else if ((nthhits120m != 0 || nthhits200m != 0 || nthhits300m != 0 || nthhitsscintm != 0)) {
1511 tnlcpthminus[std::to_string((
int)
thickness)]++;
1515 std::vector<int> bigamoth;
1518 bigamoth.push_back(nthhits120p);
1519 bigamoth.push_back(nthhits200p);
1520 bigamoth.push_back(nthhits300p);
1521 bigamoth.push_back(nthhitsscintp);
1524 bigamoth.push_back(nthhits120m);
1525 bigamoth.push_back(nthhits200m);
1526 bigamoth.push_back(nthhits300m);
1527 bigamoth.push_back(nthhitsscintm);
1529 auto bgth = std::max_element(bigamoth.begin(), bigamoth.end());
1530 istr = std::to_string(thicknesses[
std::distance(bigamoth.begin(), bgth)]);
1532 while (lay_string.size() < 2)
1533 lay_string.insert(0,
"0");
1534 istr +=
"_" + lay_string;
1537 if (
histograms.h_cellsnum_perthickperlayer.count(istr)) {
1538 histograms.h_cellsnum_perthickperlayer.at(istr)->Fill(hits_and_fractions.size());
1542 double distancebetseedandmax =
distance(seedx, seedy, maxx, maxy);
1544 std::string seedstr = std::to_string((
int)
recHitTools_->getSiThickness(seedid)) +
"_" + std::to_string(layerid);
1545 seedstr +=
"_" + lay_string;
1546 if (
histograms.h_distancebetseedandmaxcell_perthickperlayer.count(seedstr)) {
1547 histograms.h_distancebetseedandmaxcell_perthickperlayer.at(seedstr)->Fill(distancebetseedandmax);
1549 if (
histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer.count(seedstr)) {
1550 histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer.at(seedstr)->Fill(
1555 tecpl[layerid] = tecpl[layerid] +
clusters[layerclusterIndex].energy();
1556 ldbar[layerid] = ldbar[layerid] +
clusters[layerclusterIndex].energy() * cummatbudg[(double)lay];
1562 double sumeneallcluspl = 0.;
1563 double sumeneallclusmi = 0.;
1565 double sumldbarpl = 0.;
1566 double sumldbarmi = 0.;
1568 for (
unsigned ilayer = 0; ilayer <
layers * 2; ++ilayer) {
1569 if (
histograms.h_clusternum_perlayer.count(ilayer)) {
1570 histograms.h_clusternum_perlayer.at(ilayer)->Fill(tnlcpl[ilayer]);
1575 if (
histograms.h_energyclustered_perlayer.count(ilayer)) {
1576 if (caloparteneminus != 0.) {
1577 histograms.h_energyclustered_perlayer.at(ilayer)->Fill(100. * tecpl[ilayer] / caloparteneminus);
1581 sumeneallclusmi = sumeneallclusmi + tecpl[ilayer];
1583 sumldbarmi = sumldbarmi + ldbar[ilayer];
1585 if (
histograms.h_energyclustered_perlayer.count(ilayer)) {
1586 if (caloparteneplus != 0.) {
1587 histograms.h_energyclustered_perlayer.at(ilayer)->Fill(100. * tecpl[ilayer] / caloparteneplus);
1591 sumeneallcluspl = sumeneallcluspl + tecpl[ilayer];
1593 sumldbarpl = sumldbarpl + ldbar[ilayer];
1599 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
1600 if (
histograms.h_clusternum_perthick.count(*it)) {
1601 histograms.h_clusternum_perthick.at(*it)->Fill(tnlcpthplus[std::to_string(*it)]);
1602 histograms.h_clusternum_perthick.at(*it)->Fill(tnlcpthminus[std::to_string(*it)]);
1606 histograms.h_mixedhitscluster_zplus[
count]->Fill(tnlcpthplus[
"mixed"]);
1607 histograms.h_mixedhitscluster_zminus[
count]->Fill(tnlcpthminus[
"mixed"]);
1610 if (caloparteneplus != 0.) {
1611 histograms.h_energyclustered_zplus[
count]->Fill(100. * sumeneallcluspl / caloparteneplus);
1613 if (caloparteneminus != 0.) {
1614 histograms.h_energyclustered_zminus[
count]->Fill(100. * sumeneallclusmi / caloparteneminus);
1618 histograms.h_longdepthbarycentre_zplus[
count]->Fill(sumldbarpl / sumeneallcluspl);
1619 histograms.h_longdepthbarycentre_zminus[
count]->Fill(sumldbarmi / sumeneallclusmi);
1624 const std::vector<reco::HGCalMultiCluster>& multiClusters,
1625 std::vector<CaloParticle>
const& cP,
1626 std::vector<size_t>
const& cPIndices,
1627 std::vector<size_t>
const& cPSelectedIndices,
1628 std::map<DetId, const HGCRecHit*>
const& hitMap,
1630 auto nMultiClusters = multiClusters.size();
1632 auto nCaloParticles = cPIndices.size();
1634 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToCaloParticleId_Map;
1635 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInMultiCluster>> detIdToMultiClusterId_Map;
1636 std::vector<int> tracksters_fakemerge(nMultiClusters, 0);
1637 std::vector<int> tracksters_duplicate(nMultiClusters, 0);
1642 std::vector<std::vector<std::pair<unsigned int, float>>> cpsInMultiCluster;
1643 cpsInMultiCluster.resize(nMultiClusters);
1652 std::unordered_map<int, std::vector<caloParticleOnLayer>> cPOnLayer;
1653 for (
unsigned int i = 0;
i < nCaloParticles; ++
i) {
1654 auto cpIndex = cPIndices[
i];
1655 cPOnLayer[cpIndex].resize(
layers * 2);
1656 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
1657 cPOnLayer[cpIndex][
j].caloParticleId = cpIndex;
1658 cPOnLayer[cpIndex][
j].energy = 0.f;
1659 cPOnLayer[cpIndex][
j].hits_and_fractions.clear();
1663 for (
const auto& cpId : cPIndices) {
1667 for (
const auto& it_sc : simClusterRefVector) {
1670 for (
const auto& it_haf : hits_and_fractions) {
1671 DetId hitid = (it_haf.first);
1675 std::map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
1677 if (itcheck != hitMap.end()) {
1686 auto hit_find_it = detIdToCaloParticleId_Map.find(hitid);
1687 if (hit_find_it == detIdToCaloParticleId_Map.end()) {
1688 detIdToCaloParticleId_Map[hitid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
1689 detIdToCaloParticleId_Map[hitid].emplace_back(
1692 auto findHitIt =
std::find(detIdToCaloParticleId_Map[hitid].
begin(),
1693 detIdToCaloParticleId_Map[hitid].
end(),
1695 if (findHitIt != detIdToCaloParticleId_Map[hitid].
end()) {
1696 findHitIt->fraction += it_haf.second;
1698 detIdToCaloParticleId_Map[hitid].emplace_back(
1705 cPOnLayer[cpId][cpLayerId].energy += it_haf.second *
hit->energy();
1712 auto& haf = cPOnLayer[cpId][cpLayerId].hits_and_fractions;
1713 auto found = std::find_if(
1714 std::begin(haf),
std::end(haf), [&hitid](
const std::pair<DetId, float>&
v) {
return v.first == hitid; });
1715 if (
found != haf.end()) {
1716 found->second += it_haf.second;
1718 cPOnLayer[cpId][cpLayerId].hits_and_fractions.emplace_back(hitid, it_haf.second);
1726 for (
unsigned int mclId = 0; mclId < nMultiClusters; ++mclId) {
1727 const auto& hits_and_fractions = multiClusters[mclId].hitsAndFractions();
1729 if (!hits_and_fractions.empty()) {
1730 std::unordered_map<unsigned, float> CPEnergyInMCL;
1731 int maxCPId_byNumberOfHits = -1;
1732 unsigned int maxCPNumberOfHitsInMCL = 0;
1733 int maxCPId_byEnergy = -1;
1734 float maxEnergySharedMCLandCP = 0.f;
1735 float energyFractionOfMCLinCP = 0.f;
1736 float energyFractionOfCPinMCL = 0.f;
1743 std::unordered_map<unsigned, unsigned> occurrencesCPinMCL;
1744 unsigned int numberOfNoiseHitsInMCL = 0;
1745 unsigned int numberOfHaloHitsInMCL = 0;
1746 unsigned int numberOfHitsInMCL = 0;
1749 unsigned int numberOfHitsInLC = hits_and_fractions.size();
1750 numberOfHitsInMCL += numberOfHitsInLC;
1751 std::unordered_map<unsigned, float> CPEnergyInLC;
1770 std::vector<int> hitsToCaloParticleId(numberOfHitsInLC);
1773 const auto firstHitDetId = hits_and_fractions[0].first;
1774 int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) +
1778 for (
unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) {
1779 DetId rh_detid = hits_and_fractions[hitId].first;
1780 auto rhFraction = hits_and_fractions[hitId].second;
1783 std::map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
1793 auto hit_find_in_LC = detIdToMultiClusterId_Map.find(rh_detid);
1794 if (hit_find_in_LC == detIdToMultiClusterId_Map.end()) {
1795 detIdToMultiClusterId_Map[rh_detid] = std::vector<HGVHistoProducerAlgo::detIdInfoInMultiCluster>();
1797 detIdToMultiClusterId_Map[rh_detid].emplace_back(
1801 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
1809 if (rhFraction == 0.) {
1810 hitsToCaloParticleId[hitId] = -2;
1811 numberOfHaloHitsInMCL++;
1813 if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) {
1814 hitsToCaloParticleId[hitId] -= 1;
1816 auto maxCPEnergyInLC = 0.f;
1818 for (
auto&
h : hit_find_in_CP->second) {
1819 auto shared_fraction =
std::min(rhFraction,
h.fraction);
1824 CPEnergyInMCL[
h.clusterId] += shared_fraction *
hit->energy();
1826 CPEnergyInLC[
h.clusterId] += shared_fraction *
hit->energy();
1829 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[mclId].first +=
1830 shared_fraction *
hit->energy();
1831 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[mclId].second = FLT_MAX;
1834 cpsInMultiCluster[mclId].emplace_back(
h.clusterId, FLT_MAX);
1837 if (shared_fraction > maxCPEnergyInLC) {
1839 maxCPEnergyInLC = CPEnergyInLC[
h.clusterId];
1840 maxCPId =
h.clusterId;
1844 hitsToCaloParticleId[hitId] = maxCPId;
1851 for (
auto c : hitsToCaloParticleId) {
1853 numberOfNoiseHitsInMCL++;
1855 occurrencesCPinMCL[
c]++;
1861 for (
auto&
c : occurrencesCPinMCL) {
1862 if (
c.second > maxCPNumberOfHitsInMCL) {
1863 maxCPId_byNumberOfHits =
c.first;
1864 maxCPNumberOfHitsInMCL =
c.second;
1869 for (
auto&
c : CPEnergyInMCL) {
1870 if (
c.second > maxEnergySharedMCLandCP) {
1871 maxCPId_byEnergy =
c.first;
1872 maxEnergySharedMCLandCP =
c.second;
1876 float totalCPEnergyFromLayerCP = 0.f;
1877 if (maxCPId_byEnergy >= 0) {
1879 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
1880 totalCPEnergyFromLayerCP = totalCPEnergyFromLayerCP + cPOnLayer[maxCPId_byEnergy][
j].energy;
1882 energyFractionOfCPinMCL = maxEnergySharedMCLandCP / totalCPEnergyFromLayerCP;
1883 if (multiClusters[mclId].
energy() > 0.
f) {
1884 energyFractionOfMCLinCP = maxEnergySharedMCLandCP / multiClusters[mclId].energy();
1888 LogDebug(
"HGCalValidator") << std::setw(12) <<
"multiCluster"
1890 << std::setw(10) <<
"mulcl energy"
1891 <<
"\t" << std::setw(5) <<
"nhits"
1892 <<
"\t" << std::setw(12) <<
"noise hits"
1893 <<
"\t" << std::setw(22) <<
"maxCPId_byNumberOfHits"
1894 <<
"\t" << std::setw(8) <<
"nhitsCP"
1895 <<
"\t" << std::setw(16) <<
"maxCPId_byEnergy"
1896 <<
"\t" << std::setw(23) <<
"maxEnergySharedMCLandCP"
1897 <<
"\t" << std::setw(22) <<
"totalCPEnergyFromAllLayerCP"
1898 <<
"\t" << std::setw(22) <<
"energyFractionOfMCLinCP"
1899 <<
"\t" << std::setw(25) <<
"energyFractionOfCPinMCL"
1900 <<
"\t" << std::endl;
1901 LogDebug(
"HGCalValidator") << std::setw(12) << mclId <<
"\t"
1902 << std::setw(10) << multiClusters[mclId].energy() <<
"\t" << std::setw(5)
1903 << numberOfHitsInMCL <<
"\t" << std::setw(12) << numberOfNoiseHitsInMCL <<
"\t"
1904 << std::setw(22) << maxCPId_byNumberOfHits <<
"\t" << std::setw(8)
1905 << maxCPNumberOfHitsInMCL <<
"\t" << std::setw(16) << maxCPId_byEnergy <<
"\t"
1906 << std::setw(23) << maxEnergySharedMCLandCP <<
"\t" << std::setw(22)
1907 << totalCPEnergyFromLayerCP <<
"\t" << std::setw(22) << energyFractionOfMCLinCP <<
"\t"
1908 << std::setw(25) << energyFractionOfCPinMCL << std::endl;
1914 for (
unsigned int mclId = 0; mclId < nMultiClusters; ++mclId) {
1915 const auto& hits_and_fractions = multiClusters[mclId].hitsAndFractions();
1917 if (!hits_and_fractions.empty()) {
1920 std::sort(cpsInMultiCluster[mclId].
begin(), cpsInMultiCluster[mclId].
end());
1922 cpsInMultiCluster[mclId].erase(
last, cpsInMultiCluster[mclId].
end());
1924 if (multiClusters[mclId].
energy() == 0. && !cpsInMultiCluster[mclId].
empty()) {
1926 for (
auto& cpPair : cpsInMultiCluster[mclId]) {
1929 LogDebug(
"HGCalValidator") <<
"multiCluster Id: \t" << mclId <<
"\t CP id: \t" << cpPair.first
1930 <<
"\t score \t" << cpPair.second << std::endl;
1937 float invMultiClusterEnergyWeight = 0.f;
1938 for (
auto const& haf : multiClusters[mclId].hitsAndFractions()) {
1939 invMultiClusterEnergyWeight +=
1940 (haf.second * hitMap.at(haf.first)->energy()) * (haf.second * hitMap.at(haf.first)->energy());
1942 invMultiClusterEnergyWeight = 1.f / invMultiClusterEnergyWeight;
1944 unsigned int numberOfHitsInLC = hits_and_fractions.size();
1945 for (
unsigned int i = 0;
i < numberOfHitsInLC; ++
i) {
1946 DetId rh_detid = hits_and_fractions[
i].first;
1947 float rhFraction = hits_and_fractions[
i].second;
1948 bool hitWithNoCP =
false;
1950 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
1951 if (hit_find_in_CP == detIdToCaloParticleId_Map.end())
1953 auto itcheck = hitMap.find(rh_detid);
1955 float hitEnergyWeight =
hit->energy() *
hit->energy();
1957 for (
auto& cpPair : cpsInMultiCluster[mclId]) {
1958 float cpFraction = 0.f;
1960 auto findHitIt =
std::find(detIdToCaloParticleId_Map[rh_detid].
begin(),
1961 detIdToCaloParticleId_Map[rh_detid].
end(),
1963 if (findHitIt != detIdToCaloParticleId_Map[rh_detid].
end()) {
1964 cpFraction = findHitIt->fraction;
1967 if (cpPair.second == FLT_MAX) {
1968 cpPair.second = 0.f;
1971 (rhFraction - cpFraction) * (rhFraction - cpFraction) * hitEnergyWeight * invMultiClusterEnergyWeight;
1976 if (cpsInMultiCluster[mclId].
empty())
1977 LogDebug(
"HGCalValidator") <<
"multiCluster Id: \t" << mclId <<
"\tCP id:\t-1 "
1982 std::end(cpsInMultiCluster[mclId]),
1983 [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
1984 for (
auto& cpPair : cpsInMultiCluster[mclId]) {
1985 LogDebug(
"HGCalValidator") <<
"multiCluster Id: \t" << mclId <<
"\t CP id: \t" << cpPair.first <<
"\t score \t"
1986 << cpPair.second << std::endl;
1987 if (cpPair.first ==
score->first) {
1990 float sharedeneCPallLayers = 0.;
1992 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
1993 auto const& cp_linked = cPOnLayer[cpPair.first][
j].layerClusterIdToEnergyAndScore[mclId];
1994 sharedeneCPallLayers += cp_linked.first;
1996 LogDebug(
"HGCalValidator") <<
"sharedeneCPallLayers " << sharedeneCPallLayers << std::endl;
1997 if (cpPair.first ==
score->first) {
1998 histograms.h_sharedenergy_multicl2caloparticle[
count]->Fill(sharedeneCPallLayers /
1999 multiClusters[mclId].
energy());
2001 score->second, sharedeneCPallLayers / multiClusters[mclId].energy());
2005 auto assocFakeMerge = std::count_if(
std::begin(cpsInMultiCluster[mclId]),
2006 std::end(cpsInMultiCluster[mclId]),
2008 tracksters_fakemerge[mclId] = assocFakeMerge;
2012 std::unordered_map<int, std::vector<float>> score3d;
2013 std::unordered_map<int, std::vector<float>> mclsharedenergy;
2014 std::unordered_map<int, std::vector<float>> mclsharedenergyfrac;
2016 for (
unsigned int i = 0;
i < nCaloParticles; ++
i) {
2017 auto cpIndex = cPIndices[
i];
2018 score3d[cpIndex].resize(nMultiClusters);
2019 mclsharedenergy[cpIndex].resize(nMultiClusters);
2020 mclsharedenergyfrac[cpIndex].resize(nMultiClusters);
2021 for (
unsigned int j = 0;
j < nMultiClusters; ++
j) {
2022 score3d[cpIndex][
j] = FLT_MAX;
2023 mclsharedenergy[cpIndex][
j] = 0.f;
2024 mclsharedenergyfrac[cpIndex][
j] = 0.f;
2031 for (
const auto& cpId : cPSelectedIndices) {
2034 std::vector<unsigned int> cpId_mclId_related;
2035 cpId_mclId_related.clear();
2037 float CPenergy = 0.f;
2038 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId) {
2039 unsigned int CPNumberOfHits = cPOnLayer[cpId][layerId].hits_and_fractions.size();
2041 CPenergy += cPOnLayer[cpId][layerId].energy;
2042 if (CPNumberOfHits == 0)
2044 int mclWithMaxEnergyInCP = -1;
2046 float maxEnergyMCLperlayerinCP = 0.f;
2047 float CPEnergyFractionInMCLperlayer = 0.f;
2049 for (
const auto& mcl : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2050 if (mcl.second.first > maxEnergyMCLperlayerinCP) {
2051 maxEnergyMCLperlayerinCP = mcl.second.first;
2052 mclWithMaxEnergyInCP = mcl.first;
2056 CPEnergyFractionInMCLperlayer = maxEnergyMCLperlayerinCP / CPenergy;
2058 LogDebug(
"HGCalValidator") << std::setw(8) <<
"LayerId:\t" << std::setw(12) <<
"caloparticle\t" << std::setw(15)
2059 <<
"cp total energy\t" << std::setw(15) <<
"cpEnergyOnLayer\t" << std::setw(14)
2060 <<
"CPNhitsOnLayer\t" << std::setw(18) <<
"mclWithMaxEnergyInCP\t" << std::setw(15)
2061 <<
"maxEnergyMCLinCP\t" << std::setw(20) <<
"CPEnergyFractionInMCL"
2063 LogDebug(
"HGCalValidator") << std::setw(8) << layerId <<
"\t" << std::setw(12) << cpId <<
"\t" << std::setw(15)
2064 << cP[cpId].energy() <<
"\t" << std::setw(15) << CPenergy <<
"\t" << std::setw(14)
2065 << CPNumberOfHits <<
"\t" << std::setw(18) << mclWithMaxEnergyInCP <<
"\t"
2066 << std::setw(15) << maxEnergyMCLperlayerinCP <<
"\t" << std::setw(20)
2067 << CPEnergyFractionInMCLperlayer <<
"\n";
2069 for (
unsigned int i = 0;
i < CPNumberOfHits; ++
i) {
2070 auto& cp_hitDetId = cPOnLayer[cpId][layerId].hits_and_fractions[
i].first;
2071 auto& cpFraction = cPOnLayer[cpId][layerId].hits_and_fractions[
i].second;
2073 bool hitWithNoMCL =
false;
2074 if (cpFraction == 0.
f)
2076 auto hit_find_in_MCL = detIdToMultiClusterId_Map.find(cp_hitDetId);
2077 if (hit_find_in_MCL == detIdToMultiClusterId_Map.end())
2078 hitWithNoMCL =
true;
2079 auto itcheck = hitMap.find(cp_hitDetId);
2081 float hitEnergyWeight =
hit->energy() *
hit->energy();
2082 for (
auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2083 unsigned int multiClusterId = lcPair.first;
2086 cpId_mclId_related.push_back(multiClusterId);
2088 float mclFraction = 0.f;
2090 if (!hitWithNoMCL) {
2091 auto findHitIt =
std::find(detIdToMultiClusterId_Map[cp_hitDetId].
begin(),
2092 detIdToMultiClusterId_Map[cp_hitDetId].
end(),
2094 if (findHitIt != detIdToMultiClusterId_Map[cp_hitDetId].
end())
2095 mclFraction = findHitIt->fraction;
2099 if (lcPair.second.second == FLT_MAX) {
2100 lcPair.second.second = 0.f;
2102 lcPair.second.second += (mclFraction - cpFraction) * (mclFraction - cpFraction) * hitEnergyWeight;
2103 LogDebug(
"HGCalValidator") <<
"multiClusterId:\t" << multiClusterId <<
"\t"
2104 <<
"mclfraction,cpfraction:\t" << mclFraction <<
", " << cpFraction <<
"\t"
2105 <<
"hitEnergyWeight:\t" << hitEnergyWeight <<
"\t"
2106 <<
"currect score numerator:\t" << lcPair.second.second <<
"\n";
2110 if (cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore.empty())
2111 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\t MCL id:\t-1 "
2112 <<
"\t layer \t " << layerId <<
" Sub score in \t -1"
2115 for (
const auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2117 if (score3d[cpId][lcPair.first] == FLT_MAX) {
2118 score3d[cpId][lcPair.first] = 0.f;
2120 score3d[cpId][lcPair.first] += lcPair.second.second;
2121 mclsharedenergy[cpId][lcPair.first] += lcPair.second.first;
2129 float invCPEnergyWeight = 0.f;
2130 for (
const auto& layer : cPOnLayer[cpId]) {
2131 for (
const auto& haf : layer.hits_and_fractions) {
2132 invCPEnergyWeight +=
2133 (haf.second * hitMap.at(haf.first)->energy()) * (haf.second * hitMap.at(haf.first)->energy());
2136 invCPEnergyWeight = 1.f / invCPEnergyWeight;
2140 std::vector<int> cpId_mclId_related_vec(cpId_mclId_related.begin(), cpId_mclId_related.end());
2141 for (
unsigned int i = 0;
i < cpId_mclId_related_vec.size(); ++
i) {
2142 auto mclId = cpId_mclId_related_vec[
i];
2144 score3d[cpId][mclId] = score3d[cpId][mclId] * invCPEnergyWeight;
2145 mclsharedenergyfrac[cpId][mclId] = (mclsharedenergy[cpId][mclId] / CPenergy);
2147 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\t MCL id: \t" << mclId <<
"\t score \t"
2148 << score3d[cpId][mclId] <<
"\t"
2149 <<
"invCPEnergyWeight \t" << invCPEnergyWeight <<
"\t"
2150 <<
"shared energy:\t" << mclsharedenergy[cpId][mclId] <<
"\t"
2151 <<
"shared energy fraction:\t" << mclsharedenergyfrac[cpId][mclId] <<
"\n";
2153 histograms.h_score_caloparticle2multicl[
count]->Fill(score3d[cpId][mclId]);
2155 histograms.h_sharedenergy_caloparticle2multicl[
count]->Fill(mclsharedenergyfrac[cpId][mclId]);
2156 histograms.h_energy_vs_score_caloparticle2multicl[
count]->Fill(score3d[cpId][mclId],
2157 mclsharedenergyfrac[cpId][mclId]);
2162 auto assocDup = std::count_if(
std::begin(score3d[cpId]),
std::end(score3d[cpId]), is_assoc);
2165 histograms.h_num_caloparticle_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
2166 histograms.h_num_caloparticle_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
2170 histograms.h_sharedenergy_caloparticle2multicl_vs_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta(),
2171 multiClusters[bestmclId].
energy() / CPenergy);
2172 histograms.h_sharedenergy_caloparticle2multicl_vs_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi(),
2173 multiClusters[bestmclId].
energy() / CPenergy);
2175 if (assocDup >= 2) {
2177 while (
match != score3d[cpId].
end()) {
2182 histograms.h_denom_caloparticle_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
2183 histograms.h_denom_caloparticle_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
2190 for (
unsigned int mclId = 0; mclId < nMultiClusters; ++mclId) {
2191 const auto& hits_and_fractions = multiClusters[mclId].hitsAndFractions();
2192 if (!hits_and_fractions.empty()) {
2193 auto assocFakeMerge = tracksters_fakemerge[mclId];
2194 auto assocDuplicate = tracksters_duplicate[mclId];
2195 if (assocDuplicate) {
2199 if (assocFakeMerge > 0) {
2202 auto best = std::min_element(
std::begin(cpsInMultiCluster[mclId]),
2203 std::end(cpsInMultiCluster[mclId]),
2204 [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
2207 float sharedeneCPallLayers = 0.;
2209 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2210 auto const& best_cp_linked = cPOnLayer[best->first][
j].layerClusterIdToEnergyAndScore[mclId];
2211 sharedeneCPallLayers += best_cp_linked.first;
2214 multiClusters[mclId].
eta(), sharedeneCPallLayers / multiClusters[mclId].
energy());
2216 multiClusters[mclId].
phi(), sharedeneCPallLayers / multiClusters[mclId].
energy());
2218 if (assocFakeMerge >= 2) {
2230 const std::vector<reco::HGCalMultiCluster>& multiClusters,
2231 std::vector<CaloParticle>
const& cP,
2232 std::vector<size_t>
const& cPIndices,
2233 std::vector<size_t>
const& cPSelectedIndices,
2234 std::map<DetId, const HGCRecHit*>
const& hitMap,
2243 int tncontmclpz = 0;
2244 int tncontmclmz = 0;
2246 int tnnoncontmclpz = 0;
2247 int tnnoncontmclmz = 0;
2249 std::vector<bool> contmulti;
2253 std::unordered_map<unsigned int, std::vector<unsigned int>> multiplicity;
2255 std::unordered_map<unsigned int, std::vector<unsigned int>> multiplicity_vs_layer;
2262 auto nMultiClusters = multiClusters.size();
2264 for (
unsigned int mclId = 0; mclId < nMultiClusters; ++mclId) {
2268 if (nLayerClusters == 0)
2271 if (multiClusters[mclId].
z() < 0.) {
2274 if (multiClusters[mclId].
z() > 0.) {
2283 std::vector<int> tnlcinmclperlay(1000, 0);
2287 std::set<int> multicluster_layers;
2289 bool multiclusterInZplus =
false;
2290 bool multiclusterInZminus =
false;
2293 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
2295 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
layerClusters[lcId]->hitsAndFractions();
2298 multiplicity[mclId].emplace_back(hits_and_fractions.size());
2300 const auto firstHitDetId = hits_and_fractions[0].first;
2302 int layerid =
recHitTools_->getLayerWithOffset(firstHitDetId) +
2304 multicluster_layers.insert(layerid);
2305 multiplicity_vs_layer[mclId].emplace_back(layerid);
2307 tnlcinmclperlay[layerid]++;
2311 multiclusterInZplus =
true;
2314 multiclusterInZminus =
true;
2320 for (
unsigned ilayer = 0; ilayer <
layers * 2; ++ilayer) {
2321 if (
histograms.h_clusternum_in_multicluster_perlayer[
count].count(ilayer) && tnlcinmclperlay[ilayer] != 0) {
2322 histograms.h_clusternum_in_multicluster_perlayer[
count].at(ilayer)->Fill((
float)tnlcinmclperlay[ilayer]);
2325 if (tnlcinmclperlay[ilayer] != 0) {
2326 histograms.h_clusternum_in_multicluster_vs_layer[
count]->Fill((
float)ilayer, (
float)tnlcinmclperlay[ilayer]);
2331 std::vector<int> multicluster_layers_vec(multicluster_layers.begin(), multicluster_layers.end());
2333 bool contimulti =
false;
2335 if (multicluster_layers_vec.size() >= 3) {
2336 for (
unsigned int i = 1;
i < multicluster_layers_vec.size() - 1; ++
i) {
2337 if ((multicluster_layers_vec[
i - 1] + 1 == multicluster_layers_vec[
i]) &&
2338 (multicluster_layers_vec[
i + 1] - 1 == multicluster_layers_vec[
i])) {
2340 if (multiclusterInZplus) {
2343 if (multiclusterInZminus) {
2353 if (multiclusterInZplus) {
2356 if (multiclusterInZminus) {
2362 contmulti.push_back(contimulti);
2366 for (
unsigned int lc = 0; lc < multiplicity[mclId].size(); ++lc) {
2371 histograms.h_multiplicityOfLCinMCL[
count]->Fill(mlp, multiplicity[mclId][lc]);
2377 if (multiplicity_vs_layer[mclId][lc] <
layers) {
2378 histograms.h_multiplicityOfLCinMCL_vs_layercluster_zminus[
count]->Fill(mlp, multiplicity_vs_layer[mclId][lc]);
2379 histograms.h_multiplicity_zminus_numberOfEventsHistogram[
count]->Fill(mlp);
2381 histograms.h_multiplicityOfLCinMCL_vs_layercluster_zplus[
count]->Fill(
2382 mlp, multiplicity_vs_layer[mclId][lc] -
layers);
2383 histograms.h_multiplicity_zplus_numberOfEventsHistogram[
count]->Fill(mlp);
2389 if (!multicluster_layers.empty()) {
2397 histograms.h_multicluster_firstlayer[
count]->Fill((
float)*multicluster_layers.begin());
2398 histograms.h_multicluster_lastlayer[
count]->Fill((
float)*multicluster_layers.rbegin());
2399 histograms.h_multicluster_layersnum[
count]->Fill((
float)multicluster_layers.size());
2404 histograms.h_contmulticlusternum[
count]->Fill(tncontmclpz + tncontmclmz);
2405 histograms.h_noncontmulticlusternum[
count]->Fill(tnnoncontmclpz + tnnoncontmclmz);
2413 const double y2)
const {
2414 const double dx =
x1 -
x2;
2415 const double dy =
y1 -
y2;
2421 const double y2)
const {
2430 std::map<DetId, const HGCRecHit*>
const& hitMap)
const {
2432 const std::vector<std::pair<DetId, float>>& hits_and_fractions = cluster.
hitsAndFractions();
2435 for (std::vector<std::pair<DetId, float>>::const_iterator it_haf = hits_and_fractions.begin();
2436 it_haf != hits_and_fractions.end();
2438 DetId rh_detid = it_haf->first;
2440 std::map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
2443 if (maxene < hit->
energy()) {
2444 maxene =
hit->energy();
2445 themaxid = rh_detid;