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