CMS 3D CMS Logo

CalculatePtRatioRel.cc
Go to the documentation of this file.
2 
7 
8 using namespace pat;
9 
10 CalculatePtRatioRel::CalculatePtRatioRel(float dR2max) : dR2max_(dR2max) {}
11 
13 
14 namespace {
15 
16  float ptRel(const reco::Candidate::LorentzVector& muP4,
17  const reco::Candidate::LorentzVector& jetP4,
18  bool subtractMuon = true) {
20  if (subtractMuon)
21  jp4 -= muP4;
22  float dot = muP4.Vect().Dot(jp4.Vect());
23  float ptrel = muP4.P2() - dot * dot / jp4.P2();
24  ptrel = ptrel > 0 ? sqrt(ptrel) : 0.0;
25  return ptrel;
26  }
27 } // namespace
28 
31  const reco::JetCorrector* correctorL1,
32  const reco::JetCorrector* correctorL1L2L3Res) const {
33  //Initialise loop variables
34  float minDr2 = 9999;
35  double jecL1L2L3Res = 1.;
36  double jecL1 = 1.;
37 
38  // Compute corrected isolation variables
39  const float chIso = muon.pfIsolationR04().sumChargedHadronPt;
40  const float nIso = muon.pfIsolationR04().sumNeutralHadronEt;
41  const float phoIso = muon.pfIsolationR04().sumPhotonEt;
42  const float puIso = muon.pfIsolationR04().sumPUPt;
43  const float dbCorrectedIsolation = chIso + std::max(nIso + phoIso - .5f * puIso, 0.f);
44  const float dbCorrectedRelIso = dbCorrectedIsolation / muon.pt();
45 
46  float JetPtRatio = 1. / (1 + dbCorrectedRelIso);
47  float JetPtRel = 0.;
48 
49  const reco::Candidate::LorentzVector& muP4(muon.p4());
50  for (const auto& tagI : bTags) {
51  // for each muon with the lepton
52  float dr2 = deltaR2(*(tagI.first), muon);
53  if (dr2 > minDr2)
54  continue;
55  minDr2 = dr2;
56 
57  reco::Candidate::LorentzVector jetP4(tagI.first->p4());
58 
59  if (correctorL1 && correctorL1L2L3Res) {
60  jecL1L2L3Res = correctorL1L2L3Res->correction(*(tagI.first));
61  jecL1 = correctorL1->correction(*(tagI.first));
62  }
63 
64  if (minDr2 < dR2max_) {
65  if ((jetP4 - muP4).Rho() < 0.0001) {
66  JetPtRel = 0.;
67  JetPtRatio = 1.;
68  } else {
69  jetP4 -= muP4 / jecL1;
70  jetP4 *= jecL1L2L3Res;
71  jetP4 += muP4;
72 
73  JetPtRatio = muP4.pt() / jetP4.pt();
74  JetPtRel = ptRel(muP4, jetP4);
75  }
76  }
77  }
78 
79  if (JetPtRatio > 1.5)
80  JetPtRatio = 1.5;
81 
82  std::array<float, 2> outputs = {{JetPtRatio, JetPtRel}};
83  return outputs;
84 };
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:46
T dot(const Basic3DVector &v) const
Scalar product, or "dot" product, with a vector of same type.
Definition: HeavyIon.h:7
T sqrt(T t)
Definition: SSEVec.h:19
std::array< float, 2 > computePtRatioRel(const pat::Muon &imuon, const reco::JetTagCollection &bTags, const reco::JetCorrector *correctorL1=nullptr, const reco::JetCorrector *correctorL1L2L3Res=nullptr) const
double f[11][100]
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
Analysis-level muon class.
Definition: Muon.h:51