CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | 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 ()=delete
 
 FFTJetPatRecoProducer (const FFTJetPatRecoProducer &)=delete
 
FFTJetPatRecoProduceroperator= (const FFTJetPatRecoProducer &)=delete
 
 ~FFTJetPatRecoProducer () override
 
- Public Member Functions inherited from fftjetcms::FFTJetInterface
 FFTJetInterface ()=delete
 
 FFTJetInterface (const FFTJetInterface &)=delete
 
FFTJetInterfaceoperator= (const FFTJetInterface &)=delete
 
 ~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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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 selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
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
< 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::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
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...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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::VectorLike
eventData
 
edm::Handle< reco::CandidateViewinputCollection
 
const edm::InputTag inputLabel
 
const JetType jetType
 
const std::string outputLabel
 
const edm::InputTag srcPVs
 

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

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

Definition at line 74 of file FFTJetPatRecoProducer.cc.

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

Definition at line 76 of file FFTJetPatRecoProducer.cc.

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

Definition at line 75 of file FFTJetPatRecoProducer.cc.

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

Definition at line 77 of file FFTJetPatRecoProducer.cc.

Constructor & Destructor Documentation

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

Definition at line 151 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(), mps_fire::i, makeClusteringTree, submitPVResolutionJobs::out, fftjetcms::FFTJetInterface::outputLabel, peakSelector, sequencer, sparsifier, storeDiscretizationGrid, storeGridsExternally, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and AlCaHLTBitMon_QueryRunRegistry::string.

152  : FFTJetInterface(ps),
153  clusteringTree(nullptr),
154  completeEventDataCutoff(ps.getParameter<double>("completeEventDataCutoff")),
155  makeClusteringTree(ps.getParameter<bool>("makeClusteringTree")),
156  verifyDataConversion(ps.getUntrackedParameter<bool>("verifyDataConversion", false)),
157  storeDiscretizationGrid(ps.getParameter<bool>("storeDiscretizationGrid")),
158  sparsify(ps.getParameter<bool>("sparsify")),
159  extGrid(nullptr) {
160  // register your products
161  if (makeClusteringTree) {
163  produces<reco::PattRecoTree<float, reco::PattRecoPeak<float> > >(outputLabel);
164  else
165  produces<reco::PattRecoTree<double, reco::PattRecoPeak<double> > >(outputLabel);
166  }
168  produces<reco::DiscretizedEnergyFlow>(outputLabel);
169 
170  // Check if we want to write the grids into an external file
171  const std::string externalGridFile(ps.getParameter<std::string>("externalGridFile"));
172  storeGridsExternally = !externalGridFile.empty();
173  if (storeGridsExternally) {
174  externalGridStream.open(externalGridFile.c_str(), std::ios_base::out | std::ios_base::binary);
175  if (!externalGridStream.is_open())
176  throw cms::Exception("FFTJetBadConfig")
177  << "FFTJetPatRecoProducer failed to open file " << externalGridFile << std::endl;
178  }
179 
181  throw cms::Exception("FFTJetBadConfig")
182  << "FFTJetPatRecoProducer is not configured to produce anything" << std::endl;
183  }
184 
185  // now do whatever other initialization is needed
186 
187  // Build the discretization grid
189  checkConfig(energyFlow, "invalid discretization grid");
190 
191  // Build the FFT engine(s), pattern recognition kernel(s),
192  // and the kernel convolver
194 
195  // Build the peak selector
196  peakSelector = fftjet_PeakSelector_parser(ps.getParameter<edm::ParameterSet>("PeakSelectorConfiguration"));
197  checkConfig(peakSelector, "invalid peak selector");
198 
199  // Build the initial set of pattern recognition scales
200  std::unique_ptr<std::vector<double> > iniScales =
202  checkConfig(iniScales, "invalid set of scales");
203 
204  // Do we want to use the adaptive clustering tree algorithm?
205  const unsigned maxAdaptiveScales = ps.getParameter<unsigned>("maxAdaptiveScales");
206  const double minAdaptiveRatioLog = ps.getParameter<double>("minAdaptiveRatioLog");
207  if (minAdaptiveRatioLog <= 0.0)
208  throw cms::Exception("FFTJetBadConfig") << "bad adaptive ratio logarithm limit" << std::endl;
209 
210  // Make sure that all standard scales are larger than the
211  // complete event scale
212  if (getEventScale() > 0.0) {
213  const double cs = getEventScale();
214  const unsigned nscales = iniScales->size();
215  for (unsigned i = 0; i < nscales; ++i)
216  if (cs >= (*iniScales)[i])
217  throw cms::Exception("FFTJetBadConfig") << "incompatible scale for complete event" << std::endl;
218  }
219 
220  // At this point we are ready to build the clustering sequencer
221  sequencer = std::make_unique<Sequencer>(
222  convolver.get(), peakSelector.get(), buildPeakFinder(ps), *iniScales, maxAdaptiveScales, minAdaptiveRatioLog);
223 
224  // Build the clustering tree sparsifier
225  const edm::ParameterSet& SparsifierConfiguration(ps.getParameter<edm::ParameterSet>("SparsifierConfiguration"));
226  sparsifier = fftjet_ClusteringTreeSparsifier_parser(SparsifierConfiguration);
227  checkConfig(sparsifier, "invalid sparsifier parameters");
228 
229  // Build the distance calculator for the clustering tree
230  const edm::ParameterSet& TreeDistanceCalculator(ps.getParameter<edm::ParameterSet>("TreeDistanceCalculator"));
231  distanceCalc = fftjet_DistanceCalculator_parser(TreeDistanceCalculator);
232  checkConfig(distanceCalc, "invalid tree distance calculator");
233 
234  // Build the clustering tree itself
236 }
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< Sparsifier > sparsifier
unique_ptr< ClusterSequence > cs
void buildKernelConvolver(const edm::ParameterSet &)
void checkConfig(const Ptr &ptr, const char *message)
std::unique_ptr< fftjet::Grid2d< Real > > fftjet_Grid2d_parser(const edm::ParameterSet &ps)
std::unique_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > distanceCalc
std::unique_ptr< Sequencer > sequencer
std::unique_ptr< fftjet::Functor1< bool, fftjet::Peak > > peakSelector
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
ClusteringTree * clusteringTree
std::unique_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > fftjet_DistanceCalculator_parser(const edm::ParameterSet &ps)
bool storeInSinglePrecision() const
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
fftjet::PeakFinder buildPeakFinder(const edm::ParameterSet &)
std::unique_ptr< fftjet::Functor1< bool, fftjet::Peak > > fftjet_PeakSelector_parser(const edm::ParameterSet &ps)
std::unique_ptr< fftjet::ClusteringTreeSparsifier< fftjet::Peak, long > > fftjet_ClusteringTreeSparsifier_parser(const edm::ParameterSet &ps)
fftjet::ProximityClusteringTree< fftjet::Peak, long > ClusteringTree
fftjet::Grid2d< float > * extGrid
std::unique_ptr< std::vector< double > > fftjet_ScaleSet_parser(const edm::ParameterSet &ps)
const std::string outputLabel
FFTJetPatRecoProducer::FFTJetPatRecoProducer ( )
delete
FFTJetPatRecoProducer::FFTJetPatRecoProducer ( const FFTJetPatRecoProducer )
delete
FFTJetPatRecoProducer::~FFTJetPatRecoProducer ( )
override

Definition at line 319 of file FFTJetPatRecoProducer.cc.

References clusteringTree, and extGrid.

319  {
320  // do anything here that needs to be done at desctruction time
321  // (e.g. close files, deallocate resources etc.)
322  delete clusteringTree;
323  delete extGrid;
324 }
ClusteringTree * clusteringTree
fftjet::Grid2d< float > * extGrid

Member Function Documentation

void FFTJetPatRecoProducer::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 428 of file FFTJetPatRecoProducer.cc.

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

Definition at line 350 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(), MainPageGenerator::tree, and verifyDataConversion.

350  {
352 
353  auto tree = std::make_unique<StoredTree>();
354 
355  densePeakTreeToStorable(*clusteringTree, sequencer->maxAdaptiveScales(), tree.get());
356 
357  // Check that we can restore the tree
360  const std::vector<double>& scalesUsed(sequencer->getInitialScales());
362  if (*clusteringTree != check)
363  throw cms::Exception("FFTJetInterface") << "Data conversion failed for dense clustering tree" << std::endl;
364  }
365 
367 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Class for storing FFTJet sparse clustering trees.
Definition: PattRecoTree.h:20
std::unique_ptr< fftjet::AbsDistanceCalculator< fftjet::Peak > > distanceCalc
std::unique_ptr< Sequencer > sequencer
ClusteringTree * clusteringTree
def move
Definition: eostools.py:511
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)
fftjet::ProximityClusteringTree< fftjet::Peak, long > ClusteringTree
const std::string outputLabel
void FFTJetPatRecoProducer::buildKernelConvolver ( const edm::ParameterSet ps)
protected

Definition at line 238 of file FFTJetPatRecoProducer.cc.

References anotherEngine, convolver, fftjetcms::FFTJetInterface::energyFlow, engine, etaKernel, Exception, edm::ParameterSet::getParameter(), kernel2d, M_PI, and phiKernel.

Referenced by FFTJetPatRecoProducer().

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

Definition at line 305 of file FFTJetPatRecoProducer.cc.

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

Referenced by FFTJetPatRecoProducer().

305  {
306  const double peakFinderMaxEta = ps.getParameter<double>("peakFinderMaxEta");
307  if (peakFinderMaxEta <= 0.0)
308  throw cms::Exception("FFTJetBadConfig") << "invalid peak finder eta cut" << std::endl;
309  const double maxMagnitude = ps.getParameter<double>("peakFinderMaxMagnitude");
310  int minBin = energyFlow->getEtaBin(-peakFinderMaxEta);
311  if (minBin < 0)
312  minBin = 0;
313  int maxBin = energyFlow->getEtaBin(peakFinderMaxEta) + 1;
314  if (maxBin < 0)
315  maxBin = 0;
316  return fftjet::PeakFinder(maxMagnitude, true, minBin, maxBin);
317 }
constexpr unsigned int maxBin
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
constexpr unsigned int minBin
template<class Real >
void FFTJetPatRecoProducer::buildSparseProduct ( edm::Event ev) const
protected

Definition at line 330 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(), MainPageGenerator::tree, and verifyDataConversion.

330  {
332 
333  auto tree = std::make_unique<StoredTree>();
334 
335  sparsePeakTreeToStorable(sparseTree, sequencer->maxAdaptiveScales(), tree.get());
336 
337  // Check that we can restore the tree
340  const std::vector<double>& scalesUsed(sequencer->getInitialScales());
341  sparsePeakTreeFromStorable(*tree, &scalesUsed, getEventScale(), &check);
342  if (sparseTree != check)
343  throw cms::Exception("FFTJetInterface") << "Data conversion failed for sparse clustering tree" << std::endl;
344  }
345 
347 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
Class for storing FFTJet sparse clustering trees.
Definition: PattRecoTree.h:20
fftjet::SparseClusteringTree< fftjet::Peak, long > SparseTree
std::unique_ptr< Sequencer > sequencer
void sparsePeakTreeToStorable(const fftjet::SparseClusteringTree< fftjet::Peak, long > &in, bool writeOutScaleInfo, reco::PattRecoTree< Real, reco::PattRecoPeak< Real > > *out)
def move
Definition: eostools.py:511
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)
const std::string outputLabel
void FFTJetPatRecoProducer::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 431 of file FFTJetPatRecoProducer.cc.

References externalGridStream, and storeGridsExternally.

431  {
433  externalGridStream.close();
434 }
FFTJetPatRecoProducer& FFTJetPatRecoProducer::operator= ( const FFTJetPatRecoProducer )
delete
void FFTJetPatRecoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotectedvirtual

Implements edm::EDProducer.

Definition at line 370 of file FFTJetPatRecoProducer.cc.

References cms::cuda::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, eostools::move(), fftjetcms::FFTJetInterface::outputLabel, edm::Event::put(), sequencer, sparseTree, sparsifier, sparsify, storeDiscretizationGrid, storeGridsExternally, fftjetcms::FFTJetInterface::storeInSinglePrecision(), and verifyDataConversion.

370  {
371  loadInputCollection(iEvent);
373 
374  if (makeClusteringTree) {
376  if (getEventScale() > 0.0)
378 
379  if (sparsify) {
380  sparsifier->sparsify(*clusteringTree, &sparseTree);
381 
382  // Do not call the "sortNodes" method of the sparse tree here.
383  // Currently, the nodes are sorted by daughter number.
384  // This is the way we want it in storage because the stored
385  // tree does not include daughter ordering info explicitly.
386 
388  buildSparseProduct<float>(iEvent);
389  else
390  buildSparseProduct<double>(iEvent);
391  } else {
393  buildDenseProduct<float>(iEvent);
394  else
395  buildDenseProduct<double>(iEvent);
396  }
397  }
398 
400  const fftjet::Grid2d<Real>& g(*energyFlow);
401 
402  auto flow = std::make_unique<reco::DiscretizedEnergyFlow>(
403  g.data(), g.title(), g.etaMin(), g.etaMax(), g.phiBin0Edge(), g.nEta(), g.nPhi());
404 
405  if (verifyDataConversion) {
406  fftjet::Grid2d<Real> check(
407  flow->nEtaBins(), flow->etaMin(), flow->etaMax(), flow->nPhiBins(), flow->phiBin0Edge(), flow->title());
408  check.blockSet(flow->data(), flow->nEtaBins(), flow->nPhiBins());
409  assert(g == check);
410  }
411 
412  iEvent.put(std::move(flow), outputLabel);
413  }
414 
415  if (storeGridsExternally) {
416  if (extGrid)
418  else
420  if (!extGrid->write(externalGridStream)) {
421  throw cms::Exception("FFTJetPatRecoProducer::produce")
422  << "Failed to write grid data into an external file" << std::endl;
423  }
424  }
425 }
fftjet::Grid2d< float > * convert_Grid2d_to_float(const fftjet::Grid2d< Numeric > &grid)
std::unique_ptr< Sparsifier > sparsifier
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
void loadInputCollection(const edm::Event &)
assert(be >=bs)
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
std::unique_ptr< Sequencer > sequencer
int iEvent
Definition: GenABIO.cc:224
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
ClusteringTree * clusteringTree
def move
Definition: eostools.py:511
bool storeInSinglePrecision() const
void copy_Grid2d_data(fftjet::Grid2d< F2 > *to, const fftjet::Grid2d< F1 > &from)
fftjet::Grid2d< float > * extGrid
const std::string outputLabel

Member Data Documentation

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

Definition at line 104 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

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

Definition at line 126 of file FFTJetPatRecoProducer.cc.

Referenced by produce().

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

Definition at line 112 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver(), and FFTJetPatRecoProducer().

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

Definition at line 118 of file FFTJetPatRecoProducer.cc.

Referenced by buildDenseProduct(), and FFTJetPatRecoProducer().

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

Definition at line 103 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

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

Definition at line 108 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

std::ofstream FFTJetPatRecoProducer::externalGridStream
private

Definition at line 143 of file FFTJetPatRecoProducer.cc.

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

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

Definition at line 145 of file FFTJetPatRecoProducer.cc.

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

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

Definition at line 107 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

const bool FFTJetPatRecoProducer::makeClusteringTree
protected

Definition at line 129 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

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

Definition at line 115 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer().

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

Definition at line 109 of file FFTJetPatRecoProducer.cc.

Referenced by buildKernelConvolver().

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

Definition at line 121 of file FFTJetPatRecoProducer.cc.

Referenced by buildSparseProduct(), and produce().

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

Definition at line 100 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

const bool FFTJetPatRecoProducer::sparsify
protected

Definition at line 139 of file FFTJetPatRecoProducer.cc.

Referenced by produce().

const bool FFTJetPatRecoProducer::storeDiscretizationGrid
protected

Definition at line 136 of file FFTJetPatRecoProducer.cc.

Referenced by FFTJetPatRecoProducer(), and produce().

bool FFTJetPatRecoProducer::storeGridsExternally
private

Definition at line 144 of file FFTJetPatRecoProducer.cc.

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

const bool FFTJetPatRecoProducer::verifyDataConversion
protected

Definition at line 133 of file FFTJetPatRecoProducer.cc.

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