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