CMS 3D CMS Logo

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