CMS 3D CMS Logo

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