CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
NJetsMC.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: NJetsMC
4 // Class: NJetsMC
5 //
13 //
14 // Original Author: "Nathaniel Odell"
15 // Created: Thu Aug 12 09:24:46 CDT 2010
16 // then moved to more general N-jets purpose in GeneratorInterface/GenFilters
17 //
18 
27 
30 
31 #include <cstdint>
32 
33 class NJetsMC : public edm::global::EDFilter<> {
34 public:
35  explicit NJetsMC(const edm::ParameterSet&);
36 
37 private:
38  bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
39 
40  // ----------member data ---------------------------
41 
43  const int njets_;
44  const double minpt_;
45 };
46 
48  : genToken_(consumes<reco::GenJetCollection>(iConfig.getUntrackedParameter<edm::InputTag>("GenTag"))),
49  njets_(iConfig.getParameter<int32_t>("Njets")),
50  minpt_(iConfig.getParameter<double>("MinPt")) {}
51 
54  iEvent.getByToken(genToken_, genJets);
55 
56  int count = 0;
57  bool result = false;
58 
59  for (reco::GenJetCollection::const_iterator iJet = genJets->begin(); iJet != genJets->end(); ++iJet) {
60  reco::GenJet myJet = reco::GenJet(*iJet);
61 
62  if (myJet.pt() > minpt_)
63  ++count;
64  }
65 
66  if (count >= njets_)
67  result = true;
68 
69  return result;
70 }
71 //define this as a plug-in
double pt() const final
transverse momentum
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< GenJet > GenJetCollection
collection of GenJet objects
const double minpt_
Definition: NJetsMC.cc:44
const edm::EDGetTokenT< reco::GenJetCollection > genToken_
Definition: NJetsMC.cc:42
tuple result
Definition: mps_fire.py:311
int iEvent
Definition: GenABIO.cc:224
Jets made from MC generator particles.
Definition: GenJet.h:23
njets_(iConfig.getParameter< unsigned int >("njets"))
bool filter(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: NJetsMC.cc:52
const int njets_
Definition: NJetsMC.cc:43
NJetsMC(const edm::ParameterSet &)
Definition: NJetsMC.cc:47