CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoMET/METAlgorithms/src/METAlgo.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    METAlgorithms
00004 // Class:      METAlgo
00005 // 
00006 // Original Authors:  Michael Schmitt, Richard Cavanaugh The University of Florida
00007 //          Created:  May 31, 2005
00008 // $Id: METAlgo.cc,v 1.15 2012/06/08 00:51:28 sakuma Exp $
00009 //
00010 
00011 //____________________________________________________________________________||
00012 #include "RecoMET/METAlgorithms/interface/METAlgo.h"
00013 #include "DataFormats/Candidate/interface/Candidate.h"
00014 #include <cmath>
00015 
00016 CommonMETData METAlgo::run(edm::Handle<edm::View<reco::Candidate> > candidates, double globalThreshold)
00017 {
00018   CommonMETData met;
00019   run(candidates, &met, globalThreshold);
00020   return met;
00021 }
00022 
00023 //____________________________________________________________________________||
00024 void METAlgo::run(edm::Handle<edm::View<reco::Candidate> > candidates, CommonMETData *met, double globalThreshold)
00025 { 
00026   double px = 0.0;
00027   double py = 0.0;
00028   double pz = 0.0;
00029   double et = 0.0;
00030 
00031   for (unsigned int i = 0; i < candidates->size(); ++i)
00032   {
00033     const reco::Candidate &cand = (*candidates)[i];
00034     if( !(cand.et() > globalThreshold) ) continue;
00035     px += cand.px();
00036     py += cand.py();
00037     pz += cand.pz();
00038     et += cand.energy()*sin(cand.theta());
00039   }
00040 
00041   met->mex   = -px;
00042   met->mey   = -py;
00043 
00044   met->mez   = -pz; // included here since it might be useful
00045                     // for Data Quality Monitering as it should be 
00046                     // symmetrically distributed about the origin
00047 
00048   met->met   = sqrt( px*px + py*py );
00049   met->sumet = et;
00050   met->phi   = atan2( -py, -px ); // no longer needed as MET is now a candidate
00051 }
00052 
00053 //____________________________________________________________________________||