CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoMET/METAlgorithms/src/METAlgo.cc

Go to the documentation of this file.
00001 // File: METAlgo.cc
00002 // Description:  see METAlgo.h
00003 // Author: Michael Schmitt, Richard Cavanaugh The University of Florida
00004 // Creation Date:  MHS May 31, 2005 Initial version.
00005 //
00006 //------------------------------------------------------------------------
00007 
00008 #include "DataFormats/Candidate/interface/Candidate.h"
00009 #include "DataFormats/Candidate/interface/CandidateFwd.h"
00010 #include "DataFormats/METReco/interface/CommonMETData.h"
00011 #include "RecoMET/METAlgorithms/interface/METAlgo.h"
00012 #include <iostream>
00013 
00014 using namespace std;
00015 using namespace reco;
00016 
00017 //------------------------------------------------------------------------
00018 // Default Constructer
00019 //----------------------------------
00020 METAlgo::METAlgo() {}
00021 //------------------------------------------------------------------------
00022 
00023 //------------------------------------------------------------------------
00024 // Default Destructor
00025 //----------------------------------
00026 METAlgo::~METAlgo() {}
00027 //------------------------------------------------------------------------
00028 
00029 //------------------------------------------------------------------------
00030 // This method represents "the" implementation of the MET algorithm and is
00031 // very simple:
00032 // (1) It takes as input a collection of candidates (which can be
00033 // calorimeter towers, HEPMC generator-level particles, etc).
00034 // (2) It returns as output, a pointer to a struct of CommonMETData which
00035 // contains the following members:  MET, MEx, MEy, SumET, and MEz
00036 // (The inclusion of MEz deserves some justification ; it is included here
00037 // since it _may_ be useful for Data Quality Monitering as it should be 
00038 // symmetrically distributed about the origin.)
00039 //----------------------------------
00040 //void METAlgo::run(const CandidateCollection *input, CommonMETData *met, double globalThreshold) 
00041 void METAlgo::run(edm::Handle<edm::View<Candidate> > input, CommonMETData *met, double globalThreshold) 
00042 { 
00043   double sum_et = 0.0;
00044   double sum_ex = 0.0;
00045   double sum_ey = 0.0;
00046   double sum_ez = 0.0;
00047   // Loop over Candidate Objects and calculate MET and related quantities
00048   /*
00049   CandidateCollection::const_iterator candidate;
00050   for( candidate = input->begin(); candidate != input->end(); candidate++ )
00051   */
00052   for (unsigned int candidate_i = 0; candidate_i < input->size(); candidate_i++)
00053   {
00054     const Candidate *candidate = &((*input)[candidate_i]);
00055     if( candidate->et() > globalThreshold  )
00056       {
00057         double phi   = candidate->phi();
00058         double theta = candidate->theta();
00059         double e     = candidate->energy();
00060         double et    = e*sin(theta);
00061         sum_ez += e*cos(theta);
00062         sum_et += et;
00063         sum_ex += et*cos(phi);
00064         sum_ey += et*sin(phi);
00065       }
00066   }
00067   met->mex   = -sum_ex;
00068   met->mey   = -sum_ey;
00069   met->mez   = -sum_ez;
00070   met->met   = sqrt( sum_ex*sum_ex + sum_ey*sum_ey );
00071   // cout << "MET = " << met->met << endl;
00072   met->sumet = sum_et;
00073   met->phi   = atan2( -sum_ey, -sum_ex ); // since MET is now a candidate,
00074 }                                         // this is no longer needed
00075 //------------------------------------------------------------------------
00076