CMS 3D CMS Logo

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