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.
6 
8  leps_(iConfig.getParameter<edm::InputTag>("leptons"))
9 {
10 
11  lepsToken_=consumes< edm::View<reco::Candidate> >(leps_);
12 
13 }
14 
15 
17 {
18 
19  // do anything here that needs to be done at desctruction time
20  // (e.g. close files, deallocate resources etc.)
21 
22 }
23 
24 
25 //
26 // member functions
27 //
28 
29 // ------------ method called for each event ------------
30 void
32 {
33 
34  // Handle to the Leptons collections
36  iEvent.getByToken(lepsToken_, leps);
37  if(!leps.isValid()) return;
38 
39  // loop Jet collection and fill histograms
40  int nleps = 0;
41  for(edm::View<reco::Candidate>::const_iterator lep_it=leps->begin(); lep_it!=leps->end(); ++lep_it){
42 
43  ++nleps;
44 
45  if (nleps > 0) { hists_["lepPtAll" ]->Fill( lep_it->p4().pt() );
46  hists_["lepEtaAll"]->Fill( lep_it->p4().eta() );
47  }
48  if (nleps == 1) { hists_["lepPt1" ]->Fill( lep_it->p4().pt() );
49  hists_["lepEta1"]->Fill( lep_it->p4().eta() );
50  }
51  if (nleps == 2) { hists_["lepPt2" ]->Fill( lep_it->p4().pt() );
52  hists_["lepEta2"]->Fill( lep_it->p4().eta() );
53  }
54  if (nleps == 3) { hists_["lepPt3" ]->Fill( lep_it->p4().pt() );
55  hists_["lepEta3"]->Fill( lep_it->p4().eta() );
56  }
57  if (nleps == 4) { hists_["lepPt4" ]->Fill( lep_it->p4().pt() );
58  hists_["lepEta4"]->Fill( lep_it->p4().eta() );
59  }
60  }
61 
62  hists_["lepN" ]->Fill( nleps ) ;
63 
64 
65 }
66 
67 
69  DQMHelper dqm(&i); i.setCurrentFolder("Generator/TTbar");
70  hists_["lepN" ] = dqm.book1dHisto("TTbar_lepN"+leps_.label() , "N" , 10, -.5, 9.5 );
71 
72  hists_["lepPtAll" ] = dqm.book1dHisto("TTbar_lepPtAll_"+leps_.label() , "pt" , 1000, 0., 1000.);
73  hists_["lepPt1" ] = dqm.book1dHisto("TTbar_lepPt1_"+leps_.label() , "pt" , 1000, 0., 1000.);
74  hists_["lepPt2" ] = dqm.book1dHisto("TTbar_lepPt2_"+leps_.label() , "pt" , 1000, 0., 1000.);
75  hists_["lepPt3" ] = dqm.book1dHisto("TTbar_lepPt3_"+leps_.label() , "pt" , 1000, 0., 1000.);
76  hists_["lepPt4" ] = dqm.book1dHisto("TTbar_lepPt4_"+leps_.label() , "pt" , 1000, 0., 1000.);
77 
78  hists_["lepEtaAll"] = dqm.book1dHisto("TTbar_lepEtaAll"+leps_.label(), "eta", 100, -5., 5.);
79  hists_["lepEta1" ] = dqm.book1dHisto("TTbar_lepEta1"+leps_.label() , "eta", 100, -5., 5.);
80  hists_["lepEta2" ] = dqm.book1dHisto("TTbar_lepEta2"+leps_.label() , "eta", 100, -5., 5.);
81  hists_["lepEta3" ] = dqm.book1dHisto("TTbar_lepEta3"+leps_.label() , "eta", 100, -5., 5.);
82  hists_["lepEta4" ] = dqm.book1dHisto("TTbar_lepEta4"+leps_.label() , "eta", 100, -5., 5.);
83 }
84 
85 
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< reco::Candidate > > lepsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
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
bool isValid() const
Definition: HandleBase.h:75
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book1dHisto(const std::string &name, const std::string &title, int n, double xmin, double xmax)
Definition: DQMHelper.cc:12
std::string const & label() const
Definition: InputTag.h:43
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:85
std::map< std::string, MonitorElement * > hists_
Definition: Run.h:41