CMS 3D CMS Logo

VirtualJetProducer.h
Go to the documentation of this file.
1 #ifndef RecoJets_JetProducers_plugins_VirtualJetProducer_h
2 #define RecoJets_JetProducers_plugins_VirtualJetProducer_h
3 
5 
19 
21 
24 
25 #include "fastjet/JetDefinition.hh"
26 #include "fastjet/ClusterSequence.hh"
27 #include "fastjet/ClusterSequenceArea.hh"
28 #include "fastjet/PseudoJet.hh"
29 #include "fastjet/GhostedAreaSpec.hh"
30 #include "fastjet/Selector.hh"
31 
32 #include <memory>
33 #include <vector>
34 
35 class CaloGeometryRecord;
37 
39 protected:
40  //
41  // typedefs & structs
42  //
43  struct JetType {
44  enum Type {
51  LastJetType // no real type, technical
52  };
53  static const char* const names[];
54  static Type byName(const std::string& name);
55  };
56 
58 
59  inline bool makeCaloJet(const JetType::Type& fTag) { return fTag == JetType::CaloJet; }
60  inline bool makePFJet(const JetType::Type& fTag) { return fTag == JetType::PFJet; }
61  inline bool makeGenJet(const JetType::Type& fTag) { return fTag == JetType::GenJet; }
62  inline bool makeTrackJet(const JetType::Type& fTag) { return fTag == JetType::TrackJet; }
63  inline bool makePFClusterJet(const JetType::Type& fTag) { return fTag == JetType::PFClusterJet; }
64  inline bool makeBasicJet(const JetType::Type& fTag) { return fTag == JetType::BasicJet; }
65 
66  //
67  // construction/destruction
68  //
69 public:
70  explicit VirtualJetProducer(const edm::ParameterSet& iConfig);
71  ~VirtualJetProducer() override;
72  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
73  static void fillDescriptionsFromVirtualJetProducer(edm::ParameterSetDescription& desc);
74 
75  // typedefs
76  typedef std::shared_ptr<fastjet::ClusterSequence> ClusterSequencePtr;
77  typedef std::shared_ptr<fastjet::JetDefinition::Plugin> PluginPtr;
78  typedef std::shared_ptr<fastjet::JetDefinition> JetDefPtr;
79  typedef std::shared_ptr<fastjet::GhostedAreaSpec> ActiveAreaSpecPtr;
80  typedef std::shared_ptr<fastjet::AreaDefinition> AreaDefinitionPtr;
81  typedef std::shared_ptr<fastjet::Selector> SelectorPtr;
82 
83  //
84  // member functions
85  //
86 public:
87  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override;
88  std::string jetType() const { return jetType_; }
89 
90 protected:
91  //
92  // Internal methods for jet production.
93  // The user can either use the defaults, or override all of these methods.
94  //
95 
96  // This method creates the "produces" statement in the constructor.
97  // The default is to produce a single jet collection as per the user's request
98  // (Calo,PF,Basic, or Gen).
99  virtual void makeProduces(std::string s, std::string tag = "");
100 
101  // This method inputs the constituents from "inputs" and modifies
102  // fjInputs.
103  virtual void inputTowers();
104 
105  // This checks if the tower is anomalous (if a calo tower).
106  virtual bool isAnomalousTower(reco::CandidatePtr input);
107 
108  // This will copy the fastjet constituents to the jet itself.
109  virtual void copyConstituents(const std::vector<fastjet::PseudoJet>& fjConstituents, reco::Jet* jet);
110 
111  // This will run the actual algorithm. This method is pure virtual and
112  // has no default.
113  virtual void runAlgorithm(edm::Event& iEvent, const edm::EventSetup& iSetup) = 0;
114 
115  // This will allow making the HTTTopJetTagInfoCollection
117  const edm::EventSetup& iSetup,
119 
120  // Do the offset correction.
121  // Only runs if "doPUOffsetCorrection_" is true.
122  void offsetCorrectJets(std::vector<fastjet::PseudoJet>& orphanInput);
123 
124  // This will write the jets to the event.
125  // The default is to write out the single jet collection in the default "produces"
126  // statement.
127  // This is a function template that can be called for the six types
128  // CaloJet, PFJet, GenJet, TrackJet, PFClusterJet, BasicJet.
129  // This is not suitable for compound jets.
130  // Note: The "output" method is virtual and can be overriden.
131  // The default behavior is to call the function template "writeJets".
132  virtual void output(edm::Event& iEvent, edm::EventSetup const& iSetup);
133  template <typename T>
134  void writeJets(edm::Event& iEvent, edm::EventSetup const& iSetup);
135 
136  template <typename T>
137  void writeCompoundJets(edm::Event& iEvent, edm::EventSetup const& iSetup);
138 
139  template <typename T>
140  void writeJetsWithConstituents(edm::Event& iEvent, edm::EventSetup const& iSetup);
141 
142  // This method copies the constituents from the fjConstituents method
143  // to an output of CandidatePtr's.
144  virtual std::vector<reco::CandidatePtr> getConstituents(const std::vector<fastjet::PseudoJet>& fjConstituents);
145 
146  //These are only valid if we are dealing with CaloJets
147  CaloGeometry const& getGeometry(edm::EventSetup const&) const;
148  HcalTopology const& getTopology(edm::EventSetup const&) const;
149 
150  //
151  // member data
152  //
153 protected:
154  std::string moduleLabel_; // label for this module
155  edm::InputTag src_; // input constituent source
156  edm::InputTag srcPVs_; // primary vertex source
157  std::string jetType_; // type of jet (Calo,PF,Basic,Gen)
158  std::string jetAlgorithm_; // the jet algorithm to use
159  double rParam_; // the R parameter to use
160  double inputEtMin_; // minimum et of input constituents
161  double inputEMin_; // minimum e of input constituents
162  double jetPtMin_; // minimum jet pt
163  bool doPVCorrection_; // correct to primary vertex?
164 
165  // for restricting inputs due to processing time
166  bool restrictInputs_; // restrict inputs to first "maxInputs" inputs.
167  unsigned int maxInputs_; // maximum number of inputs.
168 
169  // for fastjet jet area calculation
170  bool doAreaFastjet_; // calculate area w/ fastjet?
171  bool useExplicitGhosts_; // use explicit ghosts in fastjet clustering sequence
172  bool doAreaDiskApprox_; // calculate area w/ disk approximation (only makes sense for anti-KT)?
173  // for fastjet rho calculation
174  bool doRhoFastjet_; // calculate rho w/ fastjet?
175  bool doFastJetNonUniform_; // choice of eta-dependent PU calculation
176  double
177  voronoiRfact_; // negative to calculate rho using active area (ghosts); otherwise calculates Voronoi area with this effective scale factor
178 
179  double
180  rhoEtaMax_; // Eta range of jets to be considered for Rho calculation; Should be at most (jet acceptance - jet radius)
181  double ghostEtaMax_; // default Ghost_EtaMax should be 5
182  int activeAreaRepeats_; // default Active_Area_Repeats 1
183  double ghostArea_; // default GhostArea 0.01
184 
185  // for pileup offset correction
186  bool doPUOffsetCorr_; // add the pileup calculation from offset correction?
188 
189  std::vector<edm::Ptr<reco::Candidate>>
190  inputs_; // input candidates [View, PtrVector and CandCollection have limitations]
191  reco::Particle::Point vertex_; // Primary vertex
192  ClusterSequencePtr fjClusterSeq_; // fastjet cluster sequence
193  JetDefPtr fjJetDefinition_; // fastjet jet definition
194  PluginPtr fjPlugin_; // fastjet plugin
195  ActiveAreaSpecPtr fjActiveArea_; // fastjet active area definition
196  AreaDefinitionPtr fjAreaDefinition_; // fastjet area definition
197  SelectorPtr fjSelector_; // selector for range definition
198  std::vector<fastjet::PseudoJet> fjInputs_; // fastjet inputs
199  std::vector<fastjet::PseudoJet> fjJets_; // fastjet jets
200 
201  // Parameters of the eta-dependent rho calculation
202  std::vector<double> puCenters_;
203  double puWidth_;
204  unsigned int nExclude_;
205 
206  std::string jetCollInstanceName_; // instance name for output jet collection
207  bool writeCompound_; // write compound jets (i.e. jets of jets)
208  bool writeJetsWithConst_; // write jets with constituents
209  std::shared_ptr<PileUpSubtractor> subtractor_;
210 
211  bool useDeterministicSeed_; // If desired, use a deterministic seed to fastjet
212  unsigned int minSeed_; // minimum seed to use, useful for MC generation
213 
214  int verbosity_; // flag to enable/disable debug output
215  bool fromHTTTopJetProducer_ = false; // for running the v2.0 HEPTopTagger
216  bool applyWeight_; // Apply weights stored in a value map or inside PackedCandidate (e.g. from PUPPI)
217  edm::ValueMap<float> weights_; // weights per particle (e.g. from PUPPI)
218 
219 private:
220  //These are only initialized if we are dealing with CaloJets
223 
224  std::unique_ptr<AnomalousTower> anomalousTowerDef_; // anomalous tower definition
225 
226  // tokens for the data access
232 
233 protected:
236 };
237 
238 #endif
JetType::Type jetTypeE
std::shared_ptr< PileUpSubtractor > subtractor_
edm::ValueMap< float > weights_
reco::Particle::Point vertex_
virtual void addHTTTopJetTagInfoCollection(edm::Event &iEvent, const edm::EventSetup &iSetup, edm::OrphanHandle< reco::BasicJetCollection > &oh)
edm::EDGetTokenT< reco::CandidateView > input_candidateview_token_
std::vector< fastjet::PseudoJet > fjJets_
edm::EDGetTokenT< std::vector< edm::FwdPtr< pat::PackedCandidate > > > input_packedcandidatefwdptr_token_
Base class for all types of Jets.
Definition: Jet.h:20
std::shared_ptr< fastjet::ClusterSequence > ClusterSequencePtr
std::string jetType() const
std::shared_ptr< fastjet::JetDefinition > JetDefPtr
std::string puSubtractorName_
std::vector< double > puCenters_
bool makeGenJet(const JetType::Type &fTag)
bool makeBasicJet(const JetType::Type &fTag)
const std::string names[nVars_]
static std::string const input
Definition: EdmProvDump.cc:47
bool makeTrackJet(const JetType::Type &fTag)
bool makePFJet(const JetType::Type &fTag)
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geometry_token_
std::vector< fastjet::PseudoJet > fjInputs_
int iEvent
Definition: GenABIO.cc:224
std::string jetCollInstanceName_
std::shared_ptr< fastjet::GhostedAreaSpec > ActiveAreaSpecPtr
std::vector< edm::Ptr< reco::Candidate > > inputs_
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topology_token_
ClusterSequencePtr fjClusterSeq_
math::XYZPoint Point
point in the space
Definition: Particle.h:25
ActiveAreaSpecPtr fjActiveArea_
bool makePFClusterJet(const JetType::Type &fTag)
std::shared_ptr< fastjet::AreaDefinition > AreaDefinitionPtr
#define dso_hidden
Definition: Visibility.h:12
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< edm::ValueMap< float > > input_weights_token_
edm::EDGetTokenT< std::vector< edm::FwdPtr< pat::PackedGenParticle > > > input_packedgencandidatefwdptr_token_
edm::EDGetTokenT< reco::VertexCollection > input_vertex_token_
std::unique_ptr< AnomalousTower > anomalousTowerDef_
edm::EDGetTokenT< std::vector< edm::FwdPtr< reco::GenParticle > > > input_gencandidatefwdptr_token_
edm::EDGetTokenT< std::vector< edm::FwdPtr< reco::PFCandidate > > > input_candidatefwdptr_token_
std::shared_ptr< fastjet::JetDefinition::Plugin > PluginPtr
AreaDefinitionPtr fjAreaDefinition_
bool makeCaloJet(const JetType::Type &fTag)
std::shared_ptr< fastjet::Selector > SelectorPtr