test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FFTJetProducer.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: RecoJets/FFTJetProducers
4 // Class: FFTJetProducer
5 //
21 //
22 // Original Author: Igor Volobouev
23 // Created: Sun Jun 20 14:32:36 CDT 2010
24 //
25 //
26 
27 #ifndef RecoJets_FFTJetProducers_FFTJetProducer_h
28 #define RecoJets_FFTJetProducers_FFTJetProducer_h
29 
30 #include <memory>
31 
32 // FFTJet headers
33 #include "fftjet/AbsRecombinationAlg.hh"
34 #include "fftjet/AbsVectorRecombinationAlg.hh"
35 #include "fftjet/SparseClusteringTree.hh"
36 
37 // Additional FFTJet headers
38 #include "fftjet/VectorRecombinationAlgFactory.hh"
39 #include "fftjet/RecombinationAlgFactory.hh"
40 
49 
55 
57 
58 
59 // framework include files
63 
65 
66 // local FFTJet-related definitions
70 
71 namespace fftjetcms {
73 }
74 
75 //
76 // class declaration
77 //
79 {
80 public:
81  typedef fftjet::RecombinedJet<fftjetcms::VectorLike> RecoFFTJet;
82  typedef fftjet::SparseClusteringTree<fftjet::Peak,long> SparseTree;
83 
84  // Masks for the status bits. Do not add anything
85  // here -- higher bits (starting with 0x1000) will be
86  // used to indicate jet correction levels applied.
88  {
89  RESOLUTION = 0xff,
94  };
95 
97  {
98  FIXED = 0,
103  };
104 
105  explicit FFTJetProducer(const edm::ParameterSet&);
106  virtual ~FFTJetProducer();
107 
108  // Parser for the resolution enum
110 
111 protected:
112  // Functions which should be overriden from the base
113  virtual void beginJob() override;
114  virtual void produce(edm::Event&, const edm::EventSetup&) override;
115  virtual void endJob() override;
116 
117  // The following functions can be overriden by derived classes
118  // in order to adjust jet reconstruction algorithm behavior.
119 
120  // Override the following method in order to implement
121  // your own precluster selection strategy
122  virtual void selectPreclusters(
123  const SparseTree& tree,
124  const fftjet::Functor1<bool,fftjet::Peak>& peakSelector,
125  std::vector<fftjet::Peak>* preclusters);
126 
127  // Precluster maker from GenJets (useful in calibration)
128  virtual void genJetPreclusters(
129  const SparseTree& tree,
130  edm::Event&, const edm::EventSetup&,
131  const fftjet::Functor1<bool,fftjet::Peak>& peakSelector,
132  std::vector<fftjet::Peak>* preclusters);
133 
134  // Override the following method (which by default does not do
135  // anything) in order to implement your own process-dependent
136  // assignment of membership functions to preclusters. This method
137  // will be called once per event, just before the main algorithm.
138  virtual void assignMembershipFunctions(
139  std::vector<fftjet::Peak>* preclusters);
140 
141  // Parser for the peak selector
142  virtual std::auto_ptr<fftjet::Functor1<bool,fftjet::Peak> >
144 
145  // Parser for the default jet membership function
146  virtual std::auto_ptr<fftjet::ScaleSpaceKernel>
148 
149  // Parser for the background membership function
150  virtual std::auto_ptr<fftjetcms::AbsBgFunctor>
152 
153  // Calculator for the recombination scale
154  virtual std::auto_ptr<fftjet::Functor1<double,fftjet::Peak> >
156 
157  // Calculator for the recombination scale ratio
158  virtual std::auto_ptr<fftjet::Functor1<double,fftjet::Peak> >
160 
161  // Calculator for the membership function factor
162  virtual std::auto_ptr<fftjet::Functor1<double,fftjet::Peak> >
164 
165  // Similar calculators for the iterative algorithm
166  virtual std::auto_ptr<fftjet::Functor1<double,RecoFFTJet> >
168 
169  virtual std::auto_ptr<fftjet::Functor1<double,RecoFFTJet> >
171 
172  virtual std::auto_ptr<fftjet::Functor1<double,RecoFFTJet> >
174 
175  // Calculator of the distance between jets which is used to make
176  // the decision about convergence of the iterative algorithm
177  virtual std::auto_ptr<fftjet::Functor2<double,RecoFFTJet,RecoFFTJet> >
179 
180  // Pile-up density calculator
181  virtual std::auto_ptr<fftjetcms::AbsPileupCalculator>
183 
184  // The following function performs most of the precluster selection
185  // work in this module. You might want to reuse it if only a slight
186  // modification of the "selectPreclusters" method is desired.
187  void selectTreeNodes(const SparseTree& tree,
188  const fftjet::Functor1<bool,fftjet::Peak>& peakSelect,
189  std::vector<SparseTree::NodeId>* nodes);
190 private:
191  typedef fftjet::AbsVectorRecombinationAlg<
193  typedef fftjet::AbsRecombinationAlg<
195 
196  // Explicitly disable other ways to construct this object
197  FFTJetProducer();
200 
201  // Useful local utilities
202  template<class Real>
203  void loadSparseTreeData(const edm::Event&);
204 
205  void removeFakePreclusters();
206 
207  // The following methods do most of the work.
208  // The following function tells us if the grid was rebuilt.
209  bool loadEnergyFlow(
210  const edm::Event& iEvent,
211  std::auto_ptr<fftjet::Grid2d<fftjetcms::Real> >& flow);
212  void buildGridAlg();
214  bool checkConvergence(const std::vector<RecoFFTJet>& previousIterResult,
215  std::vector<RecoFFTJet>& thisIterResult);
219  unsigned nPreclustersFound);
220 
221  template <typename Jet>
223 
224  template <typename Jet>
225  void makeProduces(const std::string& alias, const std::string& tag);
226 
227  // The following function scans the pile-up density
228  // and fills the pile-up grid. Can be overriden if
229  // necessary.
231  const edm::Event& iEvent,
232  std::auto_ptr<fftjet::Grid2d<fftjetcms::Real> >& density);
233 
234  // Similar function for getting pile-up shape from the database
235  virtual void determinePileupDensityFromDB(
236  const edm::Event& iEvent, const edm::EventSetup& iSetup,
237  std::auto_ptr<fftjet::Grid2d<fftjetcms::Real> >& density);
238 
239  // The following function builds the pile-up estimate
240  // for each jet
241  void determinePileup();
242 
243  // The following function returns the number of iterations
244  // performed. If this number equals to or less than "maxIterations"
245  // then the iterations have converged. If the number larger than
246  // "maxIterations" then the iterations failed to converge (note,
247  // however, that only "maxIterations" iterations would still be
248  // performed).
249  unsigned iterateJetReconstruction();
250 
251  // A function to set jet status bits
252  static void setJetStatusBit(RecoFFTJet* jet, int mask, bool value);
253 
254  //
255  // ----------member data ---------------------------
256  //
257 
258  // Local copy of the module configuration
260 
261  // Label for the tree produced by FFTJetPatRecoProducer
263 
264  // Are we going to use energy flow discretization grid as input
265  // to jet reconstruction?
267 
268  // Are we going to rebuild the energy flow discretization grid
269  // or to reuse the grid made by FFTJetPatRecoProducer?
270  const bool reuseExistingGrid;
271 
272  // Are we iterating?
273  const unsigned maxIterations;
274 
275  // Parameters which affect iteration convergence
276  const unsigned nJetsRequiredToConverge;
277  const double convergenceDistance;
278 
279  // Are we building assignments of collection members to jets?
280  const bool assignConstituents;
281 
282  // Are we resumming the constituents to determine jet 4-vectors?
283  // This might make sense if FFTJet is used in the crisp, gridded
284  // mode to determine jet areas, and vector recombination is desired.
285  const bool resumConstituents;
286 
287  // Are we going to subtract the pile-up? Note that
288  // pile-up subtraction does not modify eta and phi moments.
289  const bool calculatePileup;
290  const bool subtractPileup;
292 
293  // Label for the pile-up energy flow. Must be specified
294  // if the pile-up is subtracted.
296 
297  // Scale for the peak selection (if the scale is fixed)
298  const double fixedScale;
299 
300  // Minimum and maximum scale for searching stable configurations
301  const double minStableScale;
302  const double maxStableScale;
303 
304  // Stability "alpha"
305  const double stabilityAlpha;
306 
307  // Not sure at this point how to treat noise... For now, this is
308  // just a single configurable number...
309  const double noiseLevel;
310 
311  // Number of clusters requested (if the scale is adaptive)
312  const unsigned nClustersRequested;
313 
314  // Maximum eta for the grid-based algorithm
315  const double gridScanMaxEta;
316 
317  // Parameters related to the recombination algorithm
319  const bool isCrisp;
320  const double unlikelyBgWeight;
322 
323  // Label for the genJets used as seeds for jets
325 
326  // Maximum number of preclusters to use as jet seeds.
327  // This does not take into account the preclusters
328  // for which the value of the membership factor is 0.
329  const unsigned maxInitialPreclusters;
330 
331  // Resolution. The corresponding parameter value
332  // should be one of "fixed", "maximallyStable",
333  // "globallyAdaptive", "locallyAdaptive", or "fromGenJets".
335 
336  // Parameters related to the pileup shape stored
337  // in the database
342 
343  // Scales used
344  std::auto_ptr<std::vector<double> > iniScales;
345 
346  // The sparse clustering tree
348 
349  // Peak selector for the peaks already in the tree
350  std::auto_ptr<fftjet::Functor1<bool,fftjet::Peak> > peakSelector;
351 
352  // Recombination algorithms and related quantities
353  std::auto_ptr<RecoAlg> recoAlg;
354  std::auto_ptr<GridAlg> gridAlg;
355  std::auto_ptr<fftjet::ScaleSpaceKernel> jetMembershipFunction;
356  std::auto_ptr<fftjetcms::AbsBgFunctor> bgMembershipFunction;
357 
358  // Calculator for the recombination scale
359  std::auto_ptr<fftjet::Functor1<double,fftjet::Peak> > recoScaleCalcPeak;
360 
361  // Calculator for the recombination scale ratio
362  std::auto_ptr<fftjet::Functor1<double,fftjet::Peak> >
364 
365  // Calculator for the membership function factor
366  std::auto_ptr<fftjet::Functor1<double,fftjet::Peak> > memberFactorCalcPeak;
367 
368  // Similar calculators for the iterative algorithm
369  std::auto_ptr<fftjet::Functor1<double,RecoFFTJet> > recoScaleCalcJet;
370  std::auto_ptr<fftjet::Functor1<double,RecoFFTJet> > recoScaleRatioCalcJet;
371  std::auto_ptr<fftjet::Functor1<double,RecoFFTJet> > memberFactorCalcJet;
372 
373  // Calculator for the jet distance used to estimate convergence
374  // of the iterative algorithm
375  std::auto_ptr<fftjet::Functor2<double,RecoFFTJet,RecoFFTJet> >
377 
378  // Vector of selected tree nodes
379  std::vector<SparseTree::NodeId> nodes;
380 
381  // Vector of selected preclusters
382  std::vector<fftjet::Peak> preclusters;
383 
384  // Vector of reconstructed jets (we will refill it in every event)
385  std::vector<RecoFFTJet> recoJets;
386 
387  // Cluster occupancy calculated as a function of level number
388  std::vector<unsigned> occupancy;
389 
390  // The thresholds obtained by the LOCALLY_ADAPTIVE method
391  std::vector<double> thresholds;
392 
393  // Minimum, maximum and used level calculated by some algorithms
395 
396  // Unclustered/unused energy produced during recombination
398  double unused;
399 
400  // Quantities defined below are used in the iterative mode only
401  std::vector<fftjet::Peak> iterPreclusters;
402  std::vector<RecoFFTJet> iterJets;
404 
405  // Vectors of constituents
406  std::vector<std::vector<reco::CandidatePtr> > constituents;
407 
408  // Vector of pile-up. We will subtract it from the
409  // 4-vectors of reconstructed jets.
410  std::vector<fftjetcms::VectorLike> pileup;
411 
412  // The pile-up transverse energy density discretization grid.
413  // Note that this is _density_, not energy. To get energy,
414  // multiply by cell area.
415  std::auto_ptr<fftjet::Grid2d<fftjetcms::Real> > pileupEnergyFlow;
416 
417  // The functor that calculates the pile-up density
418  std::auto_ptr<fftjetcms::AbsPileupCalculator> pileupDensityCalc;
419 
420  // Memory buffers related to pile-up subtraction
421  std::vector<fftjet::AbsKernel2d*> memFcns2dVec;
422  std::vector<double> doubleBuf;
423  std::vector<unsigned> cellCountsVec;
424 
425  // Tokens for data access
430 };
431 
432 #endif // RecoJets_FFTJetProducers_FFTJetProducer_h
std::vector< std::vector< reco::CandidatePtr > > constituents
virtual void produce(edm::Event &, const edm::EventSetup &) override
virtual ~FFTJetProducer()
std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > pileupEnergyFlow
std::auto_ptr< RecoAlg > recoAlg
std::auto_ptr< fftjet::Functor1< double, fftjet::Peak > > memberFactorCalcPeak
unsigned iterationsPerformed
const bool useGriddedAlgorithm
std::vector< fftjetcms::VectorLike > pileup
static Resolution parse_resolution(const std::string &name)
const bool resumConstituents
void selectTreeNodes(const SparseTree &tree, const fftjet::Functor1< bool, fftjet::Peak > &peakSelect, std::vector< SparseTree::NodeId > *nodes)
const double gridScanMaxEta
void saveResults(edm::Event &iEvent, const edm::EventSetup &, unsigned nPreclustersFound)
virtual std::auto_ptr< fftjet::Functor1< double, fftjet::Peak > > parse_recoScaleRatioCalcPeak(const edm::ParameterSet &)
std::auto_ptr< GridAlg > gridAlg
std::auto_ptr< fftjetcms::AbsPileupCalculator > pileupDensityCalc
virtual void assignMembershipFunctions(std::vector< fftjet::Peak > *preclusters)
virtual std::auto_ptr< fftjet::Functor1< bool, fftjet::Peak > > parse_peakSelector(const edm::ParameterSet &)
virtual std::auto_ptr< fftjetcms::AbsPileupCalculator > parse_pileupDensityCalc(const edm::ParameterSet &ps)
double BgData
const std::string recombinationAlgorithm
const double fixedScale
virtual std::auto_ptr< fftjetcms::AbsBgFunctor > parse_bgMembershipFunction(const edm::ParameterSet &)
const bool subtractPileupAs4Vec
const double unlikelyBgWeight
void makeProduces(const std::string &alias, const std::string &tag)
const bool subtractPileup
const unsigned nJetsRequiredToConverge
Resolution resolution
edm::EDGetTokenT< reco::PattRecoTree< fftjetcms::Real, reco::PattRecoPeak< fftjetcms::Real > > > input_recotree_token_
std::vector< double > doubleBuf
std::auto_ptr< fftjet::Functor1< double, fftjet::Peak > > recoScaleCalcPeak
std::vector< fftjet::AbsKernel2d * > memFcns2dVec
std::vector< RecoFFTJet > recoJets
const bool isCrisp
const double recombinationDataCutoff
std::vector< unsigned > occupancy
const double minStableScale
const double maxStableScale
std::vector< fftjet::Peak > preclusters
void determineVectorConstituents()
virtual std::auto_ptr< fftjet::Functor1< double, fftjet::Peak > > parse_memberFactorCalcPeak(const edm::ParameterSet &)
void loadSparseTreeData(const edm::Event &)
std::auto_ptr< fftjetcms::AbsBgFunctor > bgMembershipFunction
const bool reuseExistingGrid
const unsigned nClustersRequested
int iEvent
Definition: GenABIO.cc:230
fftjet::AbsVectorRecombinationAlg< fftjetcms::VectorLike, fftjetcms::BgData > RecoAlg
std::auto_ptr< std::vector< double > > iniScales
math::XYZTLorentzVector VectorLike
unsigned usedLevel
std::auto_ptr< fftjet::Functor1< double, RecoFFTJet > > memberFactorCalcJet
virtual std::auto_ptr< fftjet::Functor1< double, RecoFFTJet > > parse_recoScaleCalcJet(const edm::ParameterSet &)
virtual void endJob() override
const double noiseLevel
static void setJetStatusBit(RecoFFTJet *jet, int mask, bool value)
std::vector< RecoFFTJet > iterJets
fftjet::SparseClusteringTree< fftjet::Peak, long > SparseTree
std::vector< unsigned > cellCountsVec
std::string pileupTableRecord
std::string pileupTableName
std::vector< double > thresholds
virtual std::auto_ptr< fftjet::Functor2< double, RecoFFTJet, RecoFFTJet > > parse_jetDistanceCalc(const edm::ParameterSet &)
unsigned iterateJetReconstruction()
fftjet::AbsRecombinationAlg< fftjetcms::Real, fftjetcms::VectorLike, fftjetcms::BgData > GridAlg
const bool calculatePileup
const bool assignConstituents
bool checkConvergence(const std::vector< RecoFFTJet > &previousIterResult, std::vector< RecoFFTJet > &thisIterResult)
A grid filled with discretized energy flow.
const edm::InputTag treeLabel
virtual void selectPreclusters(const SparseTree &tree, const fftjet::Functor1< bool, fftjet::Peak > &peakSelector, std::vector< fftjet::Peak > *preclusters)
virtual void determinePileupDensityFromDB(const edm::Event &iEvent, const edm::EventSetup &iSetup, std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > &density)
double Real
FFTJetProducer & operator=(const FFTJetProducer &)
const edm::InputTag genJetsLabel
const edm::ParameterSet myConfiguration
edm::EDGetTokenT< reco::DiscretizedEnergyFlow > input_energyflow_token_
fftjet::RecombinedJet< fftjetcms::VectorLike > RecoFFTJet
edm::EDGetTokenT< reco::FFTJetPileupSummary > input_pusummary_token_
const double stabilityAlpha
std::auto_ptr< fftjet::Functor1< double, fftjet::Peak > > recoScaleRatioCalcPeak
virtual std::auto_ptr< fftjet::Functor1< double, RecoFFTJet > > parse_memberFactorCalcJet(const edm::ParameterSet &)
const unsigned maxInitialPreclusters
std::string pileupTableCategory
SparseTree sparseTree
virtual std::auto_ptr< fftjet::Functor1< double, fftjet::Peak > > parse_recoScaleCalcPeak(const edm::ParameterSet &)
std::vector< SparseTree::NodeId > nodes
void determineGriddedConstituents()
const double convergenceDistance
edm::EDGetTokenT< std::vector< reco::FFTAnyJet< reco::GenJet > > > input_genjet_token_
void writeJets(edm::Event &iEvent, const edm::EventSetup &)
virtual std::auto_ptr< fftjet::ScaleSpaceKernel > parse_jetMembershipFunction(const edm::ParameterSet &)
virtual std::auto_ptr< fftjet::Functor1< double, RecoFFTJet > > parse_recoScaleRatioCalcJet(const edm::ParameterSet &)
std::auto_ptr< fftjet::Functor1< double, RecoFFTJet > > recoScaleRatioCalcJet
const edm::InputTag pileupLabel
virtual void beginJob() override
bool loadEnergyFlow(const edm::Event &iEvent, std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > &flow)
virtual void genJetPreclusters(const SparseTree &tree, edm::Event &, const edm::EventSetup &, const fftjet::Functor1< bool, fftjet::Peak > &peakSelector, std::vector< fftjet::Peak > *preclusters)
fftjetcms::VectorLike unclustered
std::auto_ptr< fftjet::Functor1< bool, fftjet::Peak > > peakSelector
std::vector< fftjet::Peak > iterPreclusters
virtual void determinePileupDensityFromConfig(const edm::Event &iEvent, std::auto_ptr< fftjet::Grid2d< fftjetcms::Real > > &density)
std::auto_ptr< fftjet::Functor2< double, RecoFFTJet, RecoFFTJet > > jetDistanceCalc
std::auto_ptr< fftjet::ScaleSpaceKernel > jetMembershipFunction
void removeFakePreclusters()
const unsigned maxIterations
std::auto_ptr< fftjet::Functor1< double, RecoFFTJet > > recoScaleCalcJet
void prepareRecombinationScales()