Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:25:29

0001 // -*- C++ -*-
0002 //
0003 // Package:    METAlgorithms
0004 // Class:      PFSpecificAlgo
0005 //
0006 // Original Authors:  R. Remington (UF), R. Cavanaugh (UIC/Fermilab)
0007 //          Created:  October 27, 2008
0008 //
0009 //
0010 //____________________________________________________________________________||
0011 #include "RecoMET/METAlgorithms/interface/PFSpecificAlgo.h"
0012 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0013 
0014 //____________________________________________________________________________||
0015 SpecificPFMETData PFSpecificAlgo::run(const edm::View<reco::Candidate>& pfCands, edm::ValueMap<float> const* weights) {
0016   if (pfCands.empty())
0017     return SpecificPFMETData();
0018 
0019   double NeutralEMEt = 0.0;
0020   double NeutralHadEt = 0.0;
0021   double ChargedEMEt = 0.0;
0022   double ChargedHadEt = 0.0;
0023   double MuonEt = 0.0;
0024   double type6Et = 0.0;
0025   double type7Et = 0.0;
0026 
0027   for (auto const& pfCandPtr : pfCands.ptrs()) {
0028     const reco::Candidate* pfCand = pfCandPtr.get();
0029     float weight = (weights != nullptr) ? (*weights)[pfCandPtr] : 1.0;
0030     if (!pfCand)
0031       continue;
0032     const double theta = pfCand->theta();
0033     const double e = pfCand->energy() * weight;
0034     const double et = e * sin(theta);
0035     switch (abs(pfCand->pdgId())) {
0036       case 211:
0037         ChargedHadEt += et;
0038         break;
0039       case 11:
0040         ChargedEMEt += et;
0041         break;
0042       case 13:
0043         MuonEt += et;
0044         break;
0045       case 22:
0046         NeutralEMEt += et;
0047         break;
0048       case 130:
0049         NeutralHadEt += et;
0050         break;
0051       case 1:
0052         type6Et += et;
0053         break;
0054       case 2:
0055         type7Et += et;
0056         break;
0057     }
0058   }
0059 
0060   const double Et_total = NeutralEMEt + NeutralHadEt + ChargedEMEt + ChargedHadEt + MuonEt + type6Et + type7Et;
0061   SpecificPFMETData specific;
0062   if (Et_total != 0.0) {
0063     specific.NeutralEMFraction = NeutralEMEt / Et_total;
0064     specific.NeutralHadFraction = NeutralHadEt / Et_total;
0065     specific.ChargedEMFraction = ChargedEMEt / Et_total;
0066     specific.ChargedHadFraction = ChargedHadEt / Et_total;
0067     specific.MuonFraction = MuonEt / Et_total;
0068     specific.Type6Fraction = type6Et / Et_total;
0069     specific.Type7Fraction = type7Et / Et_total;
0070   }
0071   return specific;
0072 }
0073 
0074 //____________________________________________________________________________||