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