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  //now do what ever initialization is needed
10  dbe = 0;
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.getByLabel(leps_, 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 
68 // ------------ method called once each job just before starting event loop ------------
69 void
71 {
72  if(!dbe) return;
73  dbe->setCurrentFolder("Generator/TTbar");
74  hists_["lepN" ] = dbe->book1D("TTbar_lepN" , "N" , 10, -.5, 9.5 );
75 
76  hists_["lepPtAll" ] = dbe->book1D("TTbar_lepPtAll_"+leps_.label() , "pt" , 1000, 0., 1000.);
77  hists_["lepPt1" ] = dbe->book1D("TTbar_lepPt1_"+leps_.label() , "pt" , 1000, 0., 1000.);
78  hists_["lepPt2" ] = dbe->book1D("TTbar_lepPt2_"+leps_.label() , "pt" , 1000, 0., 1000.);
79  hists_["lepPt3" ] = dbe->book1D("TTbar_lepPt3_"+leps_.label() , "pt" , 1000, 0., 1000.);
80  hists_["lepPt4" ] = dbe->book1D("TTbar_lepPt4_"+leps_.label() , "pt" , 1000, 0., 1000.);
81 
82  hists_["lepEtaAll"] = dbe->book1D("TTbar_lepEtaAll"+leps_.label(), "eta", 100, -5., 5.);
83  hists_["lepEta1" ] = dbe->book1D("TTbar_lepEta1"+leps_.label() , "eta", 100, -5., 5.);
84  hists_["lepEta2" ] = dbe->book1D("TTbar_lepEta2"+leps_.label() , "eta", 100, -5., 5.);
85  hists_["lepEta3" ] = dbe->book1D("TTbar_lepEta3"+leps_.label() , "eta", 100, -5., 5.);
86  hists_["lepEta4" ] = dbe->book1D("TTbar_lepEta4"+leps_.label() , "eta", 100, -5., 5.);
87 }
88 
89 // ------------ method called once each job just after ending the event loop ------------
90 void
92 {
93 }
94 
95 // ------------ method called when starting to processes a run ------------
96 void
98 {
99 }
100 
101 // ------------ method called when ending the processing of a run ------------
102 void
104 {
105 }
106 
107 // ------------ method called when starting to processes a luminosity block ------------
108 void
110 {
111 }
112 
113 // ------------ method called when ending the processing of a luminosity block ------------
114 void
116 {
117 }
118 
119 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
120 void
122  //The following says we do not know what parameters are allowed so do no validation
123  // Please change this to state exactly what you do use, even if it is no parameters
125  desc.setUnknown();
126  descriptions.addDefault(desc);
127 }
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
TTbar_GenLepAnalyzer(const edm::ParameterSet &)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void analyze(const edm::Event &, const edm::EventSetup &)
std::string const & label() const
Definition: InputTag.h:25
DQMStore * dbe
ME&#39;s &quot;container&quot;.
std::map< std::string, MonitorElement * > hists_
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
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:429
Definition: Run.h:33