CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
FFTJetPatRecoProducer Class Reference

#include <RecoJets/FFTJetProducer/plugins/FFTJetPatRecoProducer.cc>

Inheritance diagram for FFTJetPatRecoProducer:
fftjetcms::FFTJetInterface edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 FFTJetPatRecoProducer (const edm::ParameterSet &)
 
 ~FFTJetPatRecoProducer ()
 
- Public Member Functions inherited from fftjetcms::FFTJetInterface
virtual ~FFTJetInterface ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Types

typedef fftjet::ProximityClusteringTree< fftjet::Peak, long > ClusteringTree
 
typedef fftjet::ClusteringSequencer< RealSequencer
 
typedef fftjet::SparseClusteringTree< fftjet::Peak, long > SparseTree
 
typedef fftjet::ClusteringTreeSparsifier< fftjet::Peak, long > Sparsifier
 

Protected Member Functions

void beginJob () override
 
template<class Real >
void buildDenseProduct (edm::Event &) const
 
void buildKernelConvolver (const edm::ParameterSet &)
 
fftjet::PeakFinder buildPeakFinder (const edm::ParameterSet &)
 
template<class Real >
void buildSparseProduct (edm::Event &) const
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Protected Member Functions inherited from fftjetcms::FFTJetInterface
template<class Ptr >
void checkConfig (const Ptr &ptr, const char *message)
 
void discretizeEnergyFlow ()
 
 FFTJetInterface (const edm::ParameterSet &)
 
double getEventScale () const
 
void loadInputCollection (const edm::Event &)
 
bool storeInSinglePrecision () const
 
const reco::Particle::PointvertexUsed () const
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Protected Attributes

std::auto_ptr< MyFFTEngineanotherEngine
 
ClusteringTreeclusteringTree
 
const double completeEventDataCutoff
 
std::auto_ptr< fftjet::AbsConvolverBase< Real > > convolver
 
std::auto_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > distanceCalc
 
std::auto_ptr< MyFFTEngineengine
 
std::auto_ptr< fftjet::AbsFrequencyKernel1d > etaKernel
 
std::auto_ptr< fftjet::AbsFrequencyKernel > kernel2d
 
const bool makeClusteringTree
 
std::auto_ptr< fftjet::Functor1< bool, fftjet::Peak > > peakSelector
 
std::auto_ptr< fftjet::AbsFrequencyKernel1d > phiKernel
 
std::auto_ptr< Sequencersequencer
 
SparseTree sparseTree
 
std::auto_ptr< Sparsifiersparsifier
 
const bool sparsify
 
const bool storeDiscretizationGrid
 
const bool verifyDataConversion
 
- Protected Attributes inherited from fftjetcms::FFTJetInterface
const AnomalousTower anomalous
 
std::vector< unsigned > candidateIndex
 
const bool doPVCorrection
 
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
 
const std::vector< double > etaDependentMagnutideFactors
 
std::vector< fftjetcms::VectorLikeeventData
 
edm::Handle< reco::CandidateViewinputCollection
 
const edm::InputTag inputLabel
 
const JetType jetType
 
const std::string outputLabel
 
const edm::InputTag srcPVs
 

Private Member Functions

 FFTJetPatRecoProducer ()
 
 FFTJetPatRecoProducer (const FFTJetPatRecoProducer &)
 
FFTJetPatRecoProduceroperator= (const FFTJetPatRecoProducer &)
 

Private Attributes

std::ofstream externalGridStream
 
fftjet::Grid2d< float > * extGrid
 
bool storeGridsExternally
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Description: Runs FFTJet pattern recognition stage and saves the results

Implementation: [Notes on implementation]

Definition at line 63 of file FFTJetPatRecoProducer.cc.

Member Typedef Documentation

typedef fftjet::ProximityClusteringTree<fftjet::Peak,long> FFTJetPatRecoProducer::ClusteringTree
protected

Definition at line 71 of file FFTJetPatRecoProducer.cc.

typedef fftjet::ClusteringSequencer<Real> FFTJetPatRecoProducer::Sequencer
protected

Definition at line 73 of file FFTJetPatRecoProducer.cc.

typedef fftjet::SparseClusteringTree<fftjet::Peak,long> FFTJetPatRecoProducer::SparseTree
protected

Definition at line 72 of file FFTJetPatRecoProducer.cc.

typedef fftjet::ClusteringTreeSparsifier<fftjet::Peak,long> FFTJetPatRecoProducer::Sparsifier
protected

Definition at line 74 of file FFTJetPatRecoProducer.cc.

Constructor & Destructor Documentation

FFTJetPatRecoProducer::FFTJetPatRecoProducer ( const edm::ParameterSet ps)
explicit

Definition at line 152 of file FFTJetPatRecoProducer.cc.

References buildKernelConvolver(), buildPeakFinder(), fftjetcms::FFTJetInterface::checkConfig(), clusteringTree, convolver, fwrapper::cs, distanceCalc, fftjetcms::FFTJetInterface::energyFlow, Exception, fftjetpatrecoproducer_cfi::externalGridFile, externalGridStream, fftjetcms::fftjet_ClusteringTreeSparsifier_parser(), fftjetcms::fftjet_DistanceCalculator_parser(), fftjetcms::fftjet_Grid2d_parser(), fftjetcms::fftjet_PeakSelector_parser(), fftjetcms::fftjet_ScaleSet_parser(), fftjetcms::FFTJetInterface::getEventScale(), edm::ParameterSet::getParameter(), mps_fire::i, makeClusteringTree, fftjetpatrecoproducer_cfi::maxAdaptiveScales, fftjetpatrecoproducer_cfi::minAdaptiveRatioLog, MillePedeFileConverter_cfg::out, fftjetcms::FFTJetInterface::outputLabel, peakSelector, sequencer, sparsifier, fftjetpatrecoproducer_cfi::SparsifierConfiguration, storeDiscretizationGrid, storeGridsExternally, fftjetcms::FFTJetInterface::storeInSinglePrecision(), AlCaHLTBitMon_QueryRunRegistry::string, and fftjetdijetfilter_cfi::TreeDistanceCalculator.

153  : FFTJetInterface(ps),
154  clusteringTree(0),
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")),
160  extGrid(0)
161 {
162  // register your products
163  if (makeClusteringTree)
164  {
166  produces<reco::PattRecoTree<float,reco::PattRecoPeak<float> > >(outputLabel);
167  else
168  produces<reco::PattRecoTree<double,reco::PattRecoPeak<double> > >(outputLabel);
169  }
171  produces<reco::DiscretizedEnergyFlow>(outputLabel);
172 
173  // Check if we want to write the grids into an external file
174  const std::string externalGridFile(ps.getParameter<std::string>("externalGridFile"));
177  {
179  std::ios_base::binary);
180  if (!externalGridStream.is_open())
181  throw cms::Exception("FFTJetBadConfig")
182  << "FFTJetPatRecoProducer failed to open file "
183  << externalGridFile << std::endl;
184  }
185 
187  {
188  throw cms::Exception("FFTJetBadConfig")
189  << "FFTJetPatRecoProducer is not configured to produce anything"
190  << std::endl;
191  }
192 
193  // now do whatever other initialization is needed
194 
195  // Build the discretization grid
197  ps.getParameter<edm::ParameterSet>("GridConfiguration"));
198  checkConfig(energyFlow, "invalid discretization grid");
199 
200  // Build the FFT engine(s), pattern recognition kernel(s),
201  // and the kernel convolver
203 
204  // Build the peak selector
206  ps.getParameter<edm::ParameterSet>("PeakSelectorConfiguration"));
207  checkConfig(peakSelector, "invalid peak selector");
208 
209  // Build the initial set of pattern recognition scales
210  std::auto_ptr<std::vector<double> > iniScales = fftjet_ScaleSet_parser(
211  ps.getParameter<edm::ParameterSet>("InitialScales"));
212  checkConfig(iniScales, "invalid set of scales");
213 
214  // Do we want to use the adaptive clustering tree algorithm?
215  const unsigned maxAdaptiveScales =
216  ps.getParameter<unsigned>("maxAdaptiveScales");
217  const double minAdaptiveRatioLog =
218  ps.getParameter<double>("minAdaptiveRatioLog");
219  if (minAdaptiveRatioLog <= 0.0)
220  throw cms::Exception("FFTJetBadConfig")
221  << "bad adaptive ratio logarithm limit" << std::endl;
222 
223  // Make sure that all standard scales are larger than the
224  // complete event scale
225  if (getEventScale() > 0.0)
226  {
227  const double cs = getEventScale();
228  const unsigned nscales = iniScales->size();
229  for (unsigned i=0; i<nscales; ++i)
230  if (cs >= (*iniScales)[i])
231  throw cms::Exception("FFTJetBadConfig")
232  << "incompatible scale for complete event" << std::endl;
233  }
234 
235  // At this point we are ready to build the clustering sequencer
236  sequencer = std::auto_ptr<Sequencer>(new Sequencer(
237  convolver.get(), peakSelector.get(), buildPeakFinder(ps),
238  *iniScales, maxAdaptiveScales, minAdaptiveRatioLog));
239 
240  // Build the clustering tree sparsifier
242  ps.getParameter<edm::ParameterSet>("SparsifierConfiguration"));
245  checkConfig(sparsifier, "invalid sparsifier parameters");
246 
247  // Build the distance calculator for the clustering tree
249  ps.getParameter<edm::ParameterSet>("TreeDistanceCalculator"));
251  checkConfig(distanceCalc, "invalid tree distance calculator");
252 
253  // Build the clustering tree itself
255 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::auto_ptr< fftjet::Functor1< bool, fftjet::Peak > > peakSelector
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
auto_ptr< ClusterSequence > cs
std::auto_ptr< fftjet::Grid2d< Real > > fftjet_Grid2d_parser(const edm::ParameterSet &ps)
void buildKernelConvolver(const edm::ParameterSet &)
void checkConfig(const Ptr &ptr, const char *message)
std::auto_ptr< fftjet::Functor1< bool, fftjet::Peak > > fftjet_PeakSelector_parser(const edm::ParameterSet &ps)
ClusteringTree * clusteringTree
fftjet::ClusteringSequencer< Real > Sequencer
std::auto_ptr< Sparsifier > sparsifier
std::auto_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > distanceCalc
bool storeInSinglePrecision() const
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::ProximityClusteringTree< fftjet::Peak, long > ClusteringTree
fftjet::Grid2d< float > * extGrid
const std::string outputLabel
std::auto_ptr< std::vector< double > > fftjet_ScaleSet_parser(const edm::ParameterSet &ps)
FFTJetPatRecoProducer::~FFTJetPatRecoProducer ( )

Definition at line 356 of file FFTJetPatRecoProducer.cc.

References clusteringTree, and extGrid.

357 {
358  // do anything here that needs to be done at desctruction time
359  // (e.g. close files, deallocate resources etc.)
360  delete clusteringTree;
361  delete extGrid;
362 }
ClusteringTree * clusteringTree
fftjet::Grid2d< float > * extGrid
FFTJetPatRecoProducer::FFTJetPatRecoProducer ( )
private
FFTJetPatRecoProducer::FFTJetPatRecoProducer ( const FFTJetPatRecoProducer )
private

Member Function Documentation

void FFTJetPatRecoProducer::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 496 of file FFTJetPatRecoProducer.cc.

497 {
498 }
template<class Real >
void FFTJetPatRecoProducer::buildDenseProduct ( edm::Event ev) const
protected

Definition at line 396 of file FFTJetPatRecoProducer.cc.

References trackerTree::check(), clusteringTree, fftjetcms::densePeakTreeFromStorable(), fftjetcms::densePeakTreeToStorable(), distanceCalc, Exception, fftjetcms::FFTJetInterface::getEventScale(), eostools::move(), fftjetcms::FFTJetInterface::outputLabel, edm::Event::put(), sequencer, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and verifyDataConversion.

397 {
399 
400  auto tree = std::make_unique<StoredTree>();
401 
403  sequencer->maxAdaptiveScales(),
404  tree.get());
405 
406  // Check that we can restore the tree
408  {
410  const std::vector<double>& scalesUsed(sequencer->getInitialScales());
412  if (*clusteringTree != check)
413  throw cms::Exception("FFTJetInterface")
414  << "Data conversion failed for dense clustering tree"
415  << std::endl;
416  }
417 
419 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
Class for storing FFTJet sparse clustering trees.
Definition: PattRecoTree.h:18
ClusteringTree * clusteringTree
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)
void densePeakTreeFromStorable(const reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > &in, const std::vector< double > *scaleSetIfNotAdaptive, double completeEventScale, fftjet::AbsClusteringTree< fftjet::Peak, long > *out)
std::auto_ptr< Sequencer > sequencer
Definition: tree.py:1
fftjet::ProximityClusteringTree< fftjet::Peak, long > ClusteringTree
def check(config)
Definition: trackerTree.py:14
const std::string outputLabel
def move(src, dest)
Definition: eostools.py:510
void FFTJetPatRecoProducer::buildKernelConvolver ( const edm::ParameterSet ps)
protected

Definition at line 258 of file FFTJetPatRecoProducer.cc.

References anotherEngine, convolver, fftjeteflowsmoother_cfi::convolverMaxBin, fftjeteflowsmoother_cfi::convolverMinBin, fftjetcms::FFTJetInterface::energyFlow, engine, fftjeteflowsmoother_cfi::etaDependentScaleFactors, etaKernel, Exception, fftjeteflowsmoother_cfi::fixEfficiency, edm::ParameterSet::getParameter(), kernel2d, fftjeteflowsmoother_cfi::kernelEtaScale, fftjeteflowsmoother_cfi::kernelPhiScale, M_PI, and phiKernel.

Referenced by FFTJetPatRecoProducer().

259 {
260  // Check the parameter named "etaDependentScaleFactors". If the vector
261  // of scales is empty we will use 2d kernel, otherwise use 1d kernels
262  const std::vector<double> etaDependentScaleFactors(
263  ps.getParameter<std::vector<double> >("etaDependentScaleFactors"));
264 
265  // Make sure that the number of scale factors provided is correct
266  const bool use2dKernel = etaDependentScaleFactors.empty();
267  if (!use2dKernel)
268  if (etaDependentScaleFactors.size() != energyFlow->nEta())
269  throw cms::Exception("FFTJetBadConfig")
270  << "invalid number of eta-dependent scale factors"
271  << std::endl;
272 
273  // Get the eta and phi scales for the kernel(s)
274  double kernelEtaScale = ps.getParameter<double>("kernelEtaScale");
275  const double kernelPhiScale = ps.getParameter<double>("kernelPhiScale");
276  if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
277  throw cms::Exception("FFTJetBadConfig")
278  << "invalid kernel scale" << std::endl;
279 
280  // FFT assumes that the grid extent in eta is 2*Pi. Adjust the
281  // kernel scale in eta to compensate.
282  kernelEtaScale *= (2.0*M_PI/(energyFlow->etaMax() - energyFlow->etaMin()));
283 
284  // Are we going to try to fix the efficiency near detector edges?
285  const bool fixEfficiency = ps.getParameter<bool>("fixEfficiency");
286 
287  // Minimum and maximum eta bin for the convolver
288  unsigned convolverMinBin = 0, convolverMaxBin = 0;
289  if (fixEfficiency || !use2dKernel)
290  {
291  convolverMinBin = ps.getParameter<unsigned>("convolverMinBin");
292  convolverMaxBin = ps.getParameter<unsigned>("convolverMaxBin");
293  }
294 
295  if (use2dKernel)
296  {
297  // Build the FFT engine
298  engine = std::auto_ptr<MyFFTEngine>(
299  new MyFFTEngine(energyFlow->nEta(), energyFlow->nPhi()));
300 
301  // 2d kernel
302  kernel2d = std::auto_ptr<fftjet::AbsFrequencyKernel>(
303  new fftjet::DiscreteGauss2d(
304  kernelEtaScale, kernelPhiScale,
305  energyFlow->nEta(), energyFlow->nPhi()));
306 
307  // 2d convolver
308  convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
309  new fftjet::FrequencyKernelConvolver<Real,Complex>(
310  engine.get(), kernel2d.get(),
312  }
313  else
314  {
315  // Need separate FFT engines for eta and phi
316  engine = std::auto_ptr<MyFFTEngine>(
317  new MyFFTEngine(1, energyFlow->nEta()));
318  anotherEngine = std::auto_ptr<MyFFTEngine>(
319  new MyFFTEngine(1, energyFlow->nPhi()));
320 
321  // 1d kernels
322  etaKernel = std::auto_ptr<fftjet::AbsFrequencyKernel1d>(
323  new fftjet::DiscreteGauss1d(kernelEtaScale, energyFlow->nEta()));
324 
325  phiKernel = std::auto_ptr<fftjet::AbsFrequencyKernel1d>(
326  new fftjet::DiscreteGauss1d(kernelPhiScale, energyFlow->nPhi()));
327 
328  // Sequential convolver
329  convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
330  new fftjet::FrequencySequentialConvolver<Real,Complex>(
331  engine.get(), anotherEngine.get(),
332  etaKernel.get(), phiKernel.get(),
335  }
336 }
T getParameter(std::string const &) const
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
std::auto_ptr< fftjet::AbsFrequencyKernel1d > phiKernel
std::auto_ptr< MyFFTEngine > anotherEngine
std::auto_ptr< fftjet::AbsFrequencyKernel > kernel2d
std::auto_ptr< MyFFTEngine > engine
#define M_PI
std::auto_ptr< fftjet::AbsFrequencyKernel1d > etaKernel
std::auto_ptr< fftjet::AbsConvolverBase< Real > > convolver
fftjet::FFTWDoubleEngine MyFFTEngine
fftjet::PeakFinder FFTJetPatRecoProducer::buildPeakFinder ( const edm::ParameterSet ps)
protected

Definition at line 339 of file FFTJetPatRecoProducer.cc.

References fftjetcms::FFTJetInterface::energyFlow, Exception, edm::ParameterSet::getParameter(), and fftjetpatrecoproducer_cfi::peakFinderMaxEta.

Referenced by FFTJetPatRecoProducer().

340 {
341  const double peakFinderMaxEta = ps.getParameter<double>("peakFinderMaxEta");
342  if (peakFinderMaxEta <= 0.0)
343  throw cms::Exception("FFTJetBadConfig")
344  << "invalid peak finder eta cut" << std::endl;
345  const double maxMagnitude = ps.getParameter<double>("peakFinderMaxMagnitude");
346  int minBin = energyFlow->getEtaBin(-peakFinderMaxEta);
347  if (minBin < 0)
348  minBin = 0;
349  int maxBin = energyFlow->getEtaBin(peakFinderMaxEta) + 1;
350  if (maxBin < 0)
351  maxBin = 0;
352  return fftjet::PeakFinder(maxMagnitude, true, minBin, maxBin);
353 }
T getParameter(std::string const &) const
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
template<class Real >
void FFTJetPatRecoProducer::buildSparseProduct ( edm::Event ev) const
protected

Definition at line 369 of file FFTJetPatRecoProducer.cc.

References trackerTree::check(), Exception, fftjetcms::FFTJetInterface::getEventScale(), eostools::move(), fftjetcms::FFTJetInterface::outputLabel, edm::Event::put(), sequencer, fftjetcms::sparsePeakTreeFromStorable(), fftjetcms::sparsePeakTreeToStorable(), sparseTree, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and verifyDataConversion.

370 {
372 
373  auto tree = std::make_unique<StoredTree>();
374 
376  sequencer->maxAdaptiveScales(),
377  tree.get());
378 
379  // Check that we can restore the tree
381  {
383  const std::vector<double>& scalesUsed(sequencer->getInitialScales());
384  sparsePeakTreeFromStorable(*tree, &scalesUsed, getEventScale(), &check);
385  if (sparseTree != check)
386  throw cms::Exception("FFTJetInterface")
387  << "Data conversion failed for sparse clustering tree"
388  << std::endl;
389  }
390 
392 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
Class for storing FFTJet sparse clustering trees.
Definition: PattRecoTree.h:18
void sparsePeakTreeToStorable(const fftjet::SparseClusteringTree< fftjet::Peak, long > &in, bool writeOutScaleInfo, reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > *out)
bool storeInSinglePrecision() const
void sparsePeakTreeFromStorable(const reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > &in, const std::vector< double > *scaleSetIfNotAdaptive, double completeEventScale, fftjet::SparseClusteringTree< fftjet::Peak, long > *out)
std::auto_ptr< Sequencer > sequencer
Definition: tree.py:1
fftjet::SparseClusteringTree< fftjet::Peak, long > SparseTree
def check(config)
Definition: trackerTree.py:14
const std::string outputLabel
def move(src, dest)
Definition: eostools.py:510
void FFTJetPatRecoProducer::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 502 of file FFTJetPatRecoProducer.cc.

References DEFINE_FWK_MODULE, externalGridStream, and storeGridsExternally.

503 {
505  externalGridStream.close();
506 }
FFTJetPatRecoProducer& FFTJetPatRecoProducer::operator= ( const FFTJetPatRecoProducer )
private
void FFTJetPatRecoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 423 of file FFTJetPatRecoProducer.cc.

References trackerTree::check(), clusteringTree, completeEventDataCutoff, fftjetcms::convert_Grid2d_to_float(), fftjetcms::copy_Grid2d_data(), fftjetcms::FFTJetInterface::discretizeEnergyFlow(), fftjetcms::FFTJetInterface::energyFlow, Exception, externalGridStream, extGrid, fftjetcommon_cfi::flow, g, fftjetcms::FFTJetInterface::getEventScale(), iEvent, fftjetcms::FFTJetInterface::loadInputCollection(), makeClusteringTree, eostools::move(), fftjetcms::FFTJetInterface::outputLabel, edm::Event::put(), sequencer, sparseTree, sparsifier, sparsify, storeDiscretizationGrid, storeGridsExternally, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and verifyDataConversion.

425 {
426  loadInputCollection(iEvent);
428 
429  if (makeClusteringTree)
430  {
432  if (getEventScale() > 0.0)
433  sequencer->insertCompleteEvent(getEventScale(), *energyFlow,
435 
436  if (sparsify)
437  {
438  sparsifier->sparsify(*clusteringTree, &sparseTree);
439 
440  // Do not call the "sortNodes" method of the sparse tree here.
441  // Currently, the nodes are sorted by daughter number.
442  // This is the way we want it in storage because the stored
443  // tree does not include daughter ordering info explicitly.
444 
446  buildSparseProduct<float>(iEvent);
447  else
448  buildSparseProduct<double>(iEvent);
449  }
450  else
451  {
453  buildDenseProduct<float>(iEvent);
454  else
455  buildDenseProduct<double>(iEvent);
456  }
457  }
458 
460  {
461  const fftjet::Grid2d<Real>& g(*energyFlow);
462 
463  auto flow = std::make_unique<reco::DiscretizedEnergyFlow>(
464  g.data(), g.title(), g.etaMin(), g.etaMax(),
465  g.phiBin0Edge(), g.nEta(), g.nPhi());
466 
468  {
469  fftjet::Grid2d<Real> check(
470  flow->nEtaBins(), flow->etaMin(), flow->etaMax(),
471  flow->nPhiBins(), flow->phiBin0Edge(), flow->title());
472  check.blockSet(flow->data(), flow->nEtaBins(), flow->nPhiBins());
473  assert(g == check);
474  }
475 
476  iEvent.put(std::move(flow), outputLabel);
477  }
478 
480  {
481  if (extGrid)
483  else
485  if (!extGrid->write(externalGridStream))
486  {
487  throw cms::Exception("FFTJetPatRecoProducer::produce")
488  << "Failed to write grid data into an external file"
489  << std::endl;
490  }
491  }
492 }
fftjet::Grid2d< float > * convert_Grid2d_to_float(const fftjet::Grid2d< Numeric > &grid)
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
void loadInputCollection(const edm::Event &)
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
Definition: Activities.doc:4
int iEvent
Definition: GenABIO.cc:230
ClusteringTree * clusteringTree
std::auto_ptr< Sparsifier > sparsifier
bool storeInSinglePrecision() const
void copy_Grid2d_data(fftjet::Grid2d< F2 > *to, const fftjet::Grid2d< F1 > &from)
std::auto_ptr< Sequencer > sequencer
def check(config)
Definition: trackerTree.py:14
fftjet::Grid2d< float > * extGrid
const std::string outputLabel
def move(src, dest)
Definition: eostools.py:510

Member Data Documentation

std::auto_ptr<MyFFTEngine> FFTJetPatRecoProducer::anotherEngine
protected

Definition at line 101 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

ClusteringTree* FFTJetPatRecoProducer::clusteringTree
protected
const double FFTJetPatRecoProducer::completeEventDataCutoff
protected

Definition at line 123 of file FFTJetPatRecoProducer.cc.

Referenced by produce().

std::auto_ptr<fftjet::AbsConvolverBase<Real> > FFTJetPatRecoProducer::convolver
protected

Definition at line 109 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver(), and FFTJetPatRecoProducer().

std::auto_ptr<fftjet::AbsDistanceCalculator<fftjet::Peak> > FFTJetPatRecoProducer::distanceCalc
protected

Definition at line 115 of file FFTJetPatRecoProducer.cc.

Referenced by buildDenseProduct(), and FFTJetPatRecoProducer().

std::auto_ptr<MyFFTEngine> FFTJetPatRecoProducer::engine
protected

Definition at line 100 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

std::auto_ptr<fftjet::AbsFrequencyKernel1d> FFTJetPatRecoProducer::etaKernel
protected

Definition at line 105 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

std::ofstream FFTJetPatRecoProducer::externalGridStream
private

Definition at line 144 of file FFTJetPatRecoProducer.cc.

Referenced by endJob(), FFTJetPatRecoProducer(), and produce().

fftjet::Grid2d<float>* FFTJetPatRecoProducer::extGrid
private

Definition at line 146 of file FFTJetPatRecoProducer.cc.

Referenced by produce(), and ~FFTJetPatRecoProducer().

std::auto_ptr<fftjet::AbsFrequencyKernel> FFTJetPatRecoProducer::kernel2d
protected

Definition at line 104 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

const bool FFTJetPatRecoProducer::makeClusteringTree
protected

Definition at line 126 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

std::auto_ptr<fftjet::Functor1<bool,fftjet::Peak> > FFTJetPatRecoProducer::peakSelector
protected

Definition at line 112 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer().

std::auto_ptr<fftjet::AbsFrequencyKernel1d> FFTJetPatRecoProducer::phiKernel
protected

Definition at line 106 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

std::auto_ptr<Sequencer> FFTJetPatRecoProducer::sequencer
protected
SparseTree FFTJetPatRecoProducer::sparseTree
protected

Definition at line 118 of file FFTJetPatRecoProducer.cc.

Referenced by buildSparseProduct(), and produce().

std::auto_ptr<Sparsifier> FFTJetPatRecoProducer::sparsifier
protected

Definition at line 97 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

const bool FFTJetPatRecoProducer::sparsify
protected

Definition at line 136 of file FFTJetPatRecoProducer.cc.

Referenced by produce().

const bool FFTJetPatRecoProducer::storeDiscretizationGrid
protected

Definition at line 133 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

bool FFTJetPatRecoProducer::storeGridsExternally
private

Definition at line 145 of file FFTJetPatRecoProducer.cc.

Referenced by endJob(), FFTJetPatRecoProducer(), and produce().

const bool FFTJetPatRecoProducer::verifyDataConversion
protected

Definition at line 130 of file FFTJetPatRecoProducer.cc.

Referenced by buildDenseProduct(), buildSparseProduct(), and produce().