CMS 3D CMS Logo

VertexKinematicConstraint.cc
Go to the documentation of this file.
4 
6 
8 
9 AlgebraicVector VertexKinematicConstraint::value(const std::vector<KinematicState>& states,
10  const GlobalPoint& point) const {
11  int num = states.size();
12  if (num < 2)
13  throw VertexException("VertexKinematicConstraint::<2 states passed");
14 
15  //it is 2 equations per track
16  AlgebraicVector vl(2 * num, 0);
17  int num_r = 0;
18  for (std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++) {
19  TrackCharge ch = i->particleCharge();
20  GlobalVector mom = i->globalMomentum();
21  GlobalPoint pos = i->globalPosition();
22  double d_x = point.x() - pos.x();
23  double d_y = point.y() - pos.y();
24  double d_z = point.z() - pos.z();
25  double pt = mom.transverse();
26 
27  if (ch != 0) {
28  //charged particle
29  double a_i = -ch * i->magneticField()->inInverseGeV(pos).z();
30 
31  double pvx = mom.x() - a_i * d_y;
32  double pvy = mom.y() + a_i * d_x;
33  double n = a_i * (d_x * mom.x() + d_y * mom.y());
34  double m = (pvx * mom.x() + pvy * mom.y());
35  double delta = atan2(n, m);
36 
37  //vector of values
38  vl(num_r * 2 + 1) = d_y * mom.x() - d_x * mom.y() - a_i * (d_x * d_x + d_y * d_y) / 2;
39  vl(num_r * 2 + 2) = d_z - mom.z() * delta / a_i;
40  } else {
41  //neutral particle
42  vl(num_r * 2 + 1) = d_y * mom.x() - d_x * mom.y();
43  vl(num_r * 2 + 2) = d_z - mom.z() * (d_x * mom.x() + d_y * mom.y()) / (pt * pt);
44  }
45  num_r++;
46  }
47  return vl;
48 }
49 
50 AlgebraicMatrix VertexKinematicConstraint::parametersDerivative(const std::vector<KinematicState>& states,
51  const GlobalPoint& point) const {
52  int num = states.size();
53  if (num < 2)
54  throw VertexException("VertexKinematicConstraint::<2 states passed");
55  AlgebraicMatrix jac_d(2 * num, 7 * num);
56  int num_r = 0;
57  for (std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++) {
58  AlgebraicMatrix el_part_d(2, 7, 0);
59  TrackCharge ch = i->particleCharge();
60  GlobalVector mom = i->globalMomentum();
61  GlobalPoint pos = i->globalPosition();
62  double d_x = point.x() - pos.x();
63  double d_y = point.y() - pos.y();
64  double pt = mom.transverse();
65 
66  if (ch != 0) {
67  //charged particle
68  double a_i = -ch * i->magneticField()->inInverseGeV(pos).z();
69 
70  double pvx = mom.x() - a_i * d_y;
71  double pvy = mom.y() + a_i * d_x;
72  double pvt = sqrt(pvx * pvx + pvy * pvy);
73  double novera = (d_x * mom.x() + d_y * mom.y());
74  double n = a_i * novera;
75  double m = (pvx * mom.x() + pvy * mom.y());
76  double k = -mom.z() / (pvt * pvt * pt * pt);
77  double delta = atan2(n, m);
78 
79  //D Jacobian matrix
80  el_part_d(1, 1) = mom.y() + a_i * d_x;
81  el_part_d(1, 2) = -mom.x() + a_i * d_y;
82  el_part_d(2, 1) = -k * (m * mom.x() - n * mom.y());
83  el_part_d(2, 2) = -k * (m * mom.y() + n * mom.x());
84  el_part_d(2, 3) = -1.;
85  el_part_d(1, 4) = d_y;
86  el_part_d(1, 5) = -d_x;
87  el_part_d(2, 4) = k * (m * d_x - novera * (2 * mom.x() - a_i * d_y));
88  el_part_d(2, 5) = k * (m * d_y - novera * (2 * mom.y() + a_i * d_x));
89  el_part_d(2, 6) = -delta / a_i;
90  jac_d.sub(num_r * 2 + 1, num_r * 7 + 1, el_part_d);
91  } else {
92  //neutral particle
93  el_part_d(1, 1) = mom.y();
94  el_part_d(1, 2) = -mom.x();
95  el_part_d(2, 1) = mom.x() * mom.z() / (pt * pt);
96  el_part_d(2, 2) = mom.y() * mom.z() / (pt * pt);
97  el_part_d(2, 3) = -1.;
98  el_part_d(1, 4) = d_y;
99  el_part_d(1, 5) = -d_x;
100  el_part_d(2, 4) =
101  2 * (d_x * mom.x() + d_y * mom.y()) * mom.x() * mom.z() / (pt * pt * pt * pt) - mom.z() * d_x / (pt * pt);
102  el_part_d(2, 5) =
103  2 * (d_x * mom.x() + d_y * mom.y()) * mom.y() * mom.z() / (pt * pt * pt * pt) - mom.z() * d_y / (pt * pt);
104  el_part_d(2, 6) = -(d_x * mom.x() + d_y * mom.y()) / (pt * pt);
105  jac_d.sub(num_r * 2 + 1, num_r * 7 + 1, el_part_d);
106  }
107  num_r++;
108  }
109  return jac_d;
110 }
111 
112 AlgebraicMatrix VertexKinematicConstraint::positionDerivative(const std::vector<KinematicState>& states,
113  const GlobalPoint& point) const {
114  int num = states.size();
115  if (num < 2)
116  throw VertexException("VertexKinematicConstraint::<2 states passed");
117  AlgebraicMatrix jac_e(2 * num, 3);
118  int num_r = 0;
119  for (std::vector<KinematicState>::const_iterator i = states.begin(); i != states.end(); i++) {
120  AlgebraicMatrix el_part_e(2, 3, 0);
121  TrackCharge ch = i->particleCharge();
122  GlobalVector mom = i->globalMomentum();
123  GlobalPoint pos = i->globalPosition();
124  double d_x = point.x() - pos.x();
125  double d_y = point.y() - pos.y();
126  double pt = mom.transverse();
127 
128  if (ch != 0) {
129  //charged particle
130  double a_i = -ch * i->magneticField()->inInverseGeV(pos).z();
131 
132  double pvx = mom.x() - a_i * d_y;
133  double pvy = mom.y() + a_i * d_x;
134  double pvt = sqrt(pvx * pvx + pvy * pvy);
135  double n = a_i * (d_x * mom.x() + d_y * mom.y());
136  double m = (pvx * mom.x() + pvy * mom.y());
137  double k = -mom.z() / (pvt * pvt * pt * pt);
138 
139  //E jacobian matrix
140  el_part_e(1, 1) = -(mom.y() + a_i * d_x);
141  el_part_e(1, 2) = mom.x() - a_i * d_y;
142  el_part_e(2, 1) = k * (m * mom.x() - n * mom.y());
143  el_part_e(2, 2) = k * (m * mom.y() + n * mom.x());
144  el_part_e(2, 3) = 1;
145  jac_e.sub(2 * num_r + 1, 1, el_part_e);
146  } else {
147  //neutral particle
148  el_part_e(1, 1) = -mom.y();
149  el_part_e(1, 2) = mom.x();
150  el_part_e(2, 1) = -mom.x() * mom.z() / (pt * pt);
151  el_part_e(2, 2) = -mom.y() * mom.z() / (pt * pt);
152  el_part_e(2, 3) = 1;
153  jac_e.sub(2 * num_r + 1, 1, el_part_e);
154  }
155  num_r++;
156  }
157  return jac_e;
158 }
159 
Vector3DBase
Definition: Vector3DBase.h:8
mps_fire.i
i
Definition: mps_fire.py:355
MessageLogger.h
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
TrackCharge
int TrackCharge
Definition: TrackCharge.h:4
VertexKinematicConstraint::value
AlgebraicVector value(const std::vector< KinematicState > &states, const GlobalPoint &point) const override
Definition: VertexKinematicConstraint.cc:9
VertexException
Common base class.
Definition: VertexException.h:12
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
pos
Definition: PixelAliasList.h:18
alignCSCRings.d_x
d_x
Definition: alignCSCRings.py:85
VertexKinematicConstraint::parametersDerivative
AlgebraicMatrix parametersDerivative(const std::vector< KinematicState > &states, const GlobalPoint &point) const override
Definition: VertexKinematicConstraint.cc:50
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
VertexKinematicConstraint::VertexKinematicConstraint
VertexKinematicConstraint()
Definition: VertexKinematicConstraint.cc:5
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
dqmdumpme.k
k
Definition: dqmdumpme.py:60
Point3DBase< float, GlobalTag >
VertexKinematicConstraint::positionDerivative
AlgebraicMatrix positionDerivative(const std::vector< KinematicState > &states, const GlobalPoint &point) const override
Definition: VertexKinematicConstraint.cc:112
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
alignCSCRings.d_y
d_y
Definition: alignCSCRings.py:86
VertexKinematicConstraint::~VertexKinematicConstraint
~VertexKinematicConstraint() override
Definition: VertexKinematicConstraint.cc:7
VertexKinematicConstraint.h
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
VertexKinematicConstraint::numberOfEquations
int numberOfEquations() const override
Definition: VertexKinematicConstraint.cc:160
VertexException.h
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
PV3DBase::transverse
T transverse() const
Definition: PV3DBase.h:70