CMS 3D CMS Logo

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