CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TTbar_GenJetAnalyzer.cc
Go to the documentation of this file.
2 
3 
5  jets_(iConfig.getParameter<edm::InputTag>("jets")),
6  genEventInfoProductTag_(iConfig.getParameter<edm::InputTag>("genEventInfoProductTag"))
7 {
8 
9  genEventInfoProductTagToken_=consumes<GenEventInfoProduct>(genEventInfoProductTag_);
10  jetsToken_=consumes<std::vector<reco::GenJet> >(jets_);
11 
12 }
13 
14 
16 
17 
19 {
20  using namespace edm;
21 
22  // --- the MC weights ---
24  iEvent.getByToken(genEventInfoProductTagToken_, evt_info);
25  if(!evt_info.isValid()) return;
26  weight = evt_info->weight() ;
27 
28  // Gather information in the GenJet collection
30  iEvent.getByToken(jetsToken_, jets );
31 
32  if(!jets.isValid()) return;
33  // loop Jet collection and fill histograms
34  int njets = 0;
35  for(std::vector<reco::GenJet>::const_iterator jet_it=jets->begin(); jet_it!=jets->end(); ++jet_it){
36 
37  ++njets;
38 
39  hists_["jetPtAll" ]->Fill( jet_it->pt() , weight );
40  hists_["jetEtaAll"]->Fill( jet_it->eta(), weight );
41 
42  if (njets == 1) { hists_["jetPt1" ]->Fill( jet_it->pt() , weight );
43  hists_["jetEta1"]->Fill( jet_it->eta(), weight );
44  }
45  if (njets == 2) { hists_["jetPt2" ]->Fill( jet_it->pt() , weight );
46  hists_["jetEta2"]->Fill( jet_it->eta(), weight );
47  }
48  if (njets == 3) { hists_["jetPt3" ]->Fill( jet_it->pt() , weight );
49  hists_["jetEta3"]->Fill( jet_it->eta(), weight );
50  }
51  if (njets == 4) { hists_["jetPt4" ]->Fill( jet_it->pt() , weight );
52  hists_["jetEta4"]->Fill( jet_it->eta(), weight );
53  }
54  }
55 
56 }
57 
58 
60  i.setCurrentFolder("Generator/TTbar");
61  hists_["jetPtAll" ] = i.book1D("TTbar_jetPtAll" , "pt" , 1000, 0., 1000.);
62  hists_["jetPt1" ] = i.book1D("TTbar_jetPt1" , "pt" , 1000, 0., 1000.);
63  hists_["jetPt2" ] = i.book1D("TTbar_jetPt2" , "pt" , 1000, 0., 1000.);
64  hists_["jetPt3" ] = i.book1D("TTbar_jetPt3" , "pt" , 1000, 0., 1000.);
65  hists_["jetPt4" ] = i.book1D("TTbar_jetPt4" , "pt" , 1000, 0., 1000.);
66 
67  hists_["jetEtaAll"] = i.book1D("TTbar_jetEtaAll", "eta", 100, -5., 5.);
68  hists_["jetEta1" ] = i.book1D("TTbar_jetEta1" , "eta", 100, -5., 5.);
69  hists_["jetEta2" ] = i.book1D("TTbar_jetEta2" , "eta", 100, -5., 5.);
70  hists_["jetEta3" ] = i.book1D("TTbar_jetEta3" , "eta", 100, -5., 5.);
71  hists_["jetEta4" ] = i.book1D("TTbar_jetEta4" , "eta", 100, -5., 5.);
72 }
73 
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< std::vector< reco::GenJet > > jetsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
int iEvent
Definition: GenABIO.cc:230
vector< PseudoJet > jets
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
edm::InputTag genEventInfoProductTag_
edm::EDGetTokenT< GenEventInfoProduct > genEventInfoProductTagToken_
std::map< std::string, MonitorElement * > hists_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
Definition: Run.h:41
TTbar_GenJetAnalyzer(const edm::ParameterSet &)