CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/JetMETCorrections/Type1MET/src/TauMET.cc

Go to the documentation of this file.
00001 // Package:    TauMET
00002 // Class:      TauMET
00003 // 
00004 // Original Authors:  Alfredo Gurrola, Chi Nhan Nguyen
00005 
00006 #include "JetMETCorrections/Type1MET/interface/TauMET.h"
00007 
00008 #include "DataFormats/METReco/interface/MET.h"
00009 #include "DataFormats/METReco/interface/METCollection.h"
00010 #include "DataFormats/METReco/interface/CaloMET.h"
00011 #include "DataFormats/METReco/interface/CaloMETCollection.h"
00012 #include "DataFormats/METReco/interface/CorrMETData.h"
00013 
00014 #include "DataFormats/TauReco/interface/PFTau.h"
00015 #include "DataFormats/JetReco/interface/CaloJet.h"
00016 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00017 #include "JetMETCorrections/Objects/interface/JetCorrector.h"
00018 
00019 using namespace reco;
00020 using namespace std;
00021 namespace cms 
00022 {
00023 
00024   TauMET::TauMET(const edm::ParameterSet& iConfig) : _algo() {
00025 
00026     _InputTausLabel    = iConfig.getParameter<std::string>("InputTausLabel");
00027     _tauType    = iConfig.getParameter<std::string>("tauType");
00028     _InputCaloJetsLabel    = iConfig.getParameter<std::string>("InputCaloJetsLabel");
00029     _jetPTthreshold      = iConfig.getParameter<double>("jetPTthreshold");
00030     _jetEMfracLimit      = iConfig.getParameter<double>("jetEMfracLimit");
00031     _correctorLabel      = iConfig.getParameter<std::string>("correctorLabel");
00032     _InputMETLabel    = iConfig.getParameter<std::string>("InputMETLabel");
00033     _metType    = iConfig.getParameter<std::string>("metType");
00034     _JetMatchDeltaR      = iConfig.getParameter<double>("JetMatchDeltaR");
00035     _TauMinEt      = iConfig.getParameter<double>("TauMinEt");
00036     _TauEtaMax      = iConfig.getParameter<double>("TauEtaMax");
00037     _UseSeedTrack      = iConfig.getParameter<bool>("UseSeedTrack");
00038     _seedTrackPt      = iConfig.getParameter<double>("seedTrackPt");
00039     _UseTrackIsolation      = iConfig.getParameter<bool>("UseTrackIsolation");
00040     _trackIsolationMinPt      = iConfig.getParameter<double>("trackIsolationMinPt");
00041     _UseECALIsolation      = iConfig.getParameter<bool>("UseECALIsolation");
00042     _gammaIsolationMinPt      = iConfig.getParameter<double>("gammaIsolationMinPt");
00043     _UseProngStructure      = iConfig.getParameter<bool>("UseProngStructure");
00044 
00045     if( _metType == "recoMET" ) {
00046       produces< METCollection   >();
00047     } else {
00048       produces< CaloMETCollection   >();
00049     }
00050 
00051   }
00052   
00053 
00054   TauMET::~TauMET() {
00055     // do anything here that needs to be done at desctruction time
00056     // (e.g. close files, deallocate resources etc.)
00057   }
00058   
00059   // ------------ method called to produce the data  ------------
00060   void TauMET::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00061 
00062     using namespace edm;
00063 
00064     Handle<CaloJetCollection> calojetHandle;
00065     iEvent.getByLabel(_InputCaloJetsLabel, calojetHandle);
00066     const JetCorrector* correctedjets = JetCorrector::getJetCorrector (_correctorLabel, iSetup);
00067 
00068     Handle<PFTauCollection> tauHandle;
00069     iEvent.getByLabel(_InputTausLabel,tauHandle);
00070 
00071     if( _metType == "recoCaloMET" ) {
00072       Handle<CaloMETCollection> metHandle;
00073       iEvent.getByLabel(_InputMETLabel,metHandle);
00074       std::auto_ptr< CaloMETCollection > output( new CaloMETCollection() );
00075       _algo.run(iEvent,iSetup,tauHandle,calojetHandle,_jetPTthreshold,_jetEMfracLimit,*correctedjets,*(metHandle.product()),
00076                 _JetMatchDeltaR,_TauMinEt,
00077                 _TauEtaMax,_UseSeedTrack,_seedTrackPt,_UseTrackIsolation,_trackIsolationMinPt,_UseECALIsolation,
00078                 _gammaIsolationMinPt,_UseProngStructure,&*output);
00079       iEvent.put( output );
00080     } else if( _metType == "recoMET" ) {
00081       Handle<METCollection> metHandle;
00082       iEvent.getByLabel(_InputMETLabel,metHandle);
00083       std::auto_ptr< METCollection > output( new METCollection() );
00084       _algo.run(iEvent,iSetup,tauHandle,calojetHandle,_jetPTthreshold,_jetEMfracLimit,*correctedjets,*(metHandle.product()),
00085                 _JetMatchDeltaR,_TauMinEt,
00086                 _TauEtaMax,_UseSeedTrack,_seedTrackPt,_UseTrackIsolation,_trackIsolationMinPt,_UseECALIsolation,
00087                 _gammaIsolationMinPt,_UseProngStructure,&*output);
00088       iEvent.put( output );
00089     } else {
00090       std::cerr << "Incorrect Met Type!!! " << std::endl;
00091       std::cerr << "Please re-run and set the metType to 'recoCaloMET' or 'recoMET' " << std::endl;
00092       return;
00093     }
00094 
00095   }
00096   
00097   // ------------ method called once each job just before starting event loop  ------------
00098   void TauMET::beginJob() { }
00099   
00100   // ------------ method called once each job just after ending the event loop  ------------
00101   void TauMET::endJob() { }
00102 
00103   //DEFINE_FWK_MODULE(TauMET);  //define this as a plug-in
00104 }
00105 
00106