24 #include "fftjet/FrequencyKernelConvolver.hh"
25 #include "fftjet/DiscreteGauss2d.hh"
26 #include "fftjet/EquidistantSequence.hh"
27 #include "fftjet/interpolate.hh"
52 using namespace fftjetcms;
82 std::auto_ptr<fftjet::AbsFrequencyKernel>
kernel2d;
85 std::auto_ptr<fftjet::AbsConvolverBase<Real> >
convolver;
131 etaFlatteningFactors(
132 ps.getParameter<std::vector<double> >(
"etaFlatteningFactors")),
133 nPercentiles(ps.getParameter<unsigned>(
"nPercentiles")),
134 convolverMinBin(ps.getParameter<unsigned>(
"convolverMinBin")),
135 convolverMaxBin(ps.getParameter<unsigned>(
"convolverMaxBin")),
136 pileupEtaPhiArea(ps.getParameter<double>(
"pileupEtaPhiArea")),
137 externalGridFiles(ps.getParameter<std::vector<std::
string> >(
"externalGridFiles")),
138 externalGridMaxEnergy(ps.getParameter<double>(
"externalGridMaxEnergy")),
139 currentFileNum(externalGridFiles.
size() + 1U),
140 flatteningTableRecord(ps.getParameter<std::
string>(
"flatteningTableRecord")),
141 flatteningTableName(ps.getParameter<std::
string>(
"flatteningTableName")),
142 flatteningTableCategory(ps.getParameter<std::
string>(
"flatteningTableCategory")),
143 loadFlatteningFactorsFromDB(ps.getParameter<bool>(
"loadFlatteningFactorsFromDB"))
151 convolvedFlow = std::auto_ptr<fftjet::Grid2d<fftjetcms::Real> >(
152 new fftjet::Grid2d<fftjetcms::Real>(*energyFlow));
159 <<
"ERROR in FFTJetPileupProcessor constructor:"
160 " number of elements in the \"etaFlatteningFactors\""
161 " vector is inconsistent with the discretization grid binning"
170 const unsigned nScales = ps.
getParameter<
unsigned>(
"nScales");
171 const double minScale = ps.
getParameter<
double>(
"minScale");
172 const double maxScale = ps.
getParameter<
double>(
"maxScale");
173 if (minScale <= 0.0 || maxScale < minScale || nScales == 0U)
175 <<
"invalid filter scales" << std::endl;
177 filterScales = std::auto_ptr<fftjet::EquidistantInLogSpace>(
178 new fftjet::EquidistantInLogSpace(minScale, maxScale, nScales));
182 produces<reco::DiscretizedEnergyFlow>(
outputLabel);
190 double kernelEtaScale = ps.
getParameter<
double>(
"kernelEtaScale");
191 const double kernelPhiScale = ps.
getParameter<
double>(
"kernelPhiScale");
192 if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
194 <<
"invalid kernel scales" << std::endl;
200 <<
"invalid convolver bin range" << std::endl;
207 engine = std::auto_ptr<MyFFTEngine>(
211 kernel2d = std::auto_ptr<fftjet::AbsFrequencyKernel>(
212 new fftjet::DiscreteGauss2d(
213 kernelEtaScale, kernelPhiScale,
217 convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
218 new fftjet::FrequencyKernelConvolver<Real,Complex>(
242 double densityAfterMixing = -1.0;
251 const double* scales = &(*filterScales)[0];
263 convolver->setEventData(g.data(), g.nEta(), g.nPhi());
264 for (
unsigned iscale=0; iscale<nScales; ++iscale)
268 scales[iscale], convData,
285 const double dindex = q*(dataLen-1U);
286 const unsigned ilow =
static_cast<unsigned>(std::floor(dindex));
287 const double percentile = fftjet::lin_interpolate_1d(
288 ilow, ilow+1U, sortData[ilow], sortData[ilow+1U], dindex);
297 std::auto_ptr<reco::DiscretizedEnergyFlow> pTable(
303 std::auto_ptr<std::pair<double,double> > etSum(
304 new std::pair<double,double>(densityBeforeMixing, densityAfterMixing));
320 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
321 " failed to open external grid file "
325 const fftjet::Grid2d<float>*
g = 0;
326 const unsigned maxFail = 100U;
327 unsigned nEnergyRejected = 0;
334 for (
unsigned ntries=0; ntries<nFiles && g == 0; ++ntries)
342 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
343 " failed to open external grid file "
353 if (++nEnergyRejected >= maxFail)
355 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
356 " too many grids in a row (" << nEnergyRejected
357 <<
") failed the maximum energy cut" << std::endl;
370 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
371 " no valid grid records found" << std::endl;
393 boost::shared_ptr<npstat::StorableMultivariateFunctor>
f =
400 for (
unsigned ieta=0; ieta<nEta; ++ieta)
T getParameter(std::string const &) const
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
std::vector< std::string > externalGridFiles
std::string flatteningTableRecord
void produce(edm::Event &, const edm::EventSetup &)
std::auto_ptr< fftjet::EquidistantInLogSpace > filterScales
std::auto_ptr< fftjet::Grid2d< Real > > fftjet_Grid2d_parser(const edm::ParameterSet &ps)
std::auto_ptr< fftjet::AbsConvolverBase< Real > > convolver
#define DEFINE_FWK_MODULE(type)
void loadInputCollection(const edm::Event &)
void checkConfig(const Ptr &ptr, const char *message)
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 g
std::string flatteningTableCategory
std::vector< double > percentileData
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > convolvedFlow
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
std::auto_ptr< fftjet::AbsFrequencyKernel > kernel2d
void buildKernelConvolver(const edm::ParameterSet &)
std::vector< double > etaFlatteningFactors
void loadFlatteningFactors(const edm::EventSetup &iSetup)
std::string flatteningTableName
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
double externalGridMaxEnergy
void discretizeEnergyFlow()
std::auto_ptr< MyFFTEngine > engine
bool loadFlatteningFactorsFromDB
fftjet::FFTWDoubleEngine MyFFTEngine
static const Mapper & instance()
void add_Grid2d_data(fftjet::Grid2d< F2 > *to, const fftjet::Grid2d< F1 > &from)
tuple size
Write out results.
const std::string outputLabel