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