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")),
99 minTSTSharedEneFracEfficiency_(
pset.getParameter<double>(
"minTSTSharedEneFracEfficiency")),
102 minTSTSharedEneFrac_(
pset.getParameter<double>(
"minTSTSharedEneFrac")),
103 maxTSTSharedEneFrac_(
pset.getParameter<double>(
"maxTSTSharedEneFrac")),
104 nintTSTSharedEneFrac_(
pset.getParameter<
int>(
"nintTSTSharedEneFrac")),
107 minTotNsimClsperthick_(
pset.getParameter<double>(
"minTotNsimClsperthick")),
108 maxTotNsimClsperthick_(
pset.getParameter<double>(
"maxTotNsimClsperthick")),
109 nintTotNsimClsperthick_(
pset.getParameter<
int>(
"nintTotNsimClsperthick")),
112 minTotNClsperthick_(
pset.getParameter<double>(
"minTotNClsperthick")),
113 maxTotNClsperthick_(
pset.getParameter<double>(
"maxTotNClsperthick")),
114 nintTotNClsperthick_(
pset.getParameter<
int>(
"nintTotNClsperthick")),
117 minTotNcellsperthickperlayer_(
pset.getParameter<double>(
"minTotNcellsperthickperlayer")),
118 maxTotNcellsperthickperlayer_(
pset.getParameter<double>(
"maxTotNcellsperthickperlayer")),
119 nintTotNcellsperthickperlayer_(
pset.getParameter<
int>(
"nintTotNcellsperthickperlayer")),
122 minDisToSeedperthickperlayer_(
pset.getParameter<double>(
"minDisToSeedperthickperlayer")),
123 maxDisToSeedperthickperlayer_(
pset.getParameter<double>(
"maxDisToSeedperthickperlayer")),
124 nintDisToSeedperthickperlayer_(
pset.getParameter<
int>(
"nintDisToSeedperthickperlayer")),
127 minDisToSeedperthickperlayerenewei_(
pset.getParameter<double>(
"minDisToSeedperthickperlayerenewei")),
128 maxDisToSeedperthickperlayerenewei_(
pset.getParameter<double>(
"maxDisToSeedperthickperlayerenewei")),
129 nintDisToSeedperthickperlayerenewei_(
pset.getParameter<
int>(
"nintDisToSeedperthickperlayerenewei")),
132 minDisToMaxperthickperlayer_(
pset.getParameter<double>(
"minDisToMaxperthickperlayer")),
133 maxDisToMaxperthickperlayer_(
pset.getParameter<double>(
"maxDisToMaxperthickperlayer")),
134 nintDisToMaxperthickperlayer_(
pset.getParameter<
int>(
"nintDisToMaxperthickperlayer")),
137 minDisToMaxperthickperlayerenewei_(
pset.getParameter<double>(
"minDisToMaxperthickperlayerenewei")),
138 maxDisToMaxperthickperlayerenewei_(
pset.getParameter<double>(
"maxDisToMaxperthickperlayerenewei")),
139 nintDisToMaxperthickperlayerenewei_(
pset.getParameter<
int>(
"nintDisToMaxperthickperlayerenewei")),
142 minDisSeedToMaxperthickperlayer_(
pset.getParameter<double>(
"minDisSeedToMaxperthickperlayer")),
143 maxDisSeedToMaxperthickperlayer_(
pset.getParameter<double>(
"maxDisSeedToMaxperthickperlayer")),
144 nintDisSeedToMaxperthickperlayer_(
pset.getParameter<
int>(
"nintDisSeedToMaxperthickperlayer")),
147 minClEneperthickperlayer_(
pset.getParameter<double>(
"minClEneperthickperlayer")),
148 maxClEneperthickperlayer_(
pset.getParameter<double>(
"maxClEneperthickperlayer")),
149 nintClEneperthickperlayer_(
pset.getParameter<
int>(
"nintClEneperthickperlayer")),
152 minCellsEneDensperthick_(
pset.getParameter<double>(
"minCellsEneDensperthick")),
153 maxCellsEneDensperthick_(
pset.getParameter<double>(
"maxCellsEneDensperthick")),
154 nintCellsEneDensperthick_(
pset.getParameter<
int>(
"nintCellsEneDensperthick")),
158 minTotNTSTs_(
pset.getParameter<double>(
"minTotNTSTs")),
159 maxTotNTSTs_(
pset.getParameter<double>(
"maxTotNTSTs")),
160 nintTotNTSTs_(
pset.getParameter<
int>(
"nintTotNTSTs")),
163 minTotNClsinTSTs_(
pset.getParameter<double>(
"minTotNClsinTSTs")),
164 maxTotNClsinTSTs_(
pset.getParameter<double>(
"maxTotNClsinTSTs")),
165 nintTotNClsinTSTs_(
pset.getParameter<
int>(
"nintTotNClsinTSTs")),
168 minTotNClsinTSTsperlayer_(
pset.getParameter<double>(
"minTotNClsinTSTsperlayer")),
169 maxTotNClsinTSTsperlayer_(
pset.getParameter<double>(
"maxTotNClsinTSTsperlayer")),
170 nintTotNClsinTSTsperlayer_(
pset.getParameter<
int>(
"nintTotNClsinTSTsperlayer")),
173 minMplofLCs_(
pset.getParameter<double>(
"minMplofLCs")),
174 maxMplofLCs_(
pset.getParameter<double>(
"maxMplofLCs")),
175 nintMplofLCs_(
pset.getParameter<
int>(
"nintMplofLCs")),
178 minSizeCLsinTSTs_(
pset.getParameter<double>(
"minSizeCLsinTSTs")),
179 maxSizeCLsinTSTs_(
pset.getParameter<double>(
"maxSizeCLsinTSTs")),
180 nintSizeCLsinTSTs_(
pset.getParameter<
int>(
"nintSizeCLsinTSTs")),
183 minClEnepermultiplicity_(
pset.getParameter<double>(
"minClEnepermultiplicity")),
184 maxClEnepermultiplicity_(
pset.getParameter<double>(
"maxClEnepermultiplicity")),
185 nintClEnepermultiplicity_(
pset.getParameter<
int>(
"nintClEnepermultiplicity")),
188 minX_(
pset.getParameter<double>(
"minX")),
189 maxX_(
pset.getParameter<double>(
"maxX")),
190 nintX_(
pset.getParameter<
int>(
"nintX")),
193 minY_(
pset.getParameter<double>(
"minY")),
194 maxY_(
pset.getParameter<double>(
"maxY")),
195 nintY_(
pset.getParameter<
int>(
"nintY")),
198 minZ_(
pset.getParameter<double>(
"minZ")),
199 maxZ_(
pset.getParameter<double>(
"maxZ")),
200 nintZ_(
pset.getParameter<
int>(
"nintZ")) {}
229 ibook.
book1D(
"EnergyDifference",
"(Energy-SelfEnergy)/Energy", 300., -5., 1.);
232 ibook.
book1D(
"Num Sim Clusters",
"Num Sim Clusters in CaloParticles", 100, 0., 100.);
234 ibook.
book1D(
"Num Hits in Sim Clusters",
"Num Hits in Sim Clusters in CaloParticles", 1000, 0., 1000.);
236 "Num Rec-matched Hits in Sim Clusters",
"Num Hits in Sim Clusters (matched) in CaloParticles", 1000, 0., 1000.);
239 ibook.
book1D(
"Energy of Rec-matched Hits",
"Energy of Hits in Sim Clusters (matched)", 100, 0., 10.);
241 ibook.
book2D(
"Energy of Rec-matched Hits vs layer",
242 "Energy of Hits in Sim Clusters (matched) vs layer",
250 ibook.
book2D(
"Energy of Rec-matched Hits vs layer (1SC)",
251 "Energy of Hits only 1 Sim Clusters (matched) vs layer",
259 ibook.
book2D(
"Rec-matched Hits Sum Energy vs layer",
260 "Rescaled Sum Energy of Hits in Sim Clusters (matched) vs layer",
269 ibook.
book1D(
"First Layer",
"First layer of the CaloParticles", 2 *
layers, 0., (
float)2 *
layers);
271 ibook.
book1D(
"Last Layer",
"Last layer of the CaloParticles", 2 *
layers, 0., (
float)2 *
layers);
273 ibook.
book1D(
"Number of Layers",
"Number of layers of the CaloParticles", 2 *
layers, 0., (
float)2 *
layers);
275 "First Layer (rec-matched hit)",
"First layer of the CaloParticles (matched)", 2 *
layers, 0., (
float)2 *
layers);
277 "Last Layer (rec-matched hit)",
"Last layer of the CaloParticles (matched)", 2 *
layers, 0., (
float)2 *
layers);
279 ibook.
book1D(
"Number of Layers (rec-matched hit)",
280 "Number of layers of the CaloParticles (matched)",
289 std::vector<int> thicknesses) {
291 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
292 auto istr1 = std::to_string(ilayer);
293 while (istr1.size() < 2) {
294 istr1.insert(0,
"0");
300 istr2 = std::to_string(ilayer + 1) +
" in z-";
302 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
304 histograms.h_simclusternum_perlayer[ilayer] = ibook.
book1D(
"totsimclusternum_layer_" + istr1,
305 "total number of SimClusters for layer " + istr2,
312 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
313 auto istr = std::to_string(*it);
314 histograms.h_simclusternum_perthick[(*it)] = ibook.
book1D(
"totsimclusternum_thick_" + istr,
315 "total number of simclusters for thickness " + istr,
324 ibook.
book1D(
"mixedhitssimcluster_zminus",
325 "N of simclusters that contain hits of more than one kind in z-",
331 ibook.
book1D(
"mixedhitssimcluster_zplus",
332 "N of simclusters that contain hits of more than one kind in z+",
341 std::vector<int> thicknesses) {
342 std::unordered_map<int, dqm::reco::MonitorElement*> denom_layercl_in_simcl_eta_perlayer;
343 denom_layercl_in_simcl_eta_perlayer.clear();
344 std::unordered_map<int, dqm::reco::MonitorElement*> denom_layercl_in_simcl_phi_perlayer;
345 denom_layercl_in_simcl_phi_perlayer.clear();
346 std::unordered_map<int, dqm::reco::MonitorElement*> score_layercl2simcluster_perlayer;
347 score_layercl2simcluster_perlayer.clear();
348 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_layercl2simcluster_perlayer;
349 sharedenergy_layercl2simcluster_perlayer.clear();
350 std::unordered_map<int, dqm::reco::MonitorElement*> energy_vs_score_layercl2simcluster_perlayer;
351 energy_vs_score_layercl2simcluster_perlayer.clear();
352 std::unordered_map<int, dqm::reco::MonitorElement*> num_layercl_in_simcl_eta_perlayer;
353 num_layercl_in_simcl_eta_perlayer.clear();
354 std::unordered_map<int, dqm::reco::MonitorElement*> num_layercl_in_simcl_phi_perlayer;
355 num_layercl_in_simcl_phi_perlayer.clear();
356 std::unordered_map<int, dqm::reco::MonitorElement*> numMerge_layercl_in_simcl_eta_perlayer;
357 numMerge_layercl_in_simcl_eta_perlayer.clear();
358 std::unordered_map<int, dqm::reco::MonitorElement*> numMerge_layercl_in_simcl_phi_perlayer;
359 numMerge_layercl_in_simcl_phi_perlayer.clear();
360 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_layercl2simcluster_vs_eta_perlayer;
361 sharedenergy_layercl2simcluster_vs_eta_perlayer.clear();
362 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_layercl2simcluster_vs_phi_perlayer;
363 sharedenergy_layercl2simcluster_vs_phi_perlayer.clear();
364 std::unordered_map<int, dqm::reco::MonitorElement*> denom_simcluster_eta_perlayer;
365 denom_simcluster_eta_perlayer.clear();
366 std::unordered_map<int, dqm::reco::MonitorElement*> denom_simcluster_phi_perlayer;
367 denom_simcluster_phi_perlayer.clear();
368 std::unordered_map<int, dqm::reco::MonitorElement*> score_simcluster2layercl_perlayer;
369 score_simcluster2layercl_perlayer.clear();
370 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_simcluster2layercl_perlayer;
371 sharedenergy_simcluster2layercl_perlayer.clear();
372 std::unordered_map<int, dqm::reco::MonitorElement*> energy_vs_score_simcluster2layercl_perlayer;
373 energy_vs_score_simcluster2layercl_perlayer.clear();
374 std::unordered_map<int, dqm::reco::MonitorElement*> num_simcluster_eta_perlayer;
375 num_simcluster_eta_perlayer.clear();
376 std::unordered_map<int, dqm::reco::MonitorElement*> num_simcluster_phi_perlayer;
377 num_simcluster_phi_perlayer.clear();
378 std::unordered_map<int, dqm::reco::MonitorElement*> numDup_simcluster_eta_perlayer;
379 numDup_simcluster_eta_perlayer.clear();
380 std::unordered_map<int, dqm::reco::MonitorElement*> numDup_simcluster_phi_perlayer;
381 numDup_simcluster_phi_perlayer.clear();
382 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_simcluster2layercl_vs_eta_perlayer;
383 sharedenergy_simcluster2layercl_vs_eta_perlayer.clear();
384 std::unordered_map<int, dqm::reco::MonitorElement*> sharedenergy_simcluster2layercl_vs_phi_perlayer;
385 sharedenergy_simcluster2layercl_vs_phi_perlayer.clear();
388 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
389 auto istr1 = std::to_string(ilayer);
390 while (istr1.size() < 2) {
391 istr1.insert(0,
"0");
397 istr2 = std::to_string(ilayer + 1) +
" in z-";
399 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
402 denom_layercl_in_simcl_eta_perlayer[ilayer] =
403 ibook.
book1D(
"Denom_LayerCluster_in_SimCluster_Eta_perlayer" + istr1,
404 "Denom LayerCluster in SimCluster Eta per Layer Cluster for layer " + istr2,
409 denom_layercl_in_simcl_phi_perlayer[ilayer] =
410 ibook.
book1D(
"Denom_LayerCluster_in_SimCluster_Phi_perlayer" + istr1,
411 "Denom LayerCluster in SimCluster Phi per Layer Cluster for layer " + istr2,
416 score_layercl2simcluster_perlayer[ilayer] = ibook.
book1D(
"Score_layercl2simcluster_perlayer" + istr1,
417 "Score of Layer Cluster per SimCluster for layer " + istr2,
422 score_simcluster2layercl_perlayer[ilayer] = ibook.
book1D(
"Score_simcluster2layercl_perlayer" + istr1,
423 "Score of SimCluster per Layer Cluster for layer " + istr2,
428 energy_vs_score_simcluster2layercl_perlayer[ilayer] =
429 ibook.
book2D(
"Energy_vs_Score_simcluster2layer_perlayer" + istr1,
430 "Energy vs Score of SimCluster per Layer Cluster for layer " + istr2,
438 energy_vs_score_layercl2simcluster_perlayer[ilayer] =
439 ibook.
book2D(
"Energy_vs_Score_layer2simcluster_perlayer" + istr1,
440 "Energy vs Score of Layer Cluster per SimCluster for layer " + istr2,
448 sharedenergy_simcluster2layercl_perlayer[ilayer] =
449 ibook.
book1D(
"SharedEnergy_simcluster2layercl_perlayer" + istr1,
450 "Shared Energy of SimCluster per Layer Cluster for layer " + istr2,
455 sharedenergy_simcluster2layercl_vs_eta_perlayer[ilayer] =
456 ibook.
bookProfile(
"SharedEnergy_simcluster2layercl_vs_eta_perlayer" + istr1,
457 "Shared Energy of SimCluster vs #eta per best Layer Cluster for layer " + istr2,
464 sharedenergy_simcluster2layercl_vs_phi_perlayer[ilayer] =
465 ibook.
bookProfile(
"SharedEnergy_simcluster2layercl_vs_phi_perlayer" + istr1,
466 "Shared Energy of SimCluster vs #phi per best Layer Cluster for layer " + istr2,
473 sharedenergy_layercl2simcluster_perlayer[ilayer] =
474 ibook.
book1D(
"SharedEnergy_layercluster2simcluster_perlayer" + istr1,
475 "Shared Energy of Layer Cluster per SimCluster for layer " + istr2,
480 sharedenergy_layercl2simcluster_vs_eta_perlayer[ilayer] =
481 ibook.
bookProfile(
"SharedEnergy_layercl2simcluster_vs_eta_perlayer" + istr1,
482 "Shared Energy of LayerCluster vs #eta per best SimCluster for layer " + istr2,
489 sharedenergy_layercl2simcluster_vs_phi_perlayer[ilayer] =
490 ibook.
bookProfile(
"SharedEnergy_layercl2simcluster_vs_phi_perlayer" + istr1,
491 "Shared Energy of LayerCluster vs #phi per best SimCluster for layer " + istr2,
498 num_simcluster_eta_perlayer[ilayer] = ibook.
book1D(
"Num_SimCluster_Eta_perlayer" + istr1,
499 "Num SimCluster Eta per Layer Cluster for layer " + istr2,
504 numDup_simcluster_eta_perlayer[ilayer] =
505 ibook.
book1D(
"NumDup_SimCluster_Eta_perlayer" + istr1,
506 "Num Duplicate SimCluster Eta per Layer Cluster for layer " + istr2,
511 denom_simcluster_eta_perlayer[ilayer] = ibook.
book1D(
"Denom_SimCluster_Eta_perlayer" + istr1,
512 "Denom SimCluster Eta per Layer Cluster for layer " + istr2,
517 num_simcluster_phi_perlayer[ilayer] = ibook.
book1D(
"Num_SimCluster_Phi_perlayer" + istr1,
518 "Num SimCluster Phi per Layer Cluster for layer " + istr2,
523 numDup_simcluster_phi_perlayer[ilayer] =
524 ibook.
book1D(
"NumDup_SimCluster_Phi_perlayer" + istr1,
525 "Num Duplicate SimCluster Phi per Layer Cluster for layer " + istr2,
530 denom_simcluster_phi_perlayer[ilayer] = ibook.
book1D(
"Denom_SimCluster_Phi_perlayer" + istr1,
531 "Denom SimCluster Phi per Layer Cluster for layer " + istr2,
536 num_layercl_in_simcl_eta_perlayer[ilayer] =
537 ibook.
book1D(
"Num_LayerCluster_in_SimCluster_Eta_perlayer" + istr1,
538 "Num LayerCluster Eta per Layer Cluster in SimCluster for layer " + istr2,
543 numMerge_layercl_in_simcl_eta_perlayer[ilayer] =
544 ibook.
book1D(
"NumMerge_LayerCluster_in_SimCluster_Eta_perlayer" + istr1,
545 "Num Merge LayerCluster Eta per Layer Cluster in SimCluster for layer " + istr2,
550 num_layercl_in_simcl_phi_perlayer[ilayer] =
551 ibook.
book1D(
"Num_LayerCluster_in_SimCluster_Phi_perlayer" + istr1,
552 "Num LayerCluster Phi per Layer Cluster in SimCluster for layer " + istr2,
557 numMerge_layercl_in_simcl_phi_perlayer[ilayer] =
558 ibook.
book1D(
"NumMerge_LayerCluster_in_SimCluster_Phi_perlayer" + istr1,
559 "Num Merge LayerCluster Phi per Layer Cluster in SimCluster for layer " + istr2,
566 histograms.h_denom_layercl_in_simcl_eta_perlayer.push_back(
std::move(denom_layercl_in_simcl_eta_perlayer));
567 histograms.h_denom_layercl_in_simcl_phi_perlayer.push_back(
std::move(denom_layercl_in_simcl_phi_perlayer));
568 histograms.h_score_layercl2simcluster_perlayer.push_back(
std::move(score_layercl2simcluster_perlayer));
569 histograms.h_sharedenergy_layercl2simcluster_perlayer.push_back(
std::move(sharedenergy_layercl2simcluster_perlayer));
570 histograms.h_energy_vs_score_layercl2simcluster_perlayer.push_back(
571 std::move(energy_vs_score_layercl2simcluster_perlayer));
572 histograms.h_num_layercl_in_simcl_eta_perlayer.push_back(
std::move(num_layercl_in_simcl_eta_perlayer));
573 histograms.h_num_layercl_in_simcl_phi_perlayer.push_back(
std::move(num_layercl_in_simcl_phi_perlayer));
574 histograms.h_numMerge_layercl_in_simcl_eta_perlayer.push_back(
std::move(numMerge_layercl_in_simcl_eta_perlayer));
575 histograms.h_numMerge_layercl_in_simcl_phi_perlayer.push_back(
std::move(numMerge_layercl_in_simcl_phi_perlayer));
576 histograms.h_sharedenergy_layercl2simcluster_vs_eta_perlayer.push_back(
577 std::move(sharedenergy_layercl2simcluster_vs_eta_perlayer));
578 histograms.h_sharedenergy_layercl2simcluster_vs_phi_perlayer.push_back(
579 std::move(sharedenergy_layercl2simcluster_vs_phi_perlayer));
580 histograms.h_denom_simcluster_eta_perlayer.push_back(
std::move(denom_simcluster_eta_perlayer));
581 histograms.h_denom_simcluster_phi_perlayer.push_back(
std::move(denom_simcluster_phi_perlayer));
582 histograms.h_score_simcluster2layercl_perlayer.push_back(
std::move(score_simcluster2layercl_perlayer));
583 histograms.h_sharedenergy_simcluster2layercl_perlayer.push_back(
std::move(sharedenergy_simcluster2layercl_perlayer));
584 histograms.h_energy_vs_score_simcluster2layercl_perlayer.push_back(
585 std::move(energy_vs_score_simcluster2layercl_perlayer));
586 histograms.h_num_simcluster_eta_perlayer.push_back(
std::move(num_simcluster_eta_perlayer));
587 histograms.h_num_simcluster_phi_perlayer.push_back(
std::move(num_simcluster_phi_perlayer));
588 histograms.h_numDup_simcluster_eta_perlayer.push_back(
std::move(numDup_simcluster_eta_perlayer));
589 histograms.h_numDup_simcluster_phi_perlayer.push_back(
std::move(numDup_simcluster_phi_perlayer));
590 histograms.h_sharedenergy_simcluster2layercl_vs_eta_perlayer.push_back(
591 std::move(sharedenergy_simcluster2layercl_vs_eta_perlayer));
592 histograms.h_sharedenergy_simcluster2layercl_vs_phi_perlayer.push_back(
593 std::move(sharedenergy_simcluster2layercl_vs_phi_perlayer));
598 std::vector<int> thicknesses,
606 histograms.h_mixedhitscluster_zminus.push_back(
607 ibook.
book1D(
"mixedhitscluster_zminus",
608 "N of reco clusters that contain hits of more than one kind in z-",
613 histograms.h_mixedhitscluster_zplus.push_back(
614 ibook.
book1D(
"mixedhitscluster_zplus",
615 "N of reco clusters that contain hits of more than one kind in z+",
622 histograms.h_energyclustered_zminus.push_back(
623 ibook.
book1D(
"energyclustered_zminus",
624 "percent of total energy clustered by all layer clusters over CaloParticless energy in z-",
630 ibook.
book1D(
"energyclustered_zplus",
631 "percent of total energy clustered by all layer clusters over CaloParticless energy in z+",
638 std::string subpathtomat = pathtomatbudfile.substr(pathtomatbudfile.find(
"Validation"));
639 histograms.h_longdepthbarycentre_zminus.push_back(
640 ibook.
book1D(
"longdepthbarycentre_zminus",
641 "The longitudinal depth barycentre in z- for " + subpathtomat,
646 histograms.h_longdepthbarycentre_zplus.push_back(
647 ibook.
book1D(
"longdepthbarycentre_zplus",
648 "The longitudinal depth barycentre in z+ for " + subpathtomat,
654 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
655 auto istr1 = std::to_string(ilayer);
656 while (istr1.size() < 2) {
657 istr1.insert(0,
"0");
663 istr2 = std::to_string(ilayer + 1) +
" in z-";
665 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
667 histograms.h_clusternum_perlayer[ilayer] = ibook.
book1D(
"totclusternum_layer_" + istr1,
668 "total number of layer clusters for layer " + istr2,
673 "energyclustered_perlayer" + istr1,
674 "percent of total energy clustered by layer clusters over CaloParticless energy for layer " + istr2,
681 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
682 auto istr = std::to_string(*it);
683 histograms.h_clusternum_perthick[(*it)] = ibook.
book1D(
"totclusternum_thick_" + istr,
684 "total number of layer clusters for thickness " + istr,
696 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
697 auto istr1 = std::to_string(ilayer);
698 while (istr1.size() < 2) {
699 istr1.insert(0,
"0");
705 istr2 = std::to_string(ilayer + 1) +
" in z-";
707 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
709 histograms.h_score_layercl2caloparticle_perlayer[ilayer] =
710 ibook.
book1D(
"Score_layercl2caloparticle_perlayer" + istr1,
711 "Score of Layer Cluster per CaloParticle for layer " + istr2,
715 histograms.h_score_caloparticle2layercl_perlayer[ilayer] =
716 ibook.
book1D(
"Score_caloparticle2layercl_perlayer" + istr1,
717 "Score of CaloParticle per Layer Cluster for layer " + istr2,
721 histograms.h_energy_vs_score_caloparticle2layercl_perlayer[ilayer] =
722 ibook.
book2D(
"Energy_vs_Score_caloparticle2layer_perlayer" + istr1,
723 "Energy vs Score of CaloParticle per Layer Cluster for layer " + istr2,
730 histograms.h_energy_vs_score_layercl2caloparticle_perlayer[ilayer] =
731 ibook.
book2D(
"Energy_vs_Score_layer2caloparticle_perlayer" + istr1,
732 "Energy vs Score of Layer Cluster per CaloParticle Layer for layer " + istr2,
739 histograms.h_sharedenergy_caloparticle2layercl_perlayer[ilayer] =
740 ibook.
book1D(
"SharedEnergy_caloparticle2layercl_perlayer" + istr1,
741 "Shared Energy of CaloParticle per Layer Cluster for layer " + istr2,
745 histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer[ilayer] =
746 ibook.
bookProfile(
"SharedEnergy_caloparticle2layercl_vs_eta_perlayer" + istr1,
747 "Shared Energy of CaloParticle vs #eta per best Layer Cluster for layer " + istr2,
753 histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer[ilayer] =
754 ibook.
bookProfile(
"SharedEnergy_caloparticle2layercl_vs_phi_perlayer" + istr1,
755 "Shared Energy of CaloParticle vs #phi per best Layer Cluster for layer " + istr2,
761 histograms.h_sharedenergy_layercl2caloparticle_perlayer[ilayer] =
762 ibook.
book1D(
"SharedEnergy_layercluster2caloparticle_perlayer" + istr1,
763 "Shared Energy of Layer Cluster per Layer Calo Particle for layer " + istr2,
767 histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer[ilayer] =
768 ibook.
bookProfile(
"SharedEnergy_layercl2caloparticle_vs_eta_perlayer" + istr1,
769 "Shared Energy of LayerCluster vs #eta per best Calo Particle for layer " + istr2,
775 histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer[ilayer] =
776 ibook.
bookProfile(
"SharedEnergy_layercl2caloparticle_vs_phi_perlayer" + istr1,
777 "Shared Energy of LayerCluster vs #phi per best Calo Particle for layer " + istr2,
783 histograms.h_num_caloparticle_eta_perlayer[ilayer] =
784 ibook.
book1D(
"Num_CaloParticle_Eta_perlayer" + istr1,
785 "Num CaloParticle Eta per Layer Cluster for layer " + istr2,
789 histograms.h_numDup_caloparticle_eta_perlayer[ilayer] =
790 ibook.
book1D(
"NumDup_CaloParticle_Eta_perlayer" + istr1,
791 "Num Duplicate CaloParticle Eta per Layer Cluster for layer " + istr2,
795 histograms.h_denom_caloparticle_eta_perlayer[ilayer] =
796 ibook.
book1D(
"Denom_CaloParticle_Eta_perlayer" + istr1,
797 "Denom CaloParticle Eta per Layer Cluster for layer " + istr2,
801 histograms.h_num_caloparticle_phi_perlayer[ilayer] =
802 ibook.
book1D(
"Num_CaloParticle_Phi_perlayer" + istr1,
803 "Num CaloParticle Phi per Layer Cluster for layer " + istr2,
807 histograms.h_numDup_caloparticle_phi_perlayer[ilayer] =
808 ibook.
book1D(
"NumDup_CaloParticle_Phi_perlayer" + istr1,
809 "Num Duplicate CaloParticle Phi per Layer Cluster for layer " + istr2,
813 histograms.h_denom_caloparticle_phi_perlayer[ilayer] =
814 ibook.
book1D(
"Denom_CaloParticle_Phi_perlayer" + istr1,
815 "Denom CaloParticle Phi per Layer Cluster for layer " + istr2,
819 histograms.h_num_layercl_eta_perlayer[ilayer] =
820 ibook.
book1D(
"Num_LayerCluster_Eta_perlayer" + istr1,
821 "Num LayerCluster Eta per Layer Cluster for layer " + istr2,
825 histograms.h_numMerge_layercl_eta_perlayer[ilayer] =
826 ibook.
book1D(
"NumMerge_LayerCluster_Eta_perlayer" + istr1,
827 "Num Merge LayerCluster Eta per Layer Cluster for layer " + istr2,
831 histograms.h_denom_layercl_eta_perlayer[ilayer] =
832 ibook.
book1D(
"Denom_LayerCluster_Eta_perlayer" + istr1,
833 "Denom LayerCluster Eta per Layer Cluster for layer " + istr2,
837 histograms.h_num_layercl_phi_perlayer[ilayer] =
838 ibook.
book1D(
"Num_LayerCluster_Phi_perlayer" + istr1,
839 "Num LayerCluster Phi per Layer Cluster for layer " + istr2,
843 histograms.h_numMerge_layercl_phi_perlayer[ilayer] =
844 ibook.
book1D(
"NumMerge_LayerCluster_Phi_perlayer" + istr1,
845 "Num Merge LayerCluster Phi per Layer Cluster for layer " + istr2,
849 histograms.h_denom_layercl_phi_perlayer[ilayer] =
850 ibook.
book1D(
"Denom_LayerCluster_Phi_perlayer" + istr1,
851 "Denom LayerCluster Phi per Layer Cluster for layer " + istr2,
862 std::vector<int> thicknesses) {
864 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
865 auto istr1 = std::to_string(ilayer);
866 while (istr1.size() < 2) {
867 istr1.insert(0,
"0");
873 istr2 = std::to_string(ilayer + 1) +
" in z-";
875 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
877 histograms.h_cellAssociation_perlayer[ilayer] =
878 ibook.
book1D(
"cellAssociation_perlayer" + istr1,
"Cell Association for layer " + istr2, 5, -4., 1.);
879 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(2,
"TN(purity)");
880 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(3,
"FN(ineff.)");
881 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(4,
"FP(fake)");
882 histograms.h_cellAssociation_perlayer[ilayer]->setBinLabel(5,
"TP(eff.)");
885 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
886 auto istr = std::to_string(*it);
887 histograms.h_cellsenedens_perthick[(*it)] = ibook.
book1D(
"cellsenedens_thick_" + istr,
888 "energy density of cluster cells for thickness " + istr,
895 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
896 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
897 auto istr1 = std::to_string(*it);
898 auto istr2 = std::to_string(ilayer);
899 while (istr2.size() < 2)
900 istr2.insert(0,
"0");
901 auto istr = istr1 +
"_" + istr2;
906 istr3 = std::to_string(ilayer + 1) +
" in z- ";
908 istr3 = std::to_string(ilayer - (
layers - 1)) +
" in z+ ";
911 histograms.h_cellsnum_perthickperlayer[istr] =
912 ibook.
book1D(
"cellsnum_perthick_perlayer_" + istr,
913 "total number of cells for layer " + istr3 +
" for thickness " + istr1,
918 histograms.h_distancetoseedcell_perthickperlayer[istr] =
919 ibook.
book1D(
"distancetoseedcell_perthickperlayer_" + istr,
920 "distance of cluster cells to seed cell for layer " + istr3 +
" for thickness " + istr1,
925 histograms.h_distancetoseedcell_perthickperlayer_eneweighted[istr] = ibook.
book1D(
926 "distancetoseedcell_perthickperlayer_eneweighted_" + istr,
927 "energy weighted distance of cluster cells to seed cell for layer " + istr3 +
" for thickness " + istr1,
932 histograms.h_distancetomaxcell_perthickperlayer[istr] =
933 ibook.
book1D(
"distancetomaxcell_perthickperlayer_" + istr,
934 "distance of cluster cells to max cell for layer " + istr3 +
" for thickness " + istr1,
939 histograms.h_distancetomaxcell_perthickperlayer_eneweighted[istr] = ibook.
book1D(
940 "distancetomaxcell_perthickperlayer_eneweighted_" + istr,
941 "energy weighted distance of cluster cells to max cell for layer " + istr3 +
" for thickness " + istr1,
946 histograms.h_distancebetseedandmaxcell_perthickperlayer[istr] =
947 ibook.
book1D(
"distancebetseedandmaxcell_perthickperlayer_" + istr,
948 "distance of seed cell to max cell for layer " + istr3 +
" for thickness " + istr1,
953 histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer[istr] = ibook.
book2D(
954 "distancebetseedandmaxcellvsclusterenergy_perthickperlayer_" + istr,
955 "distance of seed cell to max cell vs cluster energy for layer " + istr3 +
" for thickness " + istr1,
972 histograms.h_energy_vs_score_trackster2caloparticle.push_back(
973 ibook.
book2D(
"Energy_vs_Score_trackster2caloparticle",
974 "Energy vs Score of Trackster per CaloParticle",
981 histograms.h_energy_vs_score_caloparticle2trackster.push_back(
982 ibook.
book2D(
"Energy_vs_Score_caloparticle2trackster",
983 "Energy vs Score of CaloParticle per Trackster",
994 histograms.h_numMerge_trackster_eta.push_back(
1000 histograms.h_numMerge_trackster_phi.push_back(
1004 histograms.h_sharedenergy_trackster2caloparticle.push_back(
1005 ibook.
book1D(
"SharedEnergy_trackster2caloparticle",
1006 "Shared Energy of Trackster per Calo Particle in each layer",
1010 histograms.h_sharedenergy_trackster2caloparticle_vs_eta.push_back(
1011 ibook.
bookProfile(
"SharedEnergy_trackster2caloparticle_vs_eta",
1012 "Shared Energy of Trackster vs #eta per best Calo Particle in each layer",
1018 histograms.h_sharedenergy_trackster2caloparticle_vs_phi.push_back(
1019 ibook.
bookProfile(
"SharedEnergy_trackster2caloparticle_vs_phi",
1020 "Shared Energy of Trackster vs #phi per best Calo Particle in each layer",
1026 histograms.h_sharedenergy_caloparticle2trackster.push_back(ibook.
book1D(
"SharedEnergy_caloparticle2trackster",
1027 "Shared Energy of CaloParticle per Trackster",
1031 histograms.h_sharedenergy_caloparticle2trackster_assoc.push_back(
1032 ibook.
book1D(
"SharedEnergy_caloparticle2trackster_assoc",
1033 "Shared Energy of Associated CaloParticle per Trackster",
1037 histograms.h_sharedenergy_caloparticle2trackster_vs_eta.push_back(
1038 ibook.
bookProfile(
"SharedEnergy_caloparticle2trackster_vs_eta",
1039 "Shared Energy of CaloParticle vs #eta per best Trackster",
1045 histograms.h_sharedenergy_caloparticle2trackster_vs_phi.push_back(
1046 ibook.
bookProfile(
"SharedEnergy_caloparticle2trackster_vs_phi",
1047 "Shared Energy of CaloParticle vs #phi per best Trackster",
1054 "NumEff_CaloParticle_Eta",
"Num Efficiency CaloParticle Eta per Trackster",
nintEta_,
minEta_,
maxEta_));
1059 histograms.h_denom_caloparticle_eta.push_back(
1062 "NumEff_CaloParticle_Phi",
"Num Efficiency CaloParticle Phi per Trackster",
nintPhi_,
minPhi_,
maxPhi_));
1067 histograms.h_denom_caloparticle_phi.push_back(
1070 std::unordered_map<int, dqm::reco::MonitorElement*> clusternum_in_trackster_perlayer;
1071 clusternum_in_trackster_perlayer.clear();
1073 for (
unsigned ilayer = 0; ilayer < 2 *
layers; ++ilayer) {
1074 auto istr1 = std::to_string(ilayer);
1075 while (istr1.size() < 2) {
1076 istr1.insert(0,
"0");
1082 istr2 = std::to_string(ilayer + 1) +
" in z-";
1084 istr2 = std::to_string(ilayer - (
layers - 1)) +
" in z+";
1087 clusternum_in_trackster_perlayer[ilayer] = ibook.
book1D(
"clusternum_in_trackster_perlayer" + istr1,
1088 "Number of layer clusters in Trackster for layer " + istr2,
1094 histograms.h_clusternum_in_trackster_perlayer.push_back(
std::move(clusternum_in_trackster_perlayer));
1102 histograms.h_nonconttracksternum.push_back(ibook.
book1D(
"nonconttracksternum",
1103 "number of Tracksters without 3 contiguous layers",
1108 histograms.h_clusternum_in_trackster.push_back(ibook.
book1D(
"clusternum_in_trackster",
1109 "total number of layer clusters in Trackster",
1114 histograms.h_clusternum_in_trackster_vs_layer.push_back(
1115 ibook.
bookProfile(
"clusternum_in_trackster_vs_layer",
1116 "Profile of 2d layer clusters in Trackster vs layer number",
1123 histograms.h_multiplicityOfLCinTST.push_back(ibook.
book2D(
"multiplicityOfLCinTST",
1124 "Multiplicity vs Layer cluster size in Tracksters",
1132 histograms.h_multiplicity_numberOfEventsHistogram.push_back(ibook.
book1D(
"multiplicity_numberOfEventsHistogram",
1133 "multiplicity numberOfEventsHistogram",
1138 histograms.h_multiplicity_zminus_numberOfEventsHistogram.push_back(
1139 ibook.
book1D(
"multiplicity_zminus_numberOfEventsHistogram",
1140 "multiplicity numberOfEventsHistogram in z-",
1145 histograms.h_multiplicity_zplus_numberOfEventsHistogram.push_back(
1146 ibook.
book1D(
"multiplicity_zplus_numberOfEventsHistogram",
1147 "multiplicity numberOfEventsHistogram in z+",
1152 histograms.h_multiplicityOfLCinTST_vs_layercluster_zminus.push_back(
1153 ibook.
book2D(
"multiplicityOfLCinTST_vs_layercluster_zminus",
1154 "Multiplicity vs Layer number in z-",
1162 histograms.h_multiplicityOfLCinTST_vs_layercluster_zplus.push_back(
1163 ibook.
book2D(
"multiplicityOfLCinTST_vs_layercluster_zplus",
1164 "Multiplicity vs Layer number in z+",
1172 histograms.h_multiplicityOfLCinTST_vs_layerclusterenergy.push_back(
1173 ibook.
book2D(
"multiplicityOfLCinTST_vs_layerclusterenergy",
1174 "Multiplicity vs Layer cluster energy",
1193 ibook.
book1D(
"trackster_firstlayer",
"First layer of the Trackster", 2 *
layers, 0., (
float)2 *
layers));
1195 ibook.
book1D(
"trackster_lastlayer",
"Last layer of the Trackster", 2 *
layers, 0., (
float)2 *
layers));
1197 ibook.
book1D(
"trackster_layersnum",
"Number of layers of the Trackster", 2 *
layers, 0., (
float)2 *
layers));
1218 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap)
const {
1242 int minLayerId = 999;
1245 int simHits_matched = 0;
1246 int minLayerId_matched = 999;
1247 int maxLayerId_matched = 0;
1250 std::map<int, double> totenergy_layer;
1252 for (
auto const& sc : caloParticle.
simClusters()) {
1253 LogDebug(
"HGCalValidator") <<
" This sim cluster has " << sc->hits_and_fractions().size() <<
" simHits and "
1254 << sc->energy() <<
" energy. " << std::endl;
1255 simHits += sc->hits_and_fractions().size();
1256 for (
auto const& h_and_f : sc->hits_and_fractions()) {
1257 const auto hitDetId = h_and_f.first;
1261 int layerId_matched_min = 999;
1262 int layerId_matched_max = 0;
1263 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitDetId);
1264 if (itcheck != hitMap.end()) {
1265 layerId_matched_min = layerId;
1266 layerId_matched_max = layerId;
1270 energy +=
hit->energy() * h_and_f.second;
1271 histograms.h_caloparticle_nHits_matched_energy.at(
pdgid)->Fill(
hit->energy() * h_and_f.second);
1272 histograms.h_caloparticle_nHits_matched_energy_layer.at(
pdgid)->Fill(layerId,
hit->energy() * h_and_f.second);
1274 if (totenergy_layer.find(layerId) != totenergy_layer.end()) {
1275 totenergy_layer[layerId] = totenergy_layer.at(layerId) +
hit->energy();
1277 totenergy_layer.emplace(layerId,
hit->energy());
1280 histograms.h_caloparticle_nHits_matched_energy_layer_1SimCl.at(
pdgid)->Fill(layerId,
1281 hit->energy() * h_and_f.second);
1283 LogDebug(
"HGCalValidator") <<
" matched to RecHit NOT found !" << std::endl;
1286 minLayerId =
std::min(minLayerId, layerId);
1287 maxLayerId =
std::max(maxLayerId, layerId);
1288 minLayerId_matched =
std::min(minLayerId_matched, layerId_matched_min);
1289 maxLayerId_matched =
std::max(maxLayerId_matched, layerId_matched_max);
1291 LogDebug(
"HGCalValidator") << std::endl;
1295 histograms.h_caloparticle_layersnum.at(
pdgid)->Fill(
int(maxLayerId - minLayerId));
1297 histograms.h_caloparticle_firstlayer_matchedtoRecHit.at(
pdgid)->Fill(minLayerId_matched);
1298 histograms.h_caloparticle_lastlayer_matchedtoRecHit.at(
pdgid)->Fill(maxLayerId_matched);
1299 histograms.h_caloparticle_layersnum_matchedtoRecHit.at(
pdgid)->Fill(
int(maxLayerId_matched - minLayerId_matched));
1302 histograms.h_caloparticle_nHitsInSimClusters_matchedtoRecHit.at(
pdgid)->Fill((
float)simHits_matched);
1307 auto i = totenergy_layer.begin();
1308 double sum_energy = 0.0;
1309 while (
i != totenergy_layer.end()) {
1310 sum_energy +=
i->second;
1311 histograms.h_caloparticle_sum_energy_layer.at(
pdgid)->Fill(
i->first, sum_energy / caloParticle.
energy() * 100.);
1317 void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simCluster_histos(
const Histograms&
histograms,
1318 std::vector<SimCluster>
const& simClusters,
1320 std::vector<int> thicknesses)
const {
1329 std::vector<int> tnscpl(1000, 0);
1332 std::map<std::string, int> tnscpthplus;
1333 tnscpthplus.clear();
1334 std::map<std::string, int> tnscpthminus;
1335 tnscpthminus.clear();
1337 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
1338 tnscpthplus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1339 tnscpthminus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1342 tnscpthplus.insert(std::pair<std::string, int>(
"mixed", 0));
1343 tnscpthminus.insert(std::pair<std::string, int>(
"mixed", 0));
1346 for (
unsigned int ic = 0; ic < simClusters.size(); ++ic) {
1347 const auto& sc = simClusters[ic];
1348 const auto& hitsAndFractions = sc.hits_and_fractions();
1351 int nthhits120p = 0;
1352 int nthhits200p = 0;
1353 int nthhits300p = 0;
1354 int nthhitsscintp = 0;
1355 int nthhits120m = 0;
1356 int nthhits200m = 0;
1357 int nthhits300m = 0;
1358 int nthhitsscintm = 0;
1362 std::vector<int> occurenceSCinlayer(1000, 0);
1365 for (
const auto& hAndF : hitsAndFractions) {
1366 const DetId sh_detid = hAndF.first;
1370 recHitTools_->getLayerWithOffset(sh_detid) +
layers * ((recHitTools_->zside(sh_detid) + 1) >> 1) - 1;
1372 int zside = recHitTools_->zside(sh_detid);
1375 if (occurenceSCinlayer[layerid] == 0) {
1378 occurenceSCinlayer[layerid]++;
1381 thickness = recHitTools_->getSiThickness(sh_detid);
1385 LogDebug(
"HGCalValidator") <<
"These are HGCal simClusters, you shouldn't be here !!! " << layerid <<
"\n";
1407 <<
" You are running a geometry that contains thicknesses different than the normal ones. "
1414 if ((nthhits120p != 0 && nthhits200p != 0) || (nthhits120p != 0 && nthhits300p != 0) ||
1415 (nthhits120p != 0 && nthhitsscintp != 0) || (nthhits200p != 0 && nthhits300p != 0) ||
1416 (nthhits200p != 0 && nthhitsscintp != 0) || (nthhits300p != 0 && nthhitsscintp != 0)) {
1417 tnscpthplus[
"mixed"]++;
1418 }
else if ((nthhits120p != 0 || nthhits200p != 0 || nthhits300p != 0 || nthhitsscintp != 0)) {
1420 tnscpthplus[std::to_string((
int)
thickness)]++;
1422 if ((nthhits120m != 0 && nthhits200m != 0) || (nthhits120m != 0 && nthhits300m != 0) ||
1423 (nthhits120m != 0 && nthhitsscintm != 0) || (nthhits200m != 0 && nthhits300m != 0) ||
1424 (nthhits200m != 0 && nthhitsscintm != 0) || (nthhits300m != 0 && nthhitsscintm != 0)) {
1425 tnscpthminus[
"mixed"]++;
1426 }
else if ((nthhits120m != 0 || nthhits200m != 0 || nthhits300m != 0 || nthhitsscintm != 0)) {
1428 tnscpthminus[std::to_string((
int)
thickness)]++;
1434 for (
unsigned ilayer = 0; ilayer <
layers * 2; ++ilayer) {
1435 if (
histograms.h_simclusternum_perlayer.count(ilayer)) {
1436 histograms.h_simclusternum_perlayer.at(ilayer)->Fill(tnscpl[ilayer]);
1441 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
1442 if (
histograms.h_simclusternum_perthick.count(*it)) {
1443 histograms.h_simclusternum_perthick.at(*it)->Fill(tnscpthplus[std::to_string(*it)]);
1444 histograms.h_simclusternum_perthick.at(*it)->Fill(tnscpthminus[std::to_string(*it)]);
1448 histograms.h_mixedhitssimcluster_zplus->Fill(tnscpthplus[
"mixed"]);
1449 histograms.h_mixedhitssimcluster_zminus->Fill(tnscpthminus[
"mixed"]);
1452 void HGVHistoProducerAlgo::HGVHistoProducerAlgo::fill_simClusterAssociation_histos(
1457 edm::Handle<std::vector<SimCluster>> simClusterHandle,
1458 std::vector<SimCluster>
const& simClusters,
1459 std::vector<size_t>
const& sCIndices,
1460 const std::vector<float>& mask,
1461 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
1483 scsInLayerClusterMap,
1484 lcsInSimClusterMap);
1497 edm::Handle<std::vector<CaloParticle>> caloParticleHandle,
1498 std::vector<CaloParticle>
const& cP,
1499 std::vector<size_t>
const& cPIndices,
1500 std::vector<size_t>
const& cPSelectedIndices,
1501 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
1505 auto nLayerClusters =
clusters.size();
1507 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToCaloParticleId_Map;
1508 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToLayerClusterId_Map;
1512 for (
const auto& cpId : cPIndices) {
1514 for (
const auto& it_sc : simClusterRefVector) {
1517 for (
const auto& it_haf : hits_and_fractions) {
1518 DetId hitid = (it_haf.first);
1519 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
1520 if (itcheck != hitMap.end()) {
1521 auto hit_find_it = detIdToCaloParticleId_Map.find(hitid);
1522 if (hit_find_it == detIdToCaloParticleId_Map.end()) {
1523 detIdToCaloParticleId_Map[hitid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
1524 detIdToCaloParticleId_Map[hitid].emplace_back(
1527 auto findHitIt =
std::find(detIdToCaloParticleId_Map[hitid].begin(),
1528 detIdToCaloParticleId_Map[hitid].
end(),
1530 if (findHitIt != detIdToCaloParticleId_Map[hitid].
end()) {
1531 findHitIt->fraction += it_haf.second;
1533 detIdToCaloParticleId_Map[hitid].emplace_back(
1542 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
1543 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1544 unsigned int numberOfHitsInLC = hits_and_fractions.size();
1554 std::vector<int> hitsToCaloParticleId(numberOfHitsInLC);
1555 const auto firstHitDetId = hits_and_fractions[0].first;
1560 std::unordered_map<unsigned, float> CPEnergyInLC;
1562 for (
unsigned int hitId = 0; hitId < numberOfHitsInLC; hitId++) {
1563 DetId rh_detid = hits_and_fractions[hitId].first;
1564 const auto rhFraction = hits_and_fractions[hitId].second;
1566 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
1569 auto hit_find_in_LC = detIdToLayerClusterId_Map.find(rh_detid);
1570 if (hit_find_in_LC == detIdToLayerClusterId_Map.end()) {
1571 detIdToLayerClusterId_Map[rh_detid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
1575 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
1583 if (rhFraction == 0.) {
1584 hitsToCaloParticleId[hitId] = -2;
1586 if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) {
1587 hitsToCaloParticleId[hitId] -= 1;
1589 auto maxCPEnergyInLC = 0.f;
1591 for (
auto&
h : hit_find_in_CP->second) {
1592 CPEnergyInLC[
h.clusterId] +=
h.fraction *
hit->energy();
1595 if (CPEnergyInLC[
h.clusterId] > maxCPEnergyInLC) {
1596 maxCPEnergyInLC = CPEnergyInLC[
h.clusterId];
1597 maxCPId =
h.clusterId;
1600 hitsToCaloParticleId[hitId] = maxCPId;
1602 histograms.h_cellAssociation_perlayer.at(lcLayerId)->Fill(
1603 hitsToCaloParticleId[hitId] > 0. ? 0. : hitsToCaloParticleId[hitId]);
1611 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
1612 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1613 const auto firstHitDetId = hits_and_fractions[0].first;
1614 const int lcLayerId =
1620 const auto& cpsIt = cpsInLayerClusterMap.
find(lcRef);
1621 if (cpsIt == cpsInLayerClusterMap.
end())
1624 const auto& cps = cpsIt->
val;
1626 for (
const auto& cpPair : cps) {
1627 histograms.h_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(cpPair.second);
1631 for (
const auto& cpPair : cps) {
1632 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId <<
"\t CP id: \t" << cpPair.first.index()
1633 <<
"\t score \t" << cpPair.second << std::endl;
1634 histograms.h_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(cpPair.second);
1635 auto const& cp_linked =
1636 std::find_if(std::begin(cPOnLayerMap[cpPair.first]),
1637 std::end(cPOnLayerMap[cpPair.first]),
1639 return p.first == lcRef;
1642 cPOnLayerMap[cpPair.first].
end())
1644 histograms.h_sharedenergy_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(
1645 cp_linked->second.first /
clusters[lcId].energy(),
clusters[lcId].energy());
1646 histograms.h_energy_vs_score_layercl2caloparticle_perlayer.at(lcLayerId)->Fill(
1647 cpPair.second, cp_linked->second.first /
clusters[lcId].energy());
1658 const auto& best = std::min_element(
1659 std::begin(cps),
std::end(cps), [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
1660 const auto& best_cp_linked =
1661 std::find_if(std::begin(cPOnLayerMap[best->first]),
1662 std::end(cPOnLayerMap[best->first]),
1664 return p.first == lcRef;
1666 if (best_cp_linked ==
1667 cPOnLayerMap[best->first].
end())
1669 histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer.at(lcLayerId)->Fill(
1671 histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer.at(lcLayerId)->Fill(
1679 for (
const auto& cpId : cPSelectedIndices) {
1681 const auto& lcsIt = cPOnLayerMap.
find(cpRef);
1683 std::map<unsigned int, float> cPEnergyOnLayer;
1684 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId)
1685 cPEnergyOnLayer[layerId] = 0;
1688 for (
const auto& it_sc : simClusterRefVector) {
1691 for (
const auto& it_haf : hits_and_fractions) {
1692 const DetId hitid = (it_haf.first);
1693 const int cpLayerId =
1695 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
1696 if (itcheck != hitMap.end()) {
1698 cPEnergyOnLayer[cpLayerId] += it_haf.second *
hit->energy();
1703 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId) {
1704 if (!cPEnergyOnLayer[layerId])
1707 histograms.h_denom_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1708 histograms.h_denom_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1710 if (lcsIt == cPOnLayerMap.
end())
1712 const auto& lcs = lcsIt->val;
1714 auto getLCLayerId = [&](
const unsigned int lcId) {
1715 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1716 const auto firstHitDetId = hits_and_fractions[0].first;
1717 const unsigned int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) +
1722 for (
const auto& lcPair : lcs) {
1723 if (getLCLayerId(lcPair.first.index()) != layerId)
1725 histograms.h_score_caloparticle2layercl_perlayer.at(layerId)->Fill(lcPair.second.second);
1726 histograms.h_sharedenergy_caloparticle2layercl_perlayer.at(layerId)->Fill(
1727 lcPair.second.first / cPEnergyOnLayer[layerId], cPEnergyOnLayer[layerId]);
1728 histograms.h_energy_vs_score_caloparticle2layercl_perlayer.at(layerId)->Fill(
1729 lcPair.second.second, lcPair.second.first / cPEnergyOnLayer[layerId]);
1731 const auto assoc = std::count_if(std::begin(lcs),
std::end(lcs), [&](
const auto&
obj) {
1732 if (getLCLayerId(
obj.first.index()) != layerId)
1738 histograms.h_num_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1739 histograms.h_num_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1741 histograms.h_numDup_caloparticle_eta_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
1742 histograms.h_numDup_caloparticle_phi_perlayer.at(layerId)->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
1744 const auto best = std::min_element(std::begin(lcs),
std::end(lcs), [&](
const auto& obj1,
const auto& obj2) {
1745 if (getLCLayerId(obj1.first.index()) != layerId)
1747 else if (getLCLayerId(obj2.first.index()) == layerId)
1748 return obj1.second.second < obj2.second.second;
1752 histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer.at(layerId)->Fill(
1753 cP[cpId].g4Tracks()[0].momentum().
eta(), best->second.first / cPEnergyOnLayer[layerId]);
1754 histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer.at(layerId)->Fill(
1755 cP[cpId].g4Tracks()[0].momentum().
phi(), best->second.first / cPEnergyOnLayer[layerId]);
1766 edm::Handle<std::vector<SimCluster>> simClusterHandle,
1767 std::vector<SimCluster>
const& sC,
1768 std::vector<size_t>
const& sCIndices,
1769 const std::vector<float>& mask,
1770 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
1774 auto nLayerClusters =
clusters.size();
1779 for (
unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
1780 if (mask[lcId] != 0.) {
1781 LogDebug(
"HGCalValidator") <<
"Skipping layer cluster " << lcId <<
" not belonging to mask" << std::endl;
1784 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1785 const auto firstHitDetId = hits_and_fractions[0].first;
1786 const int lcLayerId =
1794 const auto& scsIt = scsInLayerClusterMap.
find(lcRef);
1795 if (scsIt == scsInLayerClusterMap.
end())
1798 const auto& scs = scsIt->
val;
1802 for (
const auto& scPair : scs) {
1803 histograms.h_score_layercl2simcluster_perlayer[
count].at(lcLayerId)->Fill(scPair.second);
1808 for (
const auto& scPair : scs) {
1809 LogDebug(
"HGCalValidator") <<
"layerCluster Id: \t" << lcId <<
"\t SC id: \t" << scPair.first.index()
1810 <<
"\t score \t" << scPair.second << std::endl;
1812 histograms.h_score_layercl2simcluster_perlayer[
count].at(lcLayerId)->Fill(scPair.second);
1813 auto const& sc_linked =
1814 std::find_if(std::begin(lcsInSimClusterMap[scPair.first]),
1815 std::end(lcsInSimClusterMap[scPair.first]),
1817 return p.first == lcRef;
1820 lcsInSimClusterMap[scPair.first].
end())
1822 histograms.h_sharedenergy_layercl2simcluster_perlayer[
count].at(lcLayerId)->Fill(
1823 sc_linked->second.first /
clusters[lcId].energy(),
clusters[lcId].energy());
1824 histograms.h_energy_vs_score_layercl2simcluster_perlayer[
count].at(lcLayerId)->Fill(
1825 scPair.second, sc_linked->second.first /
clusters[lcId].energy());
1837 const auto& best = std::min_element(
1838 std::begin(scs),
std::end(scs), [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
1840 const auto& best_sc_linked =
1841 std::find_if(std::begin(lcsInSimClusterMap[best->first]),
1842 std::end(lcsInSimClusterMap[best->first]),
1844 return p.first == lcRef;
1846 if (best_sc_linked ==
1847 lcsInSimClusterMap[best->first].
end())
1849 histograms.h_sharedenergy_layercl2simcluster_vs_eta_perlayer[
count].at(lcLayerId)->Fill(
1851 histograms.h_sharedenergy_layercl2simcluster_vs_phi_perlayer[
count].at(lcLayerId)->Fill(
1859 for (
const auto& scId : sCIndices) {
1861 const auto& lcsIt = lcsInSimClusterMap.
find(scRef);
1863 std::map<unsigned int, float> sCEnergyOnLayer;
1864 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId)
1865 sCEnergyOnLayer[layerId] = 0;
1867 const auto& hits_and_fractions = sC[scId].hits_and_fractions();
1868 for (
const auto& it_haf : hits_and_fractions) {
1869 const DetId hitid = (it_haf.first);
1870 const int scLayerId =
1872 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
1873 if (itcheck != hitMap.end()) {
1875 sCEnergyOnLayer[scLayerId] += it_haf.second *
hit->energy();
1879 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId) {
1880 if (!sCEnergyOnLayer[layerId])
1886 if (lcsIt == lcsInSimClusterMap.
end())
1888 const auto& lcs = lcsIt->val;
1890 auto getLCLayerId = [&](
const unsigned int lcId) {
1891 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
clusters[lcId].hitsAndFractions();
1892 const auto firstHitDetId = hits_and_fractions[0].first;
1893 const unsigned int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) +
1899 for (
const auto& lcPair : lcs) {
1900 auto lcId = lcPair.first.index();
1901 if (mask[lcId] != 0.) {
1902 LogDebug(
"HGCalValidator") <<
"Skipping layer cluster " << lcId <<
" not belonging to mask" << std::endl;
1906 if (getLCLayerId(lcId) != layerId)
1908 histograms.h_score_simcluster2layercl_perlayer[
count].at(layerId)->Fill(lcPair.second.second);
1909 histograms.h_sharedenergy_simcluster2layercl_perlayer[
count].at(layerId)->Fill(
1910 lcPair.second.first / sCEnergyOnLayer[layerId], sCEnergyOnLayer[layerId]);
1911 histograms.h_energy_vs_score_simcluster2layercl_perlayer[
count].at(layerId)->Fill(
1912 lcPair.second.second, lcPair.second.first / sCEnergyOnLayer[layerId]);
1914 const auto assoc = std::count_if(std::begin(lcs),
std::end(lcs), [&](
const auto&
obj) {
1915 if (getLCLayerId(
obj.first.index()) != layerId)
1924 histograms.h_numDup_simcluster_eta_perlayer[
count].at(layerId)->Fill(sC[scId].
eta());
1925 histograms.h_numDup_simcluster_phi_perlayer[
count].at(layerId)->Fill(sC[scId].
phi());
1927 const auto best = std::min_element(std::begin(lcs),
std::end(lcs), [&](
const auto& obj1,
const auto& obj2) {
1928 if (getLCLayerId(obj1.first.index()) != layerId)
1930 else if (getLCLayerId(obj2.first.index()) == layerId)
1931 return obj1.second.second < obj2.second.second;
1935 histograms.h_sharedenergy_simcluster2layercl_vs_eta_perlayer[
count].at(layerId)->Fill(
1936 sC[scId].
eta(), best->second.first / sCEnergyOnLayer[layerId]);
1937 histograms.h_sharedenergy_simcluster2layercl_vs_phi_perlayer[
count].at(layerId)->Fill(
1938 sC[scId].
phi(), best->second.first / sCEnergyOnLayer[layerId]);
1949 edm::Handle<std::vector<CaloParticle>> caloParticleHandle,
1950 std::vector<CaloParticle>
const& cP,
1951 std::vector<size_t>
const& cPIndices,
1952 std::vector<size_t>
const& cPSelectedIndices,
1953 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
1954 std::map<double, double> cummatbudg,
1956 std::vector<int> thicknesses,
1967 std::vector<int> tnlcpl(1000, 0);
1970 std::map<std::string, int> tnlcpthplus;
1971 tnlcpthplus.clear();
1972 std::map<std::string, int> tnlcpthminus;
1973 tnlcpthminus.clear();
1975 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
1976 tnlcpthplus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1977 tnlcpthminus.insert(std::pair<std::string, int>(std::to_string(*it), 0));
1980 tnlcpthplus.insert(std::pair<std::string, int>(
"mixed", 0));
1981 tnlcpthminus.insert(std::pair<std::string, int>(
"mixed", 0));
1992 cpsInLayerClusterMap,
1997 std::vector<double> tecpl(1000, 0.0);
1999 std::vector<double> ldbar(1000, 0.0);
2002 double caloparteneplus = 0.;
2003 double caloparteneminus = 0.;
2004 for (
const auto& cpId : cPIndices) {
2005 if (cP[cpId].
eta() >= 0.) {
2006 caloparteneplus = caloparteneplus + cP[cpId].energy();
2008 if (cP[cpId].
eta() < 0.) {
2009 caloparteneminus = caloparteneminus + cP[cpId].energy();
2014 for (
unsigned int lcId = 0; lcId <
clusters.size(); lcId++) {
2015 const std::vector<std::pair<DetId, float>> hits_and_fractions =
clusters[lcId].hitsAndFractions();
2018 const double seedx =
recHitTools_->getPosition(seedid).x();
2019 const double seedy =
recHitTools_->getPosition(seedid).y();
2027 int nthhits120p = 0;
2028 int nthhits200p = 0;
2029 int nthhits300p = 0;
2030 int nthhitsscintp = 0;
2031 int nthhits120m = 0;
2032 int nthhits200m = 0;
2033 int nthhits300m = 0;
2034 int nthhitsscintm = 0;
2045 bool cluslay =
true;
2049 for (
std::vector<std::pair<DetId, float>>::const_iterator it_haf = hits_and_fractions.begin();
2050 it_haf != hits_and_fractions.end();
2052 const DetId rh_detid = it_haf->first;
2062 LogDebug(
"HGCalValidator") <<
"These are HGCal layer clusters, you shouldn't be here !!! " << layerid <<
"\n";
2069 while (lay_string.size() < 2)
2070 lay_string.insert(0,
"0");
2071 curistr +=
"_" + lay_string;
2096 <<
" You are running a geometry that contains thicknesses different than the normal ones. "
2100 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
2101 if (itcheck == hitMap.end()) {
2102 LogDebug(
"HGCalValidator") <<
" You shouldn't be here - Unable to find a hit " << rh_detid.
rawId() <<
" "
2111 const double hit_x =
recHitTools_->getPosition(rh_detid).x();
2112 const double hit_y =
recHitTools_->getPosition(rh_detid).y();
2113 double distancetoseed =
distance(seedx, seedy, hit_x, hit_y);
2114 double distancetomax =
distance(maxx, maxy, hit_x, hit_y);
2115 if (distancetoseed != 0. &&
histograms.h_distancetoseedcell_perthickperlayer.count(curistr)) {
2116 histograms.h_distancetoseedcell_perthickperlayer.at(curistr)->Fill(distancetoseed);
2119 if (distancetoseed != 0. &&
histograms.h_distancetoseedcell_perthickperlayer_eneweighted.count(curistr)) {
2120 histograms.h_distancetoseedcell_perthickperlayer_eneweighted.at(curistr)->Fill(distancetoseed,
hit->energy());
2123 if (distancetomax != 0. &&
histograms.h_distancetomaxcell_perthickperlayer.count(curistr)) {
2124 histograms.h_distancetomaxcell_perthickperlayer.at(curistr)->Fill(distancetomax);
2127 if (distancetomax != 0. &&
histograms.h_distancetomaxcell_perthickperlayer_eneweighted.count(curistr)) {
2128 histograms.h_distancetomaxcell_perthickperlayer_eneweighted.at(curistr)->Fill(distancetomax,
hit->energy());
2132 std::map<DetId, float>::const_iterator dit = densities.find(rh_detid);
2133 if (dit == densities.end()) {
2134 LogDebug(
"HGCalValidator") <<
" You shouldn't be here - Unable to find a density " << rh_detid.
rawId() <<
" "
2146 if ((nthhits120p != 0 && nthhits200p != 0) || (nthhits120p != 0 && nthhits300p != 0) ||
2147 (nthhits120p != 0 && nthhitsscintp != 0) || (nthhits200p != 0 && nthhits300p != 0) ||
2148 (nthhits200p != 0 && nthhitsscintp != 0) || (nthhits300p != 0 && nthhitsscintp != 0)) {
2149 tnlcpthplus[
"mixed"]++;
2150 }
else if ((nthhits120p != 0 || nthhits200p != 0 || nthhits300p != 0 || nthhitsscintp != 0)) {
2152 tnlcpthplus[std::to_string((
int)
thickness)]++;
2154 if ((nthhits120m != 0 && nthhits200m != 0) || (nthhits120m != 0 && nthhits300m != 0) ||
2155 (nthhits120m != 0 && nthhitsscintm != 0) || (nthhits200m != 0 && nthhits300m != 0) ||
2156 (nthhits200m != 0 && nthhitsscintm != 0) || (nthhits300m != 0 && nthhitsscintm != 0)) {
2157 tnlcpthminus[
"mixed"]++;
2158 }
else if ((nthhits120m != 0 || nthhits200m != 0 || nthhits300m != 0 || nthhitsscintm != 0)) {
2160 tnlcpthminus[std::to_string((
int)
thickness)]++;
2164 std::vector<int> bigamoth;
2167 bigamoth.push_back(nthhits120p);
2168 bigamoth.push_back(nthhits200p);
2169 bigamoth.push_back(nthhits300p);
2170 bigamoth.push_back(nthhitsscintp);
2173 bigamoth.push_back(nthhits120m);
2174 bigamoth.push_back(nthhits200m);
2175 bigamoth.push_back(nthhits300m);
2176 bigamoth.push_back(nthhitsscintm);
2178 auto bgth = std::max_element(bigamoth.begin(), bigamoth.end());
2179 istr = std::to_string(thicknesses[
std::distance(bigamoth.begin(), bgth)]);
2181 while (lay_string.size() < 2)
2182 lay_string.insert(0,
"0");
2183 istr +=
"_" + lay_string;
2186 if (
histograms.h_cellsnum_perthickperlayer.count(istr)) {
2187 histograms.h_cellsnum_perthickperlayer.at(istr)->Fill(hits_and_fractions.size());
2191 double distancebetseedandmax =
distance(seedx, seedy, maxx, maxy);
2193 std::string seedstr = std::to_string((
int)
recHitTools_->getSiThickness(seedid)) +
"_" + std::to_string(layerid);
2194 seedstr +=
"_" + lay_string;
2195 if (
histograms.h_distancebetseedandmaxcell_perthickperlayer.count(seedstr)) {
2196 histograms.h_distancebetseedandmaxcell_perthickperlayer.at(seedstr)->Fill(distancebetseedandmax);
2198 if (
histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer.count(seedstr)) {
2199 histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer.at(seedstr)->Fill(distancebetseedandmax,
2204 tecpl[layerid] = tecpl[layerid] +
clusters[lcId].energy();
2205 ldbar[layerid] = ldbar[layerid] +
clusters[lcId].energy() * cummatbudg[(double)lay];
2211 double sumeneallcluspl = 0.;
2212 double sumeneallclusmi = 0.;
2214 double sumldbarpl = 0.;
2215 double sumldbarmi = 0.;
2217 for (
unsigned ilayer = 0; ilayer <
layers * 2; ++ilayer) {
2218 if (
histograms.h_clusternum_perlayer.count(ilayer)) {
2219 histograms.h_clusternum_perlayer.at(ilayer)->Fill(tnlcpl[ilayer]);
2224 if (
histograms.h_energyclustered_perlayer.count(ilayer)) {
2225 if (caloparteneminus != 0.) {
2226 histograms.h_energyclustered_perlayer.at(ilayer)->Fill(100. * tecpl[ilayer] / caloparteneminus);
2230 sumeneallclusmi = sumeneallclusmi + tecpl[ilayer];
2232 sumldbarmi = sumldbarmi + ldbar[ilayer];
2234 if (
histograms.h_energyclustered_perlayer.count(ilayer)) {
2235 if (caloparteneplus != 0.) {
2236 histograms.h_energyclustered_perlayer.at(ilayer)->Fill(100. * tecpl[ilayer] / caloparteneplus);
2240 sumeneallcluspl = sumeneallcluspl + tecpl[ilayer];
2242 sumldbarpl = sumldbarpl + ldbar[ilayer];
2248 for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
2249 if (
histograms.h_clusternum_perthick.count(*it)) {
2250 histograms.h_clusternum_perthick.at(*it)->Fill(tnlcpthplus[std::to_string(*it)]);
2251 histograms.h_clusternum_perthick.at(*it)->Fill(tnlcpthminus[std::to_string(*it)]);
2255 histograms.h_mixedhitscluster_zplus[
count]->Fill(tnlcpthplus[
"mixed"]);
2256 histograms.h_mixedhitscluster_zminus[
count]->Fill(tnlcpthminus[
"mixed"]);
2259 if (caloparteneplus != 0.) {
2260 histograms.h_energyclustered_zplus[
count]->Fill(100. * sumeneallcluspl / caloparteneplus);
2262 if (caloparteneminus != 0.) {
2263 histograms.h_energyclustered_zminus[
count]->Fill(100. * sumeneallclusmi / caloparteneminus);
2267 histograms.h_longdepthbarycentre_zplus[
count]->Fill(sumldbarpl / sumeneallcluspl);
2268 histograms.h_longdepthbarycentre_zminus[
count]->Fill(sumldbarmi / sumeneallclusmi);
2275 std::vector<CaloParticle>
const& cP,
2276 std::vector<size_t>
const& cPIndices,
2277 std::vector<size_t>
const& cPSelectedIndices,
2278 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
2279 unsigned int layers)
const {
2280 auto nTracksters = tracksters.size();
2282 auto nCaloParticles = cPIndices.size();
2284 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToCaloParticleId_Map;
2285 std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInTrackster>> detIdToTracksterId_Map;
2286 std::vector<int> tracksters_fakemerge(nTracksters, 0);
2287 std::vector<int> tracksters_duplicate(nTracksters, 0);
2292 std::vector<std::vector<std::pair<unsigned int, float>>> cpsInTrackster;
2293 cpsInTrackster.resize(nTracksters);
2302 std::unordered_map<int, std::vector<caloParticleOnLayer>> cPOnLayer;
2303 for (
unsigned int i = 0;
i < nCaloParticles; ++
i) {
2304 auto cpIndex = cPIndices[
i];
2305 cPOnLayer[cpIndex].resize(
layers * 2);
2306 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2307 cPOnLayer[cpIndex][
j].caloParticleId = cpIndex;
2308 cPOnLayer[cpIndex][
j].energy = 0.f;
2309 cPOnLayer[cpIndex][
j].hits_and_fractions.clear();
2313 for (
const auto& cpId : cPIndices) {
2317 for (
const auto& it_sc : simClusterRefVector) {
2320 for (
const auto& it_haf : hits_and_fractions) {
2321 DetId hitid = (it_haf.first);
2325 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
2327 if (itcheck != hitMap.end()) {
2336 auto hit_find_it = detIdToCaloParticleId_Map.find(hitid);
2337 if (hit_find_it == detIdToCaloParticleId_Map.end()) {
2338 detIdToCaloParticleId_Map[hitid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
2339 detIdToCaloParticleId_Map[hitid].emplace_back(
2342 auto findHitIt =
std::find(detIdToCaloParticleId_Map[hitid].begin(),
2343 detIdToCaloParticleId_Map[hitid].
end(),
2345 if (findHitIt != detIdToCaloParticleId_Map[hitid].
end()) {
2346 findHitIt->fraction += it_haf.second;
2348 detIdToCaloParticleId_Map[hitid].emplace_back(
2355 cPOnLayer[cpId][cpLayerId].energy += it_haf.second *
hit->energy();
2362 auto& haf = cPOnLayer[cpId][cpLayerId].hits_and_fractions;
2363 auto found = std::find_if(
2364 std::begin(haf),
std::end(haf), [&hitid](
const std::pair<DetId, float>&
v) {
return v.first == hitid; });
2365 if (
found != haf.end()) {
2366 found->second += it_haf.second;
2368 cPOnLayer[cpId][cpLayerId].hits_and_fractions.emplace_back(hitid, it_haf.second);
2376 std::vector<std::pair<DetId, float>> hits_and_fractions_norm;
2381 hits_and_fractions_norm.emplace_back(cell.first, cell.second *
fraction);
2384 return hits_and_fractions_norm;
2388 for (
unsigned int tstId = 0; tstId < nTracksters; ++tstId) {
2389 if (tracksters[tstId].
vertices().empty())
2392 std::unordered_map<unsigned, float> CPEnergyInTST;
2393 int maxCPId_byNumberOfHits = -1;
2394 unsigned int maxCPNumberOfHitsInTST = 0;
2395 int maxCPId_byEnergy = -1;
2396 float maxEnergySharedTSTandCP = 0.f;
2397 float energyFractionOfTSTinCP = 0.f;
2398 float energyFractionOfCPinTST = 0.f;
2405 std::unordered_map<unsigned, unsigned> occurrencesCPinTST;
2406 unsigned int numberOfNoiseHitsInTST = 0;
2407 unsigned int numberOfHaloHitsInTST = 0;
2409 const auto tst_hitsAndFractions = apply_LCMultiplicity(tracksters[tstId],
layerClusters);
2410 const auto numberOfHitsInTST = tst_hitsAndFractions.size();
2429 std::vector<int> hitsToCaloParticleId(numberOfHitsInTST);
2434 for (
unsigned int hitId = 0; hitId < numberOfHitsInTST; hitId++) {
2435 const auto rh_detid = tst_hitsAndFractions[hitId].first;
2436 const auto rhFraction = tst_hitsAndFractions[hitId].second;
2438 const int lcLayerId =
2441 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
2451 auto hit_find_in_LC = detIdToTracksterId_Map.find(rh_detid);
2452 if (hit_find_in_LC == detIdToTracksterId_Map.end()) {
2453 detIdToTracksterId_Map[rh_detid] = std::vector<HGVHistoProducerAlgo::detIdInfoInTrackster>();
2455 detIdToTracksterId_Map[rh_detid].emplace_back(
2459 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
2467 if (rhFraction == 0.) {
2468 hitsToCaloParticleId[hitId] = -2;
2469 numberOfHaloHitsInTST++;
2471 if (hit_find_in_CP == detIdToCaloParticleId_Map.end()) {
2472 hitsToCaloParticleId[hitId] -= 1;
2474 auto maxCPEnergyInTST = 0.f;
2476 for (
const auto&
h : hit_find_in_CP->second) {
2477 auto shared_fraction =
std::min(rhFraction,
h.fraction);
2482 CPEnergyInTST[
h.clusterId] += shared_fraction *
hit->energy();
2485 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[tstId].first +=
2486 shared_fraction *
hit->energy();
2487 cPOnLayer[
h.clusterId][lcLayerId].layerClusterIdToEnergyAndScore[tstId].second = FLT_MAX;
2490 cpsInTrackster[tstId].emplace_back(
h.clusterId, FLT_MAX);
2493 if (shared_fraction > maxCPEnergyInTST) {
2495 maxCPEnergyInTST = CPEnergyInTST[
h.clusterId];
2496 maxCPId =
h.clusterId;
2500 hitsToCaloParticleId[hitId] = maxCPId;
2507 for (
auto c : hitsToCaloParticleId) {
2509 numberOfNoiseHitsInTST++;
2511 occurrencesCPinTST[
c]++;
2517 for (
auto&
c : occurrencesCPinTST) {
2518 if (
c.second > maxCPNumberOfHitsInTST) {
2519 maxCPId_byNumberOfHits =
c.first;
2520 maxCPNumberOfHitsInTST =
c.second;
2525 for (
auto&
c : CPEnergyInTST) {
2526 if (
c.second > maxEnergySharedTSTandCP) {
2527 maxCPId_byEnergy =
c.first;
2528 maxEnergySharedTSTandCP =
c.second;
2532 float totalCPEnergyFromLayerCP = 0.f;
2533 if (maxCPId_byEnergy >= 0) {
2535 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2536 totalCPEnergyFromLayerCP = totalCPEnergyFromLayerCP + cPOnLayer[maxCPId_byEnergy][
j].energy;
2538 energyFractionOfCPinTST = maxEnergySharedTSTandCP / totalCPEnergyFromLayerCP;
2539 if (tracksters[tstId].raw_energy() > 0.
f) {
2540 energyFractionOfTSTinCP = maxEnergySharedTSTandCP / tracksters[tstId].raw_energy();
2544 LogDebug(
"HGCalValidator") << std::setw(12) <<
"Trackster"
2546 << std::setw(10) <<
"mulcl energy"
2547 <<
"\t" << std::setw(5) <<
"nhits"
2548 <<
"\t" << std::setw(12) <<
"noise hits"
2549 <<
"\t" << std::setw(22) <<
"maxCPId_byNumberOfHits"
2550 <<
"\t" << std::setw(8) <<
"nhitsCP"
2551 <<
"\t" << std::setw(16) <<
"maxCPId_byEnergy"
2552 <<
"\t" << std::setw(23) <<
"maxEnergySharedTSTandCP"
2553 <<
"\t" << std::setw(22) <<
"totalCPEnergyFromAllLayerCP"
2554 <<
"\t" << std::setw(22) <<
"energyFractionOfTSTinCP"
2555 <<
"\t" << std::setw(25) <<
"energyFractionOfCPinTST"
2556 <<
"\t" << std::endl;
2557 LogDebug(
"HGCalValidator") << std::setw(12) << tstId <<
"\t"
2558 << std::setw(10) << tracksters[tstId].raw_energy() <<
"\t" << std::setw(5)
2559 << numberOfHitsInTST <<
"\t" << std::setw(12) << numberOfNoiseHitsInTST <<
"\t"
2560 << std::setw(22) << maxCPId_byNumberOfHits <<
"\t" << std::setw(8)
2561 << maxCPNumberOfHitsInTST <<
"\t" << std::setw(16) << maxCPId_byEnergy <<
"\t"
2562 << std::setw(23) << maxEnergySharedTSTandCP <<
"\t" << std::setw(22)
2563 << totalCPEnergyFromLayerCP <<
"\t" << std::setw(22) << energyFractionOfTSTinCP <<
"\t"
2564 << std::setw(25) << energyFractionOfCPinTST << std::endl;
2569 for (
unsigned int tstId = 0; tstId < nTracksters; ++tstId) {
2575 std::sort(cpsInTrackster[tstId].begin(), cpsInTrackster[tstId].
end());
2577 cpsInTrackster[tstId].erase(
last, cpsInTrackster[tstId].
end());
2579 if (tracksters[tstId].raw_energy() == 0. && !cpsInTrackster[tstId].
empty()) {
2581 for (
auto& cpPair : cpsInTrackster[tstId]) {
2584 LogDebug(
"HGCalValidator") <<
"Trackster Id: \t" << tstId <<
"\t CP id: \t" << cpPair.first <<
"\t score \t"
2585 << cpPair.second << std::endl;
2586 histograms.h_score_trackster2caloparticle[
count]->Fill(cpPair.second);
2591 const auto tst_hitsAndFractions = apply_LCMultiplicity(tracksters[tstId],
layerClusters);
2594 float invTracksterEnergyWeight = 0.f;
2595 for (
const auto& haf : tst_hitsAndFractions) {
2596 invTracksterEnergyWeight +=
2597 (haf.second * hitMap.at(haf.first)->energy()) * (haf.second * hitMap.at(haf.first)->energy());
2599 invTracksterEnergyWeight = 1.f / invTracksterEnergyWeight;
2601 for (
unsigned int i = 0;
i < tst_hitsAndFractions.size(); ++
i) {
2602 const auto rh_detid = tst_hitsAndFractions[
i].first;
2603 const auto rhFraction = tst_hitsAndFractions[
i].second;
2604 bool hitWithNoCP =
false;
2606 auto hit_find_in_CP = detIdToCaloParticleId_Map.find(rh_detid);
2607 if (hit_find_in_CP == detIdToCaloParticleId_Map.end())
2609 auto itcheck = hitMap.find(rh_detid);
2611 float hitEnergyWeight =
hit->energy() *
hit->energy();
2613 for (
auto& cpPair : cpsInTrackster[tstId]) {
2614 float cpFraction = 0.f;
2616 auto findHitIt =
std::find(detIdToCaloParticleId_Map[rh_detid].begin(),
2617 detIdToCaloParticleId_Map[rh_detid].
end(),
2619 if (findHitIt != detIdToCaloParticleId_Map[rh_detid].
end()) {
2620 cpFraction = findHitIt->fraction;
2623 if (cpPair.second == FLT_MAX) {
2624 cpPair.second = 0.f;
2627 (rhFraction - cpFraction) * (rhFraction - cpFraction) * hitEnergyWeight * invTracksterEnergyWeight;
2632 if (cpsInTrackster[tstId].
empty())
2633 LogDebug(
"HGCalValidator") <<
"Trackster Id: \t" << tstId <<
"\tCP id:\t-1 "
2637 const auto score = std::min_element(std::begin(cpsInTrackster[tstId]),
2639 [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
2640 for (
auto& cpPair : cpsInTrackster[tstId]) {
2641 LogDebug(
"HGCalValidator") <<
"Trackster Id: \t" << tstId <<
"\t CP id: \t" << cpPair.first <<
"\t score \t"
2642 << cpPair.second << std::endl;
2643 float sharedeneCPallLayers = 0.;
2644 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2645 auto const& cp_linked = cPOnLayer[cpPair.first][
j].layerClusterIdToEnergyAndScore[tstId];
2646 sharedeneCPallLayers += cp_linked.first;
2648 LogDebug(
"HGCalValidator") <<
"sharedeneCPallLayers " << sharedeneCPallLayers << std::endl;
2649 if (cpPair.first ==
score->first) {
2651 histograms.h_sharedenergy_trackster2caloparticle[
count]->Fill(sharedeneCPallLayers /
2652 tracksters[tstId].raw_energy());
2654 score->second, sharedeneCPallLayers / tracksters[tstId].raw_energy());
2657 auto assocFakeMerge = std::count_if(std::begin(cpsInTrackster[tstId]),
2660 tracksters_fakemerge[tstId] = assocFakeMerge;
2663 std::unordered_map<int, std::vector<float>> score3d;
2664 std::unordered_map<int, std::vector<float>> tstSharedEnergy;
2665 std::unordered_map<int, std::vector<float>> tstSharedEnergyFrac;
2667 for (
unsigned int i = 0;
i < nCaloParticles; ++
i) {
2668 auto cpIndex = cPIndices[
i];
2669 score3d[cpIndex].resize(nTracksters);
2670 tstSharedEnergy[cpIndex].resize(nTracksters);
2671 tstSharedEnergyFrac[cpIndex].resize(nTracksters);
2672 for (
unsigned int j = 0;
j < nTracksters; ++
j) {
2673 score3d[cpIndex][
j] = FLT_MAX;
2674 tstSharedEnergy[cpIndex][
j] = 0.f;
2675 tstSharedEnergyFrac[cpIndex][
j] = 0.f;
2682 for (
const auto& cpId : cPSelectedIndices) {
2685 std::vector<unsigned int> cpId_tstId_related;
2686 cpId_tstId_related.clear();
2688 float CPenergy = 0.f;
2689 for (
unsigned int layerId = 0; layerId <
layers * 2; ++layerId) {
2690 unsigned int CPNumberOfHits = cPOnLayer[cpId][layerId].hits_and_fractions.size();
2692 CPenergy += cPOnLayer[cpId][layerId].energy;
2693 if (CPNumberOfHits == 0)
2695 int tstWithMaxEnergyInCP = -1;
2697 float maxEnergyTSTperlayerinCP = 0.f;
2698 float CPEnergyFractionInTSTperlayer = 0.f;
2700 for (
const auto& tst : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2701 if (tst.second.first > maxEnergyTSTperlayerinCP) {
2702 maxEnergyTSTperlayerinCP = tst.second.first;
2703 tstWithMaxEnergyInCP = tst.first;
2707 CPEnergyFractionInTSTperlayer = maxEnergyTSTperlayerinCP / CPenergy;
2709 LogDebug(
"HGCalValidator") << std::setw(8) <<
"LayerId:\t" << std::setw(12) <<
"caloparticle\t" << std::setw(15)
2710 <<
"cp total energy\t" << std::setw(15) <<
"cpEnergyOnLayer\t" << std::setw(14)
2711 <<
"CPNhitsOnLayer\t" << std::setw(18) <<
"tstWithMaxEnergyInCP\t" << std::setw(15)
2712 <<
"maxEnergyTSTinCP\t" << std::setw(20) <<
"CPEnergyFractionInTST"
2714 LogDebug(
"HGCalValidator") << std::setw(8) << layerId <<
"\t" << std::setw(12) << cpId <<
"\t" << std::setw(15)
2715 << cP[cpId].energy() <<
"\t" << std::setw(15) << CPenergy <<
"\t" << std::setw(14)
2716 << CPNumberOfHits <<
"\t" << std::setw(18) << tstWithMaxEnergyInCP <<
"\t"
2717 << std::setw(15) << maxEnergyTSTperlayerinCP <<
"\t" << std::setw(20)
2718 << CPEnergyFractionInTSTperlayer <<
"\n";
2720 for (
unsigned int i = 0;
i < CPNumberOfHits; ++
i) {
2721 auto& cp_hitDetId = cPOnLayer[cpId][layerId].hits_and_fractions[
i].first;
2722 auto& cpFraction = cPOnLayer[cpId][layerId].hits_and_fractions[
i].second;
2724 bool hitWithNoTST =
false;
2725 if (cpFraction == 0.
f)
2727 auto hit_find_in_TST = detIdToTracksterId_Map.find(cp_hitDetId);
2728 if (hit_find_in_TST == detIdToTracksterId_Map.end())
2729 hitWithNoTST =
true;
2730 auto itcheck = hitMap.find(cp_hitDetId);
2732 float hitEnergyWeight =
hit->energy() *
hit->energy();
2733 for (
auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2734 unsigned int tracksterId = lcPair.first;
2735 if (
std::find(std::begin(cpId_tstId_related),
std::end(cpId_tstId_related), tracksterId) ==
2737 cpId_tstId_related.push_back(tracksterId);
2739 float tstFraction = 0.f;
2741 if (!hitWithNoTST) {
2742 auto findHitIt =
std::find(detIdToTracksterId_Map[cp_hitDetId].begin(),
2743 detIdToTracksterId_Map[cp_hitDetId].
end(),
2745 if (findHitIt != detIdToTracksterId_Map[cp_hitDetId].
end())
2746 tstFraction = findHitIt->fraction;
2750 if (lcPair.second.second == FLT_MAX) {
2751 lcPair.second.second = 0.f;
2753 lcPair.second.second += (tstFraction - cpFraction) * (tstFraction - cpFraction) * hitEnergyWeight;
2754 LogDebug(
"HGCalValidator") <<
"TracksterId:\t" << tracksterId <<
"\t"
2755 <<
"cpId:\t" << cpId <<
"\t"
2756 <<
"Layer: " << layerId <<
'\t' <<
"tstfraction,cpfraction:\t" << tstFraction
2757 <<
", " << cpFraction <<
"\t"
2758 <<
"hitEnergyWeight:\t" << hitEnergyWeight <<
"\t"
2760 << (tstFraction - cpFraction) * (tstFraction - cpFraction) * hitEnergyWeight
2762 <<
"currect score numerator:\t" << lcPair.second.second <<
"\t"
2763 <<
"shared Energy:\t" << lcPair.second.first <<
'\n';
2767 if (cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore.empty())
2768 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\t TST id:\t-1 "
2769 <<
"\t layer \t " << layerId <<
" Sub score in \t -1"
2772 for (
const auto& lcPair : cPOnLayer[cpId][layerId].layerClusterIdToEnergyAndScore) {
2774 if (score3d[cpId][lcPair.first] == FLT_MAX) {
2775 score3d[cpId][lcPair.first] = 0.f;
2777 score3d[cpId][lcPair.first] += lcPair.second.second;
2778 tstSharedEnergy[cpId][lcPair.first] += lcPair.second.first;
2786 float invCPEnergyWeight = 0.f;
2787 for (
const auto&
layer : cPOnLayer[cpId]) {
2788 for (
const auto& haf :
layer.hits_and_fractions) {
2789 invCPEnergyWeight +=
2790 (haf.second * hitMap.at(haf.first)->energy()) * (haf.second * hitMap.at(haf.first)->energy());
2793 invCPEnergyWeight = 1.f / invCPEnergyWeight;
2797 std::vector<int> cpId_tstId_related_vec(cpId_tstId_related.begin(), cpId_tstId_related.end());
2802 bool cp_considered_efficient =
false;
2803 for (
unsigned int i = 0;
i < cpId_tstId_related_vec.size(); ++
i) {
2804 auto tstId = cpId_tstId_related_vec[
i];
2806 score3d[cpId][tstId] = score3d[cpId][tstId] * invCPEnergyWeight;
2807 tstSharedEnergyFrac[cpId][tstId] = (tstSharedEnergy[cpId][tstId] / CPenergy);
2809 LogDebug(
"HGCalValidator") <<
"CP Id: \t" << cpId <<
"\t TST id: \t" << tstId <<
"\t score \t"
2810 << score3d[cpId][tstId] <<
"\t"
2811 <<
"invCPEnergyWeight \t" << invCPEnergyWeight <<
"\t"
2812 <<
"Trackste energy: \t" << tracksters[tstId].raw_energy() <<
"\t"
2813 <<
"shared energy:\t" << tstSharedEnergy[cpId][tstId] <<
"\t"
2814 <<
"shared energy fraction:\t" << tstSharedEnergyFrac[cpId][tstId] <<
"\n";
2816 histograms.h_score_caloparticle2trackster[
count]->Fill(score3d[cpId][tstId]);
2818 histograms.h_sharedenergy_caloparticle2trackster[
count]->Fill(tstSharedEnergyFrac[cpId][tstId]);
2819 histograms.h_energy_vs_score_caloparticle2trackster[
count]->Fill(score3d[cpId][tstId],
2820 tstSharedEnergyFrac[cpId][tstId]);
2823 cp_considered_efficient =
true;
2824 histograms.h_numEff_caloparticle_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
2825 histograms.h_numEff_caloparticle_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
2831 auto assocDup = std::count_if(std::begin(score3d[cpId]),
std::end(score3d[cpId]), is_assoc);
2834 histograms.h_num_caloparticle_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
2835 histograms.h_num_caloparticle_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
2836 auto best = std::min_element(std::begin(score3d[cpId]),
std::end(score3d[cpId]));
2837 auto bestTstId =
std::distance(std::begin(score3d[cpId]), best);
2840 cP[cpId].g4Tracks()[0].momentum().
eta(), tracksters[bestTstId].raw_energy() / CPenergy);
2842 cP[cpId].g4Tracks()[0].momentum().
phi(), tracksters[bestTstId].raw_energy() / CPenergy);
2843 LogDebug(
"HGCalValidator") <<
count <<
" " << cP[cpId].g4Tracks()[0].momentum().eta() <<
" "
2844 << cP[cpId].g4Tracks()[0].momentum().phi() <<
" " << tracksters[bestTstId].raw_energy()
2845 <<
" " << CPenergy <<
" " << (tracksters[bestTstId].raw_energy() / CPenergy) <<
" "
2846 << tstSharedEnergyFrac[cpId][bestTstId] <<
'\n';
2847 histograms.h_sharedenergy_caloparticle2trackster_assoc[
count]->Fill(tstSharedEnergyFrac[cpId][bestTstId]);
2849 if (assocDup >= 2) {
2850 auto match = std::find_if(std::begin(score3d[cpId]),
std::end(score3d[cpId]), is_assoc);
2851 while (
match != score3d[cpId].
end()) {
2856 histograms.h_denom_caloparticle_eta[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
eta());
2857 histograms.h_denom_caloparticle_phi[
count]->Fill(cP[cpId].g4Tracks()[0].momentum().
phi());
2864 for (
unsigned int tstId = 0; tstId < nTracksters; ++tstId) {
2867 auto assocFakeMerge = tracksters_fakemerge[tstId];
2868 auto assocDuplicate = tracksters_duplicate[tstId];
2869 if (assocDuplicate) {
2870 histograms.h_numDup_trackster_eta[
count]->Fill(tracksters[tstId].barycenter().
eta());
2871 histograms.h_numDup_trackster_phi[
count]->Fill(tracksters[tstId].barycenter().
phi());
2873 if (assocFakeMerge > 0) {
2876 auto best = std::min_element(std::begin(cpsInTrackster[tstId]),
2878 [](
const auto& obj1,
const auto& obj2) {
return obj1.second < obj2.second; });
2881 float sharedeneCPallLayers = 0.;
2883 for (
unsigned int j = 0;
j <
layers * 2; ++
j) {
2884 auto const& best_cp_linked = cPOnLayer[best->first][
j].layerClusterIdToEnergyAndScore[tstId];
2885 sharedeneCPallLayers += best_cp_linked.first;
2888 tracksters[tstId].barycenter().
eta(), sharedeneCPallLayers / tracksters[tstId].raw_energy());
2890 tracksters[tstId].barycenter().
phi(), sharedeneCPallLayers / tracksters[tstId].raw_energy());
2892 if (assocFakeMerge >= 2) {
2893 histograms.h_numMerge_trackster_eta[
count]->Fill(tracksters[tstId].barycenter().
eta());
2894 histograms.h_numMerge_trackster_phi[
count]->Fill(tracksters[tstId].barycenter().
phi());
2905 std::vector<CaloParticle>
const& cP,
2906 std::vector<size_t>
const& cPIndices,
2907 std::vector<size_t>
const& cPSelectedIndices,
2908 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap,
2909 unsigned int layers)
const {
2917 int totNContTstZp = 0;
2918 int totNContTstZm = 0;
2920 int totNNotContTstZp = 0;
2921 int totNNotContTstZm = 0;
2923 std::vector<bool> contTracksters;
2924 contTracksters.clear();
2927 std::unordered_map<unsigned int, std::vector<unsigned int>> multiplicity;
2929 std::unordered_map<unsigned int, std::vector<unsigned int>> multiplicity_vs_layer;
2936 auto nTracksters = tracksters.size();
2938 for (
unsigned int tstId = 0; tstId < nTracksters; ++tstId) {
2939 auto nLayerClusters = tracksters[tstId].vertices().size();
2941 if (nLayerClusters == 0)
2944 if (tracksters[tstId].barycenter().
z() < 0.) {
2947 if (tracksters[tstId].barycenter().
z() > 0.) {
2956 std::vector<int> tnLcInTstperlay(1000, 0);
2960 std::set<int> trackster_layers;
2962 bool tracksterInZplus =
false;
2963 bool tracksterInZminus =
false;
2966 for (
const auto lcId : tracksters[tstId].
vertices()) {
2968 const std::vector<std::pair<DetId, float>>& hits_and_fractions =
layerClusters[lcId].hitsAndFractions();
2971 multiplicity[tstId].emplace_back(hits_and_fractions.size());
2973 const auto firstHitDetId = hits_and_fractions[0].first;
2975 int layerid =
recHitTools_->getLayerWithOffset(firstHitDetId) +
2977 trackster_layers.insert(layerid);
2978 multiplicity_vs_layer[tstId].emplace_back(layerid);
2980 tnLcInTstperlay[layerid]++;
2984 tracksterInZplus =
true;
2987 tracksterInZminus =
true;
2993 for (
unsigned ilayer = 0; ilayer <
layers * 2; ++ilayer) {
2994 if (
histograms.h_clusternum_in_trackster_perlayer[
count].count(ilayer) && tnLcInTstperlay[ilayer] != 0) {
2995 histograms.h_clusternum_in_trackster_perlayer[
count].at(ilayer)->Fill((
float)tnLcInTstperlay[ilayer]);
2998 if (tnLcInTstperlay[ilayer] != 0) {
2999 histograms.h_clusternum_in_trackster_vs_layer[
count]->Fill((
float)ilayer, (
float)tnLcInTstperlay[ilayer]);
3004 std::vector<int> trackster_layers_vec(trackster_layers.begin(), trackster_layers.end());
3006 bool contiTrackster =
false;
3008 if (trackster_layers_vec.size() >= 3) {
3009 for (
unsigned int i = 1;
i < trackster_layers_vec.size() - 1; ++
i) {
3010 if ((trackster_layers_vec[
i - 1] + 1 == trackster_layers_vec[
i]) &&
3011 (trackster_layers_vec[
i + 1] - 1 == trackster_layers_vec[
i])) {
3013 if (tracksterInZplus) {
3016 if (tracksterInZminus) {
3019 contiTrackster =
true;
3025 if (!contiTrackster) {
3026 if (tracksterInZplus) {
3029 if (tracksterInZminus) {
3035 contTracksters.push_back(contiTrackster);
3039 for (
unsigned int lc = 0; lc < multiplicity[tstId].size(); ++lc) {
3041 float mlp =
std::count(std::begin(multiplicity[tstId]),
std::end(multiplicity[tstId]), multiplicity[tstId][lc]);
3044 histograms.h_multiplicityOfLCinTST[
count]->Fill(mlp, multiplicity[tstId][lc]);
3050 if (multiplicity_vs_layer[tstId][lc] <
layers) {
3051 histograms.h_multiplicityOfLCinTST_vs_layercluster_zminus[
count]->Fill(mlp, multiplicity_vs_layer[tstId][lc]);
3052 histograms.h_multiplicity_zminus_numberOfEventsHistogram[
count]->Fill(mlp);
3054 histograms.h_multiplicityOfLCinTST_vs_layercluster_zplus[
count]->Fill(
3055 mlp, multiplicity_vs_layer[tstId][lc] -
layers);
3056 histograms.h_multiplicity_zplus_numberOfEventsHistogram[
count]->Fill(mlp);
3059 histograms.h_multiplicityOfLCinTST_vs_layerclusterenergy[
count]->Fill(
3063 if (!trackster_layers.empty()) {
3070 histograms.h_trackster_firstlayer[
count]->Fill((
float)*trackster_layers.begin());
3071 histograms.h_trackster_lastlayer[
count]->Fill((
float)*trackster_layers.rbegin());
3072 histograms.h_trackster_layersnum[
count]->Fill((
float)trackster_layers.size());
3076 histograms.h_trackster_energy[
count]->Fill(tracksters[tstId].raw_energy());
3082 histograms.h_conttracksternum[
count]->Fill(totNContTstZp + totNContTstZm);
3083 histograms.h_nonconttracksternum[
count]->Fill(totNNotContTstZp + totNNotContTstZm);
3092 const double y2)
const {
3093 const double dx =
x1 -
x2;
3094 const double dy =
y1 -
y2;
3100 const double y2)
const {
3109 std::unordered_map<DetId, const HGCRecHit*>
const& hitMap)
const {
3111 const std::vector<std::pair<DetId, float>>& hits_and_fractions = cluster.
hitsAndFractions();
3114 for (
std::vector<std::pair<DetId, float>>::const_iterator it_haf = hits_and_fractions.begin();
3115 it_haf != hits_and_fractions.end();
3117 DetId rh_detid = it_haf->first;
3119 std::unordered_map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(rh_detid);
3122 if (maxene < hit->
energy()) {
3123 maxene =
hit->energy();
3124 themaxid = rh_detid;