CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/RecoJets/JetAnalyzers/src/DijetRatio.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    DijetRatio
00004 // Class:      DijetRatio
00005 // 
00013 //
00014 // Original Author:  Manoj Jha
00015 //         Created:  Thu Apr 12 15:04:37 CDT 2007
00016 // Kalanand Mishra (November 22, 2009): 
00017 //    Modified and cleaned up to work in 3.3.X
00018 //
00019 //
00020 
00021 #include "RecoJets/JetAnalyzers/interface/DijetRatio.h"
00022 
00023 template<class Jet>
00024 DijetRatio<Jet>::DijetRatio(const edm::ParameterSet& iConfig)
00025 {
00026    
00027    //get name of output file with histograms
00028   fOutputFileName = iConfig.getUntrackedParameter<std::string>("HistoFileName", 
00029                                                           "DijetRatio.root"); 
00030   
00031   // get names of modules, producing object collections
00032   m_Mid5CorRecJetsSrc   = iConfig.getParameter<std::string>("CorrectedJets");
00033   m_Mid5CaloJetsSrc   = iConfig.getParameter<std::string>("UnCorrectedJets");
00034   
00035   // eta limit for numerator and denominator
00036   m_eta3   = iConfig.getUntrackedParameter<double>("etaInner", 0.7);
00037   m_eta4   = iConfig.getUntrackedParameter<double>("etaOuter", 1.3);
00038 
00039 }
00040 
00041 
00042 
00043 template<class Jet>
00044 DijetRatio<Jet>::~DijetRatio()
00045 {
00046  
00047    // do anything here that needs to be done at desctruction time
00048    // (e.g. close files, deallocate resources etc.)
00049 
00050 }
00051 
00052 
00053 //
00054 // member functions
00055 //
00056 
00057 // ------------ method called to for each event  ------------
00058 
00059 template<class Jet>
00060 void DijetRatio<Jet>::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00061 {
00062    using namespace edm;
00063   
00064    // get calo jet collection
00065    Handle<JetCollection> Mid5CorRecJets;
00066    iEvent.getByLabel(m_Mid5CorRecJetsSrc, Mid5CorRecJets);
00067    
00068    Handle<JetCollection> Mid5CaloJets;
00069    iEvent.getByLabel(m_Mid5CaloJetsSrc, Mid5CaloJets);
00070 
00071    histoFill(hCalo, Mid5CaloJets, m_eta3, m_eta4);
00072    histoFill(hCor, Mid5CorRecJets, m_eta3, m_eta4);
00073 }
00074 
00075 
00076 
00077 // ------------ method called once each job just before starting event loop  ------------
00078 template <class Jet>
00079 void  DijetRatio<Jet>::beginJob()
00080 {
00081    hOutputFile   = new TFile( fOutputFileName.c_str(), "RECREATE" ) ;
00082 
00083    // Histo Initializations for  Jets
00084    hInit(hCalo, "DijetRatio_UnCorrectedJets");
00085    hInit(hCor, "DijetRatio_CorrectedJets");
00086 
00087    return;
00088 }
00089 
00090 // ------------ method called once each job just after ending the event loop  ------------
00091 
00092 template<class Jet>
00093 void  DijetRatio<Jet>::endJob() {
00094   
00095   hOutputFile->cd();
00096   for(int i=0; i<histoSize; ++i) {
00097     hCalo[i]->Write() ;
00098     hCor[i]->Write() ;
00099   }
00100   hOutputFile->Close() ;
00101 
00102 return ;
00103 }
00104 
00105 #include "FWCore/Framework/interface/MakerMacros.h"
00107 typedef DijetRatio<reco::CaloJet> DijetRatioCaloJets;
00108 DEFINE_FWK_MODULE(DijetRatioCaloJets);
00110 typedef DijetRatio<reco::GenJet> DijetRatioGenJets;
00111 DEFINE_FWK_MODULE(DijetRatioGenJets);
00113 typedef DijetRatio<reco::PFJet> DijetRatioPFJets;
00114 DEFINE_FWK_MODULE(DijetRatioPFJets);