CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TTbar_GenLepAnalyzer.cc
Go to the documentation of this file.
5 
7  leps_(iConfig.getParameter<edm::InputTag>("leptons"))
8 {
9 
10  lepsToken_=consumes< edm::View<reco::Candidate> >(leps_);
11 
12 }
13 
14 
16 {
17 
18  // do anything here that needs to be done at desctruction time
19  // (e.g. close files, deallocate resources etc.)
20 
21 }
22 
23 
24 //
25 // member functions
26 //
27 
28 // ------------ method called for each event ------------
29 void
31 {
32 
33  // Handle to the Leptons collections
35  iEvent.getByToken(lepsToken_, leps);
36  if(!leps.isValid()) return;
37 
38  // loop Jet collection and fill histograms
39  int nleps = 0;
40  for(edm::View<reco::Candidate>::const_iterator lep_it=leps->begin(); lep_it!=leps->end(); ++lep_it){
41 
42  ++nleps;
43 
44  if (nleps > 0) { hists_["lepPtAll" ]->Fill( lep_it->p4().pt() );
45  hists_["lepEtaAll"]->Fill( lep_it->p4().eta() );
46  }
47  if (nleps == 1) { hists_["lepPt1" ]->Fill( lep_it->p4().pt() );
48  hists_["lepEta1"]->Fill( lep_it->p4().eta() );
49  }
50  if (nleps == 2) { hists_["lepPt2" ]->Fill( lep_it->p4().pt() );
51  hists_["lepEta2"]->Fill( lep_it->p4().eta() );
52  }
53  if (nleps == 3) { hists_["lepPt3" ]->Fill( lep_it->p4().pt() );
54  hists_["lepEta3"]->Fill( lep_it->p4().eta() );
55  }
56  if (nleps == 4) { hists_["lepPt4" ]->Fill( lep_it->p4().pt() );
57  hists_["lepEta4"]->Fill( lep_it->p4().eta() );
58  }
59  }
60 
61  hists_["lepN" ]->Fill( nleps ) ;
62 
63 
64 }
65 
66 
68  i.setCurrentFolder("Generator/TTbar");
69  hists_["lepN" ] = i.book1D("TTbar_lepN" , "N" , 10, -.5, 9.5 );
70 
71  hists_["lepPtAll" ] = i.book1D("TTbar_lepPtAll_"+leps_.label() , "pt" , 1000, 0., 1000.);
72  hists_["lepPt1" ] = i.book1D("TTbar_lepPt1_"+leps_.label() , "pt" , 1000, 0., 1000.);
73  hists_["lepPt2" ] = i.book1D("TTbar_lepPt2_"+leps_.label() , "pt" , 1000, 0., 1000.);
74  hists_["lepPt3" ] = i.book1D("TTbar_lepPt3_"+leps_.label() , "pt" , 1000, 0., 1000.);
75  hists_["lepPt4" ] = i.book1D("TTbar_lepPt4_"+leps_.label() , "pt" , 1000, 0., 1000.);
76 
77  hists_["lepEtaAll"] = i.book1D("TTbar_lepEtaAll"+leps_.label(), "eta", 100, -5., 5.);
78  hists_["lepEta1" ] = i.book1D("TTbar_lepEta1"+leps_.label() , "eta", 100, -5., 5.);
79  hists_["lepEta2" ] = i.book1D("TTbar_lepEta2"+leps_.label() , "eta", 100, -5., 5.);
80  hists_["lepEta3" ] = i.book1D("TTbar_lepEta3"+leps_.label() , "eta", 100, -5., 5.);
81  hists_["lepEta4" ] = i.book1D("TTbar_lepEta4"+leps_.label() , "eta", 100, -5., 5.);
82 }
83 
84 
int i
Definition: DBlmapReader.cc:9
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
edm::EDGetTokenT< edm::View< reco::Candidate > > lepsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
TTbar_GenLepAnalyzer(const edm::ParameterSet &)
virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &) override
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:230
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
bool isValid() const
Definition: HandleBase.h:76
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
std::string const & label() const
Definition: InputTag.h:42
std::map< std::string, MonitorElement * > hists_
Definition: Run.h:41