Go to the documentation of this file.00001 #include "DataFormats/Common/interface/Handle.h"
00002 #include "DataFormats/MuonReco/interface/Muon.h"
00003 #include "DataFormats/PatCandidates/interface/Muon.h"
00004 #include "PhysicsTools/UtilAlgos/interface/BasicMuonAnalyzer.h"
00005
00006
00008 BasicMuonAnalyzer::BasicMuonAnalyzer(const edm::ParameterSet& cfg, TFileDirectory& fs):
00009 edm::BasicAnalyzer::BasicAnalyzer(cfg, fs),
00010 muons_(cfg.getParameter<edm::InputTag>("muons"))
00011 {
00012 hists_["muonPt" ] = fs.make<TH1F>("muonPt" , "pt" , 100, 0., 300.);
00013 hists_["muonEta" ] = fs.make<TH1F>("muonEta" , "eta" , 100, -3., 3.);
00014 hists_["muonPhi" ] = fs.make<TH1F>("muonPhi" , "phi" , 100, -5., 5.);
00015 hists_["mumuMass"] = fs.make<TH1F>("mumuMass", "mass", 90, 30., 120.);
00016 }
00017
00019 void
00020 BasicMuonAnalyzer::analyze(const edm::EventBase& event)
00021 {
00022
00023
00024 using reco::Muon;
00025
00026
00027 edm::Handle<std::vector<Muon> > muons;
00028 event.getByLabel(muons_, muons);
00029
00030
00031 for(std::vector<Muon>::const_iterator mu1=muons->begin(); mu1!=muons->end(); ++mu1){
00032 hists_["muonPt" ]->Fill( mu1->pt () );
00033 hists_["muonEta"]->Fill( mu1->eta() );
00034 hists_["muonPhi"]->Fill( mu1->phi() );
00035 if( mu1->pt()>20 && fabs(mu1->eta())<2.1 ){
00036 for(std::vector<Muon>::const_iterator mu2=muons->begin(); mu2!=muons->end(); ++mu2){
00037 if(mu2>mu1){
00038 if( mu1->charge()*mu2->charge()<0 ){
00039 if( mu2->pt()>20 && fabs(mu2->eta())<2.1 ){
00040 hists_["mumuMass"]->Fill( (mu1->p4()+mu2->p4()).mass() );
00041 }
00042 }
00043 }
00044 }
00045 }
00046 }
00047 }