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  //now do what ever initialization is needed
9  dbe = 0;
11 }
12 
13 
15 {
16 
17  // do anything here that needs to be done at desctruction time
18  // (e.g. close files, deallocate resources etc.)
19 
20 }
21 
22 
23 //
24 // member functions
25 //
26 
27 // ------------ method called for each event ------------
28 void
29 
31 {
32  using namespace edm;
33 
34  // --- the MC weights ---
36  iEvent.getByLabel(genEventInfoProductTag_, evt_info);
37  if(!evt_info.isValid()) return;
38  weight = evt_info->weight() ;
39 
40  // Gather information in the GenJet collection
42  iEvent.getByLabel(jets_, jets );
43 
44  if(!jets.isValid()) return;
45  // loop Jet collection and fill histograms
46  int njets = 0;
47  for(std::vector<reco::GenJet>::const_iterator jet_it=jets->begin(); jet_it!=jets->end(); ++jet_it){
48 
49  ++njets;
50 
51  hists_["jetPtAll" ]->Fill( jet_it->pt() , weight );
52  hists_["jetEtaAll"]->Fill( jet_it->eta(), weight );
53 
54  if (njets == 1) { hists_["jetPt1" ]->Fill( jet_it->pt() , weight );
55  hists_["jetEta1"]->Fill( jet_it->eta(), weight );
56  }
57  if (njets == 2) { hists_["jetPt2" ]->Fill( jet_it->pt() , weight );
58  hists_["jetEta2"]->Fill( jet_it->eta(), weight );
59  }
60  if (njets == 3) { hists_["jetPt3" ]->Fill( jet_it->pt() , weight );
61  hists_["jetEta3"]->Fill( jet_it->eta(), weight );
62  }
63  if (njets == 4) { hists_["jetPt4" ]->Fill( jet_it->pt() , weight );
64  hists_["jetEta4"]->Fill( jet_it->eta(), weight );
65  }
66  }
67 
68 }
69 
70 
71 // ------------ method called once each job just before starting event loop ------------
72 void
74 {
75  if(!dbe) return;
76  dbe->setCurrentFolder("Generator/TTbar");
77  hists_["jetPtAll" ] = dbe->book1D("TTbar_jetPtAll" , "pt" , 1000, 0., 1000.);
78  hists_["jetPt1" ] = dbe->book1D("TTbar_jetPt1" , "pt" , 1000, 0., 1000.);
79  hists_["jetPt2" ] = dbe->book1D("TTbar_jetPt2" , "pt" , 1000, 0., 1000.);
80  hists_["jetPt3" ] = dbe->book1D("TTbar_jetPt3" , "pt" , 1000, 0., 1000.);
81  hists_["jetPt4" ] = dbe->book1D("TTbar_jetPt4" , "pt" , 1000, 0., 1000.);
82 
83  hists_["jetEtaAll"] = dbe->book1D("TTbar_jetEtaAll", "eta", 100, -5., 5.);
84  hists_["jetEta1" ] = dbe->book1D("TTbar_jetEta1" , "eta", 100, -5., 5.);
85  hists_["jetEta2" ] = dbe->book1D("TTbar_jetEta2" , "eta", 100, -5., 5.);
86  hists_["jetEta3" ] = dbe->book1D("TTbar_jetEta3" , "eta", 100, -5., 5.);
87  hists_["jetEta4" ] = dbe->book1D("TTbar_jetEta4" , "eta", 100, -5., 5.);
88 }
89 
90 // ------------ method called once each job just after ending the event loop ------------
91 void
93 {
94 }
95 
96 // ------------ method called when starting to processes a run ------------
97 void
99 {
100 }
101 
102 // ------------ method called when ending the processing of a run ------------
103 void
105 {
106 }
107 
108 // ------------ method called when starting to processes a luminosity block ------------
109 void
111 {
112 }
113 
114 // ------------ method called when ending the processing of a luminosity block ------------
115 void
117 {
118 }
119 
120 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
121 void
123  //The following says we do not know what parameters are allowed so do no validation
124  // Please change this to state exactly what you do use, even if it is no parameters
126  desc.setUnknown();
127  descriptions.addDefault(desc);
128 }
129 
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
virtual void analyze(const edm::Event &, const edm::EventSetup &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
vector< PseudoJet > jets
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
edm::InputTag genEventInfoProductTag_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
std::map< std::string, MonitorElement * > hists_
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
DQMStore * dbe
ME&#39;s &quot;container&quot;.
virtual void endRun(edm::Run const &, edm::EventSetup const &)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36
TTbar_GenJetAnalyzer(const edm::ParameterSet &)