CMS 3D CMS Logo

TopMuonAnalyzer.cc

Go to the documentation of this file.
00001 #include "DataFormats/PatCandidates/interface/Muon.h"
00002 #include "DataFormats/PatCandidates/interface/Electron.h" 
00003 #include "TopQuarkAnalysis/Examples/plugins/TopMuonAnalyzer.h"
00004 
00005 
00006 TopMuonAnalyzer::TopMuonAnalyzer(const edm::ParameterSet& cfg):
00007   inputElec_(cfg.getParameter<edm::InputTag>("inputElec")),
00008   inputMuon_(cfg.getParameter<edm::InputTag>("inputMuon"))
00009 {
00010   edm::Service<TFileService> fs;
00011   
00012   Num_Muons   = fs->make<TH1I>("Number_of_Muons",  "Num_{Muons}",    10,  0 ,  10 );
00013   Num_Leptons = fs->make<TH1I>("Number_of_Leptons","Num_{Leptons}",  10,  0 ,  10 );
00014   pt_Muons    = fs->make<TH1F>("pt_of_Muons",      "pt_{Muons}",    100,  0., 300.);
00015   energy_Muons= fs->make<TH1F>("energy_of_Muons",  "energy_{Muons}",100,  0., 300.);
00016   eta_Muons   = fs->make<TH1F>("eta_of_Muons",  "eta_{Muons}",      100, -3.,   3.);
00017   phi_Muons   = fs->make<TH1F>("phi_of_Muons",  "phi_{Muons}",      100, -5.,   5.);
00018   
00019 }
00020 
00021 TopMuonAnalyzer::~TopMuonAnalyzer()
00022 {
00023 }
00024 
00025 void
00026 TopMuonAnalyzer::analyze(const edm::Event& evt, const edm::EventSetup& setup)
00027 {
00028   edm::Handle<std::vector<pat::Electron> > elecs;
00029   evt.getByLabel(inputElec_, elecs);
00030   
00031   edm::Handle<std::vector<pat::Muon> > muons;
00032   evt.getByLabel(inputMuon_, muons); 
00033 
00034   Num_Muons  ->Fill( muons->size() ); 
00035   Num_Leptons->Fill( elecs->size() + muons->size() );
00036 
00037   for( std::vector<pat::Muon>::const_iterator muon=muons->begin(); 
00038        muon!=muons->end(); ++muon){
00039     pt_Muons    ->Fill( muon->pt()     );
00040     energy_Muons->Fill( muon->energy() );
00041     eta_Muons   ->Fill( muon->eta()    );
00042     phi_Muons   ->Fill( muon->phi()    );
00043   }   
00044 }
00045 
00046 void TopMuonAnalyzer::beginJob(const edm::EventSetup&)
00047 {
00048 }
00049 
00050 void TopMuonAnalyzer::endJob()
00051 {
00052 }

Generated on Tue Jun 9 17:48:05 2009 for CMSSW by  doxygen 1.5.4