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