22 #include "fftjet/ProximityClusteringTree.hh"
23 #include "fftjet/ClusteringSequencer.hh"
24 #include "fftjet/ClusteringTreeSparsifier.hh"
25 #include "fftjet/FrequencyKernelConvolver.hh"
26 #include "fftjet/FrequencySequentialConvolver.hh"
27 #include "fftjet/DiscreteGauss1d.hh"
28 #include "fftjet/DiscreteGauss2d.hh"
58 using namespace fftjetcms;
72 typedef fftjet::SparseClusteringTree<fftjet::Peak,long>
SparseTree;
73 typedef fftjet::ClusteringSequencer<Real>
Sequencer;
74 typedef fftjet::ClusteringTreeSparsifier<fftjet::Peak,long>
Sparsifier;
79 void endJob()
override ;
104 std::auto_ptr<fftjet::AbsFrequencyKernel>
kernel2d;
109 std::auto_ptr<fftjet::AbsConvolverBase<Real> >
convolver;
115 std::auto_ptr<fftjet::AbsDistanceCalculator<fftjet::Peak> >
distanceCalc;
155 completeEventDataCutoff(ps.getParameter<double>(
"completeEventDataCutoff")),
156 makeClusteringTree(ps.getParameter<bool>(
"makeClusteringTree")),
157 verifyDataConversion(ps.getUntrackedParameter<bool>(
"verifyDataConversion",
false)),
158 storeDiscretizationGrid(ps.getParameter<bool>(
"storeDiscretizationGrid")),
159 sparsify(ps.getParameter<bool>(
"sparsify")),
166 produces<reco::PattRecoTree<float,reco::PattRecoPeak<float> > >(
outputLabel);
168 produces<reco::PattRecoTree<double,reco::PattRecoPeak<double> > >(
outputLabel);
171 produces<reco::DiscretizedEnergyFlow>(
outputLabel);
179 std::ios_base::binary);
182 <<
"FFTJetPatRecoProducer failed to open file "
183 << externalGridFile << std::endl;
189 <<
"FFTJetPatRecoProducer is not configured to produce anything"
215 const unsigned maxAdaptiveScales =
217 const double minAdaptiveRatioLog =
219 if (minAdaptiveRatioLog <= 0.0)
221 <<
"bad adaptive ratio logarithm limit" << std::endl;
228 const unsigned nscales = iniScales->size();
229 for (
unsigned i=0;
i<nscales; ++
i)
230 if (cs >= (*iniScales)[
i])
232 <<
"incompatible scale for complete event" << std::endl;
238 *iniScales, maxAdaptiveScales, minAdaptiveRatioLog));
244 SparsifierConfiguration);
262 const std::vector<double> etaDependentScaleFactors(
263 ps.
getParameter<std::vector<double> >(
"etaDependentScaleFactors"));
266 const bool use2dKernel = etaDependentScaleFactors.empty();
268 if (etaDependentScaleFactors.size() !=
energyFlow->nEta())
270 <<
"invalid number of eta-dependent scale factors"
274 double kernelEtaScale = ps.
getParameter<
double>(
"kernelEtaScale");
275 const double kernelPhiScale = ps.
getParameter<
double>(
"kernelPhiScale");
276 if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
278 <<
"invalid kernel scale" << std::endl;
285 const bool fixEfficiency = ps.
getParameter<
bool>(
"fixEfficiency");
288 unsigned convolverMinBin = 0, convolverMaxBin = 0;
289 if (fixEfficiency || !use2dKernel)
291 convolverMinBin = ps.
getParameter<
unsigned>(
"convolverMinBin");
292 convolverMaxBin = ps.
getParameter<
unsigned>(
"convolverMaxBin");
298 engine = std::auto_ptr<MyFFTEngine>(
302 kernel2d = std::auto_ptr<fftjet::AbsFrequencyKernel>(
303 new fftjet::DiscreteGauss2d(
304 kernelEtaScale, kernelPhiScale,
308 convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
309 new fftjet::FrequencyKernelConvolver<Real,Complex>(
311 convolverMinBin, convolverMaxBin));
316 engine = std::auto_ptr<MyFFTEngine>(
322 etaKernel = std::auto_ptr<fftjet::AbsFrequencyKernel1d>(
323 new fftjet::DiscreteGauss1d(kernelEtaScale,
energyFlow->nEta()));
325 phiKernel = std::auto_ptr<fftjet::AbsFrequencyKernel1d>(
326 new fftjet::DiscreteGauss1d(kernelPhiScale,
energyFlow->nPhi()));
329 convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
330 new fftjet::FrequencySequentialConvolver<Real,Complex>(
333 etaDependentScaleFactors, convolverMinBin,
334 convolverMaxBin, fixEfficiency));
341 const double peakFinderMaxEta = ps.
getParameter<
double>(
"peakFinderMaxEta");
342 if (peakFinderMaxEta <= 0.0)
344 <<
"invalid peak finder eta cut" << std::endl;
345 const double maxMagnitude = ps.
getParameter<
double>(
"peakFinderMaxMagnitude");
346 int minBin =
energyFlow->getEtaBin(-peakFinderMaxEta);
349 int maxBin =
energyFlow->getEtaBin(peakFinderMaxEta) + 1;
352 return fftjet::PeakFinder(maxMagnitude,
true, minBin, maxBin);
373 std::auto_ptr<StoredTree>
tree(
new StoredTree());
383 const std::vector<double>& scalesUsed(
sequencer->getInitialScales());
387 <<
"Data conversion failed for sparse clustering tree"
400 std::auto_ptr<StoredTree>
tree(
new StoredTree());
410 const std::vector<double>& scalesUsed(
sequencer->getInitialScales());
414 <<
"Data conversion failed for dense clustering tree"
446 buildSparseProduct<float>(
iEvent);
448 buildSparseProduct<double>(
iEvent);
453 buildDenseProduct<float>(iEvent);
455 buildDenseProduct<double>(
iEvent);
463 std::auto_ptr<reco::DiscretizedEnergyFlow> flow(
465 g.data(), g.title(), g.etaMin(), g.etaMax(),
466 g.phiBin0Edge(), g.nEta(), g.nPhi()));
470 fftjet::Grid2d<Real>
check(
471 flow->nEtaBins(), flow->etaMin(), flow->etaMax(),
472 flow->nPhiBins(), flow->phiBin0Edge(), flow->title());
473 check.blockSet(flow->data(), flow->nEtaBins(), flow->nPhiBins());
489 <<
"Failed to write grid data into an external file"
T getParameter(std::string const &) const
fftjet::Grid2d< float > * convert_Grid2d_to_float(const fftjet::Grid2d< Numeric > &grid)
std::auto_ptr< fftjet::Functor1< bool, fftjet::Peak > > peakSelector
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
auto_ptr< ClusterSequence > cs
Class for storing FFTJet sparse clustering trees.
std::auto_ptr< fftjet::AbsFrequencyKernel1d > phiKernel
std::ofstream externalGridStream
std::auto_ptr< fftjet::Grid2d< Real > > fftjet_Grid2d_parser(const edm::ParameterSet &ps)
#define DEFINE_FWK_MODULE(type)
void loadInputCollection(const edm::Event &)
void buildSparseProduct(edm::Event &) const
void buildKernelConvolver(const edm::ParameterSet &)
void checkConfig(const Ptr &ptr, const char *message)
void buildDenseProduct(edm::Event &) const
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
const bool storeDiscretizationGrid
std::auto_ptr< MyFFTEngine > anotherEngine
std::auto_ptr< fftjet::Functor1< bool, fftjet::Peak > > fftjet_PeakSelector_parser(const edm::ParameterSet &ps)
double getEventScale() const
std::auto_ptr< fftjet::AbsFrequencyKernel > kernel2d
void produce(edm::Event &, const edm::EventSetup &) override
bool check(const std::string &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void sparsePeakTreeToStorable(const fftjet::SparseClusteringTree< fftjet::Peak, long > &in, bool writeOutScaleInfo, reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > *out)
ClusteringTree * clusteringTree
fftjet::ClusteringSequencer< Real > Sequencer
std::auto_ptr< MyFFTEngine > engine
std::auto_ptr< Sparsifier > sparsifier
std::auto_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > distanceCalc
bool storeInSinglePrecision() const
void densePeakTreeToStorable(const fftjet::AbsClusteringTree< fftjet::Peak, long > &in, bool writeOutScaleInfo, reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > *out)
const double completeEventDataCutoff
const bool makeClusteringTree
void sparsePeakTreeFromStorable(const reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > &in, const std::vector< double > *scaleSetIfNotAdaptive, double completeEventScale, fftjet::SparseClusteringTree< fftjet::Peak, long > *out)
void densePeakTreeFromStorable(const reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > &in, const std::vector< double > *scaleSetIfNotAdaptive, double completeEventScale, fftjet::AbsClusteringTree< fftjet::Peak, long > *out)
fftjet::ClusteringTreeSparsifier< fftjet::Peak, long > Sparsifier
std::auto_ptr< fftjet::AbsFrequencyKernel1d > etaKernel
void copy_Grid2d_data(fftjet::Grid2d< F2 > *to, const fftjet::Grid2d< F1 > &from)
void discretizeEnergyFlow()
std::auto_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > fftjet_DistanceCalculator_parser(const edm::ParameterSet &ps)
fftjet::PeakFinder buildPeakFinder(const edm::ParameterSet &)
std::auto_ptr< Sequencer > sequencer
std::auto_ptr< fftjet::AbsConvolverBase< Real > > convolver
std::auto_ptr< fftjet::ClusteringTreeSparsifier< fftjet::Peak, long > > fftjet_ClusteringTreeSparsifier_parser(const edm::ParameterSet &ps)
fftjet::FFTWDoubleEngine MyFFTEngine
volatile std::atomic< bool > shutdown_flag false
fftjet::ProximityClusteringTree< fftjet::Peak, long > ClusteringTree
const bool verifyDataConversion
fftjet::SparseClusteringTree< fftjet::Peak, long > SparseTree
bool storeGridsExternally
fftjet::Grid2d< float > * extGrid
const std::string outputLabel
std::auto_ptr< std::vector< double > > fftjet_ScaleSet_parser(const edm::ParameterSet &ps)