CMS 3D CMS Logo

MET.cc

Go to the documentation of this file.
00001 //
00002 // $Id: MET.cc,v 1.12.2.1 2009/04/22 10:21:20 veelken Exp $
00003 //
00004 
00005 #include "DataFormats/PatCandidates/interface/MET.h"
00006 
00007 
00008 using namespace pat;
00009 
00010 
00012 MET::MET(): uncorInfo_(0) {
00013 }
00014 
00015 
00017 MET::MET(const METType & aMET) : PATObject<METType>(aMET), uncorInfo_(0) {
00018     const reco::CaloMET * calo = dynamic_cast<const reco::CaloMET *>(&aMET);
00019     if (calo != 0) caloMET_.push_back(calo->getSpecific());
00020 }
00021 
00022 
00024 MET::MET(const edm::RefToBase<METType> & aMETRef) : PATObject<METType>(aMETRef), uncorInfo_(0) {
00025     const reco::CaloMET * calo = dynamic_cast<const reco::CaloMET *>(aMETRef.get());
00026     if (calo != 0) caloMET_.push_back(calo->getSpecific());
00027 }
00028 
00030 MET::MET(const edm::Ptr<METType> & aMETRef) : PATObject<METType>(aMETRef), uncorInfo_(0) {
00031     const reco::CaloMET * calo = dynamic_cast<const reco::CaloMET *>(aMETRef.get());
00032     if (calo != 0) caloMET_.push_back(calo->getSpecific());
00033 }
00034 
00035 
00037 MET::~MET() {
00038 }
00039 
00040 
00042 const reco::GenMET * MET::genMET() const {
00043   return (genMET_.size() > 0 ? &genMET_.front() : 0 );
00044 }
00045 
00047 void MET::setGenMET(const reco::GenMET & gm) {
00048   genMET_.clear();
00049   genMET_.push_back(gm);
00050 }
00051 
00053 unsigned int MET::nCorrections() const { checkUncor_(); return nCorrections_; }
00054 
00055 float MET::corEx(UncorrectionType ix) const { 
00056   if (ix == uncorrNONE) return 0;
00057   checkUncor_(); return uncorInfo_[ix].corEx; 
00058 }
00059 float MET::corEy(UncorrectionType ix) const { 
00060   if (ix == uncorrNONE) return 0;
00061   checkUncor_(); return uncorInfo_[ix].corEy; 
00062 }
00063 float MET::corSumEt(UncorrectionType ix) const { 
00064   if (ix == uncorrNONE) return 0;
00065   checkUncor_(); return uncorInfo_[ix].corSumEt; 
00066 }
00067 float MET::uncorrectedPt(UncorrectionType ix) const { 
00068   if (ix == uncorrNONE) return pt();
00069   checkUncor_(); return uncorInfo_[ix].pt; 
00070 }
00071 float MET::uncorrectedPhi(UncorrectionType ix) const { 
00072   if (ix == uncorrNONE) return phi();
00073   checkUncor_(); return uncorInfo_[ix].phi; 
00074 }
00075 
00077 void MET::checkUncor_() const {
00078   if (uncorInfo_.size() == uncorrMAXN && oldPt_ == pt() ) return;
00079 
00080   oldPt_ = pt();
00081   std::vector<CorrMETData> corrs(mEtCorr());
00082   nCorrections_ = corrs.size();
00083 
00084   uncorInfo_.resize(uncorrMAXN);
00085   UncorrectionType ix;
00086 
00089   ix = uncorrALL;
00090   uncorInfo_[ix] = UncorInfo();
00091   for (unsigned int iC=0; iC < nCorrections_; ++iC){
00092     uncorInfo_[ix].corEx +=    corrs[iC].mex;
00093     uncorInfo_[ix].corEy +=    corrs[iC].mey;
00094     uncorInfo_[ix].corSumEt += corrs[iC].sumet;
00095   }
00096   setPtPhi_(uncorInfo_[ix]);
00097 
00099   ix = uncorrJES;
00100   uncorInfo_[ix] = UncorInfo();
00101   if (nCorrections_ >=1 ){
00102     unsigned int iC = 0;
00103     uncorInfo_[ix].corEx +=    corrs[iC].mex;
00104     uncorInfo_[ix].corEy +=    corrs[iC].mey;
00105     uncorInfo_[ix].corSumEt += corrs[iC].sumet;
00106   }
00107   setPtPhi_(uncorInfo_[ix]);
00108 
00110   ix = uncorrMUON;
00111   uncorInfo_[ix] = UncorInfo();
00112   if (nCorrections_ >=2 ){
00113     unsigned int iC = 1;
00114     uncorInfo_[ix].corEx +=    corrs[iC].mex;
00115     uncorInfo_[ix].corEy +=    corrs[iC].mey;
00116     uncorInfo_[ix].corSumEt += corrs[iC].sumet;
00117   }
00118   setPtPhi_(uncorInfo_[ix]);
00119 
00121   ix = uncorrTAU;
00122   uncorInfo_[ix] = UncorInfo();
00123   if (nCorrections_ >=3 ){
00124     unsigned int iC = 1;
00125     uncorInfo_[ix].corEx +=    corrs[iC].mex;
00126     uncorInfo_[ix].corEy +=    corrs[iC].mey;
00127     uncorInfo_[ix].corSumEt += corrs[iC].sumet;
00128   }
00129   setPtPhi_(uncorInfo_[ix]);
00130 }
00131 
00132 void MET::setPtPhi_(UncorInfo& uci) const {
00133   float lpx = px() - uci.corEx;
00134   float lpy = py() - uci.corEy;
00135   uci.pt = sqrt(lpx*lpx + lpy*lpy);
00136   uci.phi = atan2(lpy, lpx);  
00137 }

Generated on Tue Jun 9 17:31:15 2009 for CMSSW by  doxygen 1.5.4