23 #include "fftjet/FrequencyKernelConvolver.hh"
24 #include "fftjet/DiscreteGauss2d.hh"
25 #include "fftjet/EquidistantSequence.hh"
26 #include "fftjet/interpolate.hh"
48 using namespace fftjetcms;
63 void endJob()
override ;
78 std::auto_ptr<fftjet::AbsFrequencyKernel>
kernel2d;
81 std::auto_ptr<fftjet::AbsConvolverBase<Real> >
convolver;
127 etaFlatteningFactors(
128 ps.getParameter<std::vector<double> >(
"etaFlatteningFactors")),
129 nPercentiles(ps.getParameter<unsigned>(
"nPercentiles")),
130 convolverMinBin(ps.getParameter<unsigned>(
"convolverMinBin")),
131 convolverMaxBin(ps.getParameter<unsigned>(
"convolverMaxBin")),
132 pileupEtaPhiArea(ps.getParameter<double>(
"pileupEtaPhiArea")),
133 externalGridFiles(ps.getParameter<std::vector<std::
string> >(
"externalGridFiles")),
134 externalGridMaxEnergy(ps.getParameter<double>(
"externalGridMaxEnergy")),
135 currentFileNum(externalGridFiles.
size() + 1U),
136 flatteningTableRecord(ps.getParameter<std::
string>(
"flatteningTableRecord")),
137 flatteningTableName(ps.getParameter<std::
string>(
"flatteningTableName")),
138 flatteningTableCategory(ps.getParameter<std::
string>(
"flatteningTableCategory")),
139 loadFlatteningFactorsFromDB(ps.getParameter<bool>(
"loadFlatteningFactorsFromDB"))
147 convolvedFlow = std::auto_ptr<fftjet::Grid2d<fftjetcms::Real> >(
148 new fftjet::Grid2d<fftjetcms::Real>(*energyFlow));
155 <<
"ERROR in FFTJetPileupProcessor constructor:"
156 " number of elements in the \"etaFlatteningFactors\""
157 " vector is inconsistent with the discretization grid binning"
166 const unsigned nScales = ps.
getParameter<
unsigned>(
"nScales");
167 const double minScale = ps.
getParameter<
double>(
"minScale");
168 const double maxScale = ps.
getParameter<
double>(
"maxScale");
169 if (minScale <= 0.0 || maxScale < minScale || nScales == 0U)
171 <<
"invalid filter scales" << std::endl;
173 filterScales = std::auto_ptr<fftjet::EquidistantInLogSpace>(
174 new fftjet::EquidistantInLogSpace(minScale, maxScale, nScales));
178 produces<reco::DiscretizedEnergyFlow>(
outputLabel);
186 double kernelEtaScale = ps.
getParameter<
double>(
"kernelEtaScale");
187 const double kernelPhiScale = ps.
getParameter<
double>(
"kernelPhiScale");
188 if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
190 <<
"invalid kernel scales" << std::endl;
196 <<
"invalid convolver bin range" << std::endl;
203 engine = std::auto_ptr<MyFFTEngine>(
207 kernel2d = std::auto_ptr<fftjet::AbsFrequencyKernel>(
208 new fftjet::DiscreteGauss2d(
209 kernelEtaScale, kernelPhiScale,
213 convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
214 new fftjet::FrequencyKernelConvolver<Real,Complex>(
238 double densityAfterMixing = -1.0;
247 const double* scales = &(*filterScales)[0];
259 convolver->setEventData(g.data(), g.nEta(), g.nPhi());
260 for (
unsigned iscale=0; iscale<nScales; ++iscale)
264 scales[iscale], convData,
273 std::sort(sortData, sortData+dataLen);
281 const double dindex = q*(dataLen-1U);
282 const unsigned ilow =
static_cast<unsigned>(std::floor(dindex));
283 const double percentile = fftjet::lin_interpolate_1d(
284 ilow, ilow+1U, sortData[ilow], sortData[ilow+1U], dindex);
293 std::auto_ptr<reco::DiscretizedEnergyFlow> pTable(
299 std::auto_ptr<std::pair<double,double> > etSum(
300 new std::pair<double,double>(densityBeforeMixing, densityAfterMixing));
316 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
317 " failed to open external grid file "
321 const fftjet::Grid2d<float>*
g = 0;
322 const unsigned maxFail = 100U;
323 unsigned nEnergyRejected = 0;
338 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
339 " failed to open external grid file "
349 if (++nEnergyRejected >= maxFail)
351 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
352 " too many grids in a row (" << nEnergyRejected
353 <<
") failed the maximum energy cut" << std::endl;
366 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
367 " no valid grid records found" << std::endl;
389 boost::shared_ptr<npstat::StorableMultivariateFunctor>
f =
396 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
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
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
void produce(edm::Event &, const edm::EventSetup &) override
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