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