CMS 3D CMS Logo

METzCalculator.cc
Go to the documentation of this file.
1 
2 #include "METzCalculator.h"
3 #include "TMath.h"
4 
7 
10 
13  double M_W = 80.4;
14  double M_mu = 0.10566;
15  double emu = lepton_.energy();
16  double pxmu = lepton_.px();
17  double pymu = lepton_.py();
18  double pzmu = lepton_.pz();
19  double pxnu = MET_.px();
20  double pynu = MET_.py();
21  double pznu = 0.;
22 
23  double a = M_W * M_W - M_mu * M_mu + 2.0 * pxmu * pxnu + 2.0 * pymu * pynu;
24  double A = 4.0 * (emu * emu - pzmu * pzmu);
25  double B = -4.0 * a * pzmu;
26  double C = 4.0 * emu * emu * (pxnu * pxnu + pynu * pynu) - a * a;
27 
28  double tmproot = B * B - 4.0 * A * C;
29 
30  if (tmproot < 0) {
31  isComplex_ = true;
32  pznu = -B / (2 * A); // take real part of complex roots
33 
34  //std::cout << " Neutrino Solutions: complex, real part " << pznu << std::endl;
35  } else {
36  isComplex_ = false;
37  double tmpsol1 = (-B + TMath::Sqrt(tmproot)) / (2.0 * A);
38  double tmpsol2 = (-B - TMath::Sqrt(tmproot)) / (2.0 * A);
39 
40  //std::cout << " Neutrino Solutions: " << tmpsol1 << ", " << tmpsol2 << std::endl;
41 
42  if (type == 0) {
43  // two real roots, pick the one closest to pz of muon
44  if (TMath::Abs(tmpsol2 - pzmu) < TMath::Abs(tmpsol1 - pzmu)) {
45  pznu = tmpsol2;
46  } else
47  pznu = tmpsol1;
48  // if pznu is > 300 pick the most central root
49  if (pznu > 300.) {
50  if (TMath::Abs(tmpsol1) < TMath::Abs(tmpsol2))
51  pznu = tmpsol1;
52  else
53  pznu = tmpsol2;
54  }
55  }
56  if (type == 1) {
57  // two real roots, pick the one closest to pz of muon
58  if (TMath::Abs(tmpsol2 - pzmu) < TMath::Abs(tmpsol1 - pzmu)) {
59  pznu = tmpsol2;
60  } else
61  pznu = tmpsol1;
62  }
63  if (type == 2) {
64  // pick the most central root.
65  if (TMath::Abs(tmpsol1) < TMath::Abs(tmpsol2))
66  pznu = tmpsol1;
67  else
68  pznu = tmpsol2;
69  }
70  if (type == 3) {
71  // pick the largest value of the cosine
72  TVector3 p3w, p3mu;
73  p3w.SetXYZ(pxmu + pxnu, pymu + pynu, pzmu + tmpsol1);
74  p3mu.SetXYZ(pxmu, pymu, pzmu);
75 
76  double sinthcm1 = 2. * (p3mu.Perp(p3w)) / M_W;
77  p3w.SetXYZ(pxmu + pxnu, pymu + pynu, pzmu + tmpsol2);
78  double sinthcm2 = 2. * (p3mu.Perp(p3w)) / M_W;
79 
80  double costhcm1 = TMath::Sqrt(1. - sinthcm1 * sinthcm1);
81  double costhcm2 = TMath::Sqrt(1. - sinthcm2 * sinthcm2);
82 
83  if (costhcm1 > costhcm2)
84  pznu = tmpsol1;
85  else
86  pznu = tmpsol2;
87  }
88  }
89 
90  //Particle neutrino;
91  //neutrino.setP4( LorentzVector(pxnu, pynu, pznu, TMath::Sqrt(pxnu*pxnu + pynu*pynu + pznu*pznu ))) ;
92 
93  return pznu;
94 }
type
Definition: HCALResponse.h:21
double px() const final
x coordinate of momentum vector
pat::Particle lepton_
double pz() const final
z coordinate of momentum vector
T Abs(T a)
Definition: MathUtil.h:49
double energy() const final
energy
virtual ~METzCalculator()
destructor
static const std::string B
METzCalculator()
constructor
double Calculate(int type=0)
member functions
double py() const final
y coordinate of momentum vector
double a
Definition: hdecay.h:119