CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BSpdfsFcn.cc
Go to the documentation of this file.
1 
15 #include "TMath.h"
16 
17 #include <cmath>
18 #include <vector>
19 
20 //______________________________________________________________________
21 double BSpdfsFcn::PDFGauss_d(double z, double d, double sigmad,
22  double phi, const std::vector<double>& parms) const {
23 
24  //---------------------------------------------------------------------------
25  // PDF for d0 distribution. This PDF is a simple gaussian in the
26  // beam reference frame.
27  //---------------------------------------------------------------------------
28  double fsqrt2pi = sqrt(2.* TMath::Pi());
29 
30  double sig = sqrt(parms[fPar_SigmaBeam]*parms[fPar_SigmaBeam] +
31  sigmad*sigmad);
32 
33  double dprime = d - ( ( parms[fPar_X0] + z*parms[fPar_dxdz] )*sin(phi)
34  - ( parms[fPar_Y0] + z*parms[fPar_dydz] )*cos(phi) );
35 
36  double result = (exp(-(dprime*dprime)/(2.0*sig*sig)))/(sig*fsqrt2pi);
37 
38  return result;
39 
40 }
41 
42 //______________________________________________________________________
43 double BSpdfsFcn::PDFGauss_d_resolution(double z, double d, double phi, double pt, const std::vector<double>& parms) const {
44 
45  //---------------------------------------------------------------------------
46  // PDF for d0 distribution. This PDF is a simple gaussian in the
47  // beam reference frame. The IP resolution is parametrize by a linear
48  // function as a function of 1/pt.
49  //---------------------------------------------------------------------------
50  double fsqrt2pi = sqrt(2.* TMath::Pi());
51 
52  double sigmad = parms[fPar_c0] + parms[fPar_c1]/pt;
53 
54  double sig = sqrt(parms[fPar_SigmaBeam]*parms[fPar_SigmaBeam] +
55  sigmad*sigmad);
56 
57  double dprime = d - ( ( parms[fPar_X0] + z*parms[fPar_dxdz] )*sin(phi)
58  - ( parms[fPar_Y0] + z*parms[fPar_dydz] )*cos(phi) );
59 
60  double result = (exp(-(dprime*dprime)/(2.0*sig*sig)))/(sig*fsqrt2pi);
61 
62  return result;
63 
64 }
65 
66 //______________________________________________________________________
67 double BSpdfsFcn::PDFGauss_z(double z, double sigmaz, const std::vector<double>& parms) const {
68 
69  //---------------------------------------------------------------------------
70  // PDF for z-vertex distribution. This distribution
71  // is parametrized by a simple normalized gaussian distribution.
72  //---------------------------------------------------------------------------
73  double fsqrt2pi = sqrt(2.* TMath::Pi());
74 
75  double sig = sqrt(sigmaz*sigmaz+parms[fPar_SigmaZ]*parms[fPar_SigmaZ]);
76  //double sig = sqrt(sigmaz*sigmaz+parms[1]*parms[1]);
77  double result = (exp(-((z-parms[fPar_Z0])*(z-parms[fPar_Z0]))/(2.0*sig*sig)))/(sig*fsqrt2pi);
78  //double result = (exp(-((z-parms[0])*(z-parms[0]))/(2.0*sig*sig)))/(sig*fsqrt2pi);
79 
80  return result;
81 
82 }
83 
84 
85 
86 
87 //______________________________________________________________________
88 double BSpdfsFcn::operator() (const std::vector<double>& params) const {
89 
90  double f = 0.0;
91 
92  //std::cout << "fusepdfs=" << fusepdfs << " params.size="<<params.size() << std::endl;
93 
94  std::vector<BSTrkParameters>::const_iterator iparam = fBSvector.begin();
95 
96  double pdf = 0;
97 
98  for( iparam = fBSvector.begin(); iparam != fBSvector.end(); ++iparam) {
99 
100 
101  if (fusepdfs == "PDFGauss_z") {
102  pdf = PDFGauss_z( iparam->z0(), iparam->sigz0(),params);
103  }
104  else if (fusepdfs == "PDFGauss_d") {
105  pdf = PDFGauss_d( iparam->z0(), iparam->d0(),
106  iparam->sigd0(), iparam->phi0(),params);
107  }
108  else if (fusepdfs == "PDFGauss_d_resolution") {
109  pdf = PDFGauss_d_resolution( iparam->z0(), iparam->d0(),
110  iparam->phi0(), iparam->pt(),params);
111  }
112  else if (fusepdfs == "PDFGauss_d*PDFGauss_z") {
113  //std::cout << "pdf= " << pdf << std::endl;
114  pdf = PDFGauss_d( iparam->z0(), iparam->d0(),
115  iparam->sigd0(), iparam->phi0(),params)*
116  PDFGauss_z( iparam->z0(), iparam->sigz0(),params);
117  }
118  else if (fusepdfs == "PDFGauss_d_resolution*PDFGauss_z") {
119  pdf = PDFGauss_d_resolution( iparam->z0(), iparam->d0(),
120  iparam->phi0(), iparam->pt(),params)*
121  PDFGauss_z( iparam->z0(), iparam->sigz0(),params);
122  }
123 
124  f = log(pdf) + f;
125  }
126 
127  f= -2.0*f;
128  return f;
129 
130 }
std::vector< BSTrkParameters > fBSvector
Definition: BSpdfsFcn.h:50
const double Pi
static const int fPar_dydz
Definition: BSpdfsFcn.h:57
static const int fPar_Y0
Definition: BSpdfsFcn.h:53
static const int fPar_X0
Definition: BSpdfsFcn.h:52
static const int fPar_dxdz
Definition: BSpdfsFcn.h:56
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
static const int fPar_c0
Definition: BSpdfsFcn.h:59
double PDFGauss_d(double z, double d, double sigmad, double phi, const std::vector< double > &parms) const
Definition: BSpdfsFcn.cc:21
double PDFGauss_z(double z, double sigmaz, const std::vector< double > &parms) const
Definition: BSpdfsFcn.cc:67
static const int fPar_SigmaZ
Definition: BSpdfsFcn.h:55
double double double z
static const int fPar_SigmaBeam
Definition: BSpdfsFcn.h:58
virtual double operator()(const std::vector< double > &) const
Definition: BSpdfsFcn.cc:88
T sqrt(T t)
Definition: SSEVec.h:46
tuple result
Definition: query.py:137
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static const int fPar_c1
Definition: BSpdfsFcn.h:60
double f[11][100]
double PDFGauss_d_resolution(double z, double d, double phi, double pt, const std::vector< double > &parms) const
Definition: BSpdfsFcn.cc:43
std::string fusepdfs
Definition: BSpdfsFcn.h:49
static const int fPar_Z0
Definition: BSpdfsFcn.h:54
Definition: DDAxes.h:10