CMS 3D CMS Logo

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