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 () override
 
- Public Member Functions inherited from fftjetcms::FFTJetInterface
 ~FFTJetInterface () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- 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 ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
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, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
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 & itemsToGetFrom (BranchType iType) 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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Protected Attributes

std::unique_ptr< MyFFTEngineanotherEngine
 
ClusteringTreeclusteringTree
 
const double completeEventDataCutoff
 
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
 
std::unique_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > distanceCalc
 
std::unique_ptr< MyFFTEngineengine
 
std::unique_ptr< fftjet::AbsFrequencyKernel1d > etaKernel
 
std::unique_ptr< fftjet::AbsFrequencyKernel > kernel2d
 
const bool makeClusteringTree
 
std::unique_ptr< fftjet::Functor1< bool, fftjet::Peak > > peakSelector
 
std::unique_ptr< fftjet::AbsFrequencyKernel1d > phiKernel
 
std::unique_ptr< Sequencersequencer
 
SparseTree sparseTree
 
std::unique_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::unique_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 ()=delete
 
 FFTJetPatRecoProducer (const FFTJetPatRecoProducer &)=delete
 
FFTJetPatRecoProduceroperator= (const FFTJetPatRecoProducer &)=delete
 

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
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
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)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Detailed Description

Description: Runs FFTJet pattern recognition stage and saves the results

Implementation: [Notes on implementation]

Definition at line 64 of file FFTJetPatRecoProducer.cc.

Member Typedef Documentation

◆ ClusteringTree

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

Definition at line 71 of file FFTJetPatRecoProducer.cc.

◆ Sequencer

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

Definition at line 73 of file FFTJetPatRecoProducer.cc.

◆ SparseTree

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

Definition at line 72 of file FFTJetPatRecoProducer.cc.

◆ Sparsifier

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

Definition at line 74 of file FFTJetPatRecoProducer.cc.

Constructor & Destructor Documentation

◆ FFTJetPatRecoProducer() [1/3]

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

Definition at line 152 of file FFTJetPatRecoProducer.cc.

153  : FFTJetInterface(ps),
154  clusteringTree(nullptr),
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(nullptr) {
161  // register your products
162  if (makeClusteringTree) {
164  produces<reco::PattRecoTree<float, reco::PattRecoPeak<float> > >(outputLabel);
165  else
166  produces<reco::PattRecoTree<double, reco::PattRecoPeak<double> > >(outputLabel);
167  }
169  produces<reco::DiscretizedEnergyFlow>(outputLabel);
170 
171  // Check if we want to write the grids into an external file
172  const std::string externalGridFile(ps.getParameter<std::string>("externalGridFile"));
174  if (storeGridsExternally) {
175  externalGridStream.open(externalGridFile.c_str(), std::ios_base::out | std::ios_base::binary);
176  if (!externalGridStream.is_open())
177  throw cms::Exception("FFTJetBadConfig")
178  << "FFTJetPatRecoProducer failed to open file " << externalGridFile << std::endl;
179  }
180 
182  throw cms::Exception("FFTJetBadConfig")
183  << "FFTJetPatRecoProducer is not configured to produce anything" << std::endl;
184  }
185 
186  // now do whatever other initialization is needed
187 
188  // Build the discretization grid
190  checkConfig(energyFlow, "invalid discretization grid");
191 
192  // Build the FFT engine(s), pattern recognition kernel(s),
193  // and the kernel convolver
195 
196  // Build the peak selector
197  peakSelector = fftjet_PeakSelector_parser(ps.getParameter<edm::ParameterSet>("PeakSelectorConfiguration"));
198  checkConfig(peakSelector, "invalid peak selector");
199 
200  // Build the initial set of pattern recognition scales
201  std::unique_ptr<std::vector<double> > iniScales =
203  checkConfig(iniScales, "invalid set of scales");
204 
205  // Do we want to use the adaptive clustering tree algorithm?
206  const unsigned maxAdaptiveScales = ps.getParameter<unsigned>("maxAdaptiveScales");
207  const double minAdaptiveRatioLog = ps.getParameter<double>("minAdaptiveRatioLog");
208  if (minAdaptiveRatioLog <= 0.0)
209  throw cms::Exception("FFTJetBadConfig") << "bad adaptive ratio logarithm limit" << std::endl;
210 
211  // Make sure that all standard scales are larger than the
212  // complete event scale
213  if (getEventScale() > 0.0) {
214  const double cs = getEventScale();
215  const unsigned nscales = iniScales->size();
216  for (unsigned i = 0; i < nscales; ++i)
217  if (cs >= (*iniScales)[i])
218  throw cms::Exception("FFTJetBadConfig") << "incompatible scale for complete event" << std::endl;
219  }
220 
221  // At this point we are ready to build the clustering sequencer
222  sequencer = std::make_unique<Sequencer>(
224 
225  // Build the clustering tree sparsifier
226  const edm::ParameterSet& SparsifierConfiguration(ps.getParameter<edm::ParameterSet>("SparsifierConfiguration"));
228  checkConfig(sparsifier, "invalid sparsifier parameters");
229 
230  // Build the distance calculator for the clustering tree
231  const edm::ParameterSet& TreeDistanceCalculator(ps.getParameter<edm::ParameterSet>("TreeDistanceCalculator"));
233  checkConfig(distanceCalc, "invalid tree distance calculator");
234 
235  // Build the clustering tree itself
237 }

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.

◆ ~FFTJetPatRecoProducer()

FFTJetPatRecoProducer::~FFTJetPatRecoProducer ( )
override

Definition at line 320 of file FFTJetPatRecoProducer.cc.

320  {
321  // do anything here that needs to be done at desctruction time
322  // (e.g. close files, deallocate resources etc.)
323  delete clusteringTree;
324  delete extGrid;
325 }

References clusteringTree, and extGrid.

◆ FFTJetPatRecoProducer() [2/3]

FFTJetPatRecoProducer::FFTJetPatRecoProducer ( )
privatedelete

◆ FFTJetPatRecoProducer() [3/3]

FFTJetPatRecoProducer::FFTJetPatRecoProducer ( const FFTJetPatRecoProducer )
privatedelete

Member Function Documentation

◆ beginJob()

void FFTJetPatRecoProducer::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 429 of file FFTJetPatRecoProducer.cc.

429 {}

◆ buildDenseProduct()

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

Definition at line 351 of file FFTJetPatRecoProducer.cc.

351  {
353 
354  auto tree = std::make_unique<StoredTree>();
355 
356  densePeakTreeToStorable(*clusteringTree, sequencer->maxAdaptiveScales(), tree.get());
357 
358  // Check that we can restore the tree
361  const std::vector<double>& scalesUsed(sequencer->getInitialScales());
363  if (*clusteringTree != check)
364  throw cms::Exception("FFTJetInterface") << "Data conversion failed for dense clustering tree" << std::endl;
365  }
366 
367  ev.put(std::move(tree), outputLabel);
368 }

References RPCNoise_example::check, clusteringTree, fftjetcms::densePeakTreeFromStorable(), fftjetcms::densePeakTreeToStorable(), distanceCalc, ev, Exception, fftjetcms::FFTJetInterface::getEventScale(), eostools::move(), fftjetcms::FFTJetInterface::outputLabel, sequencer, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and verifyDataConversion.

◆ buildKernelConvolver()

void FFTJetPatRecoProducer::buildKernelConvolver ( const edm::ParameterSet ps)
protected

Definition at line 239 of file FFTJetPatRecoProducer.cc.

239  {
240  // Check the parameter named "etaDependentScaleFactors". If the vector
241  // of scales is empty we will use 2d kernel, otherwise use 1d kernels
242  const std::vector<double> etaDependentScaleFactors(ps.getParameter<std::vector<double> >("etaDependentScaleFactors"));
243 
244  // Make sure that the number of scale factors provided is correct
245  const bool use2dKernel = etaDependentScaleFactors.empty();
246  if (!use2dKernel)
247  if (etaDependentScaleFactors.size() != energyFlow->nEta())
248  throw cms::Exception("FFTJetBadConfig") << "invalid number of eta-dependent scale factors" << std::endl;
249 
250  // Get the eta and phi scales for the kernel(s)
251  double kernelEtaScale = ps.getParameter<double>("kernelEtaScale");
252  const double kernelPhiScale = ps.getParameter<double>("kernelPhiScale");
253  if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
254  throw cms::Exception("FFTJetBadConfig") << "invalid kernel scale" << std::endl;
255 
256  // FFT assumes that the grid extent in eta is 2*Pi. Adjust the
257  // kernel scale in eta to compensate.
258  kernelEtaScale *= (2.0 * M_PI / (energyFlow->etaMax() - energyFlow->etaMin()));
259 
260  // Are we going to try to fix the efficiency near detector edges?
261  const bool fixEfficiency = ps.getParameter<bool>("fixEfficiency");
262 
263  // Minimum and maximum eta bin for the convolver
264  unsigned convolverMinBin = 0, convolverMaxBin = 0;
265  if (fixEfficiency || !use2dKernel) {
266  convolverMinBin = ps.getParameter<unsigned>("convolverMinBin");
267  convolverMaxBin = ps.getParameter<unsigned>("convolverMaxBin");
268  }
269 
270  if (use2dKernel) {
271  // Build the FFT engine
272  engine = std::make_unique<MyFFTEngine>(energyFlow->nEta(), energyFlow->nPhi());
273 
274  // 2d kernel
275  kernel2d = std::unique_ptr<fftjet::AbsFrequencyKernel>(
276  new fftjet::DiscreteGauss2d(kernelEtaScale, kernelPhiScale, energyFlow->nEta(), energyFlow->nPhi()));
277 
278  // 2d convolver
279  convolver = std::unique_ptr<fftjet::AbsConvolverBase<Real> >(new fftjet::FrequencyKernelConvolver<Real, Complex>(
281  } else {
282  // Need separate FFT engines for eta and phi
283  engine = std::make_unique<MyFFTEngine>(1, energyFlow->nEta());
284  anotherEngine = std::make_unique<MyFFTEngine>(1, energyFlow->nPhi());
285 
286  // 1d kernels
287  etaKernel =
288  std::unique_ptr<fftjet::AbsFrequencyKernel1d>(new fftjet::DiscreteGauss1d(kernelEtaScale, energyFlow->nEta()));
289 
290  phiKernel =
291  std::unique_ptr<fftjet::AbsFrequencyKernel1d>(new fftjet::DiscreteGauss1d(kernelPhiScale, energyFlow->nPhi()));
292 
293  // Sequential convolver
294  convolver = std::unique_ptr<fftjet::AbsConvolverBase<Real> >(
295  new fftjet::FrequencySequentialConvolver<Real, Complex>(engine.get(),
296  anotherEngine.get(),
297  etaKernel.get(),
298  phiKernel.get(),
302  fixEfficiency));
303  }
304 }

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

◆ buildPeakFinder()

fftjet::PeakFinder FFTJetPatRecoProducer::buildPeakFinder ( const edm::ParameterSet ps)
protected

Definition at line 306 of file FFTJetPatRecoProducer.cc.

306  {
307  const double peakFinderMaxEta = ps.getParameter<double>("peakFinderMaxEta");
308  if (peakFinderMaxEta <= 0.0)
309  throw cms::Exception("FFTJetBadConfig") << "invalid peak finder eta cut" << std::endl;
310  const double maxMagnitude = ps.getParameter<double>("peakFinderMaxMagnitude");
311  int minBin = energyFlow->getEtaBin(-peakFinderMaxEta);
312  if (minBin < 0)
313  minBin = 0;
314  int maxBin = energyFlow->getEtaBin(peakFinderMaxEta) + 1;
315  if (maxBin < 0)
316  maxBin = 0;
317  return fftjet::PeakFinder(maxMagnitude, true, minBin, maxBin);
318 }

References fftjetcms::FFTJetInterface::energyFlow, Exception, edm::ParameterSet::getParameter(), cms::cuda::allocator::maxBin, cms::cuda::allocator::minBin, and fftjetpatrecoproducer_cfi::peakFinderMaxEta.

Referenced by FFTJetPatRecoProducer().

◆ buildSparseProduct()

template<class Real >
void FFTJetPatRecoProducer::buildSparseProduct ( edm::Event ev) const
protected

Definition at line 331 of file FFTJetPatRecoProducer.cc.

331  {
333 
334  auto tree = std::make_unique<StoredTree>();
335 
336  sparsePeakTreeToStorable(sparseTree, sequencer->maxAdaptiveScales(), tree.get());
337 
338  // Check that we can restore the tree
341  const std::vector<double>& scalesUsed(sequencer->getInitialScales());
343  if (sparseTree != check)
344  throw cms::Exception("FFTJetInterface") << "Data conversion failed for sparse clustering tree" << std::endl;
345  }
346 
347  ev.put(std::move(tree), outputLabel);
348 }

References RPCNoise_example::check, ev, Exception, fftjetcms::FFTJetInterface::getEventScale(), eostools::move(), fftjetcms::FFTJetInterface::outputLabel, sequencer, fftjetcms::sparsePeakTreeFromStorable(), fftjetcms::sparsePeakTreeToStorable(), sparseTree, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and verifyDataConversion.

◆ endJob()

void FFTJetPatRecoProducer::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 432 of file FFTJetPatRecoProducer.cc.

432  {
434  externalGridStream.close();
435 }

References externalGridStream, and storeGridsExternally.

◆ operator=()

FFTJetPatRecoProducer& FFTJetPatRecoProducer::operator= ( const FFTJetPatRecoProducer )
privatedelete

◆ produce()

void FFTJetPatRecoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotectedvirtual

Implements edm::EDProducer.

Definition at line 371 of file FFTJetPatRecoProducer.cc.

371  {
374 
375  if (makeClusteringTree) {
377  if (getEventScale() > 0.0)
379 
380  if (sparsify) {
381  sparsifier->sparsify(*clusteringTree, &sparseTree);
382 
383  // Do not call the "sortNodes" method of the sparse tree here.
384  // Currently, the nodes are sorted by daughter number.
385  // This is the way we want it in storage because the stored
386  // tree does not include daughter ordering info explicitly.
387 
389  buildSparseProduct<float>(iEvent);
390  else
391  buildSparseProduct<double>(iEvent);
392  } else {
394  buildDenseProduct<float>(iEvent);
395  else
396  buildDenseProduct<double>(iEvent);
397  }
398  }
399 
401  const fftjet::Grid2d<Real>& g(*energyFlow);
402 
403  auto flow = std::make_unique<reco::DiscretizedEnergyFlow>(
404  g.data(), g.title(), g.etaMin(), g.etaMax(), g.phiBin0Edge(), g.nEta(), g.nPhi());
405 
406  if (verifyDataConversion) {
407  fftjet::Grid2d<Real> check(
408  flow->nEtaBins(), flow->etaMin(), flow->etaMax(), flow->nPhiBins(), flow->phiBin0Edge(), flow->title());
409  check.blockSet(flow->data(), flow->nEtaBins(), flow->nPhiBins());
410  assert(g == check);
411  }
412 
414  }
415 
416  if (storeGridsExternally) {
417  if (extGrid)
419  else
421  if (!extGrid->write(externalGridStream)) {
422  throw cms::Exception("FFTJetPatRecoProducer::produce")
423  << "Failed to write grid data into an external file" << std::endl;
424  }
425  }
426 }

References cms::cuda::assert(), RPCNoise_example::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, sequencer, sparseTree, sparsifier, sparsify, storeDiscretizationGrid, storeGridsExternally, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and verifyDataConversion.

Member Data Documentation

◆ anotherEngine

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

Definition at line 101 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

◆ clusteringTree

ClusteringTree* FFTJetPatRecoProducer::clusteringTree
protected

◆ completeEventDataCutoff

const double FFTJetPatRecoProducer::completeEventDataCutoff
protected

Definition at line 123 of file FFTJetPatRecoProducer.cc.

Referenced by produce().

◆ convolver

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

Definition at line 109 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver(), and FFTJetPatRecoProducer().

◆ distanceCalc

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

Definition at line 115 of file FFTJetPatRecoProducer.cc.

Referenced by buildDenseProduct(), and FFTJetPatRecoProducer().

◆ engine

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

Definition at line 100 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

◆ etaKernel

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

Definition at line 105 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

◆ externalGridStream

std::ofstream FFTJetPatRecoProducer::externalGridStream
private

Definition at line 144 of file FFTJetPatRecoProducer.cc.

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

◆ extGrid

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

Definition at line 146 of file FFTJetPatRecoProducer.cc.

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

◆ kernel2d

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

Definition at line 104 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

◆ makeClusteringTree

const bool FFTJetPatRecoProducer::makeClusteringTree
protected

Definition at line 126 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

◆ peakSelector

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

Definition at line 112 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer().

◆ phiKernel

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

Definition at line 106 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

◆ sequencer

std::unique_ptr<Sequencer> FFTJetPatRecoProducer::sequencer
protected

◆ sparseTree

SparseTree FFTJetPatRecoProducer::sparseTree
protected

Definition at line 118 of file FFTJetPatRecoProducer.cc.

Referenced by buildSparseProduct(), and produce().

◆ sparsifier

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

Definition at line 97 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

◆ sparsify

const bool FFTJetPatRecoProducer::sparsify
protected

Definition at line 136 of file FFTJetPatRecoProducer.cc.

Referenced by produce().

◆ storeDiscretizationGrid

const bool FFTJetPatRecoProducer::storeDiscretizationGrid
protected

Definition at line 133 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

◆ storeGridsExternally

bool FFTJetPatRecoProducer::storeGridsExternally
private

Definition at line 145 of file FFTJetPatRecoProducer.cc.

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

◆ verifyDataConversion

const bool FFTJetPatRecoProducer::verifyDataConversion
protected

Definition at line 130 of file FFTJetPatRecoProducer.cc.

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

fftjetcms::densePeakTreeToStorable
void densePeakTreeToStorable(const fftjet::AbsClusteringTree< fftjet::Peak, long > &in, bool writeOutScaleInfo, reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > *out)
Definition: clusteringTreeConverters.h:210
cms::cuda::allocator::minBin
constexpr unsigned int minBin
Definition: getCachingDeviceAllocator.h:18
mps_fire.i
i
Definition: mps_fire.py:428
FFTJetPatRecoProducer::phiKernel
std::unique_ptr< fftjet::AbsFrequencyKernel1d > phiKernel
Definition: FFTJetPatRecoProducer.cc:106
fftjetcms::FFTJetInterface::FFTJetInterface
FFTJetInterface()=delete
fftjetcms::FFTJetInterface::checkConfig
void checkConfig(const Ptr &ptr, const char *message)
Definition: FFTJetInterface.h:60
fftjetcms::FFTJetInterface::loadInputCollection
void loadInputCollection(const edm::Event &)
Definition: FFTJetInterface.cc:40
FFTJetPatRecoProducer::engine
std::unique_ptr< MyFFTEngine > engine
Definition: FFTJetPatRecoProducer.cc:100
fftjetcms::FFTJetInterface::outputLabel
const std::string outputLabel
Definition: FFTJetInterface.h:76
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
FFTJetPatRecoProducer::completeEventDataCutoff
const double completeEventDataCutoff
Definition: FFTJetPatRecoProducer.cc:123
fftjetcms::fftjet_ScaleSet_parser
std::unique_ptr< std::vector< double > > fftjet_ScaleSet_parser(const edm::ParameterSet &ps)
Definition: FFTJetParameterParser.cc:350
FFTJetPatRecoProducer::sparseTree
SparseTree sparseTree
Definition: FFTJetPatRecoProducer.cc:118
tree
Definition: tree.py:1
FFTJetPatRecoProducer::verifyDataConversion
const bool verifyDataConversion
Definition: FFTJetPatRecoProducer.cc:130
FFTJetPatRecoProducer::distanceCalc
std::unique_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > distanceCalc
Definition: FFTJetPatRecoProducer.cc:115
fftjeteflowsmoother_cfi.convolverMaxBin
convolverMaxBin
Definition: fftjeteflowsmoother_cfi.py:21
cms::cuda::assert
assert(be >=bs)
fftjetcms::FFTJetInterface::getEventScale
double getEventScale() const
Definition: FFTJetInterface.cc:38
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
fftjetpatrecoproducer_cfi.minAdaptiveRatioLog
minAdaptiveRatioLog
Definition: fftjetpatrecoproducer_cfi.py:84
FFTJetPatRecoProducer::buildPeakFinder
fftjet::PeakFinder buildPeakFinder(const edm::ParameterSet &)
Definition: FFTJetPatRecoProducer.cc:306
fftjetcms::densePeakTreeFromStorable
void densePeakTreeFromStorable(const reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > &in, const std::vector< double > *scaleSetIfNotAdaptive, double completeEventScale, fftjet::AbsClusteringTree< fftjet::Peak, long > *out)
Definition: clusteringTreeConverters.h:271
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
FFTJetPatRecoProducer::kernel2d
std::unique_ptr< fftjet::AbsFrequencyKernel > kernel2d
Definition: FFTJetPatRecoProducer.cc:104
fftjetpatrecoproducer_cfi.SparsifierConfiguration
SparsifierConfiguration
Definition: fftjetpatrecoproducer_cfi.py:115
fftjeteflowsmoother_cfi.kernelEtaScale
kernelEtaScale
Definition: fftjeteflowsmoother_cfi.py:11
FFTJetPatRecoProducer::etaKernel
std::unique_ptr< fftjet::AbsFrequencyKernel1d > etaKernel
Definition: FFTJetPatRecoProducer.cc:105
FFTJetPatRecoProducer::SparseTree
fftjet::SparseClusteringTree< fftjet::Peak, long > SparseTree
Definition: FFTJetPatRecoProducer.cc:72
FFTJetPatRecoProducer::convolver
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
Definition: FFTJetPatRecoProducer.cc:109
FFTJetPatRecoProducer::ClusteringTree
fftjet::ProximityClusteringTree< fftjet::Peak, long > ClusteringTree
Definition: FFTJetPatRecoProducer.cc:71
fftjetcms::sparsePeakTreeToStorable
void sparsePeakTreeToStorable(const fftjet::SparseClusteringTree< fftjet::Peak, long > &in, bool writeOutScaleInfo, reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > *out)
Definition: clusteringTreeConverters.h:75
fftjetpatrecoproducer_cfi.peakFinderMaxEta
peakFinderMaxEta
Definition: fftjetpatrecoproducer_cfi.py:36
fftjetcms::sparsePeakTreeFromStorable
void sparsePeakTreeFromStorable(const reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > &in, const std::vector< double > *scaleSetIfNotAdaptive, double completeEventScale, fftjet::SparseClusteringTree< fftjet::Peak, long > *out)
Definition: clusteringTreeConverters.h:133
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FFTJetPatRecoProducer::clusteringTree
ClusteringTree * clusteringTree
Definition: FFTJetPatRecoProducer.cc:91
fftjetcms::fftjet_ClusteringTreeSparsifier_parser
std::unique_ptr< fftjet::ClusteringTreeSparsifier< fftjet::Peak, long > > fftjet_ClusteringTreeSparsifier_parser(const edm::ParameterSet &ps)
Definition: FFTJetParameterParser.cc:392
FFTJetPatRecoProducer::buildKernelConvolver
void buildKernelConvolver(const edm::ParameterSet &)
Definition: FFTJetPatRecoProducer.cc:239
reco::PattRecoTree
Class for storing FFTJet sparse clustering trees.
Definition: PattRecoTree.h:20
edm::ParameterSet
Definition: ParameterSet.h:47
FFTJetPatRecoProducer::peakSelector
std::unique_ptr< fftjet::Functor1< bool, fftjet::Peak > > peakSelector
Definition: FFTJetPatRecoProducer.cc:112
FFTJetPatRecoProducer::extGrid
fftjet::Grid2d< float > * extGrid
Definition: FFTJetPatRecoProducer.cc:146
FFTJetPatRecoProducer::storeGridsExternally
bool storeGridsExternally
Definition: FFTJetPatRecoProducer.cc:145
FFTJetPatRecoProducer::anotherEngine
std::unique_ptr< MyFFTEngine > anotherEngine
Definition: FFTJetPatRecoProducer.cc:101
cms::cuda::allocator::maxBin
constexpr unsigned int maxBin
Definition: getCachingDeviceAllocator.h:20
iEvent
int iEvent
Definition: GenABIO.cc:224
fftjetcms::FFTJetInterface::energyFlow
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
Definition: FFTJetInterface.h:100
FFTJetPatRecoProducer::makeClusteringTree
const bool makeClusteringTree
Definition: FFTJetPatRecoProducer.cc:126
FFTJetPatRecoProducer::sequencer
std::unique_ptr< Sequencer > sequencer
Definition: FFTJetPatRecoProducer.cc:96
M_PI
#define M_PI
Definition: BXVectorInputProducer.cc:49
fftjetcms::FFTJetInterface::storeInSinglePrecision
bool storeInSinglePrecision() const
Definition: FFTJetInterface.cc:15
FFTJetPatRecoProducer::storeDiscretizationGrid
const bool storeDiscretizationGrid
Definition: FFTJetPatRecoProducer.cc:133
fftjetcms::fftjet_Grid2d_parser
std::unique_ptr< fftjet::Grid2d< Real > > fftjet_Grid2d_parser(const edm::ParameterSet &ps)
Definition: FFTJetParameterParser.cc:125
fftjeteflowsmoother_cfi.convolverMinBin
convolverMinBin
Definition: fftjeteflowsmoother_cfi.py:20
fftjeteflowsmoother_cfi.fixEfficiency
fixEfficiency
Definition: fftjeteflowsmoother_cfi.py:15
fftjeteflowsmoother_cfi.kernelPhiScale
kernelPhiScale
Definition: fftjeteflowsmoother_cfi.py:12
fftjetcommon_cfi.flow
flow
Definition: fftjetcommon_cfi.py:191
eostools.move
def move(src, dest)
Definition: eostools.py:511
fftjetcms::copy_Grid2d_data
void copy_Grid2d_data(fftjet::Grid2d< F2 > *to, const fftjet::Grid2d< F1 > &from)
Definition: gridConverters.h:39
fftjetpatrecoproducer_cfi.maxAdaptiveScales
maxAdaptiveScales
Definition: fftjetpatrecoproducer_cfi.py:79
FFTJetPatRecoProducer::sparsifier
std::unique_ptr< Sparsifier > sparsifier
Definition: FFTJetPatRecoProducer.cc:97
fftjetdijetfilter_cfi.TreeDistanceCalculator
TreeDistanceCalculator
Definition: fftjetdijetfilter_cfi.py:25
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
Exception
Definition: hltDiff.cc:246
FFTJetPatRecoProducer::externalGridStream
std::ofstream externalGridStream
Definition: FFTJetPatRecoProducer.cc:144
fftjetcms::convert_Grid2d_to_float
fftjet::Grid2d< float > * convert_Grid2d_to_float(const fftjet::Grid2d< Numeric > &grid)
Definition: gridConverters.h:63
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
fftjetpatrecoproducer_cfi.externalGridFile
externalGridFile
Definition: fftjetpatrecoproducer_cfi.py:32
fftjetcms::FFTJetInterface::discretizeEnergyFlow
void discretizeEnergyFlow()
Definition: FFTJetInterface.cc:79
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
cms::Exception
Definition: Exception.h:70
fftjeteflowsmoother_cfi.etaDependentScaleFactors
etaDependentScaleFactors
Definition: fftjeteflowsmoother_cfi.py:42
fftjetcms::fftjet_DistanceCalculator_parser
std::unique_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > fftjet_DistanceCalculator_parser(const edm::ParameterSet &ps)
Definition: FFTJetParameterParser.cc:404
fftjetcms::fftjet_PeakSelector_parser
std::unique_ptr< fftjet::Functor1< bool, fftjet::Peak > > fftjet_PeakSelector_parser(const edm::ParameterSet &ps)
Definition: FFTJetParameterParser.cc:166
g
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
FFTJetPatRecoProducer::sparsify
const bool sparsify
Definition: FFTJetPatRecoProducer.cc:136