23 #include "fftjet/FrequencyKernelConvolver.hh"
24 #include "fftjet/DiscreteGauss2d.hh"
25 #include "fftjet/EquidistantSequence.hh"
26 #include "fftjet/interpolate.hh"
61 void endJob()
override;
76 std::unique_ptr<fftjet::AbsFrequencyKernel>
kernel2d;
79 std::unique_ptr<fftjet::AbsConvolverBase<Real>>
convolver;
126 nPercentiles(ps.getParameter<unsigned>(
"nPercentiles")),
142 convolvedFlow = std::unique_ptr<fftjet::Grid2d<fftjetcms::Real>>(
new fftjet::Grid2d<fftjetcms::Real>(*
energyFlow));
147 throw cms::Exception(
"FFTJetBadConfig") <<
"ERROR in FFTJetPileupProcessor constructor:"
148 " number of elements in the \"etaFlatteningFactors\""
149 " vector is inconsistent with the discretization grid binning"
162 throw cms::Exception(
"FFTJetBadConfig") <<
"invalid filter scales" << std::endl;
165 std::unique_ptr<fftjet::EquidistantInLogSpace>(
new fftjet::EquidistantInLogSpace(
minScale,
maxScale,
nScales));
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) {
242 std::sort(sortData, sortData + dataLen);
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"