Go to the documentation of this file.00001 #include <map>
00002 #include <string>
00003
00004 #include "TH1.h"
00005
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/Framework/interface/EDAnalyzer.h"
00008 #include "FWCore/Utilities/interface/InputTag.h"
00009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00010 #include "FWCore/ServiceRegistry/interface/Service.h"
00011 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00012 #include "Math/VectorUtil.h"
00013
00014
00015 class PatMCMatching : public edm::EDAnalyzer {
00016
00017 public:
00019 explicit PatMCMatching(const edm::ParameterSet&);
00021 ~PatMCMatching();
00022
00023 private:
00024
00025 virtual void beginJob() ;
00026 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00027 virtual void endJob() ;
00028
00029
00030
00031
00032 std::map<std::string,TH1F*> histContainer_;
00033
00034
00035 edm::InputTag muonSrc_;
00036 };
00037
00038
00039 #include "DataFormats/PatCandidates/interface/Muon.h"
00040
00041
00042 PatMCMatching::PatMCMatching(const edm::ParameterSet& iConfig):
00043 histContainer_(),
00044 muonSrc_(iConfig.getUntrackedParameter<edm::InputTag>("muonSrc"))
00045 {
00046 }
00047
00048 PatMCMatching::~PatMCMatching()
00049 {
00050 }
00051
00052 void
00053 PatMCMatching::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00054 {
00055
00056
00057 edm::Handle<edm::View<pat::Muon> > muons;
00058 iEvent.getByLabel(muonSrc_,muons);
00059
00060 for(edm::View<pat::Muon>::const_iterator muon=muons->begin(); muon!=muons->end(); ++muon){
00061
00062 for(unsigned int i = 0 ; i < muon->genParticleRefs().size() ; ++i ){
00063
00064 switch( muon->genParticle(i)->status() ){
00065 case 1:
00066 histContainer_["DR_status1Match"]->Fill( ROOT::Math::VectorUtil::DeltaR(muon->p4() , muon->genParticle(i)->p4() ) );
00067 break;
00068 case 3:
00069 histContainer_["DR_status3Match"]->Fill( ROOT::Math::VectorUtil::DeltaR(muon->p4() , muon->genParticle(i)->p4() ) );
00070 break;
00071 default:
00072 histContainer_["DR_defaultMatch"]->Fill( ROOT::Math::VectorUtil::DeltaR(muon->p4() , muon->genParticle(i)->p4() ) );
00073 break;
00074 }
00075 }
00076 }
00077
00078 }
00079
00080 void
00081 PatMCMatching::beginJob()
00082 {
00083
00084 edm::Service<TFileService> fs;
00085
00086
00087 histContainer_["DR_defaultMatch" ]=fs->make<TH1F>("DR_defaultMatch", "DR_defaultMatch", 100, 0., 0.02);
00088 histContainer_["DR_status1Match" ]=fs->make<TH1F>("DR_status1Match", "DR_status1Match", 100, 0., 0.02);
00089 histContainer_["DR_status3Match" ]=fs->make<TH1F>("DR_status3Match", "DR_status3Match", 100, 0., 0.02);
00090
00091 }
00092
00093 void
00094 PatMCMatching::endJob()
00095 {
00096 }
00097
00098 #include "FWCore/Framework/interface/MakerMacros.h"
00099 DEFINE_FWK_MODULE(PatMCMatching);