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"
61 using namespace fftjetcms;
75 typedef fftjet::SparseClusteringTree<fftjet::Peak,long>
SparseTree;
76 typedef fftjet::ClusteringSequencer<Real>
Sequencer;
77 typedef fftjet::ClusteringTreeSparsifier<fftjet::Peak,long>
Sparsifier;
82 void endJob()
override ;
107 std::auto_ptr<fftjet::AbsFrequencyKernel>
kernel2d;
112 std::auto_ptr<fftjet::AbsConvolverBase<Real> >
convolver;
118 std::auto_ptr<fftjet::AbsDistanceCalculator<fftjet::Peak> >
distanceCalc;
158 completeEventDataCutoff(ps.getParameter<double>(
"completeEventDataCutoff")),
159 makeClusteringTree(ps.getParameter<bool>(
"makeClusteringTree")),
160 verifyDataConversion(ps.getUntrackedParameter<bool>(
"verifyDataConversion",
false)),
161 storeDiscretizationGrid(ps.getParameter<bool>(
"storeDiscretizationGrid")),
162 sparsify(ps.getParameter<bool>(
"sparsify")),
169 produces<reco::PattRecoTree<float,reco::PattRecoPeak<float> > >(
outputLabel);
171 produces<reco::PattRecoTree<double,reco::PattRecoPeak<double> > >(
outputLabel);
174 produces<reco::DiscretizedEnergyFlow>(
outputLabel);
182 std::ios_base::binary);
185 <<
"FFTJetPatRecoProducer failed to open file "
186 << externalGridFile << std::endl;
192 <<
"FFTJetPatRecoProducer is not configured to produce anything"
218 const unsigned maxAdaptiveScales =
220 const double minAdaptiveRatioLog =
222 if (minAdaptiveRatioLog <= 0.0)
224 <<
"bad adaptive ratio logarithm limit" << std::endl;
231 const unsigned nscales = iniScales->size();
232 for (
unsigned i=0;
i<nscales; ++
i)
233 if (cs >= (*iniScales)[
i])
235 <<
"incompatible scale for complete event" << std::endl;
241 *iniScales, maxAdaptiveScales, minAdaptiveRatioLog));
247 SparsifierConfiguration);
265 const std::vector<double> etaDependentScaleFactors(
266 ps.
getParameter<std::vector<double> >(
"etaDependentScaleFactors"));
269 const bool use2dKernel = etaDependentScaleFactors.empty();
271 if (etaDependentScaleFactors.size() !=
energyFlow->nEta())
273 <<
"invalid number of eta-dependent scale factors"
277 double kernelEtaScale = ps.
getParameter<
double>(
"kernelEtaScale");
278 const double kernelPhiScale = ps.
getParameter<
double>(
"kernelPhiScale");
279 if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
281 <<
"invalid kernel scale" << std::endl;
288 const bool fixEfficiency = ps.
getParameter<
bool>(
"fixEfficiency");
291 unsigned convolverMinBin = 0, convolverMaxBin = 0;
292 if (fixEfficiency || !use2dKernel)
294 convolverMinBin = ps.
getParameter<
unsigned>(
"convolverMinBin");
295 convolverMaxBin = ps.
getParameter<
unsigned>(
"convolverMaxBin");
301 engine = std::auto_ptr<MyFFTEngine>(
305 kernel2d = std::auto_ptr<fftjet::AbsFrequencyKernel>(
306 new fftjet::DiscreteGauss2d(
307 kernelEtaScale, kernelPhiScale,
311 convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
312 new fftjet::FrequencyKernelConvolver<Real,Complex>(
314 convolverMinBin, convolverMaxBin));
319 engine = std::auto_ptr<MyFFTEngine>(
325 etaKernel = std::auto_ptr<fftjet::AbsFrequencyKernel1d>(
326 new fftjet::DiscreteGauss1d(kernelEtaScale,
energyFlow->nEta()));
328 phiKernel = std::auto_ptr<fftjet::AbsFrequencyKernel1d>(
329 new fftjet::DiscreteGauss1d(kernelPhiScale,
energyFlow->nPhi()));
332 convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
333 new fftjet::FrequencySequentialConvolver<Real,Complex>(
336 etaDependentScaleFactors, convolverMinBin,
337 convolverMaxBin, fixEfficiency));
344 const double peakFinderMaxEta = ps.
getParameter<
double>(
"peakFinderMaxEta");
345 if (peakFinderMaxEta <= 0.0)
347 <<
"invalid peak finder eta cut" << std::endl;
348 const double maxMagnitude = ps.
getParameter<
double>(
"peakFinderMaxMagnitude");
349 int minBin =
energyFlow->getEtaBin(-peakFinderMaxEta);
352 int maxBin =
energyFlow->getEtaBin(peakFinderMaxEta) + 1;
355 return fftjet::PeakFinder(maxMagnitude,
true, minBin, maxBin);
376 std::auto_ptr<StoredTree>
tree(
new StoredTree());
386 const std::vector<double>& scalesUsed(
sequencer->getInitialScales());
390 <<
"Data conversion failed for sparse clustering tree"
403 std::auto_ptr<StoredTree>
tree(
new StoredTree());
413 const std::vector<double>& scalesUsed(
sequencer->getInitialScales());
417 <<
"Data conversion failed for dense clustering tree"
449 buildSparseProduct<float>(
iEvent);
451 buildSparseProduct<double>(
iEvent);
456 buildDenseProduct<float>(iEvent);
458 buildDenseProduct<double>(
iEvent);
466 std::auto_ptr<reco::DiscretizedEnergyFlow> flow(
468 g.data(), g.title(), g.etaMin(), g.etaMax(),
469 g.phiBin0Edge(), g.nEta(), g.nPhi()));
473 fftjet::Grid2d<Real>
check(
474 flow->nEtaBins(), flow->etaMin(), flow->etaMax(),
475 flow->nPhiBins(), flow->phiBin0Edge(), flow->title());
476 check.blockSet(flow->data(), flow->nEtaBins(), flow->nPhiBins());
492 <<
"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
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)
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
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)