test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MultiTrackPointingKinematicConstraint.cc
Go to the documentation of this file.
3 
4 AlgebraicVector MultiTrackPointingKinematicConstraint::value(const std::vector<KinematicState> &states, const GlobalPoint& point) const{
5  int num = states.size();
6  if(num<2) throw VertexException("MultiTrackPointingKinematicConstraint::value <2 states passed");
7 
8  //2 equations (for all tracks)
9  AlgebraicVector vl(2,0);
10  double dx = point.x() - refPoint.x();
11  double dy = point.y() - refPoint.y();
12  double dz = point.z() - refPoint.z();
13  double dT = sqrt(pow(dx,2) + pow(dy,2));
14  double ds = sqrt(pow(dx,2) + pow(dy,2) + pow(dz,2));
15 
16  double pxSum=0, pySum=0, pzSum=0;
17  for(std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++)
18  {
19  double a = - i->particleCharge() * i->magneticField()->inInverseGeV(i->globalPosition()).z();
20 
21  pxSum += i->kinematicParameters()(3) - a*(point.y() - i->kinematicParameters()(1));
22  pySum += i->kinematicParameters()(4) + a*(point.x() - i->kinematicParameters()(0));
23  pzSum += i->kinematicParameters()(5);
24  }
25 
26  double pT = sqrt(pow(pxSum,2) + pow(pySum,2));
27  double pSum = sqrt(pow(pxSum,2) + pow(pySum,2) + pow(pzSum,2));
28 
29  vl(1) = (dT - dx)/dy + (pxSum - pT)/pySum;
30  vl(2) = (ds - dT)/dz + (pT - pSum)/pzSum;
31 
32  return vl;
33 }
34 
35 AlgebraicMatrix MultiTrackPointingKinematicConstraint::parametersDerivative(const std::vector<KinematicState> &states, const GlobalPoint& point) const{
36  int num = states.size();
37  if(num<2) throw VertexException("MultiTrackPointingKinematicConstraint::parametersDerivative <2 states passed");
38 
39  //2 equations (for all tracks)
40  AlgebraicMatrix matrix(2,num*7,0);//AlgebraicMatrix starts from 1
41 
42  double pxSum=0, pySum=0, pzSum=0;
43  for(std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++)
44  {
45  double a = - i->particleCharge() * i->magneticField()->inInverseGeV(i->globalPosition()).z();
46 
47  pxSum += i->kinematicParameters()(3) - a*(point.y() - i->kinematicParameters()(1));
48  pySum += i->kinematicParameters()(4) + a*(point.x() - i->kinematicParameters()(0));
49  pzSum += i->kinematicParameters()(5);
50  }
51 
52  double pT = sqrt(pow(pxSum,2) + pow(pySum,2));
53  double pSum = sqrt(pow(pxSum,2) + pow(pySum,2) + pow(pzSum,2));
54 
55  int col=0;
56  for(std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++){
57  double a = - i->particleCharge() * i->magneticField()->inInverseGeV(i->globalPosition()).z();
58 
59  matrix(1,1+col*7) = a*(1/pT + (-pT + pxSum)/pow(pySum,2));//dH/dx
60  matrix(1,2+col*7) = (a - (a*pxSum)/pT)/pySum;//dH/dy
61  //dH/dz=0
62  matrix(1,4+col*7) = (pT - pxSum)/(pT*pySum);//dH/dpx
63  matrix(1,5+col*7) = -(1/pT) + (pT - pxSum)/pow(pySum,2);//dH/dpy
64  //dH/dpz=0
65  //dH/dm=0
66  matrix(2,1+col*7) = (a*(-pSum + pT)*pySum)/(pSum*pT*pzSum);//dH/dx
67  matrix(2,2+col*7) = (a*( pSum - pT)*pxSum)/(pSum*pT*pzSum);//dH/dy
68  //dH/dz
69  matrix(2,4+col*7) = ((-(1/pSum) + 1/pT)*pxSum)/pzSum;//dH/dpx
70  matrix(2,5+col*7) = ((-(1/pSum) + 1/pT)*pySum)/pzSum;//dH/dpy
71  matrix(2,6+col*7) = -(1/pSum) + (pSum - pT)/pow(pzSum,2);//dH/dpz
72  //dH/dm=0
73 
74  col++;
75  }
76 
77  return matrix;
78 }
79 
80 AlgebraicMatrix MultiTrackPointingKinematicConstraint::positionDerivative(const std::vector<KinematicState> &states, const GlobalPoint& point) const{
81  int num = states.size();
82  if(num<2) throw VertexException("MultiTrackPointingKinematicConstraint::positionDerivative <2 states passed");
83 
84  //2 equations (for all tracks)
85  AlgebraicMatrix matrix(2,3,0);
86  double dx = point.x() - refPoint.x();
87  double dy = point.y() - refPoint.y();
88  double dz = point.z() - refPoint.z();
89  double dT = sqrt(pow(dx,2) + pow(dy,2));
90  double ds = sqrt(pow(dx,2) + pow(dy,2) + pow(dz,2));
91 
92  double pxSum=0, pySum=0, pzSum=0, aSum = 0;
93  for(std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++){
94  double a = - i->particleCharge() * i->magneticField()->inInverseGeV(i->globalPosition()).z();
95  aSum += a;
96 
97  pxSum += i->kinematicParameters()(3) - a*(point.y() - i->kinematicParameters()(1));
98  pySum += i->kinematicParameters()(4) + a*(point.x() - i->kinematicParameters()(0));
99  pzSum += i->kinematicParameters()(5);
100  }
101  double pT = sqrt(pow(pxSum,2) + pow(pySum,2));
102  double pSum = sqrt(pow(pxSum,2) + pow(pySum,2) + pow(pzSum,2));
103 
104  matrix(1,1) = (-1 + dx/dT)/dy - aSum/pT + (aSum*(pT - pxSum))/pow(pySum,2);//dH/dxv
105  matrix(1,2) = 1/dT + (-dT + dx)/pow(dy,2) - (aSum*(pT - pxSum))/(pT*pySum);//dH/dyv
106  //dH/dzv=0
107  matrix(2,1) = ((1/ds - 1/dT)*dx)/dz + (aSum*(pSum - pT)*pySum)/(pSum*pT*pzSum);//dH/dxv
108  matrix(2,2) = ((1/ds - 1/dT)*dy)/dz - (aSum*(pSum - pT)*pxSum)/(pSum*pT*pzSum);//dH/dyv
109  matrix(2,3) = 1/ds + (-ds + dT)/pow(dz,2);//dH/dzv
110 
111  return matrix;
112 }
113 
115  return 2;
116 }
int i
Definition: DBlmapReader.cc:9
Common base class.
T y() const
Definition: PV3DBase.h:63
virtual AlgebraicMatrix parametersDerivative(const std::vector< KinematicState > &states, const GlobalPoint &point) const
CLHEP::HepMatrix AlgebraicMatrix
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
virtual AlgebraicVector value(const std::vector< KinematicState > &states, const GlobalPoint &point) const
virtual AlgebraicMatrix positionDerivative(const std::vector< KinematicState > &states, const GlobalPoint &point) const
CLHEP::HepVector AlgebraicVector
double a
Definition: hdecay.h:121
int col
Definition: cuy.py:1008
T x() const
Definition: PV3DBase.h:62
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5