CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
28 
30 
33 
35 
36 #include "TROOT.h"
37 #include "TH1F.h"
38 #include "TFile.h"
39 #include "TSystem.h"
40 #include <iostream>
41 
42 using namespace edm;
43 using namespace std;
44 using namespace reco;
45 
46 //
47 // class declaration
48 //
49 
50 class NJetsMC : public edm::EDFilter
51 {
52 public:
53  explicit NJetsMC(const edm::ParameterSet&);
54  ~NJetsMC();
55 
56 private:
57  virtual void beginJob() override ;
58  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
59  virtual void endJob() override ;
60 
61  // ----------member data ---------------------------
62 
64  Int_t njets_;
65  double minpt_;
66 
67 };
68 
70  GenHandle_(iConfig.getUntrackedParameter<InputTag>("GenTag")),
71  njets_(iConfig.getParameter<int32_t>("Njets")),
72  minpt_(iConfig.getParameter<double>("MinPt"))
73 {
74 }
75 
76 
78 {
79 }
80 
82 {
83  using namespace edm;
84 
86  iEvent.getByLabel(GenHandle_, GenJets);
87 
88  Int_t count = 0;
89  bool result = false;
90 
91  for(GenJetCollection::const_iterator iJet = GenJets->begin(); iJet != GenJets->end(); ++iJet)
92  {
93  reco::GenJet myJet = reco::GenJet(*iJet);
94 
95  if(myJet.pt() > minpt_) ++count;
96  }
97 
98  if( count >= njets_ )
99  result = true;
100 
101  return result;
102 }
103 
105 {
106 }
107 
109 {
110 }
111 
112 //define this as a plug-in
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::InputTag GenHandle_
Definition: NJetsMC.cc:63
~NJetsMC()
Definition: NJetsMC.cc:77
void beginJob()
Definition: Breakpoints.cc:15
int iEvent
Definition: GenABIO.cc:230
tuple result
Definition: query.py:137
Jets made from MC generator particles.
Definition: GenJet.h:24
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
tuple GenJets
Definition: jetmet_cfg.py:40
virtual void beginJob() override
Definition: NJetsMC.cc:104
virtual bool filter(edm::Event &, const edm::EventSetup &) override
Definition: NJetsMC.cc:81
double minpt_
Definition: NJetsMC.cc:65
Int_t njets_
Definition: NJetsMC.cc:64
NJetsMC(const edm::ParameterSet &)
Definition: NJetsMC.cc:69
virtual void endJob() override
Definition: NJetsMC.cc:108
virtual float pt() const GCC11_FINAL
transverse momentum