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/ActiveAreaSpec.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::ActiveAreaSpec> ActiveAreaSpecPtr;
83  typedef boost::shared_ptr<fastjet::RangeDefinition> RangeDefPtr;
84 
85  //
86  // member functions
87  //
88 public:
89  virtual void produce(edm::Event& iEvent, const edm::EventSetup& iSetup);
90  std::string jetType() const { return jetType_; }
91 
92 protected:
93 
94  //
95  // Internal methods for jet production.
96  // The user can either use the defaults, or override all of these methods.
97  //
98 
99  // This method creates the "produces" statement in the constructor.
100  // The default is to produce a single jet collection as per the user's request
101  // (Calo,PF,Basic, or Gen).
102  virtual void makeProduces( std::string s, std::string tag = "" );
103 
104  // This method inputs the constituents from "inputs" and modifies
105  // fjInputs.
106  virtual void inputTowers();
107 
108  // This checks if the tower is anomalous (if a calo tower).
110 
111  // This will copy the fastjet constituents to the jet itself.
112  virtual void copyConstituents(const std::vector<fastjet::PseudoJet>&fjConstituents,
113  reco::Jet* jet);
114 
115  // This will run the actual algorithm. This method is pure virtual and
116  // has no default.
117  virtual void runAlgorithm( edm::Event& iEvent, const edm::EventSetup& iSetup) = 0;
118 
119  // Do the offset correction.
120  // Only runs if "doPUOffsetCorrection_" is true.
121  void offsetCorrectJets(std::vector<fastjet::PseudoJet> & orphanInput);
122 
123  // This will write the jets to the event.
124  // The default is to write out the single jet collection in the default "produces"
125  // statement.
126  // This is a function template that can be called for the six types
127  // CaloJet, PFJet, GenJet, TrackJet, PFClusterJet, BasicJet.
128  // This is not suitable for compound jets.
129  // Note: The "output" method is virtual and can be overriden.
130  // The default behavior is to call the function template "writeJets".
131  virtual void output( edm::Event & iEvent, edm::EventSetup const& iSetup );
132  template< typename T >
133  void writeJets( edm::Event & iEvent, edm::EventSetup const& iSetup );
134 
135  // This method copies the constituents from the fjConstituents method
136  // to an output of CandidatePtr's.
137  virtual std::vector<reco::CandidatePtr>
138  getConstituents(const std::vector<fastjet::PseudoJet>&fjConstituents);
139 
140  //
141  // member data
142  //
143 protected:
144  std::string moduleLabel_; // label for this module
145  edm::InputTag src_; // input constituent source
146  edm::InputTag srcPVs_; // primary vertex source
147  std::string jetType_; // type of jet (Calo,PF,Basic,Gen)
148  std::string jetAlgorithm_; // the jet algorithm to use
149  double rParam_; // the R parameter to use
150  double inputEtMin_; // minimum et of input constituents
151  double inputEMin_; // minimum e of input constituents
152  double jetPtMin_; // minimum jet pt
153  bool doPVCorrection_; // correct to primary vertex?
154 
155  // for restricting inputs due to processing time
156  bool restrictInputs_; // restrict inputs to first "maxInputs" inputs.
157  unsigned int maxInputs_; // maximum number of inputs.
158 
159  // for fastjet jet area calculation
160  bool doAreaFastjet_; // calculate area w/ fastjet?
161  bool doAreaDiskApprox_; // calculate area w/ disk approximation (only makes sense for anti-KT)?
162  // for fastjet rho calculation
163  bool doRhoFastjet_; // calculate rho w/ fastjet?
164  bool doFastJetNonUniform_; // choice of eta-dependent PU calculation
165  double voronoiRfact_; // negative to calculate rho using active area (ghosts); otherwise calculates Voronoi area with this effective scale factor
166 
167  // for pileup offset correction
168  bool doPUOffsetCorr_; // add the pileup calculation from offset correction?
169  std::string puSubtractorName_;
170 
171 
172  std::vector<edm::Ptr<reco::Candidate> > inputs_; // input candidates [View, PtrVector and CandCollection have limitations]
173  reco::Particle::Point vertex_; // Primary vertex
174  ClusterSequencePtr fjClusterSeq_; // fastjet cluster sequence
175  JetDefPtr fjJetDefinition_; // fastjet jet definition
176  PluginPtr fjPlugin_; // fastjet plugin
177  ActiveAreaSpecPtr fjActiveArea_; // fastjet active area definition
178  RangeDefPtr fjRangeDef_; // range definition
179  std::vector<fastjet::PseudoJet> fjInputs_; // fastjet inputs
180  std::vector<fastjet::PseudoJet> fjJets_; // fastjet jets
181 
182  // Parameters of the eta-dependent rho calculation
183  std::vector<double> puCenters_;
184  double puWidth_;
185  unsigned int nExclude_;
186 
187  std::string jetCollInstanceName_; // instance name for output jet collection
188  boost::shared_ptr<PileUpSubtractor> subtractor_;
189 
190  bool useDeterministicSeed_; // If desired, use a deterministic seed to fastjet
191  unsigned int minSeed_; // minimum seed to use, useful for MC generation
192 
193 private:
194  std::auto_ptr<AnomalousTower> anomalousTowerDef_; // anomalous tower definition
195 };
196 
197 
198 
199 
200 
201 #endif
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:21
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
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:30
boost::shared_ptr< fastjet::JetDefinition > JetDefPtr
std::auto_ptr< AnomalousTower > anomalousTowerDef_
ActiveAreaSpecPtr fjActiveArea_
bool makePFClusterJet(const JetType::Type &fTag)
tuple input
Definition: collect_tpl.py:10
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
VirtualJetProducer(const edm::ParameterSet &iConfig)
string s
Definition: asciidump.py:422
virtual void output(edm::Event &iEvent, edm::EventSetup const &iSetup)
boost::shared_ptr< fastjet::ActiveAreaSpec > ActiveAreaSpecPtr
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