CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
FFTJetEFlowSmoother Class Reference

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

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

Public Member Functions

 FFTJetEFlowSmoother (const edm::ParameterSet &)
 
 ~FFTJetEFlowSmoother ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 
- Public Member Functions inherited from fftjetcms::FFTJetInterface
virtual ~FFTJetInterface ()
 

Protected Member Functions

void beginJob () override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
- Protected 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 &)
 
 FFTJetEFlowSmoother ()
 
 FFTJetEFlowSmoother (const FFTJetEFlowSmoother &)
 
FFTJetEFlowSmootheroperator= (const FFTJetEFlowSmoother &)
 

Private Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Attributes inherited from fftjetcms::FFTJetInterface
const AnomalousTower anomalous
 
std::vector< unsigned > candidateIndex
 
const bool doPVCorrection
 
std::auto_ptr< fftjet::Grid2d
< fftjetcms::Real > > 
energyFlow
 
const std::vector< double > etaDependentMagnutideFactors
 
std::vector
< fftjetcms::VectorLike
eventData
 
edm::Handle< reco::CandidateViewinputCollection
 
const edm::InputTag inputLabel
 
const JetType jetType
 
const std::string outputLabel
 
const edm::InputTag srcPVs
 

Detailed Description

Description: Runs FFTJet filtering code for multiple scales and saves the results

Implementation: [Notes on implementation]

Definition at line 52 of file FFTJetEFlowSmoother.cc.

Constructor & Destructor Documentation

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

Definition at line 99 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.

100  : FFTJetInterface(ps),
101  scalePower(ps.getParameter<double>("scalePower")),
102  etConversionFactor(ps.getParameter<double>("etConversionFactor"))
103 {
104  // Build the discretization grid
106  ps.getParameter<edm::ParameterSet>("GridConfiguration"));
107  checkConfig(energyFlow, "invalid discretization grid");
108 
109  // Copy of the grid which will be used for convolutions
110  convolvedFlow = std::auto_ptr<fftjet::Grid2d<fftjetcms::Real> >(
111  new fftjet::Grid2d<fftjetcms::Real>(*energyFlow));
112 
113  // Build the initial set of pattern recognition scales
115  ps.getParameter<edm::ParameterSet>("InitialScales"));
116  checkConfig(iniScales, "invalid set of scales");
117 
118  // Build the FFT engine(s), pattern recognition kernel(s),
119  // and the kernel convolver
121 
122  // Build the set of pattern recognition scales
123  produces<TH3F>(outputLabel);
124 }
T getParameter(std::string const &) const
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
std::auto_ptr< fftjet::Grid2d< Real > > fftjet_Grid2d_parser(const edm::ParameterSet &ps)
void checkConfig(const Ptr &ptr, const char *message)
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > convolvedFlow
std::auto_ptr< std::vector< double > > iniScales
void buildKernelConvolver(const edm::ParameterSet &)
const std::string outputLabel
std::auto_ptr< std::vector< double > > fftjet_ScaleSet_parser(const edm::ParameterSet &ps)
FFTJetEFlowSmoother::~FFTJetEFlowSmoother ( )

Definition at line 208 of file FFTJetEFlowSmoother.cc.

209 {
210 }
FFTJetEFlowSmoother::FFTJetEFlowSmoother ( )
private
FFTJetEFlowSmoother::FFTJetEFlowSmoother ( const FFTJetEFlowSmoother )
private

Member Function Documentation

void FFTJetEFlowSmoother::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 274 of file FFTJetEFlowSmoother.cc.

275 {
276 }
void FFTJetEFlowSmoother::buildKernelConvolver ( const edm::ParameterSet ps)
private

Definition at line 127 of file FFTJetEFlowSmoother.cc.

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

Referenced by FFTJetEFlowSmoother().

128 {
129  // Check the parameter named "etaDependentScaleFactors". If the vector
130  // of scales is empty we will use 2d kernel, otherwise use 1d kernels
131  const std::vector<double> etaDependentScaleFactors(
132  ps.getParameter<std::vector<double> >("etaDependentScaleFactors"));
133 
134  // Make sure that the number of scale factors provided is correct
135  const bool use2dKernel = etaDependentScaleFactors.empty();
136  if (!use2dKernel)
137  if (etaDependentScaleFactors.size() != energyFlow->nEta())
138  throw cms::Exception("FFTJetBadConfig")
139  << "invalid number of eta-dependent scale factors"
140  << std::endl;
141 
142  // Get the eta and phi scales for the kernel(s)
143  double kernelEtaScale = ps.getParameter<double>("kernelEtaScale");
144  const double kernelPhiScale = ps.getParameter<double>("kernelPhiScale");
145  if (kernelEtaScale <= 0.0 || kernelPhiScale <= 0.0)
146  throw cms::Exception("FFTJetBadConfig")
147  << "invalid kernel scale" << std::endl;
148 
149  // FFT assumes that the grid extent in eta is 2*Pi. Adjust the
150  // kernel scale in eta to compensate.
151  kernelEtaScale *= (2.0*M_PI/(energyFlow->etaMax() - energyFlow->etaMin()));
152 
153  // Are we going to try to fix the efficiency near detector edges?
154  const bool fixEfficiency = ps.getParameter<bool>("fixEfficiency");
155 
156  // Minimum and maximum eta bin for the convolver
157  unsigned convolverMinBin = 0, convolverMaxBin = 0;
158  if (fixEfficiency || !use2dKernel)
159  {
160  convolverMinBin = ps.getParameter<unsigned>("convolverMinBin");
161  convolverMaxBin = ps.getParameter<unsigned>("convolverMaxBin");
162  }
163 
164  if (use2dKernel)
165  {
166  // Build the FFT engine
167  engine = std::auto_ptr<MyFFTEngine>(
168  new MyFFTEngine(energyFlow->nEta(), energyFlow->nPhi()));
169 
170  // 2d kernel
171  kernel2d = std::auto_ptr<fftjet::AbsFrequencyKernel>(
172  new fftjet::DiscreteGauss2d(
173  kernelEtaScale, kernelPhiScale,
174  energyFlow->nEta(), energyFlow->nPhi()));
175 
176  // 2d convolver
177  convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
178  new fftjet::FrequencyKernelConvolver<Real,Complex>(
179  engine.get(), kernel2d.get(),
180  convolverMinBin, convolverMaxBin));
181  }
182  else
183  {
184  // Need separate FFT engines for eta and phi
185  engine = std::auto_ptr<MyFFTEngine>(
186  new MyFFTEngine(1, energyFlow->nEta()));
187  anotherEngine = std::auto_ptr<MyFFTEngine>(
188  new MyFFTEngine(1, energyFlow->nPhi()));
189 
190  // 1d kernels
191  etaKernel = std::auto_ptr<fftjet::AbsFrequencyKernel1d>(
192  new fftjet::DiscreteGauss1d(kernelEtaScale, energyFlow->nEta()));
193 
194  phiKernel = std::auto_ptr<fftjet::AbsFrequencyKernel1d>(
195  new fftjet::DiscreteGauss1d(kernelPhiScale, energyFlow->nPhi()));
196 
197  // Sequential convolver
198  convolver = std::auto_ptr<fftjet::AbsConvolverBase<Real> >(
199  new fftjet::FrequencySequentialConvolver<Real,Complex>(
200  engine.get(), anotherEngine.get(),
201  etaKernel.get(), phiKernel.get(),
202  etaDependentScaleFactors, convolverMinBin,
203  convolverMaxBin, fixEfficiency));
204  }
205 }
T getParameter(std::string const &) const
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
std::auto_ptr< MyFFTEngine > anotherEngine
std::auto_ptr< fftjet::AbsFrequencyKernel1d > etaKernel
std::auto_ptr< fftjet::AbsFrequencyKernel1d > phiKernel
std::auto_ptr< MyFFTEngine > engine
std::auto_ptr< fftjet::AbsFrequencyKernel > kernel2d
#define M_PI
Definition: BFit3D.cc:3
fftjet::FFTWDoubleEngine MyFFTEngine
std::auto_ptr< fftjet::AbsConvolverBase< Real > > convolver
void FFTJetEFlowSmoother::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 280 of file FFTJetEFlowSmoother.cc.

281 {
282 }
FFTJetEFlowSmoother& FFTJetEFlowSmoother::operator= ( const FFTJetEFlowSmoother )
private
void FFTJetEFlowSmoother::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotectedvirtual

Implements edm::EDProducer.

Definition at line 214 of file FFTJetEFlowSmoother.cc.

References convolvedFlow, convolver, fftjetcms::FFTJetInterface::discretizeEnergyFlow(), fftjetcms::FFTJetInterface::energyFlow, etConversionFactor, g, fftjetcms::FFTJetInterface::getEventScale(), h, iniScales, fftjetcms::FFTJetInterface::loadInputCollection(), M_PI, fftjetcms::FFTJetInterface::outputLabel, funct::pow(), edm::Event::put(), and scalePower.

216 {
217  loadInputCollection(iEvent);
219 
220  // Various useful variables
221  const fftjet::Grid2d<Real>& g(*energyFlow);
222  const unsigned nScales = iniScales->size();
223  const double* scales = &(*iniScales)[0];
224  Real* convData = const_cast<Real*>(convolvedFlow->data());
225  const unsigned nEta = g.nEta();
226  const unsigned nPhi = g.nPhi();
227  const double bin0edge = g.phiBin0Edge();
228 
229  // We will fill the following histo
230  std::auto_ptr<TH3F> pTable(
231  new TH3F("FFTJetEFlowSmoother", "FFTJetEFlowSmoother",
232  nScales+1U, -1.5, nScales-0.5,
233  nEta, g.etaMin(), g.etaMax(),
234  nPhi, bin0edge, bin0edge+2.0*M_PI));
235  TH3F* h = pTable.get();
236  h->SetDirectory(0);
237  h->GetXaxis()->SetTitle("Scale");
238  h->GetYaxis()->SetTitle("Eta");
239  h->GetZaxis()->SetTitle("Phi");
240 
241  // Fill the original thing
242  double factor = etConversionFactor*pow(getEventScale(), scalePower);
243  for (unsigned ieta=0; ieta<nEta; ++ieta)
244  for (unsigned iphi=0; iphi<nPhi; ++iphi)
245  h->SetBinContent(1U, ieta+1U, iphi+1U,
246  factor*g.binValue(ieta, iphi));
247 
248  // Go over all scales and perform the convolutions
249  convolver->setEventData(g.data(), nEta, nPhi);
250  for (unsigned iscale=0; iscale<nScales; ++iscale)
251  {
252  factor = etConversionFactor*pow(scales[iscale], scalePower);
253 
254  // Perform the convolution
255  convolver->convolveWithKernel(
256  scales[iscale], convData,
257  convolvedFlow->nEta(), convolvedFlow->nPhi());
258 
259  // Fill the output histo
260  for (unsigned ieta=0; ieta<nEta; ++ieta)
261  {
262  const Real* etaData = convData + ieta*nPhi;
263  for (unsigned iphi=0; iphi<nPhi; ++iphi)
264  h->SetBinContent(iscale+2U, ieta+1U, iphi+1U,
265  factor*etaData[iphi]);
266  }
267  }
268 
269  iEvent.put(pTable, outputLabel);
270 }
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > energyFlow
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
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > convolvedFlow
std::auto_ptr< std::vector< double > > iniScales
double Real
#define M_PI
Definition: BFit3D.cc:3
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::auto_ptr< fftjet::AbsConvolverBase< Real > > convolver
const std::string outputLabel
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

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

Definition at line 79 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

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

Definition at line 72 of file FFTJetEFlowSmoother.cc.

Referenced by FFTJetEFlowSmoother(), and produce().

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

Definition at line 87 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver(), and produce().

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

Definition at line 78 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

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

Definition at line 83 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

double FFTJetEFlowSmoother::etConversionFactor
private

Definition at line 93 of file FFTJetEFlowSmoother.cc.

Referenced by produce().

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

Definition at line 75 of file FFTJetEFlowSmoother.cc.

Referenced by FFTJetEFlowSmoother(), and produce().

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

Definition at line 82 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

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

Definition at line 84 of file FFTJetEFlowSmoother.cc.

Referenced by buildKernelConvolver().

double FFTJetEFlowSmoother::scalePower
private

Definition at line 90 of file FFTJetEFlowSmoother.cc.

Referenced by produce().