8 : seedingAlgoType_(conf.getParameter<
std::
string>(
"type_histoalgo")),
9 nBins1_(conf.getParameter<unsigned>(
"nBins_X1_histo_multicluster")),
10 nBins2_(conf.getParameter<unsigned>(
"nBins_X2_histo_multicluster")),
11 binsSumsHisto_(conf.getParameter<
std::vector<unsigned>>(
"binSumsHisto")),
12 histoThreshold_(conf.getParameter<double>(
"threshold_histo_multicluster")),
13 neighbour_weights_(conf.getParameter<
std::vector<double>>(
"neighbour_weights")),
14 smoothing_ecal_(conf.getParameter<
std::vector<double>>(
"seed_smoothing_ecal")),
15 smoothing_hcal_(conf.getParameter<
std::vector<double>>(
"seed_smoothing_hcal")) {
48 <<
"\nMulticluster number of X1-bins for the histo algorithm: " <<
nBins1_ 49 <<
"\nMulticluster number of X2-bins for the histo algorithm: " <<
nBins2_ 50 <<
"\nMulticluster MIPT threshold for histo threshold algorithm: " <<
histoThreshold_ 53 if (seedingAlgoType_.find(
"Histo") != std::string::npos &&
seedingSpace_ ==
RPhi &&
56 <<
"Inconsistent nBins_X1_histo_multicluster ( " <<
nBins1_ <<
" ) and binSumsHisto ( " <<
binsSumsHisto_.size()
57 <<
" ) size in HGCalMulticlustering\n";
62 <<
"Inconsistent size of neighbour weights vector in HGCalMulticlustering ( " <<
neighbour_weights_.size()
71 double minx1 = std::get<0>(bounds);
72 double maxx1 = std::get<1>(bounds);
73 double minx2 = std::get<2>(bounds);
74 double maxx2 = std::get<3>(bounds);
76 for (
auto& clu : clustersPtrs) {
77 float x1 = 0.,
x2 = 0;
80 x1 =
sqrt(
pow(clu->centreProj().x(), 2) +
pow(clu->centreProj().y(), 2));
84 x1 = clu->centreProj().x();
85 x2 = clu->centreProj().y();
88 if (x1 < minx1 || x1 >= maxx1) {
89 throw cms::Exception(
"OutOfBound") <<
"TC X1 = " << x1 <<
" out of the seeding histogram bounds " << minx1
92 if (x2 < minx2 || x2 >= maxx2) {
93 throw cms::Exception(
"OutOfBound") <<
"TC X2 = " <<
x2 <<
" out of the seeding histogram bounds " << minx2
96 unsigned bin1 = unsigned((x1 - minx1) *
nBins1_ / (maxx1 - minx1));
97 unsigned bin2 = unsigned((
x2 - minx2) *
nBins2_ / (maxx2 - minx2));
102 bin.values[Bin::Content::Ecal] += clu->mipPt();
104 bin.values[Bin::Content::Hcal] += clu->mipPt();
106 bin.weighted_x += (clu->centreProj().x()) * clu->mipPt();
107 bin.weighted_y += (clu->centreProj().y()) * clu->mipPt();
110 for (
auto&
bin : histoClusters) {
115 return histoClusters;
119 const vector<double>& kernel,
123 unsigned kernel_size =
std::sqrt(kernel.size());
124 if (kernel_size * kernel_size != kernel.size()) {
125 throw cms::Exception(
"HGCTriggerParameterError") <<
"Only square kernels can be used.";
127 if (kernel_size % 2 != 1) {
128 throw cms::Exception(
"HGCTriggerParameterError") <<
"The kernel size must be an odd value.";
130 int shift_max = (kernel_size - 1) / 2;
131 double normalization = std::accumulate(kernel.begin(), kernel.end(), 0.);
132 for (
int z_side : {-1, 1}) {
135 const auto& bin_orig = histoClusters.
at(z_side,
x1,
x2);
138 for (
int x1_shift = -shift_max; x1_shift <= shift_max; x1_shift++) {
139 int index1 = x1_shift + shift_max;
140 for (
int x2_shift = -shift_max; x2_shift <= shift_max; x2_shift++) {
142 int index2 = x2_shift + shift_max;
143 double kernel_value = kernel.at(index1 * kernel_size + index2);
144 bool out = shifted[0] == -1 || shifted[1] == -1;
145 double content = (out ? 0. : histoClusters.
at(z_side, shifted[0], shifted[1]).values[binContent]);
146 smooth += content * kernel_value;
149 auto&
bin = histoSmooth.
at(z_side,
x1,
x2);
151 bin.weighted_x = bin_orig.weighted_x;
152 bin.weighted_y = bin_orig.weighted_y;
161 const vector<unsigned>&
binSums) {
164 for (
int z_side : {-1, 1}) {
165 for (
unsigned bin1 = 0; bin1 <
nBins1_; bin1++) {
166 int nBinsSide = (binSums[bin1] - 1) / 2;
170 0.5 * (
pow(R2, 2) -
pow(R1, 2)) *
177 for (
unsigned bin2 = 0; bin2 <
nBins2_; bin2++) {
178 const auto& bin_orig = histoClusters.
at(z_side, bin1, bin2);
181 for (
int bin22 = 1; bin22 <= nBinsSide; bin22++) {
182 int binToSumLeft = bin2 - bin22;
183 if (binToSumLeft < 0)
185 unsigned binToSumRight = bin2 + bin22;
186 if (binToSumRight >= nBins2_)
196 auto&
bin = histoSumPhiClusters.
at(z_side, bin1, bin2);
198 bin.weighted_x = bin_orig.weighted_x;
199 bin.weighted_y = bin_orig.weighted_y;
204 return histoSumPhiClusters;
210 for (
int z_side : {-1, 1}) {
211 for (
unsigned bin1 = 0; bin1 <
nBins1_; bin1++) {
213 (bin1 == 0 || bin1 == nBins1_ - 1) ? 1.5 : 2.;
215 for (
unsigned bin2 = 0; bin2 <
nBins2_; bin2++) {
216 const auto& bin_orig = histoClusters.
at(z_side, bin1, bin2);
218 float contentDown = bin1 > 0 ? histoClusters.
at(z_side, bin1 - 1, bin2).values[
Bin::Content::Sum] : 0;
219 float contentUp = bin1 < (nBins1_ - 1) ? histoClusters.
at(z_side, bin1 + 1, bin2).values[
Bin::Content::Sum] : 0;
221 auto&
bin = histoSumRPhiClusters.
at(z_side, bin1, bin2);
223 bin.weighted_x = bin_orig.weighted_x;
224 bin.weighted_y = bin_orig.weighted_y;
229 return histoSumRPhiClusters;
236 const Bin& histBin) {
240 double minx1 = std::get<0>(bounds);
241 double maxx1 = std::get<1>(bounds);
242 double minx2 = std::get<2>(bounds);
243 double maxx2 = std::get<3>(bounds);
246 float x1_seed = minx1 + (bin1 + 0.5) * (maxx1 - minx1) /
nBins1_;
247 float x2_seed = minx2 + (bin2 + 0.5) * (maxx2 - minx2) /
nBins2_;
250 x_seed = x1_seed *
cos(x2_seed);
251 y_seed = x1_seed *
sin(x2_seed);
266 std::vector<std::pair<GlobalPoint, double>> seedPositionsEnergy;
268 for (
int z_side : {-1, 1}) {
269 for (
unsigned bin1 = 0; bin1 <
nBins1_; bin1++) {
270 for (
unsigned bin2 = 0; bin2 <
nBins2_; bin2++) {
286 float MIPT_N = (pos_N[0] != -1 && pos_N[1] != -1)
289 float MIPT_S = (pos_S[0] != -1 && pos_S[1] != -1)
292 float MIPT_W = (pos_W[0] != -1 && pos_W[1] != -1)
295 float MIPT_E = (pos_E[0] != -1 && pos_E[1] != -1)
298 float MIPT_NW = (pos_NW[0] != -1 && pos_NW[1] != -1)
301 float MIPT_NE = (pos_NE[0] != -1 && pos_NE[1] != -1)
304 float MIPT_SW = (pos_SW[0] != -1 && pos_SW[1] != -1)
307 float MIPT_SE = (pos_SE[0] != -1 && pos_SE[1] != -1)
311 isMax &= MIPT_seed >= MIPT_S && MIPT_seed > MIPT_N && MIPT_seed >= MIPT_E && MIPT_seed >= MIPT_SE &&
312 MIPT_seed >= MIPT_NE && MIPT_seed > MIPT_W && MIPT_seed > MIPT_SW && MIPT_seed > MIPT_NW;
321 return seedPositionsEnergy;
326 std::vector<std::pair<GlobalPoint, double>> seedPositionsEnergy;
328 for (
int z_side : {-1, 1}) {
329 for (
unsigned bin1 = 0; bin1 <
nBins1_; bin1++) {
330 for (
unsigned bin2 = 0; bin2 <
nBins2_; bin2++) {
343 float MIPT_N = (pos_N[0] != -1 && pos_N[1] != -1)
346 float MIPT_S = (pos_S[0] != -1 && pos_S[1] != -1)
349 float MIPT_W = (pos_W[0] != -1 && pos_W[1] != -1)
352 float MIPT_E = (pos_E[0] != -1 && pos_E[1] != -1)
355 float MIPT_NW = (pos_NW[0] != -1 && pos_NW[1] != -1)
358 float MIPT_NE = (pos_NE[0] != -1 && pos_NE[1] != -1)
361 float MIPT_SW = (pos_SW[0] != -1 && pos_SW[1] != -1)
364 float MIPT_SE = (pos_SE[0] != -1 && pos_SE[1] != -1)
382 return seedPositionsEnergy;
387 std::vector<std::pair<GlobalPoint, double>> seedPositionsEnergy;
389 for (
int z_side : {-1, 1}) {
390 for (
unsigned bin1 = 0; bin1 <
nBins1_; bin1++) {
391 for (
unsigned bin2 = 0; bin2 <
nBins2_; bin2++) {
402 return seedPositionsEnergy;
407 std::vector<std::pair<GlobalPoint, double>> seedPositionsEnergy;
413 for (
int z_side : {-1, 1}) {
414 for (
unsigned bin1 = 0; bin1 <
nBins1_; bin1++) {
415 for (
unsigned bin2 = 0; bin2 <
nBins2_; bin2++) {
422 float MIPT_S = bin1 < (nBins1_ - 1) ? histoClusters.
at(z_side, bin1 + 1, bin2).values[
Bin::Content::Sum] : 0;
423 float MIPT_N = bin1 > 0 ? histoClusters.
at(z_side, bin1 - 1, bin2).values[
Bin::Content::Sum] : 0;
425 int binLeft = bin2 - 1;
428 unsigned binRight = bin2 + 1;
429 if (binRight >= nBins2_)
434 float MIPT_NW = bin1 > 0 ? histoClusters.
at(z_side, bin1 - 1, binLeft).values[
Bin::Content::Sum] : 0;
435 float MIPT_NE = bin1 > 0 ? histoClusters.
at(z_side, bin1 - 1, binRight).values[
Bin::Content::Sum] : 0;
437 bin1 < (nBins1_ - 1) ? histoClusters.
at(z_side, bin1 + 1, binLeft).values[
Bin::Content::Sum] : 0;
439 bin1 < (nBins1_ - 1) ? histoClusters.
at(z_side, bin1 + 1, binRight).values[
Bin::Content::Sum] : 0;
441 isMax &= MIPT_seed >= MIPT_S && MIPT_seed > MIPT_N && MIPT_seed >= MIPT_E && MIPT_seed >= MIPT_SE &&
442 MIPT_seed >= MIPT_NE && MIPT_seed > MIPT_W && MIPT_seed > MIPT_SW && MIPT_seed > MIPT_NW;
447 primarySeedPositions.
at(z_side, bin1, bin2) =
true;
449 vetoPositions.
at(z_side, bin1, binLeft) =
true;
450 vetoPositions.
at(z_side, bin1, binRight) =
true;
452 vetoPositions.
at(z_side, bin1 - 1, bin2) =
true;
453 vetoPositions.
at(z_side, bin1 - 1, binRight) =
true;
454 vetoPositions.
at(z_side, bin1 - 1, binLeft) =
true;
456 if (bin1 < (nBins1_ - 1)) {
457 vetoPositions.
at(z_side, bin1 + 1, bin2) =
true;
458 vetoPositions.
at(z_side, bin1 + 1, binRight) =
true;
459 vetoPositions.
at(z_side, bin1 + 1, binLeft) =
true;
468 for (
int z_side : {-1, 1}) {
469 for (
unsigned bin1 = 0; bin1 <
nBins1_; bin1++) {
470 for (
unsigned bin2 = 0; bin2 <
nBins2_; bin2++) {
472 if (primarySeedPositions.
at(z_side, bin1, bin2) || vetoPositions.
at(z_side, bin1, bin2))
478 float MIPT_S = bin1 < (nBins1_ - 1) ? histoClusters.
at(z_side, bin1 + 1, bin2).values[
Bin::Content::Sum] : 0;
479 float MIPT_N = bin1 > 0 ? histoClusters.
at(z_side, bin1 - 1, bin2).values[
Bin::Content::Sum] : 0;
481 int binLeft = bin2 - 1;
484 unsigned binRight = bin2 + 1;
485 if (binRight >= nBins2_)
490 float MIPT_NW = bin1 > 0 ? histoClusters.
at(z_side, bin1 - 1, binLeft).values[
Bin::Content::Sum] : 0;
491 float MIPT_NE = bin1 > 0 ? histoClusters.
at(z_side, bin1 - 1, binRight).values[
Bin::Content::Sum] : 0;
493 bin1 < (nBins1_ - 1) ? histoClusters.
at(z_side, bin1 + 1, binLeft).values[
Bin::Content::Sum] : 0;
495 bin1 < (nBins1_ - 1) ? histoClusters.
at(z_side, bin1 + 1, binRight).values[
Bin::Content::Sum] : 0;
497 isMax &= (((bin1 < nBins1_ - 1) && vetoPositions.
at(z_side, bin1 + 1, bin2))
or MIPT_seed >= MIPT_S) &&
498 (((bin1 > 0) && vetoPositions.
at(z_side, bin1 - 1, bin2))
or MIPT_seed > MIPT_N) &&
499 ((vetoPositions.
at(z_side, bin1, binRight))
or MIPT_seed >= MIPT_E) &&
500 (((bin1 < nBins1_ - 1) && vetoPositions.
at(z_side, bin1 + 1, binRight))
or MIPT_seed >= MIPT_SE) &&
501 (((bin1 > 0) && vetoPositions.
at(z_side, bin1 - 1, binRight))
or MIPT_seed >= MIPT_NE) &&
502 ((vetoPositions.
at(z_side, bin1, binLeft))
or MIPT_seed > MIPT_W) &&
503 (((bin1 < nBins1_ - 1) && vetoPositions.
at(z_side, bin1 + 1, binLeft))
or MIPT_seed > MIPT_SW) &&
504 (((bin1 > 0) && vetoPositions.
at(z_side, bin1 - 1, binLeft))
or MIPT_seed > MIPT_NW);
513 return seedPositionsEnergy;
517 std::vector<std::pair<GlobalPoint, double>>& seedPositionsEnergy) {
532 for (
int z_side : {-1, 1}) {
535 auto&
bin = smoothHistoCluster.
at(z_side,
x1,
x2);
560 return {{0., 0., 0., 0.}};
std::vector< std::pair< GlobalPoint, double > > computeInterpolatedMaxSeeds(const Histogram &histoClusters)
T getParameter(std::string const &) const
std::vector< unsigned > binsSumsHisto_
constexpr T reduceRange(T x)
Histogram fillSmoothPhiHistoClusters(const Histogram &histoClusters, const vector< unsigned > &binSums)
static unsigned neighbour_weights_size_
void setHome(int x1, int x2)
Histogram fillSmoothRPhiHistoClusters(const Histogram &histoClusters)
Sin< T >::type sin(const T &t)
Global3DPoint GlobalPoint
SeedingPosition seedingPosition_
static double kROverZMax_
std::vector< std::pair< GlobalPoint, double > > computeMaxSeeds(const Histogram &histoClusters)
HGCalTriggerTools triggerTools_
std::vector< std::pair< GlobalPoint, double > > computeSecondaryMaxSeeds(const Histogram &histoClusters)
SeedingSpace seedingSpace_
void findHistoSeeds(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, std::vector< std::pair< GlobalPoint, double >> &seedPositionsEnergy)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
void setSeedEnergyAndPosition(std::vector< std::pair< GlobalPoint, double >> &seedPositionsEnergy, int z_side, unsigned bin_R, unsigned bin_phi, const Bin &histBin)
Cos< T >::type cos(const T &t)
Histogram fillSmoothHistoClusters(const Histogram &, const vector< double > &, Bin::Content)
std::array< int, 2 > move(int offset1, int offset2)
std::array< double, 4 > boundaries()
std::vector< double > smoothing_ecal_
std::vector< std::pair< GlobalPoint, double > > computeThresholdSeeds(const Histogram &histoClusters)
std::array< float, 3 > values
static double kROverZMin_
std::vector< double > neighbour_weights_
Histogram fillHistoClusters(const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtrs)
std::string seedingAlgoType_
T & at(int zside, unsigned x1, unsigned x2)
std::vector< double > smoothing_hcal_
Power< A, B >::type pow(const A &a, const B &b)
HGCalHistoSeedingImpl(const edm::ParameterSet &conf)