CMS 3D CMS Logo

NoPileUpMEtUtilities.cc
Go to the documentation of this file.
2 
4 
5 #include <algorithm>
6 #include <cmath>
7 
9  minPtDef_ = -1;
10  maxPtDef_ = 1000000;
11 }
12 
14 
15 // namespace NoPileUpMEtUtilities
16 // {
17 //-------------------------------------------------------------------------------
18 // general auxiliary functions
20  metData.met = sqrt(metData.mex * metData.mex + metData.mey * metData.mey);
21  metData.mez = 0.;
22  metData.phi = atan2(metData.mey, metData.mex);
23 }
24 //-------------------------------------------------------------------------------
25 
26 //-------------------------------------------------------------------------------
27 // auxiliary functions for jets
30  const std::vector<reco::Candidate::LorentzVector>& leptons,
31  double dRoverlap,
32  bool invert) {
34  for (reco::PUSubMETCandInfoCollection::const_iterator jet = jets.begin(); jet != jets.end(); ++jet) {
35  bool isOverlap = false;
36  for (std::vector<reco::Candidate::LorentzVector>::const_iterator lepton = leptons.begin(); lepton != leptons.end();
37  ++lepton) {
38  if (deltaR2(jet->p4(), *lepton) < dRoverlap * dRoverlap) {
39  isOverlap = true;
40  break;
41  }
42  }
43  if ((!isOverlap && !invert) || (isOverlap && invert))
44  retVal.push_back(*jet);
45  }
46  return retVal;
47 }
48 
50  bool neutralFracOnly,
51  double& sumAbsPx,
52  double& sumAbsPy) {
53  CommonMETData retVal;
54  retVal.mex = 0.;
55  retVal.mey = 0.;
56  retVal.sumet = 0.;
57  double retVal_sumAbsPx = 0.;
58  double retVal_sumAbsPy = 0.;
59  double pFrac = 1;
60  for (reco::PUSubMETCandInfoCollection::const_iterator cand = cands.begin(); cand != cands.end(); ++cand) {
61  pFrac = 1;
62  if (neutralFracOnly)
63  pFrac = (1 - cand->chargedEnFrac());
64 
65  retVal.mex += cand->p4().px() * pFrac;
66  retVal.mey += cand->p4().py() * pFrac;
67  retVal.sumet += cand->p4().pt() * pFrac;
68  retVal_sumAbsPx += std::abs(cand->p4().px());
69  retVal_sumAbsPy += std::abs(cand->p4().py());
70  }
71  finalizeMEtData(retVal);
72  sumAbsPx = retVal_sumAbsPx;
73  sumAbsPy = retVal_sumAbsPy;
74  return retVal;
75 }
76 
77 //-------------------------------------------------------------------------------
78 
79 //-------------------------------------------------------------------------------
80 // auxiliary functions for PFCandidates
83  const std::vector<reco::Candidate::LorentzVector>& leptons,
84  double dRoverlap,
85  bool invert) {
86  // invert: false = PFCandidates are required not to overlap with leptons
87  // true = PFCandidates are required to overlap with leptons
88 
90  for (reco::PUSubMETCandInfoCollection::const_iterator pfCandidate = pfCandidates.begin();
91  pfCandidate != pfCandidates.end();
92  ++pfCandidate) {
93  bool isOverlap = false;
94  for (std::vector<reco::Candidate::LorentzVector>::const_iterator lepton = leptons.begin(); lepton != leptons.end();
95  ++lepton) {
96  if (deltaR2(pfCandidate->p4(), *lepton) < dRoverlap * dRoverlap) {
97  isOverlap = true;
98  break;
99  }
100  }
101  if ((!isOverlap && !invert) || (isOverlap && invert))
102  retVal.push_back(*pfCandidate);
103  }
104  return retVal;
105 }
106 
108  double minPt,
109  double maxPt,
110  int type,
111  bool isCharged,
112  int isWithinJet) {
114  for (reco::PUSubMETCandInfoCollection::const_iterator cand = cands.begin(); cand != cands.end(); ++cand) {
115  if (isCharged && cand->charge() == 0)
116  continue;
117  double jetPt = cand->p4().pt();
118  if (jetPt < minPt || jetPt > maxPt)
119  continue;
120  if (type != reco::PUSubMETCandInfo::kUndefined && cand->type() != type)
121  continue;
122 
123  //for pf candidates
124  if (isWithinJet != NoPileUpMEtUtilities::kAll && (cand->isWithinJet() != isWithinJet))
125  continue;
126 
127  retVal.push_back(*cand);
128  }
129  return retVal;
130 }
131 //-------------------------------------------------------------------------------
132 
133 //-------------------------------------------------------------------------------
134 // auxiliary functions to compute different types of MEt/hadronic recoils
135 //
136 // NOTE: all pfCandidates and jets passed as function arguments
137 // need to be cleaned wrt. leptons
138 //
139 
144 
147 
150 
153 
158 
159  //not used so far
160  //_chPfcSum = computeCandidateSum(pfcsCh, false, &_chPfcSumAbsPx, &_chPfcSumAbsPy);
164 
167 }
168 
169 CommonMETData NoPileUpMEtUtilities::computeRecoil(int metType, double& sumAbsPx, double& sumAbsPy) {
170  CommonMETData retVal;
171  double retSumAbsPx = 0.;
172  double retSumAbsPy = 0.;
173 
174  //never used....
175  // if(metType==NoPileUpMEtUtilities::kChMET) {
176  // CommonMETData chPfcSum = computeCandidateSum(_pfcsCh, false, &trackSumAbsPx, &trackSumAbsPy);
177  // retVal.mex = -chPfcSum.mex;
178  // retVal.mey = -chPfcSum.mey;
179  // retVal.sumet = chPfcSum.sumet;
180  // retSumAbsPx = ;
181  // retSumAbsPy = ;
182  // }
184  retVal.mex = chHSPfcSum_.mex;
185  retVal.mey = chHSPfcSum_.mey;
186  retVal.sumet = chHSPfcSum_.sumet;
187  retSumAbsPx = chHSPfcSumAbsPx_;
188  retSumAbsPy = chHSPfcSumAbsPy_;
189  }
191  retVal.mex = chPUPfcSum_.mex;
192  retVal.mey = chPUPfcSum_.mey;
193  retVal.sumet = chPUPfcSum_.sumet;
194  retSumAbsPx = chPUPfcSumAbsPx_;
195  retSumAbsPy = chPUPfcSumAbsPy_;
196  }
198  retVal.mex = nUncPfcSum_.mex;
199  retVal.mey = nUncPfcSum_.mey;
200  retVal.sumet = nUncPfcSum_.sumet;
201  retSumAbsPx = nUncPfcSumAbsPx_;
202  retSumAbsPy = nUncPfcSumAbsPy_;
203  }
205  retVal.mex = chHSPfcSum_.mex + nHSJetSum_.mex;
206  retVal.mey = chHSPfcSum_.mey + nHSJetSum_.mey;
208  retSumAbsPx = chHSPfcSumAbsPx_ + nHSJetSumAbsPx_;
209  retSumAbsPy = chHSPfcSumAbsPy_ + nHSJetSumAbsPy_;
210  }
212  retVal.mex = chPUPfcSum_.mex + nHSJetSum_.mex;
213  retVal.mey = chPUPfcSum_.mey + nHSJetSum_.mey;
215  retSumAbsPx = chPUPfcSumAbsPx_ + nHSJetSumAbsPx_;
216  retSumAbsPy = chPUPfcSumAbsPy_ + nHSJetSumAbsPy_;
217  }
218 
219  sumAbsPx = retSumAbsPx;
220  sumAbsPy = retSumAbsPy;
221 
222  return retVal;
223 }
NoPileUpMEtUtilities::~NoPileUpMEtUtilities
~NoPileUpMEtUtilities()
Definition: NoPileUpMEtUtilities.cc:13
reco::btau::jetPt
Definition: TaggingVariable.h:32
CommonMETData::met
double met
Definition: CommonMETData.h:14
NoPileUpMEtUtilities::finalizeMEtData
void finalizeMEtData(CommonMETData &)
Definition: NoPileUpMEtUtilities.cc:19
NoPileUpMEtUtilities::kChHSMET
Definition: NoPileUpMEtUtilities.h:16
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
reco::PUSubMETCandInfo::kHS
Definition: PUSubMETData.h:63
HLT_FULL_cff.leptons
leptons
Definition: HLT_FULL_cff.py:26294
reco::PUSubMETCandInfo::kChPU
Definition: PUSubMETData.h:63
NoPileUpMEtUtilities::nUncPfcSum_
CommonMETData nUncPfcSum_
Definition: NoPileUpMEtUtilities.h:64
NoPileUpMEtUtilities::kChPUMET
Definition: NoPileUpMEtUtilities.h:16
NoPileUpMEtUtilities::cleanPFCandidates
reco::PUSubMETCandInfoCollection cleanPFCandidates(const reco::PUSubMETCandInfoCollection &, const std::vector< reco::Candidate::LorentzVector > &, double, bool)
Definition: NoPileUpMEtUtilities.cc:81
L1TrackerEtMissProducer_cfi.maxPt
maxPt
Definition: L1TrackerEtMissProducer_cfi.py:14
CommonMETData::mez
double mez
Definition: CommonMETData.h:17
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
CommonMETData
Structure containing data common to all types of MET.
Definition: CommonMETData.h:12
objects.autophobj.metType
metType
Definition: autophobj.py:214
reco::PUSubMETCandInfo::kPU
Definition: PUSubMETData.h:63
NoPileUpMEtUtilities.h
NoPileUpMEtUtilities::kHadronicPUMET
Definition: NoPileUpMEtUtilities.h:16
NoPileUpMEtUtilities::cleanJets
reco::PUSubMETCandInfoCollection cleanJets(const reco::PUSubMETCandInfoCollection &, const std::vector< reco::Candidate::LorentzVector > &, double, bool)
Definition: NoPileUpMEtUtilities.cc:28
CommonMETData::mex
double mex
Definition: CommonMETData.h:15
NoPileUpMEtUtilities::computeCandidateSum
CommonMETData computeCandidateSum(const reco::PUSubMETCandInfoCollection &cands, bool neutralFracOnly, double &sumAbsPx, double &sumAbsPy)
Definition: NoPileUpMEtUtilities.cc:49
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
NoPileUpMEtUtilities::chPUPfcSumAbsPx_
double chPUPfcSumAbsPx_
Definition: NoPileUpMEtUtilities.h:69
NoPileUpMEtUtilities::nHSJetSum_
CommonMETData nHSJetSum_
Definition: NoPileUpMEtUtilities.h:65
NoPileUpMEtUtilities::kAll
Definition: NoPileUpMEtUtilities.h:15
NoPileUpMEtUtilities::chPUPfcSum_
CommonMETData chPUPfcSum_
Definition: NoPileUpMEtUtilities.h:63
CommonMETData::sumet
double sumet
Definition: CommonMETData.h:18
NoPileUpMEtUtilities::NoPileUpMEtUtilities
NoPileUpMEtUtilities()
Definition: NoPileUpMEtUtilities.cc:8
CommonMETData::phi
double phi
Definition: CommonMETData.h:19
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15161
NoPileUpMEtUtilities::kNeutralUncMET
Definition: NoPileUpMEtUtilities.h:16
NoPileUpMEtUtilities::nHSJetSumAbsPy_
double nHSJetSumAbsPy_
Definition: NoPileUpMEtUtilities.h:77
deltaR.h
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
NoPileUpMEtUtilities::chHSPfcSumAbsPx_
double chHSPfcSumAbsPx_
Definition: NoPileUpMEtUtilities.h:68
gainCalibHelper::gainCalibPI::type
type
Definition: SiPixelGainCalibHelper.h:40
cand
Definition: decayParser.h:32
NoPileUpMEtUtilities::chHSPfcSum_
CommonMETData chHSPfcSum_
Definition: NoPileUpMEtUtilities.h:62
NoPileUpMEtUtilities::minPtDef_
double minPtDef_
Definition: NoPileUpMEtUtilities.h:59
NoPileUpMEtUtilities::kOutsideJet
Definition: NoPileUpMEtUtilities.h:15
NoPileUpMEtUtilities::nPUJetSumAbsPy_
double nPUJetSumAbsPy_
Definition: NoPileUpMEtUtilities.h:78
beam_dqm_sourceclient-live_cfg.minPt
minPt
Definition: beam_dqm_sourceclient-live_cfg.py:322
NoPileUpMEtUtilities::nPUJetSumAbsPx_
double nPUJetSumAbsPx_
Definition: NoPileUpMEtUtilities.h:72
NoPileUpMEtUtilities::chHSPfcSumAbsPy_
double chHSPfcSumAbsPy_
Definition: NoPileUpMEtUtilities.h:74
NoPileUpMEtUtilities::nHSJetSumAbsPx_
double nHSJetSumAbsPx_
Definition: NoPileUpMEtUtilities.h:71
NoPileUpMEtUtilities::nUncPfcSumAbsPy_
double nUncPfcSumAbsPy_
Definition: NoPileUpMEtUtilities.h:76
NoPileUpMEtUtilities::nUncPfcSumAbsPx_
double nUncPfcSumAbsPx_
Definition: NoPileUpMEtUtilities.h:70
NoPileUpMEtUtilities::chPUPfcSumAbsPy_
double chPUPfcSumAbsPy_
Definition: NoPileUpMEtUtilities.h:75
NoPileUpMEtUtilities::computeAllSums
void computeAllSums(const reco::PUSubMETCandInfoCollection &jets, const reco::PUSubMETCandInfoCollection &pfCandidates)
Definition: NoPileUpMEtUtilities.cc:140
reco::PUSubMETCandInfo::kUndefined
Definition: PUSubMETData.h:63
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
l1tstage2_dqm_sourceclient-live_cfg.invert
invert
Definition: l1tstage2_dqm_sourceclient-live_cfg.py:86
metsig::jet
Definition: SignAlgoResolutions.h:47
NoPileUpMEtUtilities::selectCandidates
reco::PUSubMETCandInfoCollection selectCandidates(const reco::PUSubMETCandInfoCollection &cands, double minPt, double maxPt, int type, bool isCharged, int isWithinJet)
Definition: NoPileUpMEtUtilities.cc:107
NoPileUpMEtUtilities::maxPtDef_
double maxPtDef_
Definition: NoPileUpMEtUtilities.h:60
reco::PUSubMETCandInfo::kNeutral
Definition: PUSubMETData.h:63
reco::PUSubMETCandInfo::kChHS
Definition: PUSubMETData.h:63
NoPileUpMEtUtilities::computeRecoil
CommonMETData computeRecoil(int metType, double &sumAbsPx, double &sumAbsPy)
Definition: NoPileUpMEtUtilities.cc:169
reco::PUSubMETCandInfoCollection
std::vector< reco::PUSubMETCandInfo > PUSubMETCandInfoCollection
Definition: PUSubMETDataFwd.h:9
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
NoPileUpMEtUtilities::nPUJetSum_
CommonMETData nPUJetSum_
Definition: NoPileUpMEtUtilities.h:66
CommonMETData::mey
double mey
Definition: CommonMETData.h:16
NoPileUpMEtUtilities::kHadronicHSMET
Definition: NoPileUpMEtUtilities.h:16