From 8b984be11f69c7acf1fd24222610e85c76540c4a Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Mon, 12 Apr 2021 18:41:41 +0200 Subject: [PATCH 1/9] remove normalisation by area in seeding --- .../L1THGCal/src/backend/HGCalHistoSeedingImpl.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index 2353c592070be..df6ea7821d300 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -163,13 +163,19 @@ HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoCluste const vector& binSums) { Histogram histoSumPhiClusters(nBins1_, nBins2_); + const int bin1_10pct = (int) 0.1*nBins1_; + const float R1_10pct = kROverZMin_ + bin1_10pct * (kROverZMax_ - kROverZMin_) / nBins1_; + const float R2_10pct = R1_10pct + ((kROverZMax_ - kROverZMin_) / nBins1_); + const float area_10pct = ((M_PI * (pow(R2_10pct, 2) - pow(R1_10pct, 2))) / nBins2_); + for (int z_side : {-1, 1}) { for (unsigned bin1 = 0; bin1 < nBins1_; bin1++) { int nBinsSide = (binSums[bin1] - 1) / 2; - float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; - float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); + // float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; + // float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); double area = - ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_) * + // ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_) * + area_10pct * (1 + 2.0 * (1 - From 4734a02e4a04e6b96a2892e51063c5b1a683aa70 Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Thu, 1 Jul 2021 19:16:43 +0200 Subject: [PATCH 2/9] Add custominsation function --- .../interface/backend/HGCalHistoSeedingImpl.h | 6 ++++ .../L1THGCal/python/customHistoSeeding.py | 20 +++++++++---- .../python/hgcalBackEndLayer2Producer_cfi.py | 1 + .../src/backend/HGCalHistoSeedingImpl.cc | 30 ++++++++++--------- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h index 03519dc76dad6..91d06cbcc1c7a 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h @@ -156,6 +156,12 @@ class HGCalHistoSeedingImpl { std::vector neighbour_weights_; std::vector smoothing_ecal_; std::vector smoothing_hcal_; + bool seeds_norm_by_area_; + + int bin1_10pct_; + float R1_10pct_; + float R2_10pct_; + float area_10pct_; HGCalTriggerTools triggerTools_; Navigator navigator_; diff --git a/L1Trigger/L1THGCal/python/customHistoSeeding.py b/L1Trigger/L1THGCal/python/customHistoSeeding.py index 04f3b1924c3ad..fd762c4431a30 100644 --- a/L1Trigger/L1THGCal/python/customHistoSeeding.py +++ b/L1Trigger/L1THGCal/python/customHistoSeeding.py @@ -14,11 +14,13 @@ def set_histomax_seeding_params(parameters_seeding_c3d, nBins_X2, binSumsHisto, seed_threshold, + seeds_norm_by_area ): parameters_seeding_c3d.nBins_X1_histo_multicluster = nBins_X1 parameters_seeding_c3d.nBins_X2_histo_multicluster = nBins_X2 parameters_seeding_c3d.binSumsHisto = binSumsHisto parameters_seeding_c3d.threshold_histo_multicluster = seed_threshold + parameters_seeding_c3d.seeds_norm_by_area = seeds_norm_by_area def custom_3dclustering_histoMax(process, @@ -27,10 +29,11 @@ def custom_3dclustering_histoMax(process, binSumsHisto=histoMax_C3d_seeding_params.binSumsHisto, seed_threshold=histoMax_C3d_seeding_params.threshold_histo_multicluster, seed_position=histoMax_C3d_seeding_params.seed_position, + norm_by_area=histoMax_C3d_seeding_params.seeds_norm_by_area ): parameters_c3d = histoMax_C3d_seeding_params.clone() set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold) + seed_threshold, norm_by_area) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -39,10 +42,11 @@ def custom_3dclustering_histoSecondaryMax(process, nBins_X1=histoSecondaryMax_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoSecondaryMax_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoSecondaryMax_C3d_params.binSumsHisto, + norm_by_area=histoSecondaryMax_C3d_params.seeds_norm_by_area ): parameters_c3d = histoSecondaryMax_C3d_params.clone() set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - threshold) + threshold, norm_by_area) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -52,12 +56,13 @@ def custom_3dclustering_histoInterpolatedMax1stOrder(process, nBins_X2=histoInterpolatedMax_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoInterpolatedMax_C3d_params.binSumsHisto, seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster, + norm_by_area=histoInterpolatedMax_C3d_params.seeds_norm_by_area ): parameters_c3d = histoInterpolatedMax_C3d_params.clone( neighbour_weights = neighbour_weights_1stOrder ) set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold) + seed_threshold, norm_by_area) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -67,12 +72,13 @@ def custom_3dclustering_histoInterpolatedMax2ndOrder(process, nBins_X2=histoInterpolatedMax_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoInterpolatedMax_C3d_params.binSumsHisto, seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster, + norm_by_area=histoInterpolatedMax_C3d_params.seeds_norm_by_area ): parameters_c3d = histoInterpolatedMax_C3d_params.clone( neighbour_weights = neighbour_weights_2ndOrder ) set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold) + seed_threshold, norm_by_area) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -82,10 +88,11 @@ def custom_3dclustering_histoThreshold(process, nBins_X2=histoThreshold_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoThreshold_C3d_params.binSumsHisto, seed_threshold=histoThreshold_C3d_params.threshold_histo_multicluster, + norm_by_area=histoThreshold_C3d_params.seeds_norm_by_area ): parameters_c3d = histoThreshold_C3d_params.clone() set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold) + seed_threshold, norm_by_area) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -95,10 +102,11 @@ def custom_3dclustering_XYHistoMax(process, nBins_X2=histoMaxXYVariableDR_C3d_params.nBins_X2_histo_multicluster, seed_threshold=histoMaxXYVariableDR_C3d_params.threshold_histo_multicluster, seed_position=histoMaxXYVariableDR_C3d_params.seed_position, + norm_by_area=histoThreshold_C3d_params.seeds_norm_by_area ): parameters_c3d = histoMaxXYVariableDR_C3d_params.clone() set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, - histoMaxXYVariableDR_C3d_params.binSumsHisto,seed_threshold) + histoMaxXYVariableDR_C3d_params.binSumsHisto,seed_threshold, norm_by_area) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py index b940dd36920c3..82e3a9f24ce3c 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py @@ -87,6 +87,7 @@ seeding_space=cms.string("RPhi"),# RPhi, XY seed_smoothing_ecal=seed_smoothing_ecal, seed_smoothing_hcal=seed_smoothing_hcal, + seeds_norm_by_area=cms.bool(True) ) histoMax_C3d_clustering_params = cms.PSet(dR_multicluster=cms.double(0.03), diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index df6ea7821d300..fd5078d07266a 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -13,6 +13,7 @@ HGCalHistoSeedingImpl::HGCalHistoSeedingImpl(const edm::ParameterSet& conf) neighbour_weights_(conf.getParameter>("neighbour_weights")), smoothing_ecal_(conf.getParameter>("seed_smoothing_ecal")), smoothing_hcal_(conf.getParameter>("seed_smoothing_hcal")), + seeds_norm_by_area_(conf.getParameter("seeds_norm_by_area")), kROverZMin_(conf.getParameter("kROverZMin")), kROverZMax_(conf.getParameter("kROverZMax")) { if (seedingAlgoType_ == "HistoMaxC3d") { @@ -64,6 +65,12 @@ HGCalHistoSeedingImpl::HGCalHistoSeedingImpl(const edm::ParameterSet& conf) << "Inconsistent size of neighbour weights vector in HGCalMulticlustering ( " << neighbour_weights_.size() << " ). Should be " << neighbour_weights_size_ << "\n"; } + + // compute quantities for non-normalised-by-area histoMax + bin1_10pct_ = (int) 0.1*nBins1_; + R1_10pct_ = kROverZMin_ + bin1_10pct_ * (kROverZMax_ - kROverZMin_) / nBins1_; + R2_10pct_ = R1_10pct_ + ((kROverZMax_ - kROverZMin_) / nBins1_); + area_10pct_ = ((M_PI * (pow(R2_10pct_, 2) - pow(R1_10pct_, 2))) / nBins2_); } HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillHistoClusters( @@ -163,24 +170,19 @@ HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoCluste const vector& binSums) { Histogram histoSumPhiClusters(nBins1_, nBins2_); - const int bin1_10pct = (int) 0.1*nBins1_; - const float R1_10pct = kROverZMin_ + bin1_10pct * (kROverZMax_ - kROverZMin_) / nBins1_; - const float R2_10pct = R1_10pct + ((kROverZMax_ - kROverZMin_) / nBins1_); - const float area_10pct = ((M_PI * (pow(R2_10pct, 2) - pow(R1_10pct, 2))) / nBins2_); for (int z_side : {-1, 1}) { for (unsigned bin1 = 0; bin1 < nBins1_; bin1++) { int nBinsSide = (binSums[bin1] - 1) / 2; - // float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; - // float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); - double area = - // ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_) * - area_10pct * - (1 + - 2.0 * - (1 - - pow(0.5, - nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used + double area = (1 + 2.0 * (1 - pow(0.5, nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used + + if (seeds_norm_by_area_) { + float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; + float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); + area = area * ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_); + } else { + area = area * area_10pct_; + } for (unsigned bin2 = 0; bin2 < nBins2_; bin2++) { const auto& bin_orig = histoClusters.at(z_side, bin1, bin2); From 1e6a73994cc6cf490dd15fa0f18209271686d621 Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Wed, 7 Jul 2021 15:14:48 +0200 Subject: [PATCH 3/9] Default to mod. seeding with thr=20 --- L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py index 82e3a9f24ce3c..65d24e117725c 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py @@ -87,7 +87,7 @@ seeding_space=cms.string("RPhi"),# RPhi, XY seed_smoothing_ecal=seed_smoothing_ecal, seed_smoothing_hcal=seed_smoothing_hcal, - seeds_norm_by_area=cms.bool(True) + seeds_norm_by_area=cms.bool(False) ) histoMax_C3d_clustering_params = cms.PSet(dR_multicluster=cms.double(0.03), @@ -106,7 +106,7 @@ # (see https://indico.cern.ch/event/806845/contributions/3359859/attachments/1815187/2966402/19-03-20_EGPerf_HGCBE.pdf # for more details) phase2_hgcalV10.toModify(histoMax_C3d_seeding_params, - threshold_histo_multicluster=8.5, # MipT + threshold_histo_multicluster=20, # arb. units (for seeds_norm_by_area=False) ) From 3916fdfbddcaa3468716a56bf3e1103913a9fcd5 Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Wed, 7 Jul 2021 15:21:41 +0200 Subject: [PATCH 4/9] code-format --- .../src/backend/HGCalHistoSeedingImpl.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index fd5078d07266a..99d3e3b48a4fd 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -67,7 +67,7 @@ HGCalHistoSeedingImpl::HGCalHistoSeedingImpl(const edm::ParameterSet& conf) } // compute quantities for non-normalised-by-area histoMax - bin1_10pct_ = (int) 0.1*nBins1_; + bin1_10pct_ = (int)0.1 * nBins1_; R1_10pct_ = kROverZMin_ + bin1_10pct_ * (kROverZMax_ - kROverZMin_) / nBins1_; R2_10pct_ = R1_10pct_ + ((kROverZMax_ - kROverZMin_) / nBins1_); area_10pct_ = ((M_PI * (pow(R2_10pct_, 2) - pow(R1_10pct_, 2))) / nBins2_); @@ -170,18 +170,22 @@ HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoCluste const vector& binSums) { Histogram histoSumPhiClusters(nBins1_, nBins2_); - for (int z_side : {-1, 1}) { for (unsigned bin1 = 0; bin1 < nBins1_; bin1++) { int nBinsSide = (binSums[bin1] - 1) / 2; - double area = (1 + 2.0 * (1 - pow(0.5, nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used + double area = + (1 + + 2.0 * + (1 - + pow(0.5, + nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used if (seeds_norm_by_area_) { - float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; - float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); - area = area * ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_); + float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; + float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); + area = area * ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_); } else { - area = area * area_10pct_; + area = area * area_10pct_; } for (unsigned bin2 = 0; bin2 < nBins2_; bin2++) { From 49e646fd86fa2f58b643b000705ded949536effc Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Mon, 12 Apr 2021 18:41:41 +0200 Subject: [PATCH 5/9] remove normalisation by area in seeding --- L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index 99d3e3b48a4fd..870a90a616608 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -170,10 +170,19 @@ HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoCluste const vector& binSums) { Histogram histoSumPhiClusters(nBins1_, nBins2_); + const int bin1_10pct = (int) 0.1*nBins1_; + const float R1_10pct = kROverZMin_ + bin1_10pct * (kROverZMax_ - kROverZMin_) / nBins1_; + const float R2_10pct = R1_10pct + ((kROverZMax_ - kROverZMin_) / nBins1_); + const float area_10pct = ((M_PI * (pow(R2_10pct, 2) - pow(R1_10pct, 2))) / nBins2_); + for (int z_side : {-1, 1}) { for (unsigned bin1 = 0; bin1 < nBins1_; bin1++) { int nBinsSide = (binSums[bin1] - 1) / 2; + // float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; + // float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); double area = + // ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_) * + area_10pct * (1 + 2.0 * (1 - From 7b7599980e301450f00ad14b122d77177ad882cc Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Thu, 1 Jul 2021 19:16:43 +0200 Subject: [PATCH 6/9] Add custominsation function --- .../python/hgcalBackEndLayer2Producer_cfi.py | 2 +- .../src/backend/HGCalHistoSeedingImpl.cc | 25 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py index 65d24e117725c..b97cdf18fa655 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py @@ -87,7 +87,7 @@ seeding_space=cms.string("RPhi"),# RPhi, XY seed_smoothing_ecal=seed_smoothing_ecal, seed_smoothing_hcal=seed_smoothing_hcal, - seeds_norm_by_area=cms.bool(False) + seeds_norm_by_area=cms.bool(True) ) histoMax_C3d_clustering_params = cms.PSet(dR_multicluster=cms.double(0.03), diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index 870a90a616608..4b1b9fa77b5a2 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -67,7 +67,7 @@ HGCalHistoSeedingImpl::HGCalHistoSeedingImpl(const edm::ParameterSet& conf) } // compute quantities for non-normalised-by-area histoMax - bin1_10pct_ = (int)0.1 * nBins1_; + bin1_10pct_ = (int) 0.1*nBins1_; R1_10pct_ = kROverZMin_ + bin1_10pct_ * (kROverZMax_ - kROverZMin_) / nBins1_; R2_10pct_ = R1_10pct_ + ((kROverZMax_ - kROverZMin_) / nBins1_); area_10pct_ = ((M_PI * (pow(R2_10pct_, 2) - pow(R1_10pct_, 2))) / nBins2_); @@ -170,24 +170,19 @@ HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoCluste const vector& binSums) { Histogram histoSumPhiClusters(nBins1_, nBins2_); - const int bin1_10pct = (int) 0.1*nBins1_; - const float R1_10pct = kROverZMin_ + bin1_10pct * (kROverZMax_ - kROverZMin_) / nBins1_; - const float R2_10pct = R1_10pct + ((kROverZMax_ - kROverZMin_) / nBins1_); - const float area_10pct = ((M_PI * (pow(R2_10pct, 2) - pow(R1_10pct, 2))) / nBins2_); for (int z_side : {-1, 1}) { for (unsigned bin1 = 0; bin1 < nBins1_; bin1++) { int nBinsSide = (binSums[bin1] - 1) / 2; - // float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; - // float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); - double area = - // ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_) * - area_10pct * - (1 + - 2.0 * - (1 - - pow(0.5, - nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used + double area = (1 + 2.0 * (1 - pow(0.5, nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used + + if (seeds_norm_by_area_) { + float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; + float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); + area = area * ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_); + } else { + area = area * area_10pct_; + } if (seeds_norm_by_area_) { float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; From 1bf04322b726a02cd55cbea8a247c428d3ea6f56 Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Mon, 19 Jul 2021 16:22:47 +0200 Subject: [PATCH 7/9] JB's comments to the PR --- .../interface/backend/HGCalHistoSeedingImpl.h | 3 -- .../L1THGCal/python/customHistoSeeding.py | 46 ++++++++----------- .../python/hgcalBackEndLayer2Producer_cfi.py | 2 +- .../src/backend/HGCalHistoSeedingImpl.cc | 9 ++-- 4 files changed, 26 insertions(+), 34 deletions(-) diff --git a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h index 91d06cbcc1c7a..b39795420ad64 100644 --- a/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h +++ b/L1Trigger/L1THGCal/interface/backend/HGCalHistoSeedingImpl.h @@ -158,9 +158,6 @@ class HGCalHistoSeedingImpl { std::vector smoothing_hcal_; bool seeds_norm_by_area_; - int bin1_10pct_; - float R1_10pct_; - float R2_10pct_; float area_10pct_; HGCalTriggerTools triggerTools_; diff --git a/L1Trigger/L1THGCal/python/customHistoSeeding.py b/L1Trigger/L1THGCal/python/customHistoSeeding.py index fd762c4431a30..fc3515a5c88e6 100644 --- a/L1Trigger/L1THGCal/python/customHistoSeeding.py +++ b/L1Trigger/L1THGCal/python/customHistoSeeding.py @@ -13,14 +13,12 @@ def set_histomax_seeding_params(parameters_seeding_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold, - seeds_norm_by_area + seed_threshold ): parameters_seeding_c3d.nBins_X1_histo_multicluster = nBins_X1 parameters_seeding_c3d.nBins_X2_histo_multicluster = nBins_X2 parameters_seeding_c3d.binSumsHisto = binSumsHisto parameters_seeding_c3d.threshold_histo_multicluster = seed_threshold - parameters_seeding_c3d.seeds_norm_by_area = seeds_norm_by_area def custom_3dclustering_histoMax(process, @@ -28,12 +26,10 @@ def custom_3dclustering_histoMax(process, nBins_X2=histoMax_C3d_seeding_params.nBins_X2_histo_multicluster, binSumsHisto=histoMax_C3d_seeding_params.binSumsHisto, seed_threshold=histoMax_C3d_seeding_params.threshold_histo_multicluster, - seed_position=histoMax_C3d_seeding_params.seed_position, - norm_by_area=histoMax_C3d_seeding_params.seeds_norm_by_area + seed_position=histoMax_C3d_seeding_params.seed_position ): parameters_c3d = histoMax_C3d_seeding_params.clone() - set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold, norm_by_area) + set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -41,12 +37,10 @@ def custom_3dclustering_histoSecondaryMax(process, threshold=histoSecondaryMax_C3d_params.threshold_histo_multicluster, nBins_X1=histoSecondaryMax_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoSecondaryMax_C3d_params.nBins_X2_histo_multicluster, - binSumsHisto=histoSecondaryMax_C3d_params.binSumsHisto, - norm_by_area=histoSecondaryMax_C3d_params.seeds_norm_by_area + binSumsHisto=histoSecondaryMax_C3d_params.binSumsHisto ): parameters_c3d = histoSecondaryMax_C3d_params.clone() - set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - threshold, norm_by_area) + set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -55,14 +49,13 @@ def custom_3dclustering_histoInterpolatedMax1stOrder(process, nBins_X1=histoInterpolatedMax_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoInterpolatedMax_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoInterpolatedMax_C3d_params.binSumsHisto, - seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster, - norm_by_area=histoInterpolatedMax_C3d_params.seeds_norm_by_area + seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster ): parameters_c3d = histoInterpolatedMax_C3d_params.clone( neighbour_weights = neighbour_weights_1stOrder ) set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold, norm_by_area) + seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -71,14 +64,12 @@ def custom_3dclustering_histoInterpolatedMax2ndOrder(process, nBins_X1=histoInterpolatedMax_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoInterpolatedMax_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoInterpolatedMax_C3d_params.binSumsHisto, - seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster, - norm_by_area=histoInterpolatedMax_C3d_params.seeds_norm_by_area + seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster ): parameters_c3d = histoInterpolatedMax_C3d_params.clone( neighbour_weights = neighbour_weights_2ndOrder ) - set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold, norm_by_area) + set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -87,12 +78,9 @@ def custom_3dclustering_histoThreshold(process, nBins_X1=histoThreshold_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoThreshold_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoThreshold_C3d_params.binSumsHisto, - seed_threshold=histoThreshold_C3d_params.threshold_histo_multicluster, - norm_by_area=histoThreshold_C3d_params.seeds_norm_by_area - ): + seed_threshold=histoThreshold_C3d_params.threshold_histo_multicluster): parameters_c3d = histoThreshold_C3d_params.clone() - set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold, norm_by_area) + set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -101,12 +89,18 @@ def custom_3dclustering_XYHistoMax(process, nBins_X1=histoMaxXYVariableDR_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoMaxXYVariableDR_C3d_params.nBins_X2_histo_multicluster, seed_threshold=histoMaxXYVariableDR_C3d_params.threshold_histo_multicluster, - seed_position=histoMaxXYVariableDR_C3d_params.seed_position, - norm_by_area=histoThreshold_C3d_params.seeds_norm_by_area + seed_position=histoMaxXYVariableDR_C3d_params.seed_position ): parameters_c3d = histoMaxXYVariableDR_C3d_params.clone() set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, - histoMaxXYVariableDR_C3d_params.binSumsHisto,seed_threshold, norm_by_area) + histoMaxXYVariableDR_C3d_params.binSumsHisto,seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process +def custom_3dclustering_seedNoArea(process, + seeds_norm_by_area=cms.bool(False), + seed_threshold=cms.double(20)): + parameters_c3d = histoMax_C3d_seeding_params.clone() + parameters_c3d.seeds_norm_by_area = seeds_norm_by_area + parameters_c3d.threshold_histo_multicluster = seed_threshold + process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d diff --git a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py index b97cdf18fa655..82e3a9f24ce3c 100644 --- a/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py +++ b/L1Trigger/L1THGCal/python/hgcalBackEndLayer2Producer_cfi.py @@ -106,7 +106,7 @@ # (see https://indico.cern.ch/event/806845/contributions/3359859/attachments/1815187/2966402/19-03-20_EGPerf_HGCBE.pdf # for more details) phase2_hgcalV10.toModify(histoMax_C3d_seeding_params, - threshold_histo_multicluster=20, # arb. units (for seeds_norm_by_area=False) + threshold_histo_multicluster=8.5, # MipT ) diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index 4b1b9fa77b5a2..65d5257e9c403 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -67,10 +67,11 @@ HGCalHistoSeedingImpl::HGCalHistoSeedingImpl(const edm::ParameterSet& conf) } // compute quantities for non-normalised-by-area histoMax - bin1_10pct_ = (int) 0.1*nBins1_; - R1_10pct_ = kROverZMin_ + bin1_10pct_ * (kROverZMax_ - kROverZMin_) / nBins1_; - R2_10pct_ = R1_10pct_ + ((kROverZMax_ - kROverZMin_) / nBins1_); - area_10pct_ = ((M_PI * (pow(R2_10pct_, 2) - pow(R1_10pct_, 2))) / nBins2_); + // The 0.1 factor in bin1_10pct is an attempt to keep the same rough scale for seeds. The exact value is arbitrary. + int bin1_10pct = (int) 0.1*nBins1_; + float R1_10pct = kROverZMin_ + bin1_10pct * (kROverZMax_ - kROverZMin_) / nBins1_; + float R2_10pct = R1_10pct + ((kROverZMax_ - kROverZMin_) / nBins1_); + area_10pct_ = ((M_PI * (pow(R2_10pct, 2) - pow(R1_10pct, 2))) / nBins2_); } HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillHistoClusters( From c575216c4d9e187636e4e89f285749161d98e3b8 Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Fri, 23 Jul 2021 11:48:22 +0200 Subject: [PATCH 8/9] code-formats and fixes in customHistoSeeding.py --- .../L1THGCal/python/customHistoSeeding.py | 34 +++++++++++-------- .../src/backend/HGCalHistoSeedingImpl.cc | 18 ++++++---- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/L1Trigger/L1THGCal/python/customHistoSeeding.py b/L1Trigger/L1THGCal/python/customHistoSeeding.py index fc3515a5c88e6..90583a5c6caae 100644 --- a/L1Trigger/L1THGCal/python/customHistoSeeding.py +++ b/L1Trigger/L1THGCal/python/customHistoSeeding.py @@ -13,7 +13,7 @@ def set_histomax_seeding_params(parameters_seeding_c3d, nBins_X1, nBins_X2, binSumsHisto, - seed_threshold + seed_threshold, ): parameters_seeding_c3d.nBins_X1_histo_multicluster = nBins_X1 parameters_seeding_c3d.nBins_X2_histo_multicluster = nBins_X2 @@ -26,10 +26,11 @@ def custom_3dclustering_histoMax(process, nBins_X2=histoMax_C3d_seeding_params.nBins_X2_histo_multicluster, binSumsHisto=histoMax_C3d_seeding_params.binSumsHisto, seed_threshold=histoMax_C3d_seeding_params.threshold_histo_multicluster, - seed_position=histoMax_C3d_seeding_params.seed_position + seed_position=histoMax_C3d_seeding_params.seed_position, ): parameters_c3d = histoMax_C3d_seeding_params.clone() - set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, seed_threshold) + set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, + seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -37,10 +38,11 @@ def custom_3dclustering_histoSecondaryMax(process, threshold=histoSecondaryMax_C3d_params.threshold_histo_multicluster, nBins_X1=histoSecondaryMax_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoSecondaryMax_C3d_params.nBins_X2_histo_multicluster, - binSumsHisto=histoSecondaryMax_C3d_params.binSumsHisto + binSumsHisto=histoSecondaryMax_C3d_params.binSumsHisto, ): parameters_c3d = histoSecondaryMax_C3d_params.clone() - set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, threshold) + set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, + threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -49,7 +51,7 @@ def custom_3dclustering_histoInterpolatedMax1stOrder(process, nBins_X1=histoInterpolatedMax_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoInterpolatedMax_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoInterpolatedMax_C3d_params.binSumsHisto, - seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster + seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster, ): parameters_c3d = histoInterpolatedMax_C3d_params.clone( neighbour_weights = neighbour_weights_1stOrder @@ -64,12 +66,13 @@ def custom_3dclustering_histoInterpolatedMax2ndOrder(process, nBins_X1=histoInterpolatedMax_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoInterpolatedMax_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoInterpolatedMax_C3d_params.binSumsHisto, - seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster + seed_threshold=histoInterpolatedMax_C3d_params.threshold_histo_multicluster, ): parameters_c3d = histoInterpolatedMax_C3d_params.clone( neighbour_weights = neighbour_weights_2ndOrder ) - set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, seed_threshold) + set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, + seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -78,9 +81,11 @@ def custom_3dclustering_histoThreshold(process, nBins_X1=histoThreshold_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoThreshold_C3d_params.nBins_X2_histo_multicluster, binSumsHisto=histoThreshold_C3d_params.binSumsHisto, - seed_threshold=histoThreshold_C3d_params.threshold_histo_multicluster): + seed_threshold=histoThreshold_C3d_params.threshold_histo_multicluster, + ): parameters_c3d = histoThreshold_C3d_params.clone() - set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, seed_threshold) + set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, binSumsHisto, + seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d return process @@ -89,7 +94,7 @@ def custom_3dclustering_XYHistoMax(process, nBins_X1=histoMaxXYVariableDR_C3d_params.nBins_X1_histo_multicluster, nBins_X2=histoMaxXYVariableDR_C3d_params.nBins_X2_histo_multicluster, seed_threshold=histoMaxXYVariableDR_C3d_params.threshold_histo_multicluster, - seed_position=histoMaxXYVariableDR_C3d_params.seed_position + seed_position=histoMaxXYVariableDR_C3d_params.seed_position, ): parameters_c3d = histoMaxXYVariableDR_C3d_params.clone() set_histomax_seeding_params(parameters_c3d, nBins_X1, nBins_X2, @@ -98,9 +103,8 @@ def custom_3dclustering_XYHistoMax(process, return process def custom_3dclustering_seedNoArea(process, - seeds_norm_by_area=cms.bool(False), seed_threshold=cms.double(20)): - parameters_c3d = histoMax_C3d_seeding_params.clone() - parameters_c3d.seeds_norm_by_area = seeds_norm_by_area - parameters_c3d.threshold_histo_multicluster = seed_threshold + parameters_c3d = histoMax_C3d_seeding_params.clone(seeds_norm_by_area = False, + threshold_histo_multicluster = seed_threshold) process.hgcalBackEndLayer2Producer.ProcessorParameters.C3d_parameters.histoMax_C3d_seeding_parameters = parameters_c3d + return process diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index 65d5257e9c403..6925b0371ee91 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -68,7 +68,7 @@ HGCalHistoSeedingImpl::HGCalHistoSeedingImpl(const edm::ParameterSet& conf) // compute quantities for non-normalised-by-area histoMax // The 0.1 factor in bin1_10pct is an attempt to keep the same rough scale for seeds. The exact value is arbitrary. - int bin1_10pct = (int) 0.1*nBins1_; + int bin1_10pct = (int)0.1 * nBins1_; float R1_10pct = kROverZMin_ + bin1_10pct * (kROverZMax_ - kROverZMin_) / nBins1_; float R2_10pct = R1_10pct + ((kROverZMax_ - kROverZMin_) / nBins1_); area_10pct_ = ((M_PI * (pow(R2_10pct, 2) - pow(R1_10pct, 2))) / nBins2_); @@ -171,18 +171,22 @@ HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoCluste const vector& binSums) { Histogram histoSumPhiClusters(nBins1_, nBins2_); - for (int z_side : {-1, 1}) { for (unsigned bin1 = 0; bin1 < nBins1_; bin1++) { int nBinsSide = (binSums[bin1] - 1) / 2; - double area = (1 + 2.0 * (1 - pow(0.5, nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used + double area = + (1 + + 2.0 * + (1 - + pow(0.5, + nBinsSide))); // Takes into account different area of bins in different R-rings + sum of quadratic weights used if (seeds_norm_by_area_) { - float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; - float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); - area = area * ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_); + float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; + float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); + area = area * ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_); } else { - area = area * area_10pct_; + area = area * area_10pct_; } if (seeds_norm_by_area_) { From 1d48cf4ede06ed9b2cf4dda994a13038be24806e Mon Sep 17 00:00:00 2001 From: Emilien Chapon Date: Fri, 23 Jul 2021 11:52:12 +0200 Subject: [PATCH 9/9] Remove duplicated code --- L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc | 8 -------- 1 file changed, 8 deletions(-) diff --git a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc index 6925b0371ee91..558ec2ee58dc7 100644 --- a/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc +++ b/L1Trigger/L1THGCal/src/backend/HGCalHistoSeedingImpl.cc @@ -189,14 +189,6 @@ HGCalHistoSeedingImpl::Histogram HGCalHistoSeedingImpl::fillSmoothPhiHistoCluste area = area * area_10pct_; } - if (seeds_norm_by_area_) { - float R1 = kROverZMin_ + bin1 * (kROverZMax_ - kROverZMin_) / nBins1_; - float R2 = R1 + ((kROverZMax_ - kROverZMin_) / nBins1_); - area = area * ((M_PI * (pow(R2, 2) - pow(R1, 2))) / nBins2_); - } else { - area = area * area_10pct_; - } - for (unsigned bin2 = 0; bin2 < nBins2_; bin2++) { const auto& bin_orig = histoClusters.at(z_side, bin1, bin2); float content = bin_orig.values[Bin::Content::Sum];