CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/CommonTools/ParticleFlow/src/PFMETAlgo.cc

Go to the documentation of this file.
00001 #include "CommonTools/ParticleFlow/interface/PFMETAlgo.h"
00002 
00003 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
00004 
00005 #include "DataFormats/METReco/interface/MET.h"
00006 #include "DataFormats/METReco/interface/METFwd.h"
00007 #include "DataFormats/Math/interface/LorentzVector.h"
00008 
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 
00011 
00012 using namespace std;
00013 using namespace edm;
00014 using namespace reco;
00015 using namespace math;
00016 using namespace pf2pat;
00017 
00018 PFMETAlgo::PFMETAlgo(const edm::ParameterSet& iConfig) {
00019   
00020 
00021   verbose_ = 
00022     iConfig.getUntrackedParameter<bool>("verbose",false);
00023 
00024   hfCalibFactor_ = 
00025     iConfig.getParameter<double>("hfCalibFactor");
00026 
00027 }
00028 
00029 
00030 
00031 PFMETAlgo::~PFMETAlgo() { }
00032 
00033 reco::MET  PFMETAlgo::produce( const reco::PFCandidateCollection& pfCandidates) {
00034   
00035   double sumEx = 0;
00036   double sumEy = 0;
00037   double sumEt = 0;
00038 
00039   for( unsigned i=0; i<pfCandidates.size(); i++ ) {
00040 
00041     const reco::PFCandidate& cand = pfCandidates[i];
00042     
00043     double E = cand.energy();
00044 
00046     if( cand.particleId()==PFCandidate::h_HF || 
00047         cand.particleId()==PFCandidate::egamma_HF ) 
00048       E *= hfCalibFactor_;
00049 
00050     double phi = cand.phi();
00051     double cosphi = cos(phi);
00052     double sinphi = sin(phi);
00053 
00054     double theta = cand.theta();
00055     double sintheta = sin(theta);
00056     
00057     double et = E*sintheta;
00058     double ex = et*cosphi;
00059     double ey = et*sinphi;
00060     
00061     sumEx += ex;
00062     sumEy += ey;
00063     sumEt += et;
00064   }
00065   
00066   double Et = sqrt( sumEx*sumEx + sumEy*sumEy);
00067   XYZTLorentzVector missingEt( -sumEx, -sumEy, 0, Et);
00068   
00069   if(verbose_) {
00070     cout<<"PFMETAlgo: mEx, mEy, mEt = "
00071         << missingEt.X() <<", "
00072         << missingEt.Y() <<", "
00073         << missingEt.T() <<endl;
00074   }
00075 
00076   XYZPoint vertex; // dummy vertex
00077   return MET(sumEt, missingEt, vertex);
00078 
00079  
00080 }
00081 
00082