Go to the documentation of this file.00001 #include <vector>
00002
00003 #include "TH1.h"
00004 #include "TFile.h"
00005 #include <TROOT.h>
00006 #include <TSystem.h>
00007
00008 #include "DataFormats/Math/interface/deltaR.h"
00009 #include "DataFormats/FWLite/interface/Event.h"
00010 #include "DataFormats/Common/interface/Handle.h"
00011 #include "DataFormats/PatCandidates/interface/Jet.h"
00012 #include "FWCore/ParameterSet/interface/ProcessDesc.h"
00013 #include "FWCore/FWLite/interface/AutoLibraryLoader.h"
00014 #include "PhysicsTools/FWLite/interface/TFileService.h"
00015 #include "FWCore/PythonParameterSet/interface/PythonProcessDesc.h"
00016
00017
00018
00019
00020
00021
00022
00023 int main(int argc, char *argv[]){
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 gSystem->Load( "libFWCoreFWLite" );
00034 AutoLibraryLoader::enable();
00035
00036
00037
00038 if ( argc < 2 ) {
00039 std::cout << "Usage : " << argv[0] << " [parameters.py]" << std::endl;
00040 return 0;
00041 }
00042
00043
00044 PythonProcessDesc builder(argv[1]);
00045 const edm::ParameterSet& fwliteParameters = builder.processDesc()->getProcessPSet()->getParameter<edm::ParameterSet>("FWLiteParams");
00046
00047
00048 std::string input_ ( fwliteParameters.getParameter<std::string >("inputFile" ) );
00049 std::string output_ ( fwliteParameters.getParameter<std::string >("outputFile" ) );
00050 std::string overlaps_( fwliteParameters.getParameter<std::string >("overlaps") );
00051 edm::InputTag jets_ ( fwliteParameters.getParameter<edm::InputTag>("jets" ) );
00052
00053
00054 fwlite::TFileService fs = fwlite::TFileService(output_.c_str());
00055 TFileDirectory theDir = fs.mkdir("analyzePatCOC");
00056 TH1F* deltaRElecJet_ = theDir.make<TH1F>("deltaRElecJet" , "#DeltaR (elec, jet)" , 10, 0., 0.5);
00057 TH1F* elecOverJet_ = theDir.make<TH1F>("elecOverJet" , "E_{elec}/E_{jet}" , 100, 0., 2.);
00058 TH1F* nOverlaps_ = theDir.make<TH1F>("nOverlaps" , "Number of overlaps" , 5, 0., 5.);
00059
00060
00061 TFile* inFile = TFile::Open(input_.c_str());
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 unsigned int iEvent=0;
00074 fwlite::Event ev(inFile);
00075 for(ev.toBegin(); !ev.atEnd(); ++ev, ++iEvent){
00076 edm::EventBase const & event = ev;
00077
00078
00079
00080 if( iEvent==1000 ) break;
00081
00082
00083 if(iEvent>0 && iEvent%1==0){
00084 std::cout << " processing event: " << iEvent << std::endl;
00085 }
00086
00087
00088 edm::Handle<std::vector<pat::Jet> > jets;
00089 event.getByLabel(jets_, jets);
00090
00091
00092 for( std::vector<pat::Jet>::const_iterator jet = jets->begin(); jet != jets->end(); jet++ ){
00093 if(jet->pt()>20 && jet==jets->begin()){
00094
00095 if(jet->hasOverlaps(overlaps_)){
00096
00097 const reco::CandidatePtrVector overlaps = jet->overlaps(overlaps_);
00098 nOverlaps_->Fill( overlaps.size() );
00099
00100 for( reco::CandidatePtrVector::const_iterator overlap = overlaps.begin(); overlap != overlaps.end(); overlap++){
00101 float deltaR = reco::deltaR( (*overlap)->eta(), (*overlap)->phi(), jet->eta(), jet->phi() );
00102 deltaRElecJet_->Fill( deltaR );
00103 elecOverJet_->Fill( (*overlap)->energy()/jet->energy() );
00104 }
00105 }
00106 }
00107 }
00108 }
00109 inFile->Close();
00110 return 0;
00111 }