File indexing completed on 2023-03-17 11:18:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #ifndef RecoJets_FFTJetProducers_FFTJetProducer_h
0028 #define RecoJets_FFTJetProducers_FFTJetProducer_h
0029
0030 #include <memory>
0031
0032
0033 #include "fftjet/AbsRecombinationAlg.hh"
0034 #include "fftjet/AbsVectorRecombinationAlg.hh"
0035 #include "fftjet/SparseClusteringTree.hh"
0036
0037
0038 #include "fftjet/VectorRecombinationAlgFactory.hh"
0039 #include "fftjet/RecombinationAlgFactory.hh"
0040
0041 #include "DataFormats/JetReco/interface/FFTCaloJetCollection.h"
0042 #include "DataFormats/JetReco/interface/FFTGenJetCollection.h"
0043 #include "DataFormats/JetReco/interface/FFTPFJetCollection.h"
0044 #include "DataFormats/JetReco/interface/FFTJPTJetCollection.h"
0045 #include "DataFormats/JetReco/interface/FFTBasicJetCollection.h"
0046 #include "DataFormats/JetReco/interface/FFTTrackJetCollection.h"
0047 #include "DataFormats/JetReco/interface/FFTJetProducerSummary.h"
0048 #include "RecoJets/FFTJetProducers/interface/FFTJetParameterParser.h"
0049
0050 #include "RecoJets/FFTJetAlgorithms/interface/clusteringTreeConverters.h"
0051 #include "RecoJets/FFTJetAlgorithms/interface/jetConverters.h"
0052 #include "RecoJets/FFTJetAlgorithms/interface/matchOneToOne.h"
0053 #include "RecoJets/FFTJetAlgorithms/interface/JetToPeakDistance.h"
0054 #include "RecoJets/FFTJetAlgorithms/interface/adjustForPileup.h"
0055
0056 #include "DataFormats/JetReco/interface/DiscretizedEnergyFlow.h"
0057
0058
0059 #include "FWCore/Framework/interface/Frameworkfwd.h"
0060 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0061 #include "FWCore/Framework/interface/Event.h"
0062
0063 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0064
0065
0066 #include "RecoJets/FFTJetAlgorithms/interface/fftjetTypedefs.h"
0067 #include "RecoJets/FFTJetAlgorithms/interface/AbsPileupCalculator.h"
0068 #include "RecoJets/FFTJetProducers/interface/FFTJetInterface.h"
0069
0070 #include "JetMETCorrections/FFTJetObjects/interface/FFTJetLookupTableSequenceLoader.h"
0071
0072 namespace fftjetcms {
0073 class DiscretizedEnergyFlow;
0074 }
0075
0076 class CaloGeometry;
0077 class CaloGeometryRecord;
0078 class HcalTopology;
0079 class HcalRecNumberingRecord;
0080
0081
0082
0083
0084 class FFTJetProducer : public fftjetcms::FFTJetInterface {
0085 public:
0086 typedef fftjet::RecombinedJet<fftjetcms::VectorLike> RecoFFTJet;
0087 typedef fftjet::SparseClusteringTree<fftjet::Peak, long> SparseTree;
0088
0089
0090
0091
0092 enum StatusBits {
0093 RESOLUTION = 0xff,
0094 CONSTITUENTS_RESUMMED = 0x100,
0095 PILEUP_CALCULATED = 0x200,
0096 PILEUP_SUBTRACTED_4VEC = 0x400,
0097 PILEUP_SUBTRACTED_PT = 0x800
0098 };
0099
0100 enum Resolution { FIXED = 0, MAXIMALLY_STABLE, GLOBALLY_ADAPTIVE, LOCALLY_ADAPTIVE, FROM_GENJETS };
0101
0102 explicit FFTJetProducer(const edm::ParameterSet&);
0103
0104 FFTJetProducer() = delete;
0105 FFTJetProducer(const FFTJetProducer&) = delete;
0106 FFTJetProducer& operator=(const FFTJetProducer&) = delete;
0107
0108 ~FFTJetProducer() override;
0109
0110
0111 static Resolution parse_resolution(const std::string& name);
0112
0113 protected:
0114
0115 void beginStream(edm::StreamID) override;
0116 void produce(edm::Event&, const edm::EventSetup&) override;
0117
0118
0119
0120
0121
0122
0123 virtual void selectPreclusters(const SparseTree& tree,
0124 const fftjet::Functor1<bool, fftjet::Peak>& peakSelector,
0125 std::vector<fftjet::Peak>* preclusters);
0126
0127
0128 virtual void genJetPreclusters(const SparseTree& tree,
0129 edm::Event&,
0130 const edm::EventSetup&,
0131 const fftjet::Functor1<bool, fftjet::Peak>& peakSelector,
0132 std::vector<fftjet::Peak>* preclusters);
0133
0134
0135
0136
0137
0138 virtual void assignMembershipFunctions(std::vector<fftjet::Peak>* preclusters);
0139
0140
0141 virtual std::unique_ptr<fftjet::Functor1<bool, fftjet::Peak> > parse_peakSelector(const edm::ParameterSet&);
0142
0143
0144 virtual std::unique_ptr<fftjet::ScaleSpaceKernel> parse_jetMembershipFunction(const edm::ParameterSet&);
0145
0146
0147 virtual std::unique_ptr<fftjetcms::AbsBgFunctor> parse_bgMembershipFunction(const edm::ParameterSet&);
0148
0149
0150 virtual std::unique_ptr<fftjet::Functor1<double, fftjet::Peak> > parse_recoScaleCalcPeak(const edm::ParameterSet&);
0151
0152
0153 virtual std::unique_ptr<fftjet::Functor1<double, fftjet::Peak> > parse_recoScaleRatioCalcPeak(
0154 const edm::ParameterSet&);
0155
0156
0157 virtual std::unique_ptr<fftjet::Functor1<double, fftjet::Peak> > parse_memberFactorCalcPeak(const edm::ParameterSet&);
0158
0159
0160 virtual std::unique_ptr<fftjet::Functor1<double, RecoFFTJet> > parse_recoScaleCalcJet(const edm::ParameterSet&);
0161
0162 virtual std::unique_ptr<fftjet::Functor1<double, RecoFFTJet> > parse_recoScaleRatioCalcJet(const edm::ParameterSet&);
0163
0164 virtual std::unique_ptr<fftjet::Functor1<double, RecoFFTJet> > parse_memberFactorCalcJet(const edm::ParameterSet&);
0165
0166
0167
0168 virtual std::unique_ptr<fftjet::Functor2<double, RecoFFTJet, RecoFFTJet> > parse_jetDistanceCalc(
0169 const edm::ParameterSet&);
0170
0171
0172 virtual std::unique_ptr<fftjetcms::AbsPileupCalculator> parse_pileupDensityCalc(const edm::ParameterSet& ps);
0173
0174
0175
0176
0177 void selectTreeNodes(const SparseTree& tree,
0178 const fftjet::Functor1<bool, fftjet::Peak>& peakSelect,
0179 std::vector<SparseTree::NodeId>* nodes);
0180
0181 private:
0182 typedef fftjet::AbsVectorRecombinationAlg<fftjetcms::VectorLike, fftjetcms::BgData> RecoAlg;
0183 typedef fftjet::AbsRecombinationAlg<fftjetcms::Real, fftjetcms::VectorLike, fftjetcms::BgData> GridAlg;
0184
0185
0186 template <class Real>
0187 void loadSparseTreeData(const edm::Event&,
0188 const edm::EDGetTokenT<reco::PattRecoTree<Real, reco::PattRecoPeak<Real> > >& tok);
0189
0190 void removeFakePreclusters();
0191
0192
0193
0194 bool loadEnergyFlow(const edm::Event& iEvent, std::unique_ptr<fftjet::Grid2d<fftjetcms::Real> >& flow);
0195 void buildGridAlg();
0196 void prepareRecombinationScales();
0197 bool checkConvergence(const std::vector<RecoFFTJet>& previousIterResult, std::vector<RecoFFTJet>& thisIterResult);
0198 void determineGriddedConstituents();
0199 void determineVectorConstituents();
0200 void saveResults(edm::Event& iEvent, const edm::EventSetup&, unsigned nPreclustersFound);
0201
0202 template <typename Jet>
0203 void writeJets(edm::Event& iEvent, const edm::EventSetup&);
0204
0205 template <typename Jet>
0206 void makeProduces(const std::string& alias, const std::string& tag);
0207
0208
0209
0210
0211 virtual void determinePileupDensityFromConfig(const edm::Event& iEvent,
0212 std::unique_ptr<fftjet::Grid2d<fftjetcms::Real> >& density);
0213
0214
0215 virtual void determinePileupDensityFromDB(const edm::Event& iEvent,
0216 const edm::EventSetup& iSetup,
0217 std::unique_ptr<fftjet::Grid2d<fftjetcms::Real> >& density);
0218
0219
0220
0221 void determinePileup();
0222
0223
0224
0225
0226
0227
0228
0229 unsigned iterateJetReconstruction();
0230
0231
0232 static void setJetStatusBit(RecoFFTJet* jet, int mask, bool value);
0233
0234
0235
0236
0237
0238
0239 const edm::ParameterSet myConfiguration;
0240
0241
0242 const edm::InputTag treeLabel;
0243
0244
0245
0246 const bool useGriddedAlgorithm;
0247
0248
0249
0250 const bool reuseExistingGrid;
0251
0252
0253 const unsigned maxIterations;
0254
0255
0256 const unsigned nJetsRequiredToConverge;
0257 const double convergenceDistance;
0258
0259
0260 const bool assignConstituents;
0261
0262
0263
0264
0265 const bool resumConstituents;
0266
0267
0268
0269 const bool calculatePileup;
0270 const bool subtractPileup;
0271 const bool subtractPileupAs4Vec;
0272
0273
0274
0275 const edm::InputTag pileupLabel;
0276
0277
0278 const double fixedScale;
0279
0280
0281 const double minStableScale;
0282 const double maxStableScale;
0283
0284
0285 const double stabilityAlpha;
0286
0287
0288
0289 const double noiseLevel;
0290
0291
0292 const unsigned nClustersRequested;
0293
0294
0295 const double gridScanMaxEta;
0296
0297
0298 const std::string recombinationAlgorithm;
0299 const bool isCrisp;
0300 const double unlikelyBgWeight;
0301 const double recombinationDataCutoff;
0302
0303
0304 const edm::InputTag genJetsLabel;
0305
0306
0307
0308
0309 const unsigned maxInitialPreclusters;
0310
0311
0312
0313
0314 Resolution resolution;
0315
0316
0317
0318 std::string pileupTableRecord;
0319 std::string pileupTableName;
0320 std::string pileupTableCategory;
0321 bool loadPileupFromDB;
0322
0323
0324 std::unique_ptr<std::vector<double> > iniScales;
0325
0326
0327 SparseTree sparseTree;
0328
0329
0330 std::unique_ptr<fftjet::Functor1<bool, fftjet::Peak> > peakSelector;
0331
0332
0333 std::unique_ptr<RecoAlg> recoAlg;
0334 std::unique_ptr<GridAlg> gridAlg;
0335 std::unique_ptr<fftjet::ScaleSpaceKernel> jetMembershipFunction;
0336 std::unique_ptr<fftjetcms::AbsBgFunctor> bgMembershipFunction;
0337
0338
0339 std::unique_ptr<fftjet::Functor1<double, fftjet::Peak> > recoScaleCalcPeak;
0340
0341
0342 std::unique_ptr<fftjet::Functor1<double, fftjet::Peak> > recoScaleRatioCalcPeak;
0343
0344
0345 std::unique_ptr<fftjet::Functor1<double, fftjet::Peak> > memberFactorCalcPeak;
0346
0347
0348 std::unique_ptr<fftjet::Functor1<double, RecoFFTJet> > recoScaleCalcJet;
0349 std::unique_ptr<fftjet::Functor1<double, RecoFFTJet> > recoScaleRatioCalcJet;
0350 std::unique_ptr<fftjet::Functor1<double, RecoFFTJet> > memberFactorCalcJet;
0351
0352
0353
0354 std::unique_ptr<fftjet::Functor2<double, RecoFFTJet, RecoFFTJet> > jetDistanceCalc;
0355
0356
0357 std::vector<SparseTree::NodeId> nodes;
0358
0359
0360 std::vector<fftjet::Peak> preclusters;
0361
0362
0363 std::vector<RecoFFTJet> recoJets;
0364
0365
0366 std::vector<unsigned> occupancy;
0367
0368
0369 std::vector<double> thresholds;
0370
0371
0372 unsigned minLevel, maxLevel, usedLevel;
0373
0374
0375 fftjetcms::VectorLike unclustered;
0376 double unused;
0377
0378
0379 std::vector<fftjet::Peak> iterPreclusters;
0380 std::vector<RecoFFTJet> iterJets;
0381 unsigned iterationsPerformed;
0382
0383
0384 std::vector<std::vector<reco::CandidatePtr> > constituents;
0385
0386
0387
0388 std::vector<fftjetcms::VectorLike> pileup;
0389
0390
0391
0392
0393 std::unique_ptr<fftjet::Grid2d<fftjetcms::Real> > pileupEnergyFlow;
0394
0395
0396 std::unique_ptr<fftjetcms::AbsPileupCalculator> pileupDensityCalc;
0397
0398
0399 std::vector<fftjet::AbsKernel2d*> memFcns2dVec;
0400 std::vector<double> doubleBuf;
0401 std::vector<unsigned> cellCountsVec;
0402
0403
0404 edm::EDGetTokenT<reco::PattRecoTree<double, reco::PattRecoPeak<double> > > input_recotree_token_d_;
0405 edm::EDGetTokenT<reco::PattRecoTree<float, reco::PattRecoPeak<float> > > input_recotree_token_f_;
0406 edm::EDGetTokenT<std::vector<reco::FFTAnyJet<reco::GenJet> > > input_genjet_token_;
0407 edm::EDGetTokenT<reco::DiscretizedEnergyFlow> input_energyflow_token_;
0408 edm::EDGetTokenT<reco::FFTJetPileupSummary> input_pusummary_token_;
0409
0410 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geometry_token_;
0411 edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> topology_token_;
0412
0413 FFTJetLookupTableSequenceLoader esLoader_;
0414 };
0415
0416 #endif