CMS 3D CMS Logo

MultiTrackVertexLinkKinematicConstraint.cc
Go to the documentation of this file.
3 
4 AlgebraicVector MultiTrackVertexLinkKinematicConstraint::value(const std::vector<KinematicState>& states,
5  const GlobalPoint& point) const {
6  int num = states.size();
7  if (num < 2)
8  throw VertexException("MultiTrackVertexLinkKinematicConstraint::value <2 states passed");
9 
10  //2 equations (for all tracks)
11  AlgebraicVector vl(2, 0);
12  double dx = point.x() - refPoint.x();
13  double dy = point.y() - refPoint.y();
14  double dz = point.z() - refPoint.z();
15  double dT = sqrt(pow(dx, 2) + pow(dy, 2));
16  double ds = sqrt(pow(dx, 2) + pow(dy, 2) + pow(dz, 2));
17 
18  double pxSum = 0, pySum = 0, pzSum = 0;
19  double aSum = 0;
20  for (std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++) {
21  double a = -i->particleCharge() * i->magneticField()->inInverseGeV(i->globalPosition()).z();
22  aSum += a;
23 
24  pxSum += i->kinematicParameters()(3) - a * (point.y() - i->kinematicParameters()(1));
25  pySum += i->kinematicParameters()(4) + a * (point.x() - i->kinematicParameters()(0));
26  pzSum += i->kinematicParameters()(5);
27  }
28 
29  double pT = sqrt(pow(pxSum, 2) + pow(pySum, 2));
30  double pSum = sqrt(pow(pxSum, 2) + pow(pySum, 2) + pow(pzSum, 2));
31 
32  vl(1) = (dT - dx) / dy + (-2 * pT + sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2))) / (aSum * dT) +
33  (-pT + pxSum) / pySum;
34  vl(2) = (ds - dT) / dz + (pT - pSum) / pzSum;
35 
36  return vl;
37 }
38 
40  const GlobalPoint& point) const {
41  int num = states.size();
42  if (num < 2)
43  throw VertexException("MultiTrackVertexLinkKinematicConstraint::parametersDerivative <2 states passed");
44 
45  //2 equations (for all tracks)
46  AlgebraicMatrix matrix(2, num * 7, 0); //AlgebraicMatrix starts from 1
47  double dx = point.x() - refPoint.x();
48  double dy = point.y() - refPoint.y();
49  double dT = sqrt(pow(dx, 2) + pow(dy, 2));
50 
51  double pxSum = 0, pySum = 0, pzSum = 0;
52  double aSum = 0;
53  for (std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++) {
54  double a = -i->particleCharge() * i->magneticField()->inInverseGeV(i->globalPosition()).z();
55  aSum += a;
56 
57  pxSum += i->kinematicParameters()(3) - a * (point.y() - i->kinematicParameters()(1));
58  pySum += i->kinematicParameters()(4) + a * (point.x() - i->kinematicParameters()(0));
59  pzSum += i->kinematicParameters()(5);
60  }
61 
62  double pT = sqrt(pow(pxSum, 2) + pow(pySum, 2));
63  double pSum = sqrt(pow(pxSum, 2) + pow(pySum, 2) + pow(pzSum, 2));
64 
65  int col = 0;
66  for (std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++) {
67  double a = -i->particleCharge() * i->magneticField()->inInverseGeV(i->globalPosition()).z();
68 
69  matrix(1, 1 + col * 7) = a * (-(pT / pow(pySum, 2)) + pxSum / pow(pySum, 2) -
70  (4 * pySum) / (aSum * dT * sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2))) +
71  (1 + (2 * pySum) / (aSum * dT)) / pT); //dH/dx
72  matrix(1, 2 + col * 7) =
73  (a * (aSum * dT * (pT - pxSum) +
74  2 * (-1 + (2 * pT) / sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2))) * pxSum * pySum)) /
75  (aSum * dT * pT * pySum); //dH/dy
76  //dH/dz=0
77  matrix(1, 4 + col * 7) =
78  (aSum * dT * (pT - pxSum) +
79  2 * (-1 + (2 * pT) / sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2))) * pxSum * pySum) /
80  (aSum * dT * pT * pySum); //dH/dpx
81  matrix(1, 5 + col * 7) = pT / pow(pySum, 2) - pxSum / pow(pySum, 2) +
82  (4 * pySum) / (aSum * dT * sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2))) +
83  (-1 - (2 * pySum) / (aSum * dT)) / pT; //dH/dpy
84  //dH/dpz=0
85  //dH/dm=0
86  matrix(2, 1 + col * 7) = (a * (-pSum + pT) * pySum) / (pSum * pT * pzSum); //dH/dx
87  matrix(2, 2 + col * 7) = (a * (pSum - pT) * pxSum) / (pSum * pT * pzSum); //dH/dy
88  //dH/dz
89  matrix(2, 4 + col * 7) = ((-(1 / pSum) + 1 / pT) * pxSum) / pzSum; //dH/dpx
90  matrix(2, 5 + col * 7) = ((-(1 / pSum) + 1 / pT) * pySum) / pzSum; //dH/dpy
91  matrix(2, 6 + col * 7) = -(1 / pSum) + (pSum - pT) / pow(pzSum, 2); //dH/dpz
92  //dH/dm=0
93 
94  col++;
95  }
96 
97  return matrix;
98 }
99 
101  const GlobalPoint& point) const {
102  int num = states.size();
103  if (num < 2)
104  throw VertexException("MultiTrackVertexLinkKinematicConstraint::positionDerivative <2 states passed");
105 
106  //2 equations (for all tracks)
107  AlgebraicMatrix matrix(2, 3, 0);
108  double dx = point.x() - refPoint.x();
109  double dy = point.y() - refPoint.y();
110  double dz = point.z() - refPoint.z();
111  double dT = sqrt(pow(dx, 2) + pow(dy, 2));
112  double ds = sqrt(pow(dx, 2) + pow(dy, 2) + pow(dz, 2));
113 
114  double pxSum = 0, pySum = 0, pzSum = 0, aSum = 0;
115  for (std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++) {
116  double a = -i->particleCharge() * i->magneticField()->inInverseGeV(i->globalPosition()).z();
117  aSum += a;
118 
119  pxSum += i->kinematicParameters()(3) - a * (point.y() - i->kinematicParameters()(1));
120  pySum += i->kinematicParameters()(4) + a * (point.x() - i->kinematicParameters()(0));
121  pzSum += i->kinematicParameters()(5);
122  }
123  double pT = sqrt(pow(pxSum, 2) + pow(pySum, 2));
124  double pSum = sqrt(pow(pxSum, 2) + pow(pySum, 2) + pow(pzSum, 2));
125 
126  matrix(1, 1) =
127  (-1 + dx / dT) / dy +
128  (2 * dx * pT * (1 - (2 * pT) / sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2)))) / (aSum * pow(dT, 3)) +
129  aSum * (-(1 / pT) + pT / pow(pySum, 2) - pxSum / pow(pySum, 2)) +
130  (2 * (-(1 / pT) + 2 / sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2))) * pySum) / dT; //dH/dxv
131  matrix(1, 2) = 1 / dT + (-dT + dx) / pow(dy, 2) -
132  (dy * (-2 * pT + sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2)))) / (aSum * pow(dT, 3)) -
133  ((-2 + sqrt(4 - (pow(aSum, 2) * pow(dT, 2)) / pow(pT, 2))) * pxSum) / (dT * pT) -
134  (aSum * (dy * pow(pT, 2) + aSum * pow(dT, 2) * pxSum)) /
135  (dT * pow(pT, 2) * sqrt(-(pow(aSum, 2) * pow(dT, 2)) + 4 * pow(pT, 2))) +
136  (aSum * (-pT + pxSum)) / (pT * pySum); //dH/dyv
137  //dH/dzv=0
138  matrix(2, 1) = ((1 / ds - 1 / dT) * dx) / dz + (aSum * (pSum - pT) * pySum) / (pSum * pT * pzSum); //dH/dxv
139  matrix(2, 2) = ((1 / ds - 1 / dT) * dy) / dz - (aSum * (pSum - pT) * pxSum) / (pSum * pT * pzSum); //dH/dyv
140  matrix(2, 3) = 1 / ds + (-ds + dT) / pow(dz, 2); //dH/dzv
141 
142  return matrix;
143 }
144 
T z() const
Definition: PV3DBase.h:61
AlgebraicMatrix parametersDerivative(const std::vector< KinematicState > &states, const GlobalPoint &point) const override
Common base class.
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
AlgebraicVector value(const std::vector< KinematicState > &states, const GlobalPoint &point) const override
CLHEP::HepMatrix AlgebraicMatrix
T sqrt(T t)
Definition: SSEVec.h:19
CLHEP::HepVector AlgebraicVector
AlgebraicMatrix positionDerivative(const std::vector< KinematicState > &states, const GlobalPoint &point) const override
double a
Definition: hdecay.h:121
col
Definition: cuy.py:1009
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
*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