24 #include "fftjet/FrequencyKernelConvolver.hh"
25 #include "fftjet/DiscreteGauss2d.hh"
26 #include "fftjet/EquidistantSequence.hh"
27 #include "fftjet/interpolate.hh"
62 void endJob()
override;
77 std::unique_ptr<fftjet::AbsFrequencyKernel>
kernel2d;
80 std::unique_ptr<fftjet::AbsConvolverBase<Real>>
convolver;
127 nPercentiles(ps.getParameter<unsigned>(
"nPercentiles")),
143 convolvedFlow = std::make_unique<fftjet::Grid2d<fftjetcms::Real>>(*energyFlow);
148 throw cms::Exception(
"FFTJetBadConfig") <<
"ERROR in FFTJetPileupProcessor constructor:"
149 " number of elements in the \"etaFlatteningFactors\""
150 " vector is inconsistent with the discretization grid binning"
163 throw cms::Exception(
"FFTJetBadConfig") <<
"invalid filter scales" << std::endl;
169 produces<reco::DiscretizedEnergyFlow>(
outputLabel);
178 throw cms::Exception(
"FFTJetBadConfig") <<
"invalid kernel scales" << std::endl;
182 throw cms::Exception(
"FFTJetBadConfig") <<
"invalid convolver bin range" << std::endl;
192 kernel2d = std::unique_ptr<fftjet::AbsFrequencyKernel>(
196 convolver = std::unique_ptr<fftjet::AbsConvolverBase<Real>>(
new fftjet::FrequencyKernelConvolver<Real, Complex>(
213 double densityAfterMixing = -1.0;
221 const double* scales = &(*filterScales)[0];
233 for (
unsigned iscale = 0; iscale <
nScales; ++iscale) {
249 const double dindex =
q * (dataLen - 1
U);
250 const unsigned ilow = static_cast<unsigned>(std::floor(dindex));
251 const double percentile =
252 fftjet::lin_interpolate_1d(ilow, ilow + 1
U, sortData[ilow], sortData[ilow + 1
U], dindex);
261 iEvent.put(std::make_unique<reco::DiscretizedEnergyFlow>(
265 iEvent.put(std::make_unique<std::pair<double, double>>(densityBeforeMixing, densityAfterMixing),
outputLabel);
275 throw cms::Exception(
"FFTJetBadConfig") <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
276 " failed to open external grid file "
280 const fftjet::Grid2d<float>*
g =
nullptr;
281 const unsigned maxFail = 100
U;
282 unsigned nEnergyRejected = 0;
293 throw cms::Exception(
"FFTJetBadConfig") <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
294 " failed to open external grid file "
303 if (++nEnergyRejected >= maxFail)
304 throw cms::Exception(
"FFTJetBadConfig") <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
305 " too many grids in a row ("
306 << nEnergyRejected <<
") failed the maximum energy cut" << std::endl;
315 throw cms::Exception(
"FFTJetBadConfig") <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
316 " no valid grid records found"