Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:41

0001 // -*- C++ -*-
0002 //
0003 // Package:    METAlgorithms
0004 // Class:      METAlgo
0005 //
0006 // Original Authors:  Michael Schmitt, Richard Cavanaugh The University of Florida
0007 //          Created:  May 31, 2005
0008 //
0009 
0010 //____________________________________________________________________________||
0011 #include "RecoMET/METAlgorithms/interface/METAlgo.h"
0012 #include "DataFormats/Candidate/interface/Candidate.h"
0013 #include "DataFormats/Math/interface/LorentzVector.h"
0014 
0015 //____________________________________________________________________________||
0016 CommonMETData METAlgo::run(const edm::View<reco::Candidate>& candidates,
0017                            double globalThreshold,
0018                            edm::ValueMap<float> const* weights) {
0019   math::XYZTLorentzVector p4;
0020   for (auto const& candPtr : candidates.ptrs()) {
0021     const reco::Candidate* cand = candPtr.get();
0022     float weight = (weights != nullptr) ? (*weights)[candPtr] : 1.0;
0023     if (!(cand->et() * weight > globalThreshold))
0024       continue;
0025     p4 += cand->p4() * weight;
0026   }
0027   math::XYZTLorentzVector met = -p4;
0028 
0029   CommonMETData ret;
0030   ret.mex = met.Px();
0031   ret.mey = met.Py();
0032 
0033   ret.mez = met.Pz();  // included here since it might be useful
0034                        // for Data Quality Monitering as it should be
0035                        // symmetrically distributed about the origin
0036 
0037   ret.met = met.Pt();
0038 
0039   double et = 0.0;
0040   for (auto const& candPtr : candidates.ptrs()) {
0041     const reco::Candidate* cand = candPtr.get();
0042     float weight = (weights != nullptr) ? (*weights)[candPtr] : 1.0;
0043     if (!(cand->et() * weight > globalThreshold))
0044       continue;
0045     et += cand->et() * weight;
0046   }
0047 
0048   ret.sumet = et;
0049 
0050   return ret;
0051 }
0052 
0053 //____________________________________________________________________________||