CMS 3D CMS Logo

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