CMS 3D CMS Logo

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

#include <RecoJets/FFTJetProducers/plugins/FFTJetPileupProcessor.cc>

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

Public Member Functions

 FFTJetPileupProcessor (const edm::ParameterSet &)
 
 FFTJetPileupProcessor ()=delete
 
 FFTJetPileupProcessor (const FFTJetPileupProcessor &)=delete
 
FFTJetPileupProcessoroperator= (const FFTJetPileupProcessor &)=delete
 
 ~FFTJetPileupProcessor () 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
 
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 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 Member Functions

void beginJob () override
 
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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
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< Bconsumes (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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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)
 

Private Member Functions

void buildKernelConvolver (const edm::ParameterSet &)
 
void loadFlatteningFactors (const edm::EventSetup &iSetup)
 
void mixExtraGrid ()
 

Private Attributes

std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > convolvedFlow
 
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
 
unsigned convolverMaxBin
 
unsigned convolverMinBin
 
unsigned currentFileNum
 
std::unique_ptr< MyFFTEngineengine
 
std::vector< double > etaFlatteningFactors
 
std::vector< std::string > externalGridFiles
 
double externalGridMaxEnergy
 
std::unique_ptr< fftjet::EquidistantInLogSpace > filterScales
 
std::string flatteningTableCategory
 
std::string flatteningTableName
 
std::string flatteningTableRecord
 
std::ifstream gridStream
 
std::unique_ptr< fftjet::AbsFrequencyKernel > kernel2d
 
bool loadFlatteningFactorsFromDB
 
unsigned nPercentiles
 
std::vector< double > percentileData
 
double pileupEtaPhiArea
 

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

Detailed Description

Description: Runs FFTJet multiscale pileup filtering code and saves the results

Implementation: [Notes on implementation]

Definition at line 53 of file FFTJetPileupProcessor.cc.

Constructor & Destructor Documentation

◆ FFTJetPileupProcessor() [1/3]

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

Definition at line 123 of file FFTJetPileupProcessor.cc.

References buildKernelConvolver(), fftjetcms::FFTJetInterface::checkConfig(), convolvedFlow, fftjetcms::FFTJetInterface::energyFlow, etaFlatteningFactors, Exception, fftjetcms::fftjet_Grid2d_parser(), filterScales, edm::ParameterSet::getParameter(), fftjetcommon_cfi::maxScale, fftjetcommon_cfi::minScale, nPercentiles, fftjetcommon_cfi::nScales, fftjetcms::FFTJetInterface::outputLabel, percentileData, and mitigatedMETSequence_cff::U.

124  : FFTJetInterface(ps),
125  etaFlatteningFactors(ps.getParameter<std::vector<double>>("etaFlatteningFactors")),
126  nPercentiles(ps.getParameter<unsigned>("nPercentiles")),
127  convolverMinBin(ps.getParameter<unsigned>("convolverMinBin")),
128  convolverMaxBin(ps.getParameter<unsigned>("convolverMaxBin")),
129  pileupEtaPhiArea(ps.getParameter<double>("pileupEtaPhiArea")),
130  externalGridFiles(ps.getParameter<std::vector<std::string>>("externalGridFiles")),
131  externalGridMaxEnergy(ps.getParameter<double>("externalGridMaxEnergy")),
133  flatteningTableRecord(ps.getParameter<std::string>("flatteningTableRecord")),
134  flatteningTableName(ps.getParameter<std::string>("flatteningTableName")),
135  flatteningTableCategory(ps.getParameter<std::string>("flatteningTableCategory")),
136  loadFlatteningFactorsFromDB(ps.getParameter<bool>("loadFlatteningFactorsFromDB")) {
137  // Build the discretization grid
139  checkConfig(energyFlow, "invalid discretization grid");
140 
141  // Copy of the grid which will be used for convolutions
142  convolvedFlow = std::make_unique<fftjet::Grid2d<fftjetcms::Real>>(*energyFlow);
143 
144  // Make sure the size of flattening factors is appropriate
145  if (!etaFlatteningFactors.empty()) {
146  if (etaFlatteningFactors.size() != convolvedFlow->nEta())
147  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetPileupProcessor constructor:"
148  " number of elements in the \"etaFlatteningFactors\""
149  " vector is inconsistent with the discretization grid binning"
150  << std::endl;
151  }
152 
153  // Build the FFT engine(s), pattern recognition kernel(s),
154  // and the kernel convolver
156 
157  // Build the set of pattern recognition scales
158  const unsigned nScales = ps.getParameter<unsigned>("nScales");
159  const double minScale = ps.getParameter<double>("minScale");
160  const double maxScale = ps.getParameter<double>("maxScale");
161  if (minScale <= 0.0 || maxScale < minScale || nScales == 0U)
162  throw cms::Exception("FFTJetBadConfig") << "invalid filter scales" << std::endl;
163 
164  filterScales = std::make_unique<fftjet::EquidistantInLogSpace>(minScale, maxScale, nScales);
165 
167 
168  produces<reco::DiscretizedEnergyFlow>(outputLabel);
169  produces<std::pair<double, double>>(outputLabel);
170 }
std::vector< std::string > externalGridFiles
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
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::Grid2d< fftjetcms::Real > > convolvedFlow
std::vector< double > percentileData
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
std::unique_ptr< fftjet::EquidistantInLogSpace > filterScales
void buildKernelConvolver(const edm::ParameterSet &)
std::vector< double > etaFlatteningFactors
const std::string outputLabel

◆ FFTJetPileupProcessor() [2/3]

FFTJetPileupProcessor::FFTJetPileupProcessor ( )
delete

◆ FFTJetPileupProcessor() [3/3]

FFTJetPileupProcessor::FFTJetPileupProcessor ( const FFTJetPileupProcessor )
delete

◆ ~FFTJetPileupProcessor()

FFTJetPileupProcessor::~FFTJetPileupProcessor ( )
override

Definition at line 199 of file FFTJetPileupProcessor.cc.

199 {}

Member Function Documentation

◆ beginJob()

void FFTJetPileupProcessor::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 321 of file FFTJetPileupProcessor.cc.

321 {}

◆ buildKernelConvolver()

void FFTJetPileupProcessor::buildKernelConvolver ( const edm::ParameterSet ps)
private

Definition at line 172 of file FFTJetPileupProcessor.cc.

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

Referenced by FFTJetPileupProcessor().

172  {
173  // Get the eta and phi scales for the kernel(s)
174  double kernelEtaScale = ps.getParameter<double>("kernelEtaScale");
175  const double kernelPhiScale = ps.getParameter<double>("kernelPhiScale");
176  if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
177  throw cms::Exception("FFTJetBadConfig") << "invalid kernel scales" << std::endl;
178 
181  throw cms::Exception("FFTJetBadConfig") << "invalid convolver bin range" << std::endl;
182 
183  // FFT assumes that the grid extent in eta is 2*Pi. Adjust the
184  // kernel scale in eta to compensate.
185  kernelEtaScale *= (2.0 * M_PI / (energyFlow->etaMax() - energyFlow->etaMin()));
186 
187  // Build the FFT engine
188  engine = std::make_unique<MyFFTEngine>(energyFlow->nEta(), energyFlow->nPhi());
189 
190  // 2d kernel
191  kernel2d = std::unique_ptr<fftjet::AbsFrequencyKernel>(
192  new fftjet::DiscreteGauss2d(kernelEtaScale, kernelPhiScale, energyFlow->nEta(), energyFlow->nPhi()));
193 
194  // 2d convolver
195  convolver = std::unique_ptr<fftjet::AbsConvolverBase<Real>>(new fftjet::FrequencyKernelConvolver<Real, Complex>(
197 }
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
std::unique_ptr< MyFFTEngine > engine
#define M_PI
std::unique_ptr< fftjet::AbsFrequencyKernel > kernel2d

◆ endJob()

void FFTJetPileupProcessor::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 324 of file FFTJetPileupProcessor.cc.

324 {}

◆ loadFlatteningFactors()

void FFTJetPileupProcessor::loadFlatteningFactors ( const edm::EventSetup iSetup)
private

Definition at line 326 of file FFTJetPileupProcessor.cc.

References fftjetcms::FFTJetInterface::energyFlow, PVValHelper::eta, etaFlatteningFactors, f, flatteningTableCategory, flatteningTableName, flatteningTableRecord, h, LEDCalibrationChannels::ieta, StaticFFTJetRcdMapper< Mapper >::instance(), HLT_2022v11_cff::nEta, and mitigatedMETSequence_cff::U.

Referenced by produce().

326  {
329  std::shared_ptr<npstat::StorableMultivariateFunctor> f = (*h)[flatteningTableCategory][flatteningTableName];
330 
331  // Fill out the table of flattening factors as a function of eta
332  const unsigned nEta = energyFlow->nEta();
333  etaFlatteningFactors.clear();
334  etaFlatteningFactors.reserve(nEta);
335  for (unsigned ieta = 0; ieta < nEta; ++ieta) {
336  const double eta = energyFlow->etaBinCenter(ieta);
337  etaFlatteningFactors.push_back((*f)(&eta, 1U));
338  }
339 }
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
double f[11][100]
std::vector< double > etaFlatteningFactors
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
static const Mapper & instance()

◆ mixExtraGrid()

void FFTJetPileupProcessor::mixExtraGrid ( )
private

Definition at line 267 of file FFTJetPileupProcessor.cc.

References fftjetcms::add_Grid2d_data(), currentFileNum, fftjetcms::FFTJetInterface::energyFlow, Exception, externalGridFiles, externalGridMaxEnergy, g, gridStream, recoMuon::in, cmsBatch::nFiles, mergeAndRegister::ntries, fileinputsource_cfi::read, and mitigatedMETSequence_cff::U.

Referenced by produce().

267  {
268  const unsigned nFiles = externalGridFiles.size();
269  if (currentFileNum > nFiles) {
270  // This is the first time this function is called
271  currentFileNum = 0;
272  gridStream.open(externalGridFiles[currentFileNum].c_str(), std::ios_base::in | std::ios_base::binary);
273  if (!gridStream.is_open())
274  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetPileupProcessor::mixExtraGrid():"
275  " failed to open external grid file "
276  << externalGridFiles[currentFileNum] << std::endl;
277  }
278 
279  const fftjet::Grid2d<float>* g = nullptr;
280  const unsigned maxFail = 100U;
281  unsigned nEnergyRejected = 0;
282 
283  while (!g) {
285 
286  // If we can't read the grid, we need to switch to another file
287  for (unsigned ntries = 0; ntries < nFiles && g == nullptr; ++ntries) {
288  gridStream.close();
290  gridStream.open(externalGridFiles[currentFileNum].c_str(), std::ios_base::in | std::ios_base::binary);
291  if (!gridStream.is_open())
292  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetPileupProcessor::mixExtraGrid():"
293  " failed to open external grid file "
294  << externalGridFiles[currentFileNum] << std::endl;
296  }
297 
298  if (g)
299  if (g->sum() > externalGridMaxEnergy) {
300  delete g;
301  g = nullptr;
302  if (++nEnergyRejected >= maxFail)
303  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetPileupProcessor::mixExtraGrid():"
304  " too many grids in a row ("
305  << nEnergyRejected << ") failed the maximum energy cut" << std::endl;
306  }
307  }
308 
309  if (g) {
310  add_Grid2d_data(energyFlow.get(), *g);
311  delete g;
312  } else {
313  // Too bad, no useful file found
314  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetPileupProcessor::mixExtraGrid():"
315  " no valid grid records found"
316  << std::endl;
317  }
318 }
std::vector< std::string > externalGridFiles
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< fftjet::Grid2d< fftjetcms::Real > > energyFlow
void add_Grid2d_data(fftjet::Grid2d< F2 > *to, const fftjet::Grid2d< F1 > &from)

◆ operator=()

FFTJetPileupProcessor& FFTJetPileupProcessor::operator= ( const FFTJetPileupProcessor )
delete

◆ produce()

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

Implements edm::EDProducer.

Definition at line 202 of file FFTJetPileupProcessor.cc.

References convolvedFlow, convolver, convolverMaxBin, convolverMinBin, fftjetcms::FFTJetInterface::discretizeEnergyFlow(), fftjetcms::FFTJetInterface::energyFlow, etaFlatteningFactors, externalGridFiles, filterScales, g, iEvent, loadFlatteningFactors(), loadFlatteningFactorsFromDB, fftjetcms::FFTJetInterface::loadInputCollection(), mixExtraGrid(), nPercentiles, fftjetcommon_cfi::nScales, fftjetcms::FFTJetInterface::outputLabel, percentileData, pileupEtaPhiArea, submitPVResolutionJobs::q, jetUpdater_cfi::sort, and mitigatedMETSequence_cff::U.

202  {
205 
206  // Determine the average Et density for this event.
207  // Needs to be done here, before mixing in another grid.
208  const fftjet::Grid2d<Real>& g(*energyFlow);
209  const double densityBeforeMixing = g.sum() / pileupEtaPhiArea;
210 
211  // Mix an extra grid (if requested)
212  double densityAfterMixing = -1.0;
213  if (!externalGridFiles.empty()) {
214  mixExtraGrid();
215  densityAfterMixing = g.sum() / pileupEtaPhiArea;
216  }
217 
218  // Various useful variables
219  const unsigned nScales = filterScales->size();
220  const double* scales = &(*filterScales)[0];
221  Real* convData = const_cast<Real*>(convolvedFlow->data());
222  Real* sortData = convData + convolverMinBin * convolvedFlow->nPhi();
223  const unsigned dataLen = convolverMaxBin ? (convolverMaxBin - convolverMinBin) * convolvedFlow->nPhi()
224  : convolvedFlow->nEta() * convolvedFlow->nPhi();
225 
226  // Load flattenning factors from DB (if requested)
228  loadFlatteningFactors(iSetup);
229 
230  // Go over all scales and perform the convolutions
231  convolver->setEventData(g.data(), g.nEta(), g.nPhi());
232  for (unsigned iscale = 0; iscale < nScales; ++iscale) {
233  // Perform the convolution
234  convolver->convolveWithKernel(scales[iscale], convData, convolvedFlow->nEta(), convolvedFlow->nPhi());
235 
236  // Apply the flattening factors
237  if (!etaFlatteningFactors.empty())
239 
240  // Sort the convolved data
241  std::sort(sortData, sortData + dataLen);
242 
243  // Determine the percentile points
244  for (unsigned iper = 0; iper < nPercentiles; ++iper) {
245  // Map percentile 0 into point number 0,
246  // 1 into point number dataLen-1
247  const double q = (iper + 0.5) / nPercentiles;
248  const double dindex = q * (dataLen - 1U);
249  const unsigned ilow = static_cast<unsigned>(std::floor(dindex));
250  const double percentile =
251  fftjet::lin_interpolate_1d(ilow, ilow + 1U, sortData[ilow], sortData[ilow + 1U], dindex);
252 
253  // Store the calculated percentile
254  percentileData[iscale * nPercentiles + iper] = percentile;
255  }
256  }
257 
258  // Convert percentile data into a more convenient storable object
259  // and put it into the event record
260  iEvent.put(std::make_unique<reco::DiscretizedEnergyFlow>(
261  &percentileData[0], "FFTJetPileupProcessor", -0.5, nScales - 0.5, 0.0, nScales, nPercentiles),
262  outputLabel);
263 
264  iEvent.put(std::make_unique<std::pair<double, double>>(densityBeforeMixing, densityAfterMixing), outputLabel);
265 }
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
std::vector< std::string > externalGridFiles
void loadInputCollection(const edm::Event &)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > convolvedFlow
int iEvent
Definition: GenABIO.cc:224
std::vector< double > percentileData
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
std::unique_ptr< fftjet::EquidistantInLogSpace > filterScales
std::vector< double > etaFlatteningFactors
void loadFlatteningFactors(const edm::EventSetup &iSetup)
double Real
const std::string outputLabel

Member Data Documentation

◆ convolvedFlow

std::unique_ptr<fftjet::Grid2d<fftjetcms::Real> > FFTJetPileupProcessor::convolvedFlow
private

Definition at line 82 of file FFTJetPileupProcessor.cc.

Referenced by FFTJetPileupProcessor(), and produce().

◆ convolver

std::unique_ptr<fftjet::AbsConvolverBase<Real> > FFTJetPileupProcessor::convolver
private

Definition at line 79 of file FFTJetPileupProcessor.cc.

Referenced by buildKernelConvolver(), and produce().

◆ convolverMaxBin

unsigned FFTJetPileupProcessor::convolverMaxBin
private

Definition at line 96 of file FFTJetPileupProcessor.cc.

Referenced by buildKernelConvolver(), and produce().

◆ convolverMinBin

unsigned FFTJetPileupProcessor::convolverMinBin
private

Definition at line 95 of file FFTJetPileupProcessor.cc.

Referenced by buildKernelConvolver(), and produce().

◆ currentFileNum

unsigned FFTJetPileupProcessor::currentFileNum
private

Definition at line 105 of file FFTJetPileupProcessor.cc.

Referenced by mixExtraGrid().

◆ engine

std::unique_ptr<MyFFTEngine> FFTJetPileupProcessor::engine
private

Definition at line 73 of file FFTJetPileupProcessor.cc.

Referenced by buildKernelConvolver().

◆ etaFlatteningFactors

std::vector<double> FFTJetPileupProcessor::etaFlatteningFactors
private

Definition at line 89 of file FFTJetPileupProcessor.cc.

Referenced by FFTJetPileupProcessor(), loadFlatteningFactors(), and produce().

◆ externalGridFiles

std::vector<std::string> FFTJetPileupProcessor::externalGridFiles
private

Definition at line 102 of file FFTJetPileupProcessor.cc.

Referenced by mixExtraGrid(), and produce().

◆ externalGridMaxEnergy

double FFTJetPileupProcessor::externalGridMaxEnergy
private

Definition at line 104 of file FFTJetPileupProcessor.cc.

Referenced by mixExtraGrid().

◆ filterScales

std::unique_ptr<fftjet::EquidistantInLogSpace> FFTJetPileupProcessor::filterScales
private

Definition at line 85 of file FFTJetPileupProcessor.cc.

Referenced by FFTJetPileupProcessor(), and produce().

◆ flatteningTableCategory

std::string FFTJetPileupProcessor::flatteningTableCategory
private

Definition at line 116 of file FFTJetPileupProcessor.cc.

Referenced by loadFlatteningFactors().

◆ flatteningTableName

std::string FFTJetPileupProcessor::flatteningTableName
private

Definition at line 115 of file FFTJetPileupProcessor.cc.

Referenced by loadFlatteningFactors().

◆ flatteningTableRecord

std::string FFTJetPileupProcessor::flatteningTableRecord
private

Definition at line 114 of file FFTJetPileupProcessor.cc.

Referenced by loadFlatteningFactors().

◆ gridStream

std::ifstream FFTJetPileupProcessor::gridStream
private

Definition at line 103 of file FFTJetPileupProcessor.cc.

Referenced by mixExtraGrid().

◆ kernel2d

std::unique_ptr<fftjet::AbsFrequencyKernel> FFTJetPileupProcessor::kernel2d
private

Definition at line 76 of file FFTJetPileupProcessor.cc.

Referenced by buildKernelConvolver().

◆ loadFlatteningFactorsFromDB

bool FFTJetPileupProcessor::loadFlatteningFactorsFromDB
private

Definition at line 117 of file FFTJetPileupProcessor.cc.

Referenced by produce().

◆ nPercentiles

unsigned FFTJetPileupProcessor::nPercentiles
private

Definition at line 92 of file FFTJetPileupProcessor.cc.

Referenced by FFTJetPileupProcessor(), and produce().

◆ percentileData

std::vector<double> FFTJetPileupProcessor::percentileData
private

Definition at line 108 of file FFTJetPileupProcessor.cc.

Referenced by FFTJetPileupProcessor(), and produce().

◆ pileupEtaPhiArea

double FFTJetPileupProcessor::pileupEtaPhiArea
private

Definition at line 99 of file FFTJetPileupProcessor.cc.

Referenced by produce().