CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TTbar_GenLepAnalyzer.cc
Go to the documentation of this file.
6 
8  : leps_(iConfig.getParameter<edm::InputTag>("leptons")) {
9  lepsToken_ = consumes<edm::View<reco::Candidate> >(leps_);
10 }
11 
13  // do anything here that needs to be done at desctruction time
14  // (e.g. close files, deallocate resources etc.)
15 }
16 
17 //
18 // member functions
19 //
20 
21 // ------------ method called for each event ------------
23  // Handle to the Leptons collections
25  iEvent.getByToken(lepsToken_, leps);
26  if (!leps.isValid())
27  return;
28 
29  // loop Jet collection and fill histograms
30  int nleps = 0;
31  for (edm::View<reco::Candidate>::const_iterator lep_it = leps->begin(); lep_it != leps->end(); ++lep_it) {
32  ++nleps;
33 
34  if (nleps > 0) {
35  hists_["lepPtAll"]->Fill(lep_it->p4().pt());
36  hists_["lepEtaAll"]->Fill(lep_it->p4().eta());
37  }
38  if (nleps == 1) {
39  hists_["lepPt1"]->Fill(lep_it->p4().pt());
40  hists_["lepEta1"]->Fill(lep_it->p4().eta());
41  }
42  if (nleps == 2) {
43  hists_["lepPt2"]->Fill(lep_it->p4().pt());
44  hists_["lepEta2"]->Fill(lep_it->p4().eta());
45  }
46  if (nleps == 3) {
47  hists_["lepPt3"]->Fill(lep_it->p4().pt());
48  hists_["lepEta3"]->Fill(lep_it->p4().eta());
49  }
50  if (nleps == 4) {
51  hists_["lepPt4"]->Fill(lep_it->p4().pt());
52  hists_["lepEta4"]->Fill(lep_it->p4().eta());
53  }
54  }
55 
56  hists_["lepN"]->Fill(nleps);
57 }
58 
60  DQMHelper dqm(&i);
61  i.setCurrentFolder("Generator/TTbar");
62  hists_["lepN"] = dqm.book1dHisto(
63  "TTbar_lepN" + leps_.label(), "N", 10, -.5, 9.5, "Number of " + leps_.label(), "Number of Events");
64 
65  hists_["lepPtAll"] = dqm.book1dHisto("TTbar_lepPtAll_" + leps_.label(),
66  "pt",
67  1000,
68  0.,
69  1000.,
70  "P_{t}^{All-" + leps_.label() + "} (GeV)",
71  "Number of Events");
72  hists_["lepPt1"] = dqm.book1dHisto("TTbar_lepPt1_" + leps_.label(),
73  "pt",
74  1000,
75  0.,
76  1000.,
77  "P_{t}^{1st-" + leps_.label() + "} (GeV)",
78  "Number of Events");
79  hists_["lepPt2"] = dqm.book1dHisto("TTbar_lepPt2_" + leps_.label(),
80  "pt",
81  1000,
82  0.,
83  1000.,
84  "P_{t}^{2nd-" + leps_.label() + "} (GeV)",
85  "Number of Events");
86  hists_["lepPt3"] = dqm.book1dHisto("TTbar_lepPt3_" + leps_.label(),
87  "pt",
88  1000,
89  0.,
90  1000.,
91  "P_{t}^{3rd-" + leps_.label() + "} (GeV)",
92  "Number of Events");
93  hists_["lepPt4"] = dqm.book1dHisto("TTbar_lepPt4_" + leps_.label(),
94  "pt",
95  1000,
96  0.,
97  1000.,
98  "P_{t}^{4th-" + leps_.label() + "} (GeV)",
99  "Number of Events");
100 
101  hists_["lepEtaAll"] = dqm.book1dHisto(
102  "TTbar_lepEtaAll" + leps_.label(), "eta", 100, -5., 5., "#eta^{All-" + leps_.label() + "}", "Number of Events");
103  hists_["lepEta1"] = dqm.book1dHisto(
104  "TTbar_lepEta1" + leps_.label(), "eta", 100, -5., 5., "#eta^{1st-" + leps_.label() + "}", "Number of Events");
105  hists_["lepEta2"] = dqm.book1dHisto(
106  "TTbar_lepEta2" + leps_.label(), "eta", 100, -5., 5., "#eta^{2nd-" + leps_.label() + "}", "Number of Events");
107  hists_["lepEta3"] = dqm.book1dHisto(
108  "TTbar_lepEta3" + leps_.label(), "eta", 100, -5., 5., "#eta^{3rd-" + leps_.label() + "}", "Number of Events");
109  hists_["lepEta4"] = dqm.book1dHisto(
110  "TTbar_lepEta4" + leps_.label(), "eta", 100, -5., 5., "#eta^{4th-" + leps_.label() + "}", "Number of Events");
111 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
edm::EDGetTokenT< edm::View< reco::Candidate > > lepsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
TTbar_GenLepAnalyzer(const edm::ParameterSet &)
void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
bool isValid() const
Definition: HandleBase.h:70
MonitorElement * book1dHisto(const std::string &name, const std::string &title, int n, double xmin, double xmax, const std::string &xaxis, const std::string &yaxis)
Definition: DQMHelper.cc:7
std::string const & label() const
Definition: InputTag.h:36
std::map< std::string, MonitorElement * > hists_
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
Definition: Run.h:45