File indexing completed on 2024-04-06 12:24:00
0001 #include <memory>
0002 #include <string>
0003 #include <vector>
0004 #include <sstream>
0005 #include <fstream>
0006 #include <iostream>
0007
0008 #include <TH2F.h> // Use the correct histograms
0009 #include <TROOT.h>
0010 #include <TFile.h>
0011 #include <TSystem.h>
0012
0013 #include "DataFormats/FWLite/interface/Handle.h"
0014 #include "DataFormats/PatCandidates/interface/Muon.h" // Include the examined data formats
0015 #include "DataFormats/PatCandidates/interface/Jet.h" // Include the examined data formats
0016 #include "FWCore/FWLite/interface/FWLiteEnabler.h"
0017
0018
0019 int main(int argc, char* argv[])
0020 {
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 gSystem->Load( "libFWCoreFWLite" );
0031 FWLiteEnabler::enable();
0032
0033
0034 TH2F* muonPt_ = new TH2F( "muonPt", "Muon Pt", 60, 0., 300., 60, 0., 300. );
0035 muonPt_->SetXTitle( "gen." );
0036 muonPt_->SetYTitle( "reco." );
0037 TH2F* jetPt_ = new TH2F( "jetPt", "Jet Pt", 100, 0., 500., 100, 0., 500. );
0038 jetPt_->SetXTitle( "gen." );
0039 jetPt_->SetYTitle( "reco." );
0040
0041
0042 TFile* inFile = TFile::Open( "file:edmPatMcMatch.root" );
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 unsigned int iEvent=0;
0055 fwlite::Event event(inFile);
0056 for(event.toBegin(); !event.atEnd(); ++event, ++iEvent){
0057
0058
0059 if( iEvent==1000 ) break;
0060
0061
0062 if(iEvent>0 && iEvent%25==0){
0063 std::cout << " processing event: " << iEvent << std::endl;
0064 }
0065
0066
0067 fwlite::Handle<std::vector<pat::Muon> > muons;
0068 muons.getByLabel(event, "cleanLayer1Muons");
0069
0070 fwlite::Handle<std::vector<pat::Jet> > jets;
0071 jets.getByLabel(event, "cleanLayer1Jets");
0072
0073
0074 for(unsigned i=0; i<muons->size(); ++i){
0075 const reco::GenParticle * genMuon = (*muons)[i].genParticle();
0076 if ( genMuon ) {
0077 muonPt_->Fill( genMuon->pt(), (*muons)[i].pt() );
0078 }
0079 }
0080
0081 for(unsigned i=0; i<jets->size(); ++i){
0082 const reco::GenJet * genJet = (*jets)[i].genJet();
0083 if ( genJet ) {
0084 jetPt_->Fill( genJet->pt(), (*jets)[i].pt() );
0085 }
0086 }
0087 }
0088
0089 inFile->Close();
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 TFile outFile( "rootPatMcMatch.root", "recreate" );
0101 outFile.mkdir("analyzeMcMatchPat");
0102 outFile.cd("analyzeMcMatchPat");
0103 muonPt_->Write( );
0104 jetPt_->Write( );
0105 outFile.Close();
0106
0107
0108
0109
0110
0111
0112
0113
0114 delete muonPt_;
0115 delete jetPt_;
0116
0117
0118 return 0;
0119 }