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