23 #include "fftjet/FrequencyKernelConvolver.hh"
24 #include "fftjet/DiscreteGauss2d.hh"
25 #include "fftjet/EquidistantSequence.hh"
26 #include "fftjet/interpolate.hh"
51 using namespace fftjetcms;
66 void endJob()
override ;
81 std::auto_ptr<fftjet::AbsFrequencyKernel>
kernel2d;
84 std::auto_ptr<fftjet::AbsConvolverBase<Real> >
convolver;
130 etaFlatteningFactors(
131 ps.getParameter<std::vector<double> >(
"etaFlatteningFactors")),
132 nPercentiles(ps.getParameter<unsigned>(
"nPercentiles")),
133 convolverMinBin(ps.getParameter<unsigned>(
"convolverMinBin")),
134 convolverMaxBin(ps.getParameter<unsigned>(
"convolverMaxBin")),
135 pileupEtaPhiArea(ps.getParameter<double>(
"pileupEtaPhiArea")),
136 externalGridFiles(ps.getParameter<std::vector<std::
string> >(
"externalGridFiles")),
137 externalGridMaxEnergy(ps.getParameter<double>(
"externalGridMaxEnergy")),
138 currentFileNum(externalGridFiles.
size() + 1U),
139 flatteningTableRecord(ps.getParameter<std::
string>(
"flatteningTableRecord")),
140 flatteningTableName(ps.getParameter<std::
string>(
"flatteningTableName")),
141 flatteningTableCategory(ps.getParameter<std::
string>(
"flatteningTableCategory")),
142 loadFlatteningFactorsFromDB(ps.getParameter<bool>(
"loadFlatteningFactorsFromDB"))
150 convolvedFlow = std::auto_ptr<fftjet::Grid2d<fftjetcms::Real> >(
151 new fftjet::Grid2d<fftjetcms::Real>(*energyFlow));
158 <<
"ERROR in FFTJetPileupProcessor constructor:"
159 " number of elements in the \"etaFlatteningFactors\""
160 " vector is inconsistent with the discretization grid binning"
169 const unsigned nScales = ps.
getParameter<
unsigned>(
"nScales");
170 const double minScale = ps.
getParameter<
double>(
"minScale");
171 const double maxScale = ps.
getParameter<
double>(
"maxScale");
172 if (minScale <= 0.0 || maxScale < minScale || nScales == 0U)
174 <<
"invalid filter scales" << std::endl;
176 filterScales = std::auto_ptr<fftjet::EquidistantInLogSpace>(
177 new fftjet::EquidistantInLogSpace(minScale, maxScale, nScales));
181 produces<reco::DiscretizedEnergyFlow>(
outputLabel);
189 double kernelEtaScale = ps.
getParameter<
double>(
"kernelEtaScale");
190 const double kernelPhiScale = ps.
getParameter<
double>(
"kernelPhiScale");
191 if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
193 <<
"invalid kernel scales" << std::endl;
199 <<
"invalid convolver bin range" << std::endl;
206 engine = std::auto_ptr<MyFFTEngine>(
210 kernel2d = std::auto_ptr<fftjet::AbsFrequencyKernel>(
211 new fftjet::DiscreteGauss2d(
212 kernelEtaScale, kernelPhiScale,
216 convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
217 new fftjet::FrequencyKernelConvolver<Real,Complex>(
241 double densityAfterMixing = -1.0;
250 const double* scales = &(*filterScales)[0];
262 convolver->setEventData(g.data(), g.nEta(), g.nPhi());
263 for (
unsigned iscale=0; iscale<nScales; ++iscale)
267 scales[iscale], convData,
284 const double dindex = q*(dataLen-1U);
285 const unsigned ilow =
static_cast<unsigned>(std::floor(dindex));
286 const double percentile = fftjet::lin_interpolate_1d(
287 ilow, ilow+1U, sortData[ilow], sortData[ilow+1U], dindex);
296 std::auto_ptr<reco::DiscretizedEnergyFlow> pTable(
302 std::auto_ptr<std::pair<double,double> > etSum(
303 new std::pair<double,double>(densityBeforeMixing, densityAfterMixing));
319 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
320 " failed to open external grid file "
324 const fftjet::Grid2d<float>*
g = 0;
325 const unsigned maxFail = 100U;
326 unsigned nEnergyRejected = 0;
333 for (
unsigned ntries=0; ntries<nFiles && g == 0; ++ntries)
341 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
342 " failed to open external grid file "
352 if (++nEnergyRejected >= maxFail)
354 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
355 " too many grids in a row (" << nEnergyRejected
356 <<
") failed the maximum energy cut" << std::endl;
369 <<
"ERROR in FFTJetPileupProcessor::mixExtraGrid():"
370 " no valid grid records found" << std::endl;
392 boost::shared_ptr<npstat::StorableMultivariateFunctor>
f =
399 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
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.
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