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