File indexing completed on 2024-09-07 04:37:34
0001 #ifndef RecoJets_JetProducers_plugins_VirtualJetProducer_h
0002 #define RecoJets_JetProducers_plugins_VirtualJetProducer_h
0003
0004 #include "RecoJets/JetProducers/interface/JetSpecific.h"
0005
0006 #include "FWCore/Framework/interface/stream/EDProducer.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0010 #include "DataFormats/Candidate/interface/Candidate.h"
0011 #include "DataFormats/Candidate/interface/CandidateFwd.h"
0012 #include "DataFormats/JetReco/interface/Jet.h"
0013 #include "DataFormats/JetReco/interface/CaloJet.h"
0014 #include "DataFormats/JetReco/interface/PFJet.h"
0015 #include "DataFormats/JetReco/interface/BasicJet.h"
0016 #include "DataFormats/JetReco/interface/GenJet.h"
0017 #include "DataFormats/PatCandidates/interface/PackedCandidate.h"
0018 #include "DataFormats/PatCandidates/interface/PackedGenParticle.h"
0019
0020 #include "DataFormats/JetReco/interface/BasicJetCollection.h"
0021
0022 #include "RecoJets/JetProducers/interface/PileUpSubtractor.h"
0023 #include "RecoJets/JetProducers/interface/AnomalousTower.h"
0024
0025 #include "fastjet/JetDefinition.hh"
0026 #include "fastjet/ClusterSequence.hh"
0027 #include "fastjet/ClusterSequenceArea.hh"
0028 #include "fastjet/PseudoJet.hh"
0029 #include "fastjet/GhostedAreaSpec.hh"
0030 #include "fastjet/Selector.hh"
0031
0032 #include <memory>
0033 #include <vector>
0034
0035 class CaloGeometryRecord;
0036 class HcalRecNumberingRecord;
0037
0038 class dso_hidden VirtualJetProducer : public edm::stream::EDProducer<> {
0039 protected:
0040
0041
0042
0043 struct JetType {
0044 enum Type {
0045 BasicJet,
0046 GenJet,
0047 CaloJet,
0048 PFJet,
0049 TrackJet,
0050 PFClusterJet,
0051 LastJetType
0052 };
0053 static const char* const names[];
0054 static Type byName(const std::string& name);
0055 };
0056
0057 JetType::Type jetTypeE;
0058
0059 inline bool makeCaloJet(const JetType::Type& fTag) { return fTag == JetType::CaloJet; }
0060 inline bool makePFJet(const JetType::Type& fTag) { return fTag == JetType::PFJet; }
0061 inline bool makeGenJet(const JetType::Type& fTag) { return fTag == JetType::GenJet; }
0062 inline bool makeTrackJet(const JetType::Type& fTag) { return fTag == JetType::TrackJet; }
0063 inline bool makePFClusterJet(const JetType::Type& fTag) { return fTag == JetType::PFClusterJet; }
0064 inline bool makeBasicJet(const JetType::Type& fTag) { return fTag == JetType::BasicJet; }
0065
0066
0067
0068
0069 public:
0070 explicit VirtualJetProducer(const edm::ParameterSet& iConfig);
0071 ~VirtualJetProducer() override;
0072 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0073 static void fillDescriptionsFromVirtualJetProducer(edm::ParameterSetDescription& desc);
0074
0075
0076 typedef std::shared_ptr<fastjet::ClusterSequence> ClusterSequencePtr;
0077 typedef std::shared_ptr<fastjet::JetDefinition::Plugin> PluginPtr;
0078 typedef std::shared_ptr<fastjet::JetDefinition> JetDefPtr;
0079 typedef std::shared_ptr<fastjet::GhostedAreaSpec> ActiveAreaSpecPtr;
0080 typedef std::shared_ptr<fastjet::AreaDefinition> AreaDefinitionPtr;
0081 typedef std::shared_ptr<fastjet::Selector> SelectorPtr;
0082
0083
0084
0085
0086 public:
0087 void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
0088 std::string jetType() const { return jetType_; }
0089
0090 protected:
0091
0092
0093
0094
0095
0096
0097
0098
0099 virtual void makeProduces(std::string s, std::string tag = "");
0100
0101
0102
0103 virtual void inputTowers();
0104
0105
0106 virtual bool isAnomalousTower(reco::CandidatePtr input);
0107
0108
0109 virtual void copyConstituents(const std::vector<fastjet::PseudoJet>& fjConstituents, reco::Jet* jet);
0110
0111
0112
0113 virtual void runAlgorithm(edm::Event& iEvent, const edm::EventSetup& iSetup) = 0;
0114
0115
0116 virtual void addHTTTopJetTagInfoCollection(edm::Event& iEvent,
0117 const edm::EventSetup& iSetup,
0118 edm::OrphanHandle<reco::BasicJetCollection>& oh) {};
0119
0120
0121
0122 void offsetCorrectJets(std::vector<fastjet::PseudoJet>& orphanInput);
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132 virtual void output(edm::Event& iEvent, edm::EventSetup const& iSetup);
0133 template <typename T>
0134 void writeJets(edm::Event& iEvent, edm::EventSetup const& iSetup);
0135
0136 template <typename T>
0137 void writeCompoundJets(edm::Event& iEvent, edm::EventSetup const& iSetup);
0138
0139 template <typename T>
0140 void writeJetsWithConstituents(edm::Event& iEvent, edm::EventSetup const& iSetup);
0141
0142
0143
0144 virtual std::vector<reco::CandidatePtr> getConstituents(const std::vector<fastjet::PseudoJet>& fjConstituents);
0145
0146
0147 CaloGeometry const& getGeometry(edm::EventSetup const&) const;
0148 HcalTopology const& getTopology(edm::EventSetup const&) const;
0149
0150
0151
0152
0153 protected:
0154 std::string moduleLabel_;
0155 edm::InputTag src_;
0156 edm::InputTag srcPVs_;
0157 std::string jetType_;
0158 std::string jetAlgorithm_;
0159 double rParam_;
0160 double inputEtMin_;
0161 double inputEMin_;
0162 double jetPtMin_;
0163 bool doPVCorrection_;
0164
0165
0166 bool restrictInputs_;
0167 unsigned int maxInputs_;
0168
0169
0170 bool doAreaFastjet_;
0171 bool useExplicitGhosts_;
0172 bool doAreaDiskApprox_;
0173
0174 bool doRhoFastjet_;
0175 bool doFastJetNonUniform_;
0176 double
0177 voronoiRfact_;
0178
0179 double
0180 rhoEtaMax_;
0181 double ghostEtaMax_;
0182 int activeAreaRepeats_;
0183 double ghostArea_;
0184
0185
0186 bool doPUOffsetCorr_;
0187 std::string puSubtractorName_;
0188
0189 std::vector<edm::Ptr<reco::Candidate>>
0190 inputs_;
0191 reco::Particle::Point vertex_;
0192 ClusterSequencePtr fjClusterSeq_;
0193 JetDefPtr fjJetDefinition_;
0194 PluginPtr fjPlugin_;
0195 ActiveAreaSpecPtr fjActiveArea_;
0196 AreaDefinitionPtr fjAreaDefinition_;
0197 SelectorPtr fjSelector_;
0198 std::vector<fastjet::PseudoJet> fjInputs_;
0199 std::vector<fastjet::PseudoJet> fjJets_;
0200
0201
0202 std::vector<double> puCenters_;
0203 double puWidth_;
0204 unsigned int nExclude_;
0205
0206 std::string jetCollInstanceName_;
0207 bool writeCompound_;
0208 bool writeJetsWithConst_;
0209 std::shared_ptr<PileUpSubtractor> subtractor_;
0210
0211 bool useDeterministicSeed_;
0212 unsigned int minSeed_;
0213
0214 int verbosity_;
0215 bool fromHTTTopJetProducer_ = false;
0216 bool applyWeight_;
0217 edm::ValueMap<float> weights_;
0218
0219 private:
0220
0221 edm::ESGetToken<CaloGeometry, CaloGeometryRecord> geometry_token_;
0222 edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> topology_token_;
0223
0224 std::unique_ptr<AnomalousTower> anomalousTowerDef_;
0225
0226
0227 edm::EDGetTokenT<reco::CandidateView> input_candidateview_token_;
0228 edm::EDGetTokenT<std::vector<edm::FwdPtr<reco::PFCandidate>>> input_candidatefwdptr_token_;
0229 edm::EDGetTokenT<std::vector<edm::FwdPtr<pat::PackedCandidate>>> input_packedcandidatefwdptr_token_;
0230 edm::EDGetTokenT<std::vector<edm::FwdPtr<reco::GenParticle>>> input_gencandidatefwdptr_token_;
0231 edm::EDGetTokenT<std::vector<edm::FwdPtr<pat::PackedGenParticle>>> input_packedgencandidatefwdptr_token_;
0232
0233 protected:
0234 edm::EDGetTokenT<reco::VertexCollection> input_vertex_token_;
0235 edm::EDGetTokenT<edm::ValueMap<float>> input_weights_token_;
0236 };
0237
0238 #endif