CMS 3D CMS Logo

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

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

Inheritance diagram for FFTJetEFlowSmoother:
fftjetcms::FFTJetInterface edm::stream::EDProducer<>

Public Member Functions

 FFTJetEFlowSmoother (const edm::ParameterSet &)
 
 FFTJetEFlowSmoother ()=delete
 
 FFTJetEFlowSmoother (const FFTJetEFlowSmoother &)=delete
 
FFTJetEFlowSmootheroperator= (const FFTJetEFlowSmoother &)=delete
 
 ~FFTJetEFlowSmoother () 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::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Protected Member Functions

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
 

Private Member Functions

void buildKernelConvolver (const edm::ParameterSet &)
 

Private Attributes

std::unique_ptr< MyFFTEngineanotherEngine
 
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > convolvedFlow
 
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
 
std::unique_ptr< MyFFTEngineengine
 
std::unique_ptr< fftjet::AbsFrequencyKernel1d > etaKernel
 
double etConversionFactor
 
std::unique_ptr< std::vector< double > > iniScales
 
std::unique_ptr< fftjet::AbsFrequencyKernel > kernel2d
 
std::unique_ptr< fftjet::AbsFrequencyKernel1d > phiKernel
 
double scalePower
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- 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 filtering code for multiple scales and saves the results

Implementation: [Notes on implementation]

Definition at line 51 of file FFTJetEFlowSmoother.cc.

Constructor & Destructor Documentation

◆ FFTJetEFlowSmoother() [1/3]

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

Definition at line 94 of file FFTJetEFlowSmoother.cc.

References buildKernelConvolver(), fftjetcms::FFTJetInterface::checkConfig(), convolvedFlow, fftjetcms::FFTJetInterface::energyFlow, fftjetcms::fftjet_Grid2d_parser(), fftjetcms::fftjet_ScaleSet_parser(), edm::ParameterSet::getParameter(), iniScales, and fftjetcms::FFTJetInterface::outputLabel.

95  : FFTJetInterface(ps),
96  scalePower(ps.getParameter<double>("scalePower")),
97  etConversionFactor(ps.getParameter<double>("etConversionFactor")) {
98  // Build the discretization grid
100  checkConfig(energyFlow, "invalid discretization grid");
101 
102  // Copy of the grid which will be used for convolutions
103  convolvedFlow = std::make_unique<fftjet::Grid2d<fftjetcms::Real> >(*energyFlow);
104 
105  // Build the initial set of pattern recognition scales
107  checkConfig(iniScales, "invalid set of scales");
108 
109  // Build the FFT engine(s), pattern recognition kernel(s),
110  // and the kernel convolver
112 
113  // Build the set of pattern recognition scales
114  produces<TH3F>(outputLabel);
115 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void checkConfig(const Ptr &ptr, const char *message)
std::unique_ptr< fftjet::Grid2d< Real > > fftjet_Grid2d_parser(const edm::ParameterSet &ps)
std::unique_ptr< std::vector< double > > iniScales
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > convolvedFlow
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
void buildKernelConvolver(const edm::ParameterSet &)
std::unique_ptr< std::vector< double > > fftjet_ScaleSet_parser(const edm::ParameterSet &ps)
const std::string outputLabel

◆ FFTJetEFlowSmoother() [2/3]

FFTJetEFlowSmoother::FFTJetEFlowSmoother ( )
delete

◆ FFTJetEFlowSmoother() [3/3]

FFTJetEFlowSmoother::FFTJetEFlowSmoother ( const FFTJetEFlowSmoother )
delete

◆ ~FFTJetEFlowSmoother()

FFTJetEFlowSmoother::~FFTJetEFlowSmoother ( )
override

Definition at line 184 of file FFTJetEFlowSmoother.cc.

184 {}

Member Function Documentation

◆ buildKernelConvolver()

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

Definition at line 117 of file FFTJetEFlowSmoother.cc.

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

Referenced by FFTJetEFlowSmoother().

117  {
118  // Check the parameter named "etaDependentScaleFactors". If the vector
119  // of scales is empty we will use 2d kernel, otherwise use 1d kernels
120  const std::vector<double> etaDependentScaleFactors(ps.getParameter<std::vector<double> >("etaDependentScaleFactors"));
121 
122  // Make sure that the number of scale factors provided is correct
123  const bool use2dKernel = etaDependentScaleFactors.empty();
124  if (!use2dKernel)
125  if (etaDependentScaleFactors.size() != energyFlow->nEta())
126  throw cms::Exception("FFTJetBadConfig") << "invalid number of eta-dependent scale factors" << std::endl;
127 
128  // Get the eta and phi scales for the kernel(s)
129  double kernelEtaScale = ps.getParameter<double>("kernelEtaScale");
130  const double kernelPhiScale = ps.getParameter<double>("kernelPhiScale");
131  if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
132  throw cms::Exception("FFTJetBadConfig") << "invalid kernel scale" << std::endl;
133 
134  // FFT assumes that the grid extent in eta is 2*Pi. Adjust the
135  // kernel scale in eta to compensate.
136  kernelEtaScale *= (2.0 * M_PI / (energyFlow->etaMax() - energyFlow->etaMin()));
137 
138  // Are we going to try to fix the efficiency near detector edges?
139  const bool fixEfficiency = ps.getParameter<bool>("fixEfficiency");
140 
141  // Minimum and maximum eta bin for the convolver
142  unsigned convolverMinBin = 0, convolverMaxBin = 0;
143  if (fixEfficiency || !use2dKernel) {
144  convolverMinBin = ps.getParameter<unsigned>("convolverMinBin");
145  convolverMaxBin = ps.getParameter<unsigned>("convolverMaxBin");
146  }
147 
148  if (use2dKernel) {
149  // Build the FFT engine
150  engine = std::make_unique<MyFFTEngine>(energyFlow->nEta(), energyFlow->nPhi());
151 
152  // 2d kernel
153  kernel2d = std::unique_ptr<fftjet::AbsFrequencyKernel>(
154  new fftjet::DiscreteGauss2d(kernelEtaScale, kernelPhiScale, energyFlow->nEta(), energyFlow->nPhi()));
155 
156  // 2d convolver
157  convolver = std::unique_ptr<fftjet::AbsConvolverBase<Real> >(new fftjet::FrequencyKernelConvolver<Real, Complex>(
159  } else {
160  // Need separate FFT engines for eta and phi
161  engine = std::make_unique<MyFFTEngine>(1, energyFlow->nEta());
162  anotherEngine = std::make_unique<MyFFTEngine>(1, energyFlow->nPhi());
163 
164  // 1d kernels
165  etaKernel =
166  std::unique_ptr<fftjet::AbsFrequencyKernel1d>(new fftjet::DiscreteGauss1d(kernelEtaScale, energyFlow->nEta()));
167 
168  phiKernel =
169  std::unique_ptr<fftjet::AbsFrequencyKernel1d>(new fftjet::DiscreteGauss1d(kernelPhiScale, energyFlow->nPhi()));
170 
171  // Sequential convolver
172  convolver = std::unique_ptr<fftjet::AbsConvolverBase<Real> >(
173  new fftjet::FrequencySequentialConvolver<Real, Complex>(engine.get(),
174  anotherEngine.get(),
175  etaKernel.get(),
176  phiKernel.get(),
180  fixEfficiency));
181  }
182 }
std::unique_ptr< MyFFTEngine > engine
std::unique_ptr< fftjet::AbsFrequencyKernel1d > etaKernel
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
std::unique_ptr< MyFFTEngine > anotherEngine
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
#define M_PI
std::unique_ptr< fftjet::AbsFrequencyKernel > kernel2d
std::unique_ptr< fftjet::AbsFrequencyKernel1d > phiKernel

◆ operator=()

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

◆ produce()

void FFTJetEFlowSmoother::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 187 of file FFTJetEFlowSmoother.cc.

References convolvedFlow, convolver, fftjetcms::FFTJetInterface::discretizeEnergyFlow(), fftjetcms::FFTJetInterface::energyFlow, etConversionFactor, g, fftjetcms::FFTJetInterface::getEventScale(), h, hcalRecHitTable_cff::ieta, iEvent, iniScales, hcalRecHitTable_cff::iphi, fftjetcms::FFTJetInterface::loadInputCollection(), M_PI, eostools::move(), HLT_2023v12_cff::nEta, HLT_2023v12_cff::nPhi, fftjetcommon_cfi::nScales, fftjetcms::FFTJetInterface::outputLabel, conifer::pow(), scalePower, l1tGTDoubleObjectCond_cfi::scales, and mitigatedMETSequence_cff::U.

187  {
190 
191  // Various useful variables
192  const fftjet::Grid2d<Real>& g(*energyFlow);
193  const unsigned nScales = iniScales->size();
194  const double* scales = &(*iniScales)[0];
195  Real* convData = const_cast<Real*>(convolvedFlow->data());
196  const unsigned nEta = g.nEta();
197  const unsigned nPhi = g.nPhi();
198  const double bin0edge = g.phiBin0Edge();
199 
200  // We will fill the following histo
201  auto pTable = std::make_unique<TH3F>("FFTJetEFlowSmoother",
202  "FFTJetEFlowSmoother",
203  nScales + 1U,
204  -1.5,
205  nScales - 0.5,
206  nEta,
207  g.etaMin(),
208  g.etaMax(),
209  nPhi,
210  bin0edge,
211  bin0edge + 2.0 * M_PI);
212  TH3F* h = pTable.get();
213  h->SetDirectory(nullptr);
214  h->GetXaxis()->SetTitle("Scale");
215  h->GetYaxis()->SetTitle("Eta");
216  h->GetZaxis()->SetTitle("Phi");
217 
218  // Fill the original thing
220  for (unsigned ieta = 0; ieta < nEta; ++ieta)
221  for (unsigned iphi = 0; iphi < nPhi; ++iphi)
222  h->SetBinContent(1U, ieta + 1U, iphi + 1U, factor * g.binValue(ieta, iphi));
223 
224  // Go over all scales and perform the convolutions
225  convolver->setEventData(g.data(), nEta, nPhi);
226  for (unsigned iscale = 0; iscale < nScales; ++iscale) {
228 
229  // Perform the convolution
230  convolver->convolveWithKernel(scales[iscale], convData, convolvedFlow->nEta(), convolvedFlow->nPhi());
231 
232  // Fill the output histo
233  for (unsigned ieta = 0; ieta < nEta; ++ieta) {
234  const Real* etaData = convData + ieta * nPhi;
235  for (unsigned iphi = 0; iphi < nPhi; ++iphi)
236  h->SetBinContent(iscale + 2U, ieta + 1U, iphi + 1U, factor * etaData[iphi]);
237  }
238  }
239 
240  iEvent.put(std::move(pTable), outputLabel);
241 }
std::unique_ptr< fftjet::AbsConvolverBase< Real > > convolver
void loadInputCollection(const edm::Event &)
constexpr int pow(int x)
Definition: conifer.h:24
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
int iEvent
Definition: GenABIO.cc:224
std::unique_ptr< std::vector< double > > iniScales
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > convolvedFlow
std::unique_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
#define M_PI
double Real
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
const std::string outputLabel
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ anotherEngine

std::unique_ptr<MyFFTEngine> FFTJetEFlowSmoother::anotherEngine
private

Definition at line 74 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

◆ convolvedFlow

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

Definition at line 67 of file FFTJetEFlowSmoother.cc.

Referenced by FFTJetEFlowSmoother(), and produce().

◆ convolver

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

Definition at line 82 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver(), and produce().

◆ engine

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

Definition at line 73 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

◆ etaKernel

std::unique_ptr<fftjet::AbsFrequencyKernel1d> FFTJetEFlowSmoother::etaKernel
private

Definition at line 78 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

◆ etConversionFactor

double FFTJetEFlowSmoother::etConversionFactor
private

Definition at line 88 of file FFTJetEFlowSmoother.cc.

Referenced by produce().

◆ iniScales

std::unique_ptr<std::vector<double> > FFTJetEFlowSmoother::iniScales
private

Definition at line 70 of file FFTJetEFlowSmoother.cc.

Referenced by FFTJetEFlowSmoother(), and produce().

◆ kernel2d

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

Definition at line 77 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

◆ phiKernel

std::unique_ptr<fftjet::AbsFrequencyKernel1d> FFTJetEFlowSmoother::phiKernel
private

Definition at line 79 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

◆ scalePower

double FFTJetEFlowSmoother::scalePower
private

Definition at line 85 of file FFTJetEFlowSmoother.cc.

Referenced by produce().