/
HGVHistoProducerAlgo.cc
2476 lines (2261 loc) · 133 KB
/
HGVHistoProducerAlgo.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <numeric>
#include <iomanip>
#include "Validation/HGCalValidation/interface/HGVHistoProducerAlgo.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "SimDataFormats/CaloAnalysis/interface/SimCluster.h"
#include "TMath.h"
#include "TLatex.h"
#include "TF1.h"
using namespace std;
//Parameters for the score cut. Later, this will become part of the
//configuration parameter for the HGCAL associator.
const double ScoreCutLCtoCP_ = 0.01;
const double ScoreCutCPtoLC_ = 0.01;
const double ScoreCutMCLtoCP_ = 0.2;
const double ScoreCutCPtoMCL_ = 0.2;
HGVHistoProducerAlgo::HGVHistoProducerAlgo(const edm::ParameterSet& pset)
: //parameters for eta
minEta_(pset.getParameter<double>("minEta")),
maxEta_(pset.getParameter<double>("maxEta")),
nintEta_(pset.getParameter<int>("nintEta")),
useFabsEta_(pset.getParameter<bool>("useFabsEta")),
//parameters for energy
minEne_(pset.getParameter<double>("minEne")),
maxEne_(pset.getParameter<double>("maxEne")),
nintEne_(pset.getParameter<int>("nintEne")),
//parameters for pt
minPt_(pset.getParameter<double>("minPt")),
maxPt_(pset.getParameter<double>("maxPt")),
nintPt_(pset.getParameter<int>("nintPt")),
//parameters for phi
minPhi_(pset.getParameter<double>("minPhi")),
maxPhi_(pset.getParameter<double>("maxPhi")),
nintPhi_(pset.getParameter<int>("nintPhi")),
//parameters for counting mixed hits clusters
minMixedHitsCluster_(pset.getParameter<double>("minMixedHitsCluster")),
maxMixedHitsCluster_(pset.getParameter<double>("maxMixedHitsCluster")),
nintMixedHitsCluster_(pset.getParameter<int>("nintMixedHitsCluster")),
//parameters for the total amount of energy clustered by all layer clusters (fraction over caloparticles)
minEneCl_(pset.getParameter<double>("minEneCl")),
maxEneCl_(pset.getParameter<double>("maxEneCl")),
nintEneCl_(pset.getParameter<int>("nintEneCl")),
//parameters for the longitudinal depth barycenter.
minLongDepBary_(pset.getParameter<double>("minLongDepBary")),
maxLongDepBary_(pset.getParameter<double>("maxLongDepBary")),
nintLongDepBary_(pset.getParameter<int>("nintLongDepBary")),
//parameters for z positionof vertex plots
minZpos_(pset.getParameter<double>("minZpos")),
maxZpos_(pset.getParameter<double>("maxZpos")),
nintZpos_(pset.getParameter<int>("nintZpos")),
//Parameters for the total number of layer clusters per layer
minTotNClsperlay_(pset.getParameter<double>("minTotNClsperlay")),
maxTotNClsperlay_(pset.getParameter<double>("maxTotNClsperlay")),
nintTotNClsperlay_(pset.getParameter<int>("nintTotNClsperlay")),
//Parameters for the energy clustered by layer clusters per layer (fraction over caloparticles)
minEneClperlay_(pset.getParameter<double>("minEneClperlay")),
maxEneClperlay_(pset.getParameter<double>("maxEneClperlay")),
nintEneClperlay_(pset.getParameter<int>("nintEneClperlay")),
//Parameters for the score both for:
//1. calo particle to layer clusters association per layer
//2. layer cluster to calo particles association per layer
minScore_(pset.getParameter<double>("minScore")),
maxScore_(pset.getParameter<double>("maxScore")),
nintScore_(pset.getParameter<int>("nintScore")),
//Parameters for shared energy fraction. That is:
//1. Fraction of each of the layer clusters energy related to a
//calo particle over that calo particle's energy.
//2. Fraction of each of the calo particles energy
//related to a layer cluster over that layer cluster's energy.
minSharedEneFrac_(pset.getParameter<double>("minSharedEneFrac")),
maxSharedEneFrac_(pset.getParameter<double>("maxSharedEneFrac")),
nintSharedEneFrac_(pset.getParameter<int>("nintSharedEneFrac")),
//Same as above for multiclusters
minMCLSharedEneFrac_(pset.getParameter<double>("minMCLSharedEneFrac")),
maxMCLSharedEneFrac_(pset.getParameter<double>("maxMCLSharedEneFrac")),
nintMCLSharedEneFrac_(pset.getParameter<int>("nintMCLSharedEneFrac")),
//Parameters for the total number of layer clusters per thickness
minTotNClsperthick_(pset.getParameter<double>("minTotNClsperthick")),
maxTotNClsperthick_(pset.getParameter<double>("maxTotNClsperthick")),
nintTotNClsperthick_(pset.getParameter<int>("nintTotNClsperthick")),
//Parameters for the total number of cells per per thickness per layer
minTotNcellsperthickperlayer_(pset.getParameter<double>("minTotNcellsperthickperlayer")),
maxTotNcellsperthickperlayer_(pset.getParameter<double>("maxTotNcellsperthickperlayer")),
nintTotNcellsperthickperlayer_(pset.getParameter<int>("nintTotNcellsperthickperlayer")),
//Parameters for the distance of cluster cells to seed cell per thickness per layer
minDisToSeedperthickperlayer_(pset.getParameter<double>("minDisToSeedperthickperlayer")),
maxDisToSeedperthickperlayer_(pset.getParameter<double>("maxDisToSeedperthickperlayer")),
nintDisToSeedperthickperlayer_(pset.getParameter<int>("nintDisToSeedperthickperlayer")),
//Parameters for the energy weighted distance of cluster cells to seed cell per thickness per layer
minDisToSeedperthickperlayerenewei_(pset.getParameter<double>("minDisToSeedperthickperlayerenewei")),
maxDisToSeedperthickperlayerenewei_(pset.getParameter<double>("maxDisToSeedperthickperlayerenewei")),
nintDisToSeedperthickperlayerenewei_(pset.getParameter<int>("nintDisToSeedperthickperlayerenewei")),
//Parameters for the distance of cluster cells to max cell per thickness per layer
minDisToMaxperthickperlayer_(pset.getParameter<double>("minDisToMaxperthickperlayer")),
maxDisToMaxperthickperlayer_(pset.getParameter<double>("maxDisToMaxperthickperlayer")),
nintDisToMaxperthickperlayer_(pset.getParameter<int>("nintDisToMaxperthickperlayer")),
//Parameters for the energy weighted distance of cluster cells to max cell per thickness per layer
minDisToMaxperthickperlayerenewei_(pset.getParameter<double>("minDisToMaxperthickperlayerenewei")),
maxDisToMaxperthickperlayerenewei_(pset.getParameter<double>("maxDisToMaxperthickperlayerenewei")),
nintDisToMaxperthickperlayerenewei_(pset.getParameter<int>("nintDisToMaxperthickperlayerenewei")),
//Parameters for the distance of seed cell to max cell per thickness per layer
minDisSeedToMaxperthickperlayer_(pset.getParameter<double>("minDisSeedToMaxperthickperlayer")),
maxDisSeedToMaxperthickperlayer_(pset.getParameter<double>("maxDisSeedToMaxperthickperlayer")),
nintDisSeedToMaxperthickperlayer_(pset.getParameter<int>("nintDisSeedToMaxperthickperlayer")),
//Parameters for the energy of a cluster per thickness per layer
minClEneperthickperlayer_(pset.getParameter<double>("minClEneperthickperlayer")),
maxClEneperthickperlayer_(pset.getParameter<double>("maxClEneperthickperlayer")),
nintClEneperthickperlayer_(pset.getParameter<int>("nintClEneperthickperlayer")),
//Parameters for the energy density of cluster cells per thickness
minCellsEneDensperthick_(pset.getParameter<double>("minCellsEneDensperthick")),
maxCellsEneDensperthick_(pset.getParameter<double>("maxCellsEneDensperthick")),
nintCellsEneDensperthick_(pset.getParameter<int>("nintCellsEneDensperthick")),
//Parameters for the total number of multiclusters per event
//We always treet one event as two events, one in +z one in -z
minTotNMCLs_(pset.getParameter<double>("minTotNMCLs")),
maxTotNMCLs_(pset.getParameter<double>("maxTotNMCLs")),
nintTotNMCLs_(pset.getParameter<int>("nintTotNMCLs")),
//Parameters for the total number of layer clusters in multicluster
minTotNClsinMCLs_(pset.getParameter<double>("minTotNClsinMCLs")),
maxTotNClsinMCLs_(pset.getParameter<double>("maxTotNClsinMCLs")),
nintTotNClsinMCLs_(pset.getParameter<int>("nintTotNClsinMCLs")),
//Parameters for the total number of layer clusters in multicluster per layer
minTotNClsinMCLsperlayer_(pset.getParameter<double>("minTotNClsinMCLsperlayer")),
maxTotNClsinMCLsperlayer_(pset.getParameter<double>("maxTotNClsinMCLsperlayer")),
nintTotNClsinMCLsperlayer_(pset.getParameter<int>("nintTotNClsinMCLsperlayer")),
//Parameters for the multiplicity of layer clusters in multicluster
minMplofLCs_(pset.getParameter<double>("minMplofLCs")),
maxMplofLCs_(pset.getParameter<double>("maxMplofLCs")),
nintMplofLCs_(pset.getParameter<int>("nintMplofLCs")),
//Parameters for cluster size
minSizeCLsinMCLs_(pset.getParameter<double>("minSizeCLsinMCLs")),
maxSizeCLsinMCLs_(pset.getParameter<double>("maxSizeCLsinMCLs")),
nintSizeCLsinMCLs_(pset.getParameter<int>("nintSizeCLsinMCLs")),
//Parameters for the energy of a cluster per thickness per layer
minClEnepermultiplicity_(pset.getParameter<double>("minClEnepermultiplicity")),
maxClEnepermultiplicity_(pset.getParameter<double>("maxClEnepermultiplicity")),
nintClEnepermultiplicity_(pset.getParameter<int>("nintClEnepermultiplicity")),
//parameters for x
minX_(pset.getParameter<double>("minX")),
maxX_(pset.getParameter<double>("maxX")),
nintX_(pset.getParameter<int>("nintX")),
//parameters for y
minY_(pset.getParameter<double>("minY")),
maxY_(pset.getParameter<double>("maxY")),
nintY_(pset.getParameter<int>("nintY")),
//parameters for z
minZ_(pset.getParameter<double>("minZ")),
maxZ_(pset.getParameter<double>("maxZ")),
nintZ_(pset.getParameter<int>("nintZ")) {}
HGVHistoProducerAlgo::~HGVHistoProducerAlgo() {}
void HGVHistoProducerAlgo::bookInfo(DQMStore::ConcurrentBooker& ibook, Histograms& histograms) {
histograms.lastLayerEEzm = ibook.bookInt("lastLayerEEzm");
histograms.lastLayerFHzm = ibook.bookInt("lastLayerFHzm");
histograms.maxlayerzm = ibook.bookInt("maxlayerzm");
histograms.lastLayerEEzp = ibook.bookInt("lastLayerEEzp");
histograms.lastLayerFHzp = ibook.bookInt("lastLayerFHzp");
histograms.maxlayerzp = ibook.bookInt("maxlayerzp");
}
void HGVHistoProducerAlgo::bookCaloParticleHistos(DQMStore::ConcurrentBooker& ibook,
Histograms& histograms,
int pdgid) {
histograms.h_caloparticle_eta[pdgid] =
ibook.book1D("num_caloparticle_eta", "N of caloparticle vs eta", nintEta_, minEta_, maxEta_);
histograms.h_caloparticle_eta_Zorigin[pdgid] =
ibook.book2D("Eta vs Zorigin", "Eta vs Zorigin", nintEta_, minEta_, maxEta_, nintZpos_, minZpos_, maxZpos_);
histograms.h_caloparticle_energy[pdgid] =
ibook.book1D("caloparticle_energy", "Energy of caloparticle", nintEne_, minEne_, maxEne_);
histograms.h_caloparticle_pt[pdgid] = ibook.book1D("caloparticle_pt", "Pt of caloparticle", nintPt_, minPt_, maxPt_);
histograms.h_caloparticle_phi[pdgid] =
ibook.book1D("caloparticle_phi", "Phi of caloparticle", nintPhi_, minPhi_, maxPhi_);
}
void HGVHistoProducerAlgo::bookClusterHistos(DQMStore::ConcurrentBooker& ibook,
Histograms& histograms,
unsigned layers,
std::vector<int> thicknesses,
std::string pathtomatbudfile) {
//---------------------------------------------------------------------------------------------------------------------------
histograms.h_cluster_eta.push_back(
ibook.book1D("num_reco_cluster_eta", "N of reco clusters vs eta", nintEta_, minEta_, maxEta_));
//---------------------------------------------------------------------------------------------------------------------------
//z-
histograms.h_mixedhitscluster_zminus.push_back(
ibook.book1D("mixedhitscluster_zminus",
"N of reco clusters that contain hits of more than one kind in z-",
nintMixedHitsCluster_,
minMixedHitsCluster_,
maxMixedHitsCluster_));
//z+
histograms.h_mixedhitscluster_zplus.push_back(
ibook.book1D("mixedhitscluster_zplus",
"N of reco clusters that contain hits of more than one kind in z+",
nintMixedHitsCluster_,
minMixedHitsCluster_,
maxMixedHitsCluster_));
//---------------------------------------------------------------------------------------------------------------------------
//z-
histograms.h_energyclustered_zminus.push_back(
ibook.book1D("energyclustered_zminus",
"percent of total energy clustered by all layer clusters over caloparticles energy in z-",
nintEneCl_,
minEneCl_,
maxEneCl_));
//z+
histograms.h_energyclustered_zplus.push_back(
ibook.book1D("energyclustered_zplus",
"percent of total energy clustered by all layer clusters over caloparticles energy in z+",
nintEneCl_,
minEneCl_,
maxEneCl_));
//---------------------------------------------------------------------------------------------------------------------------
//z-
std::string subpathtomat = pathtomatbudfile.substr(pathtomatbudfile.find("Validation"));
histograms.h_longdepthbarycentre_zminus.push_back(
ibook.book1D("longdepthbarycentre_zminus",
"The longitudinal depth barycentre in z- for " + subpathtomat,
nintLongDepBary_,
minLongDepBary_,
maxLongDepBary_));
//z+
histograms.h_longdepthbarycentre_zplus.push_back(
ibook.book1D("longdepthbarycentre_zplus",
"The longitudinal depth barycentre in z+ for " + subpathtomat,
nintLongDepBary_,
minLongDepBary_,
maxLongDepBary_));
//---------------------------------------------------------------------------------------------------------------------------
for (unsigned ilayer = 0; ilayer < 2 * layers; ++ilayer) {
auto istr1 = std::to_string(ilayer);
while (istr1.size() < 2) {
istr1.insert(0, "0");
}
//We will make a mapping to the regural layer naming plus z- or z+ for convenience
std::string istr2 = "";
//First with the -z endcap
if (ilayer < layers) {
istr2 = std::to_string(ilayer + 1) + " in z-";
} else { //Then for the +z
istr2 = std::to_string(ilayer - (layers - 1)) + " in z+";
}
histograms.h_clusternum_perlayer[ilayer] = ibook.book1D("totclusternum_layer_" + istr1,
"total number of layer clusters for layer " + istr2,
nintTotNClsperlay_,
minTotNClsperlay_,
maxTotNClsperlay_);
histograms.h_energyclustered_perlayer[ilayer] =
ibook.book1D("energyclustered_perlayer" + istr1,
"percent of total energy clustered by layer clusters over caloparticles energy for layer " + istr2,
nintEneClperlay_,
minEneClperlay_,
maxEneClperlay_);
histograms.h_score_layercl2caloparticle_perlayer[ilayer] =
ibook.book1D("Score_layercl2caloparticle_perlayer" + istr1,
"Score of Layer Cluster per CaloParticle for layer " + istr2,
nintScore_,
minScore_,
maxScore_);
histograms.h_score_caloparticle2layercl_perlayer[ilayer] =
ibook.book1D("Score_caloparticle2layercl_perlayer" + istr1,
"Score of CaloParticle per Layer Cluster for layer " + istr2,
nintScore_,
minScore_,
maxScore_);
histograms.h_energy_vs_score_caloparticle2layercl_perlayer[ilayer] =
ibook.book2D("Energy_vs_Score_caloparticle2layer_perlayer" + istr1,
"Energy vs Score of CaloParticle per Layer Cluster for layer " + istr2,
nintScore_,
minScore_,
maxScore_,
nintSharedEneFrac_,
minSharedEneFrac_,
maxSharedEneFrac_);
histograms.h_energy_vs_score_layercl2caloparticle_perlayer[ilayer] =
ibook.book2D("Energy_vs_Score_layer2caloparticle_perlayer" + istr1,
"Energy vs Score of Layer Cluster per CaloParticle Layer for layer " + istr2,
nintScore_,
minScore_,
maxScore_,
nintSharedEneFrac_,
minSharedEneFrac_,
maxSharedEneFrac_);
histograms.h_sharedenergy_caloparticle2layercl_perlayer[ilayer] =
ibook.book1D("SharedEnergy_caloparticle2layercl_perlayer" + istr1,
"Shared Energy of CaloParticle per Layer Cluster for layer " + istr2,
nintSharedEneFrac_,
minSharedEneFrac_,
maxSharedEneFrac_);
histograms.h_sharedenergy_caloparticle2layercl_vs_eta_perlayer[ilayer] =
ibook.bookProfile("SharedEnergy_caloparticle2layercl_vs_eta_perlayer" + istr1,
"Shared Energy of CaloParticle vs #eta per best Layer Cluster for layer " + istr2,
nintEta_,
minEta_,
maxEta_,
minSharedEneFrac_,
maxSharedEneFrac_);
histograms.h_sharedenergy_caloparticle2layercl_vs_phi_perlayer[ilayer] =
ibook.bookProfile("SharedEnergy_caloparticle2layercl_vs_phi_perlayer" + istr1,
"Shared Energy of CaloParticle vs #phi per best Layer Cluster for layer " + istr2,
nintPhi_,
minPhi_,
maxPhi_,
minSharedEneFrac_,
maxSharedEneFrac_);
histograms.h_sharedenergy_layercl2caloparticle_perlayer[ilayer] =
ibook.book1D("SharedEnergy_layercluster2caloparticle_perlayer" + istr1,
"Shared Energy of Layer Cluster per Layer Calo Particle for layer " + istr2,
nintSharedEneFrac_,
minSharedEneFrac_,
maxSharedEneFrac_);
histograms.h_sharedenergy_layercl2caloparticle_vs_eta_perlayer[ilayer] =
ibook.bookProfile("SharedEnergy_layercl2caloparticle_vs_eta_perlayer" + istr1,
"Shared Energy of LayerCluster vs #eta per best Calo Particle for layer " + istr2,
nintEta_,
minEta_,
maxEta_,
minSharedEneFrac_,
maxSharedEneFrac_);
histograms.h_sharedenergy_layercl2caloparticle_vs_phi_perlayer[ilayer] =
ibook.bookProfile("SharedEnergy_layercl2caloparticle_vs_phi_perlayer" + istr1,
"Shared Energy of LayerCluster vs #phi per best Calo Particle for layer " + istr2,
nintPhi_,
minPhi_,
maxPhi_,
minSharedEneFrac_,
maxSharedEneFrac_);
histograms.h_num_caloparticle_eta_perlayer[ilayer] =
ibook.book1D("Num_CaloParticle_Eta_perlayer" + istr1,
"Num CaloParticle Eta per Layer Cluster for layer " + istr2,
nintEta_,
minEta_,
maxEta_);
histograms.h_numDup_caloparticle_eta_perlayer[ilayer] =
ibook.book1D("NumDup_CaloParticle_Eta_perlayer" + istr1,
"Num Duplicate CaloParticle Eta per Layer Cluster for layer " + istr2,
nintEta_,
minEta_,
maxEta_);
histograms.h_denom_caloparticle_eta_perlayer[ilayer] =
ibook.book1D("Denom_CaloParticle_Eta_perlayer" + istr1,
"Denom CaloParticle Eta per Layer Cluster for layer " + istr2,
nintEta_,
minEta_,
maxEta_);
histograms.h_num_caloparticle_phi_perlayer[ilayer] =
ibook.book1D("Num_CaloParticle_Phi_perlayer" + istr1,
"Num CaloParticle Phi per Layer Cluster for layer " + istr2,
nintPhi_,
minPhi_,
maxPhi_);
histograms.h_numDup_caloparticle_phi_perlayer[ilayer] =
ibook.book1D("NumDup_CaloParticle_Phi_perlayer" + istr1,
"Num Duplicate CaloParticle Phi per Layer Cluster for layer " + istr2,
nintPhi_,
minPhi_,
maxPhi_);
histograms.h_denom_caloparticle_phi_perlayer[ilayer] =
ibook.book1D("Denom_CaloParticle_Phi_perlayer" + istr1,
"Denom CaloParticle Phi per Layer Cluster for layer " + istr2,
nintPhi_,
minPhi_,
maxPhi_);
histograms.h_num_layercl_eta_perlayer[ilayer] =
ibook.book1D("Num_LayerCluster_Eta_perlayer" + istr1,
"Num LayerCluster Eta per Layer Cluster for layer " + istr2,
nintEta_,
minEta_,
maxEta_);
histograms.h_numMerge_layercl_eta_perlayer[ilayer] =
ibook.book1D("NumMerge_LayerCluster_Eta_perlayer" + istr1,
"Num Merge LayerCluster Eta per Layer Cluster for layer " + istr2,
nintEta_,
minEta_,
maxEta_);
histograms.h_denom_layercl_eta_perlayer[ilayer] =
ibook.book1D("Denom_LayerCluster_Eta_perlayer" + istr1,
"Denom LayerCluster Eta per Layer Cluster for layer " + istr2,
nintEta_,
minEta_,
maxEta_);
histograms.h_num_layercl_phi_perlayer[ilayer] =
ibook.book1D("Num_LayerCluster_Phi_perlayer" + istr1,
"Num LayerCluster Phi per Layer Cluster for layer " + istr2,
nintPhi_,
minPhi_,
maxPhi_);
histograms.h_numMerge_layercl_phi_perlayer[ilayer] =
ibook.book1D("NumMerge_LayerCluster_Phi_perlayer" + istr1,
"Num Merge LayerCluster Phi per Layer Cluster for layer " + istr2,
nintPhi_,
minPhi_,
maxPhi_);
histograms.h_denom_layercl_phi_perlayer[ilayer] =
ibook.book1D("Denom_LayerCluster_Phi_perlayer" + istr1,
"Denom LayerCluster Phi per Layer Cluster for layer " + istr2,
nintPhi_,
minPhi_,
maxPhi_);
histograms.h_cellAssociation_perlayer[ilayer] =
ibook.book1D("cellAssociation_perlayer" + istr1, "Cell Association for layer " + istr2, 5, -4., 1.);
histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(2, "TN(purity)");
histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(3, "FN(ineff.)");
histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(4, "FP(fake)");
histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(5, "TP(eff.)");
}
//---------------------------------------------------------------------------------------------------------------------------
for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
auto istr = std::to_string(*it);
histograms.h_clusternum_perthick[(*it)] = ibook.book1D("totclusternum_thick_" + istr,
"total number of layer clusters for thickness " + istr,
nintTotNClsperthick_,
minTotNClsperthick_,
maxTotNClsperthick_);
//---
histograms.h_cellsenedens_perthick[(*it)] = ibook.book1D("cellsenedens_thick_" + istr,
"energy density of cluster cells for thickness " + istr,
nintCellsEneDensperthick_,
minCellsEneDensperthick_,
maxCellsEneDensperthick_);
}
//---------------------------------------------------------------------------------------------------------------------------
//Not all combination exists but we should keep them all for cross checking reason.
for (std::vector<int>::iterator it = thicknesses.begin(); it != thicknesses.end(); ++it) {
for (unsigned ilayer = 0; ilayer < 2 * layers; ++ilayer) {
auto istr1 = std::to_string(*it);
auto istr2 = std::to_string(ilayer);
while (istr2.size() < 2)
istr2.insert(0, "0");
auto istr = istr1 + "_" + istr2;
//We will make a mapping to the regural layer naming plus z- or z+ for convenience
std::string istr3 = "";
//First with the -z endcap
if (ilayer < layers) {
istr3 = std::to_string(ilayer + 1) + " in z- ";
} else { //Then for the +z
istr3 = std::to_string(ilayer - (layers - 1)) + " in z+ ";
}
//---
histograms.h_cellsnum_perthickperlayer[istr] =
ibook.book1D("cellsnum_perthick_perlayer_" + istr,
"total number of cells for layer " + istr3 + " for thickness " + istr1,
nintTotNcellsperthickperlayer_,
minTotNcellsperthickperlayer_,
maxTotNcellsperthickperlayer_);
//---
histograms.h_distancetoseedcell_perthickperlayer[istr] =
ibook.book1D("distancetoseedcell_perthickperlayer_" + istr,
"distance of cluster cells to seed cell for layer " + istr3 + " for thickness " + istr1,
nintDisToSeedperthickperlayer_,
minDisToSeedperthickperlayer_,
maxDisToSeedperthickperlayer_);
//---
histograms.h_distancetoseedcell_perthickperlayer_eneweighted[istr] = ibook.book1D(
"distancetoseedcell_perthickperlayer_eneweighted_" + istr,
"energy weighted distance of cluster cells to seed cell for layer " + istr3 + " for thickness " + istr1,
nintDisToSeedperthickperlayerenewei_,
minDisToSeedperthickperlayerenewei_,
maxDisToSeedperthickperlayerenewei_);
//---
histograms.h_distancetomaxcell_perthickperlayer[istr] =
ibook.book1D("distancetomaxcell_perthickperlayer_" + istr,
"distance of cluster cells to max cell for layer " + istr3 + " for thickness " + istr1,
nintDisToMaxperthickperlayer_,
minDisToMaxperthickperlayer_,
maxDisToMaxperthickperlayer_);
//---
histograms.h_distancetomaxcell_perthickperlayer_eneweighted[istr] = ibook.book1D(
"distancetomaxcell_perthickperlayer_eneweighted_" + istr,
"energy weighted distance of cluster cells to max cell for layer " + istr3 + " for thickness " + istr1,
nintDisToMaxperthickperlayerenewei_,
minDisToMaxperthickperlayerenewei_,
maxDisToMaxperthickperlayerenewei_);
//---
histograms.h_distancebetseedandmaxcell_perthickperlayer[istr] =
ibook.book1D("distancebetseedandmaxcell_perthickperlayer_" + istr,
"distance of seed cell to max cell for layer " + istr3 + " for thickness " + istr1,
nintDisSeedToMaxperthickperlayer_,
minDisSeedToMaxperthickperlayer_,
maxDisSeedToMaxperthickperlayer_);
//---
histograms.h_distancebetseedandmaxcellvsclusterenergy_perthickperlayer[istr] = ibook.book2D(
"distancebetseedandmaxcellvsclusterenergy_perthickperlayer_" + istr,
"distance of seed cell to max cell vs cluster energy for layer " + istr3 + " for thickness " + istr1,
nintDisSeedToMaxperthickperlayer_,
minDisSeedToMaxperthickperlayer_,
maxDisSeedToMaxperthickperlayer_,
nintClEneperthickperlayer_,
minClEneperthickperlayer_,
maxClEneperthickperlayer_);
}
}
//---------------------------------------------------------------------------------------------------------------------------
}
void HGVHistoProducerAlgo::bookMultiClusterHistos(DQMStore::ConcurrentBooker& ibook,
Histograms& histograms,
unsigned layers) {
histograms.h_score_multicl2caloparticle = ibook.book1D(
"Score_multicl2caloparticle", "Score of Multi Cluster per CaloParticle", nintScore_, minScore_, maxScore_);
histograms.h_score_caloparticle2multicl = ibook.book1D(
"Score_caloparticle2multicl", "Score of CaloParticle per Multi Cluster", nintScore_, minScore_, maxScore_);
histograms.h_energy_vs_score_multicl2caloparticle = ibook.book2D("Energy_vs_Score_multi2caloparticle",
"Energy vs Score of Multi Cluster per CaloParticle",
nintScore_,
minScore_,
maxScore_,
nintSharedEneFrac_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_energy_vs_score_caloparticle2multicl = ibook.book2D("Energy_vs_Score_caloparticle2multi",
"Energy vs Score of CaloParticle per Multi Cluster",
nintScore_,
minScore_,
maxScore_,
nintSharedEneFrac_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
//contiguous
histograms.h_score_contimulticl2caloparticle = ibook.book1D("Score_contimulticl2caloparticle",
"Score of contiguous Multi Cluster per CaloParticle",
nintScore_,
minScore_,
maxScore_);
histograms.h_score_caloparticle2contimulticl = ibook.book1D("Score_caloparticle2contimulticl",
"Score of CaloParticle per contiguous Multi Cluster",
nintScore_,
minScore_,
maxScore_);
histograms.h_energy_vs_score_contimulticl2caloparticle =
ibook.book2D("Energy_vs_Score_contimulti2caloparticle",
"Energy vs Score of contiguous multi Cluster per CaloParticle",
nintScore_,
minScore_,
maxScore_,
nintSharedEneFrac_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_energy_vs_score_caloparticle2contimulticl =
ibook.book2D("Energy_vs_Score_caloparticle2contimulti",
"Energy vs Score of CaloParticle per contiguous multi Cluster",
nintScore_,
minScore_,
maxScore_,
nintSharedEneFrac_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
//non contiguous
histograms.h_score_noncontimulticl2caloparticle =
ibook.book1D("Score_noncontimulticl2caloparticle",
"Score of non contiguous Multi Cluster per CaloParticle",
nintScore_,
minScore_,
maxScore_);
histograms.h_score_caloparticle2noncontimulticl =
ibook.book1D("Score_caloparticle2noncontimulticl",
"Score of CaloParticle per non contiguous Multi Cluster",
nintScore_,
minScore_,
maxScore_);
histograms.h_energy_vs_score_noncontimulticl2caloparticle =
ibook.book2D("Energy_vs_Score_noncontimulti2caloparticle",
"Energy vs Score of non contiguous multi Cluster per CaloParticle",
nintScore_,
minScore_,
maxScore_,
nintSharedEneFrac_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_energy_vs_score_caloparticle2noncontimulticl =
ibook.book2D("Energy_vs_Score_caloparticle2noncontimulti",
"Energy vs Score of CaloParticle per non contiguous multi Cluster",
nintScore_,
minScore_,
maxScore_,
nintSharedEneFrac_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
//back to all multiclusters
histograms.h_num_multicl_eta =
ibook.book1D("Num_MultiCluster_Eta", "Num MultiCluster Eta per Multi Cluster ", nintEta_, minEta_, maxEta_);
histograms.h_numMerge_multicl_eta = ibook.book1D(
"NumMerge_MultiCluster_Eta", "Num Merge MultiCluster Eta per Multi Cluster ", nintEta_, minEta_, maxEta_);
histograms.h_denom_multicl_eta =
ibook.book1D("Denom_MultiCluster_Eta", "Denom MultiCluster Eta per Multi Cluster", nintEta_, minEta_, maxEta_);
histograms.h_num_multicl_phi =
ibook.book1D("Num_MultiCluster_Phi", "Num MultiCluster Phi per Multi Cluster ", nintPhi_, minPhi_, maxPhi_);
histograms.h_numMerge_multicl_phi = ibook.book1D(
"NumMerge_MultiCluster_Phi", "Num Merge MultiCluster Phi per Multi Cluster", nintPhi_, minPhi_, maxPhi_);
histograms.h_denom_multicl_phi =
ibook.book1D("Denom_MultiCluster_Phi", "Denom MultiCluster Phi per Multi Cluster", nintPhi_, minPhi_, maxPhi_);
histograms.h_sharedenergy_multicl2caloparticle =
ibook.book1D("SharedEnergy_multicluster2caloparticle",
"Shared Energy of Multi Cluster per Calo Particle in each layer",
nintSharedEneFrac_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_sharedenergy_multicl2caloparticle_vs_eta =
ibook.bookProfile("SharedEnergy_multicl2caloparticle_vs_eta",
"Shared Energy of MultiCluster vs #eta per best Calo Particle in each layer",
nintEta_,
minEta_,
maxEta_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_sharedenergy_multicl2caloparticle_vs_phi =
ibook.bookProfile("SharedEnergy_multicl2caloparticle_vs_phi",
"Shared Energy of MultiCluster vs #phi per best Calo Particle in each layer",
nintPhi_,
minPhi_,
maxPhi_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_sharedenergy_caloparticle2multicl = ibook.book1D("SharedEnergy_caloparticle2multicl",
"Shared Energy of CaloParticle per Multi Cluster",
nintSharedEneFrac_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_sharedenergy_caloparticle2multicl_vs_eta =
ibook.bookProfile("SharedEnergy_caloparticle2multicl_vs_eta",
"Shared Energy of CaloParticle vs #eta per best Multi Cluster",
nintEta_,
minEta_,
maxEta_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_sharedenergy_caloparticle2multicl_vs_phi =
ibook.bookProfile("SharedEnergy_caloparticle2multicl_vs_phi",
"Shared Energy of CaloParticle vs #phi per best Multi Cluster",
nintPhi_,
minPhi_,
maxPhi_,
minMCLSharedEneFrac_,
maxMCLSharedEneFrac_);
histograms.h_num_caloparticle_eta =
ibook.book1D("Num_CaloParticle_Eta", "Num CaloParticle Eta per Multi Cluster", nintEta_, minEta_, maxEta_);
histograms.h_numDup_caloparticle_eta = ibook.book1D(
"NumDup_CaloParticle_Eta", "Num Duplicate CaloParticle Eta per Multi Cluster", nintEta_, minEta_, maxEta_);
histograms.h_denom_caloparticle_eta =
ibook.book1D("Denom_CaloParticle_Eta", "Denom CaloParticle Eta per Multi Cluster", nintEta_, minEta_, maxEta_);
histograms.h_num_caloparticle_phi =
ibook.book1D("Num_CaloParticle_Phi", "Num CaloParticle Phi per Multi Cluster", nintPhi_, minPhi_, maxPhi_);
histograms.h_numDup_caloparticle_phi = ibook.book1D(
"NumDup_CaloParticle_Phi", "Num Duplicate CaloParticle Phi per Multi Cluster", nintPhi_, minPhi_, maxPhi_);
histograms.h_denom_caloparticle_phi =
ibook.book1D("Denom_CaloParticle_Phi", "Denom CaloParticle Phi per Multi Cluster", nintPhi_, minPhi_, maxPhi_);
for (unsigned ilayer = 0; ilayer < 2 * layers; ++ilayer) {
auto istr1 = std::to_string(ilayer);
while (istr1.size() < 2) {
istr1.insert(0, "0");
}
//We will make a mapping to the regural layer naming plus z- or z+ for convenience
std::string istr2 = "";
//First with the -z endcap
if (ilayer < layers) {
istr2 = std::to_string(ilayer + 1) + " in z-";
} else { //Then for the +z
istr2 = std::to_string(ilayer - (layers - 1)) + " in z+";
}
histograms.h_cellAssociation_perlayer[ilayer] =
ibook.book1D("cellAssociation_perlayer" + istr1, "Cell Association for layer " + istr2, 5, -4., 1.);
histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(2, "TN(purity)");
histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(3, "FN(ineff.)");
histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(4, "FP(fake)");
histograms.h_cellAssociation_perlayer[ilayer].setBinLabel(5, "TP(eff.)");
histograms.h_clusternum_in_multicluster_perlayer[ilayer] =
ibook.book1D("clusternum_in_multicluster_perlayer" + istr1,
"Number of layer clusters in multicluster for layer " + istr2,
nintTotNClsinMCLsperlayer_,
minTotNClsinMCLsperlayer_,
maxTotNClsinMCLsperlayer_);
}
histograms.h_cellAssociation = ibook.book1D("cellAssociation", "Cell Association per multicluster", 5, -4., 1.);
histograms.h_cellAssociation.setBinLabel(2, "TN(purity)");
histograms.h_cellAssociation.setBinLabel(3, "FN(ineff.)");
histograms.h_cellAssociation.setBinLabel(4, "FP(fake)");
histograms.h_cellAssociation.setBinLabel(5, "TP(eff.)");
histograms.h_multiclusternum =
ibook.book1D("totmulticlusternum", "total number of multiclusters", nintTotNMCLs_, minTotNMCLs_, maxTotNMCLs_);
histograms.h_contmulticlusternum = ibook.book1D("contmulticlusternum",
"number of multiclusters with 3 contiguous layers",
nintTotNMCLs_,
minTotNMCLs_,
maxTotNMCLs_);
histograms.h_noncontmulticlusternum = ibook.book1D("noncontmulticlusternum",
"number of multiclusters without 3 contiguous layers",
nintTotNMCLs_,
minTotNMCLs_,
maxTotNMCLs_);
histograms.h_clusternum_in_multicluster = ibook.book1D("clusternum_in_multicluster",
"total number of layer clusters in multicluster",
nintTotNClsinMCLs_,
minTotNClsinMCLs_,
maxTotNClsinMCLs_);
histograms.h_clusternum_in_multicluster_vs_layer =
ibook.bookProfile("clusternum_in_multicluster_vs_layer",
"Profile of 2d layer clusters in multicluster vs layer number",
2 * layers,
0.,
(float)2 * layers,
minTotNClsinMCLsperlayer_,
maxTotNClsinMCLsperlayer_);
histograms.h_multiplicityOfLCinMCL = ibook.book2D("multiplicityOfLCinMCL",
"Multiplicity vs Layer cluster size in Multiclusters",
nintMplofLCs_,
minMplofLCs_,
maxMplofLCs_,
nintSizeCLsinMCLs_,
minSizeCLsinMCLs_,
maxSizeCLsinMCLs_);
histograms.h_multiplicity_numberOfEventsHistogram = ibook.book1D("multiplicity_numberOfEventsHistogram",
"multiplicity numberOfEventsHistogram",
nintMplofLCs_,
minMplofLCs_,
maxMplofLCs_);
histograms.h_multiplicity_zminus_numberOfEventsHistogram = ibook.book1D("multiplicity_zminus_numberOfEventsHistogram",
"multiplicity numberOfEventsHistogram in z-",
nintMplofLCs_,
minMplofLCs_,
maxMplofLCs_);
histograms.h_multiplicity_zplus_numberOfEventsHistogram = ibook.book1D("multiplicity_zplus_numberOfEventsHistogram",
"multiplicity numberOfEventsHistogram in z+",
nintMplofLCs_,
minMplofLCs_,
maxMplofLCs_);
histograms.h_multiplicityOfLCinMCL_vs_layercluster_zminus =
ibook.book2D("multiplicityOfLCinMCL_vs_layercluster_zminus",
"Multiplicity vs Layer number in z-",
nintMplofLCs_,
minMplofLCs_,
maxMplofLCs_,
layers,
0.,
(float)layers);
histograms.h_multiplicityOfLCinMCL_vs_layercluster_zplus = ibook.book2D("multiplicityOfLCinMCL_vs_layercluster_zplus",
"Multiplicity vs Layer number in z+",
nintMplofLCs_,
minMplofLCs_,
maxMplofLCs_,
layers,
0.,
(float)layers);
histograms.h_multiplicityOfLCinMCL_vs_layerclusterenergy = ibook.book2D("multiplicityOfLCinMCL_vs_layerclusterenergy",
"Multiplicity vs Layer cluster energy",
nintMplofLCs_,
minMplofLCs_,
maxMplofLCs_,
nintClEnepermultiplicity_,
minClEnepermultiplicity_,
maxClEnepermultiplicity_);
histograms.h_multicluster_pt = ibook.book1D("multicluster_pt", "Pt of the multicluster", nintPt_, minPt_, maxPt_);
histograms.h_multicluster_eta =
ibook.book1D("multicluster_eta", "Eta of the multicluster", nintEta_, minEta_, maxEta_);
histograms.h_multicluster_phi =
ibook.book1D("multicluster_phi", "Phi of the multicluster", nintPhi_, minPhi_, maxPhi_);
histograms.h_multicluster_energy =
ibook.book1D("multicluster_energy", "Energy of the multicluster", nintEne_, minEne_, maxEne_);
histograms.h_multicluster_x = ibook.book1D("multicluster_x", "X position of the multicluster", nintX_, minX_, maxX_);
histograms.h_multicluster_y = ibook.book1D("multicluster_y", "Y position of the multicluster", nintY_, minY_, maxY_);
histograms.h_multicluster_z = ibook.book1D("multicluster_z", "Z position of the multicluster", nintZ_, minZ_, maxZ_);
histograms.h_multicluster_firstlayer =
ibook.book1D("multicluster_firstlayer", "First layer of the multicluster", 2 * layers, 0., (float)2 * layers);
histograms.h_multicluster_lastlayer =
ibook.book1D("multicluster_lastlayer", "Last layer of the multicluster", 2 * layers, 0., (float)2 * layers);
histograms.h_multicluster_layersnum =
ibook.book1D("multicluster_layersnum", "Number of layers of the multicluster", 2 * layers, 0., (float)2 * layers);
}
void HGVHistoProducerAlgo::fill_info_histos(const Histograms& histograms, unsigned layers) const {
//We will save some info straight from geometry to avoid mistakes from updates
//----------- TODO ----------------------------------------------------------
//For now values returned for 'lastLayerFHzp': '104', 'lastLayerFHzm': '52' are not the one expected.
//Will come back to this when there will be info in CMSSW to put in DQM file.
histograms.lastLayerEEzm.fill(recHitTools_->lastLayerEE());
histograms.lastLayerFHzm.fill(recHitTools_->lastLayerFH());
histograms.maxlayerzm.fill(layers);
histograms.lastLayerEEzp.fill(recHitTools_->lastLayerEE() + layers);
histograms.lastLayerFHzp.fill(recHitTools_->lastLayerFH() + layers);
histograms.maxlayerzp.fill(layers + layers);
}
void HGVHistoProducerAlgo::fill_caloparticle_histos(const Histograms& histograms,
int pdgid,
const CaloParticle& caloparticle,
std::vector<SimVertex> const& simVertices) const {
const auto eta = getEta(caloparticle.eta());
if (histograms.h_caloparticle_eta.count(pdgid)) {
histograms.h_caloparticle_eta.at(pdgid).fill(eta);
}
if (histograms.h_caloparticle_eta_Zorigin.count(pdgid)) {
histograms.h_caloparticle_eta_Zorigin.at(pdgid).fill(
simVertices.at(caloparticle.g4Tracks()[0].vertIndex()).position().z(), eta);
}
if (histograms.h_caloparticle_energy.count(pdgid)) {
histograms.h_caloparticle_energy.at(pdgid).fill(caloparticle.energy());
}
if (histograms.h_caloparticle_pt.count(pdgid)) {
histograms.h_caloparticle_pt.at(pdgid).fill(caloparticle.pt());
}
if (histograms.h_caloparticle_phi.count(pdgid)) {
histograms.h_caloparticle_phi.at(pdgid).fill(caloparticle.phi());
}
}
void HGVHistoProducerAlgo::fill_cluster_histos(const Histograms& histograms,
int count,
const reco::CaloCluster& cluster) const {
const auto eta = getEta(cluster.eta());
histograms.h_cluster_eta[count].fill(eta);
}
void HGVHistoProducerAlgo::layerClusters_to_CaloParticles(const Histograms& histograms,
const reco::CaloClusterCollection& clusters,
std::vector<CaloParticle> const& cP,
std::vector<size_t> const& cPIndices,
std::map<DetId, const HGCRecHit*> const& hitMap,
unsigned layers) const {
auto nLayerClusters = clusters.size();
//Consider CaloParticles coming from the hard scatterer, excluding the PU contribution.
auto nCaloParticles = cPIndices.size();
std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToCaloParticleId_Map;
std::unordered_map<DetId, std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>> detIdToLayerClusterId_Map;
// this contains the ids of the caloparticles contributing with at least one hit to the layer cluster and the reconstruction error
std::vector<std::vector<std::pair<unsigned int, float>>> cpsInLayerCluster;
cpsInLayerCluster.resize(nLayerClusters);
std::vector<std::vector<caloParticleOnLayer>> cPOnLayer;
cPOnLayer.resize(nCaloParticles);
for (unsigned int i = 0; i < nCaloParticles; ++i) {
cPOnLayer[i].resize(layers * 2);
for (unsigned int j = 0; j < layers * 2; ++j) {
cPOnLayer[i][j].caloParticleId = i;
cPOnLayer[i][j].energy = 0.f;
cPOnLayer[i][j].hits_and_fractions.clear();
}
}
for (const auto& cpId : cPIndices) {
const SimClusterRefVector& simClusterRefVector = cP[cpId].simClusters();
for (const auto& it_sc : simClusterRefVector) {
const SimCluster& simCluster = (*(it_sc));
const auto& hits_and_fractions = simCluster.hits_and_fractions();
for (const auto& it_haf : hits_and_fractions) {
DetId hitid = (it_haf.first);
int cpLayerId = recHitTools_->getLayerWithOffset(hitid) + layers * ((recHitTools_->zside(hitid) + 1) >> 1) - 1;
std::map<DetId, const HGCRecHit*>::const_iterator itcheck = hitMap.find(hitid);
if (itcheck != hitMap.end()) {
const HGCRecHit* hit = itcheck->second;
auto hit_find_it = detIdToCaloParticleId_Map.find(hitid);
if (hit_find_it == detIdToCaloParticleId_Map.end()) {
detIdToCaloParticleId_Map[hitid] = std::vector<HGVHistoProducerAlgo::detIdInfoInCluster>();
detIdToCaloParticleId_Map[hitid].emplace_back(
HGVHistoProducerAlgo::detIdInfoInCluster{cpId, it_haf.second});
} else {
auto findHitIt = std::find(detIdToCaloParticleId_Map[hitid].begin(),
detIdToCaloParticleId_Map[hitid].end(),
HGVHistoProducerAlgo::detIdInfoInCluster{cpId, it_haf.second});
if (findHitIt != detIdToCaloParticleId_Map[hitid].end()) {
findHitIt->fraction += it_haf.second;
} else {
detIdToCaloParticleId_Map[hitid].emplace_back(
HGVHistoProducerAlgo::detIdInfoInCluster{cpId, it_haf.second});
}
}
cPOnLayer[cpId][cpLayerId].energy += it_haf.second * hit->energy();
// We need to compress the hits and fractions in order to have a
// reasonable score between CP and LC. Imagine, for example, that a
// CP has detID X used by 2 SimClusters with different fractions. If
// a single LC uses X with fraction 1 and is compared to the 2
// contributions separately, it will be assigned a score != 0, which
// is wrong.
auto& haf = cPOnLayer[cpId][cpLayerId].hits_and_fractions;
auto found = std::find_if(
std::begin(haf), std::end(haf), [&hitid](const std::pair<DetId, float>& v) { return v.first == hitid; });
if (found != haf.end()) {
found->second += it_haf.second;
} else {
cPOnLayer[cpId][cpLayerId].hits_and_fractions.emplace_back(hitid, it_haf.second);
}
}
}
}
}
LogDebug("HGCalValidator") << "cPOnLayer INFO" << std::endl;
for (size_t cp = 0; cp < cPOnLayer.size(); ++cp) {
LogDebug("HGCalValidator") << "For CaloParticle Idx: " << cp << " we have: " << std::endl;
for (size_t cpp = 0; cpp < cPOnLayer[cp].size(); ++cpp) {
LogDebug("HGCalValidator") << " On Layer: " << cpp << " we have:" << std::endl;
LogDebug("HGCalValidator") << " CaloParticleIdx: " << cPOnLayer[cp][cpp].caloParticleId << std::endl;
LogDebug("HGCalValidator") << " Energy: " << cPOnLayer[cp][cpp].energy << std::endl;
double tot_energy = 0.;
for (auto const& haf : cPOnLayer[cp][cpp].hits_and_fractions) {
LogDebug("HGCalValidator") << " Hits/fraction/energy: " << (uint32_t)haf.first << "/" << haf.second << "/"
<< haf.second * hitMap.at(haf.first)->energy() << std::endl;
tot_energy += haf.second * hitMap.at(haf.first)->energy();
}
LogDebug("HGCalValidator") << " Tot Sum haf: " << tot_energy << std::endl;
for (auto const& lc : cPOnLayer[cp][cpp].layerClusterIdToEnergyAndScore) {
LogDebug("HGCalValidator") << " lcIdx/energy/score: " << lc.first << "/" << lc.second.first << "/"
<< lc.second.second << std::endl;
}
}
}
LogDebug("HGCalValidator") << "detIdToCaloParticleId_Map INFO" << std::endl;
for (auto const& cp : detIdToCaloParticleId_Map) {
LogDebug("HGCalValidator") << "For detId: " << (uint32_t)cp.first
<< " we have found the following connections with CaloParticles:" << std::endl;
for (auto const& cpp : cp.second) {
LogDebug("HGCalValidator") << " CaloParticle Id: " << cpp.clusterId << " with fraction: " << cpp.fraction
<< " and energy: " << cpp.fraction * hitMap.at(cp.first)->energy() << std::endl;
}
}
for (unsigned int lcId = 0; lcId < nLayerClusters; ++lcId) {
const std::vector<std::pair<DetId, float>>& hits_and_fractions = clusters[lcId].hitsAndFractions();
unsigned int numberOfHitsInLC = hits_and_fractions.size();
// This vector will store, for each hit in the Layercluster, the index of
// the CaloParticle that contributed the most, in terms of energy, to it.
// Special values are:
//
// -2 --> the reconstruction fraction of the RecHit is 0 (used in the past to monitor Halo Hits)
// -3 --> same as before with the added condition that no CaloParticle has been linked to this RecHit
// -1 --> the reco fraction is >0, but no CaloParticle has been linked to it
// >=0 --> index of the linked CaloParticle
std::vector<int> hitsToCaloParticleId(numberOfHitsInLC);
const auto firstHitDetId = hits_and_fractions[0].first;
int lcLayerId =
recHitTools_->getLayerWithOffset(firstHitDetId) + layers * ((recHitTools_->zside(firstHitDetId) + 1) >> 1) - 1;
// This will store the index of the CaloParticle linked to the LayerCluster that has the most number of hits in common.
int maxCPId_byNumberOfHits = -1;
// This will store the maximum number of shared hits between a Layercluster andd a CaloParticle
unsigned int maxCPNumberOfHitsInLC = 0;
// This will store the index of the CaloParticle linked to the LayerCluster that has the most energy in common.
//
int maxCPId_byEnergy = -1;
// This will store the maximum number of shared energy between a Layercluster and a CaloParticle
float maxEnergySharedLCandCP = 0.f;
// This will store the fraction of the LayerCluster energy shared with the best(energy) CaloParticle: e_shared/lc_energy