CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Types

typedef
fftjet::ProximityClusteringTree
< fftjet::Peak, long > 
ClusteringTree
 
typedef
fftjet::ClusteringSequencer
< Real
Sequencer
 
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::VectorLike
eventData
 
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, 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(), i, makeClusteringTree, GenerateHcalLaserBadRunList::out, fftjetcms::FFTJetInterface::outputLabel, peakSelector, sequencer, sparsifier, storeDiscretizationGrid, storeGridsExternally, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and AlCaHLTBitMon_QueryRunRegistry::string.

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"));
175  storeGridsExternally = externalGridFile.size() > 0;
177  {
178  externalGridStream.open(externalGridFile.c_str(), std::ios_base::out |
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
241  const edm::ParameterSet& SparsifierConfiguration(
242  ps.getParameter<edm::ParameterSet>("SparsifierConfiguration"));
244  SparsifierConfiguration);
245  checkConfig(sparsifier, "invalid sparsifier parameters");
246 
247  // Build the distance calculator for the clustering tree
248  const edm::ParameterSet& TreeDistanceCalculator(
249  ps.getParameter<edm::ParameterSet>("TreeDistanceCalculator"));
250  distanceCalc = fftjet_DistanceCalculator_parser(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
int i
Definition: DBlmapReader.cc:9
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 497 of file FFTJetPatRecoProducer.cc.

498 {
499 }
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(), fftjetcms::FFTJetInterface::outputLabel, edm::Event::put(), sequencer, fftjetcms::FFTJetInterface::storeInSinglePrecision(), MainPageGenerator::tree, and verifyDataConversion.

397 {
399 
400  std::auto_ptr<StoredTree> tree(new 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 
418  ev.put(tree, outputLabel);
419 }
Class for storing FFTJet sparse clustering trees.
Definition: PattRecoTree.h:18
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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
fftjet::ProximityClusteringTree< fftjet::Peak, long > ClusteringTree
const std::string outputLabel
void FFTJetPatRecoProducer::buildKernelConvolver ( const edm::ParameterSet ps)
protected

Definition at line 258 of file FFTJetPatRecoProducer.cc.

References anotherEngine, convolver, fftjetcms::FFTJetInterface::energyFlow, engine, etaKernel, Exception, edm::ParameterSet::getParameter(), kernel2d, 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(),
311  convolverMinBin, convolverMaxBin));
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(),
333  etaDependentScaleFactors, convolverMinBin,
334  convolverMaxBin, fixEfficiency));
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, and edm::ParameterSet::getParameter().

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(), fftjetcms::FFTJetInterface::outputLabel, edm::Event::put(), sequencer, fftjetcms::sparsePeakTreeFromStorable(), fftjetcms::sparsePeakTreeToStorable(), sparseTree, fftjetcms::FFTJetInterface::storeInSinglePrecision(), MainPageGenerator::tree, and verifyDataConversion.

370 {
372 
373  std::auto_ptr<StoredTree> tree(new 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 
391  ev.put(tree, outputLabel);
392 }
Class for storing FFTJet sparse clustering trees.
Definition: PattRecoTree.h:18
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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
fftjet::SparseClusteringTree< fftjet::Peak, long > SparseTree
const std::string outputLabel
void FFTJetPatRecoProducer::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 503 of file FFTJetPatRecoProducer.cc.

References externalGridStream, and storeGridsExternally.

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

Implements edm::EDProducer.

Definition at line 423 of file FFTJetPatRecoProducer.cc.

References assert(), trackerTree::check(), clusteringTree, completeEventDataCutoff, fftjetcms::convert_Grid2d_to_float(), fftjetcms::copy_Grid2d_data(), fftjetcms::FFTJetInterface::discretizeEnergyFlow(), fftjetcms::FFTJetInterface::energyFlow, Exception, externalGridStream, extGrid, g, fftjetcms::FFTJetInterface::getEventScale(), iEvent, fftjetcms::FFTJetInterface::loadInputCollection(), makeClusteringTree, 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  std::auto_ptr<reco::DiscretizedEnergyFlow> flow(
465  g.data(), g.title(), g.etaMin(), g.etaMax(),
466  g.phiBin0Edge(), g.nEta(), g.nPhi()));
467 
469  {
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());
474  assert(g == check);
475  }
476 
477  iEvent.put(flow, outputLabel);
478  }
479 
481  {
482  if (extGrid)
484  else
486  if (!extGrid->write(externalGridStream))
487  {
488  throw cms::Exception("FFTJetPatRecoProducer::produce")
489  << "Failed to write grid data into an external file"
490  << std::endl;
491  }
492  }
493 }
fftjet::Grid2d< float > * convert_Grid2d_to_float(const fftjet::Grid2d< Numeric > &grid)
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
void loadInputCollection(const edm::Event &)
assert(m_qm.get())
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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
fftjet::Grid2d< float > * extGrid
const std::string outputLabel

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().