File indexing completed on 2024-04-06 12:26:41
0001
0002
0003
0004
0005
0006
0007
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();
0034
0035
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