Go to the documentation of this file.00001 #include <memory>
00002 #include <string>
00003 #include <vector>
00004 #include <sstream>
00005 #include <fstream>
00006 #include <iostream>
00007
00008 #include <TH2F.h>
00009 #include <TROOT.h>
00010 #include <TFile.h>
00011 #include <TSystem.h>
00012
00013 #include "DataFormats/FWLite/interface/Handle.h"
00014 #include "DataFormats/PatCandidates/interface/Muon.h"
00015 #include "DataFormats/PatCandidates/interface/Jet.h"
00016 #include "FWCore/FWLite/interface/AutoLibraryLoader.h"
00017
00018
00019 int main(int argc, char* argv[])
00020 {
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 gSystem->Load( "libFWCoreFWLite" );
00031 AutoLibraryLoader::enable();
00032
00033
00034 TH2F* muonPt_ = new TH2F( "muonPt", "Muon Pt", 60, 0., 300., 60, 0., 300. );
00035 muonPt_->SetXTitle( "gen." );
00036 muonPt_->SetYTitle( "reco." );
00037 TH2F* jetPt_ = new TH2F( "jetPt", "Jet Pt", 100, 0., 500., 100, 0., 500. );
00038 jetPt_->SetXTitle( "gen." );
00039 jetPt_->SetYTitle( "reco." );
00040
00041
00042 TFile* inFile = TFile::Open( "file:edmPatMcMatch.root" );
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 unsigned int iEvent=0;
00055 fwlite::Event event(inFile);
00056 for(event.toBegin(); !event.atEnd(); ++event, ++iEvent){
00057
00058
00059 if( iEvent==1000 ) break;
00060
00061
00062 if(iEvent>0 && iEvent%25==0){
00063 std::cout << " processing event: " << iEvent << std::endl;
00064 }
00065
00066
00067 fwlite::Handle<std::vector<pat::Muon> > muons;
00068 muons.getByLabel(event, "cleanLayer1Muons");
00069
00070 fwlite::Handle<std::vector<pat::Jet> > jets;
00071 jets.getByLabel(event, "cleanLayer1Jets");
00072
00073
00074 for(unsigned i=0; i<muons->size(); ++i){
00075 const reco::GenParticle * genMuon = (*muons)[i].genParticle();
00076 if ( genMuon ) {
00077 muonPt_->Fill( genMuon->pt(), (*muons)[i].pt() );
00078 }
00079 }
00080
00081 for(unsigned i=0; i<jets->size(); ++i){
00082 const reco::GenJet * genJet = (*jets)[i].genJet();
00083 if ( genJet ) {
00084 jetPt_->Fill( genJet->pt(), (*jets)[i].pt() );
00085 }
00086 }
00087 }
00088
00089 inFile->Close();
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100 TFile outFile( "rootPatMcMatch.root", "recreate" );
00101 outFile.mkdir("analyzeMcMatchPat");
00102 outFile.cd("analyzeMcMatchPat");
00103 muonPt_->Write( );
00104 jetPt_->Write( );
00105 outFile.Close();
00106
00107
00108
00109
00110
00111
00112
00113
00114 delete muonPt_;
00115 delete jetPt_;
00116
00117
00118 return 0;
00119 }