CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastHelix.cc
Go to the documentation of this file.
6 
8 
9  if(isValid() && (fabs(tesla0) > 1e-3) && theCircle.rho()<maxRho)
10  return helixStateAtVertex();
11  else
13 
14 }
15 
17 
18  // given the above rho>0.
19  double rho = theCircle.rho();
20  //remember (radius rho in cm):
21  //rho =
22  //100. * pt *
23  //(10./(3.*MagneticField::inTesla(GlobalPoint(0., 0., 0.)).z()));
24 
25  // pt = 0.01 * rho * (0.3*MagneticField::inTesla(GlobalPoint(0.,0.,0.)).z());
26  double pt = 0.01 * rho * 0.3*tesla0;
27 
28  // verify that rho is not toooo large
29  double dcphi = ((theOuterHit.x()-theCircle.x0())*(theMiddleHit.x()-theCircle.x0()) +
31  )/(rho*rho);
32  if (fabs(dcphi)>=1.) return straightLineStateAtVertex();
33 
36 
37  double dydx = 0., dxdy = 0.;
38  double px = 0., py = 0.;
39 
40 
41  // (py/px)|x=v.x() = (dy/dx)|x=v.x()
42  //remember:
43  //y(x) = +-sqrt(rho^2 - (x-x0)^2) + y0
44  //y(x) = sqrt(rho^2 - (x-x0)^2) + y0 if y(x) >= y0
45  //y(x) = -sqrt(rho^2 - (x-x0)^2) + y0 if y(x) < y0
46  //=> (dy/dx) = -(x-x0)/sqrt(Q) if y(x) >= y0
47  // (dy/dx) = (x-x0)/sqrt(Q) if y(x) < y0
48  //with Q = rho^2 - (x-x0)^2
49  // Check approximate slope to determine whether to use dydx or dxdy
50  // Choose the one that goes to 0 rather than infinity.
51  double arg1 = rho*rho - (v.x()-theCircle.x0())*(v.x()-theCircle.x0());
52  double arg2 = rho*rho - (v.y()-theCircle.y0())*(v.y()-theCircle.y0());
53  if (arg1<0.0 && arg2<0.0) {
54  if(fabs(theCircle.n2()) > 0.) {
55  dydx = -theCircle.n1()/theCircle.n2(); //else px = 0
56  px = pt/sqrt(1. + dydx*dydx);
57  py = px*dydx;
58  } else {
59  px = 0.;
60  py = pt;
61  }
62  } else if ( arg1>arg2 ) {
63  if( v.y() > theCircle.y0() )
64  dydx = -(v.x() - theCircle.x0()) / sqrt(arg1);
65  else
66  dydx = (v.x() - theCircle.x0()) / sqrt(arg1);
67  px = pt/sqrt(1. + dydx*dydx);
68  py = px*dydx;
69  } else {
70  if( v.x() > theCircle.x0() )
71  dxdy = -(v.y() - theCircle.y0()) / sqrt(arg2);
72  else
73  dxdy = (v.y() - theCircle.y0()) / sqrt(arg2);
74  py = pt/sqrt(1. + dxdy*dxdy);
75  px = py*dxdy;
76  }
77  // check sign with scalar product
78  if(px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
79  px *= -1.;
80  py *= -1.;
81  }
82 
83  //calculate z0, pz
84  //(z, R*phi) linear relation in a helix
85  //with R, phi defined as radius and angle w.r.t. centre of circle
86  //in transverse plane
87  //pz = pT*(dz/d(R*phi)))
88 
89 
90  // VI 23/01/2012
91  double dzdrphi = theOuterHit.z() - theMiddleHit.z();
92  dzdrphi /= rho*acos(dcphi);
93  double pz = pt*dzdrphi;
94 
95  /*
96  // old crap
97  FastLine flfit(theOuterHit, theMiddleHit, theCircle.rho());
98  double dzdrphi2 = -flfit.n1()/flfit.n2();
99 
100  // if (fabs(dzdrphi2-dzdrphi)>1.e-5)
101  std::cout << "FastHelix: old,new " << dzdrphi2 <<", " << dzdrphi << std::endl;
102  */
103 
104  //get sign of particle
105 
106  /*
107  TrackCharge q =
108  ((theCircle.x0()*py - theCircle.y0()*px) /
109  (magvtx.z()) < 0.) ?
110  -1 : 1;
111  */
112  TrackCharge q = 1;
113  if (theCircle.x0()*py - theCircle.y0()*px < 0) q =-q;
114  if (tesla0 < 0.) q =-q;
115 
116  //VI
117  if ( useBasisVertex ) {
118  return FTS(basisVertex,
119  GlobalVector(px, py, pz),
120  q,
121  &(*pSetup)
122  );
123  } else {
124  double z_0 = theMiddleHit.z();
125  // assume v is before middleHit (opposite to outer)
126  double ds = ( (v.x()-theCircle.x0())*(theMiddleHit.x()-theCircle.x0()) +
127  (v.y()-theCircle.y0())*(theMiddleHit.y()-theCircle.y0())
128  )/(rho*rho);
129  if (fabs(ds)<1.) {
130  ds = rho*acos(ds);
131  z_0 -= ds*dzdrphi;
132  } else { // line????
134  }
135 
136  //double z_old = -flfit.c()/flfit.n2();
137  // std::cout << "v:xyz, z,old,new " << v << " " << z_old << " " << z_0 << std::endl;
138 
139  return FTS(GlobalPoint(v.x(),v.y(),z_0),
140  GlobalVector(px, py, pz),
141  q,
142  &(*pSetup)
143  );
144  }
145 
146 }
147 
149 
150  //calculate FTS assuming straight line...
151 
154 
155  double dydx = 0.;
156  double pt = 0., px = 0., py = 0.;
157 
158  if(fabs(theCircle.n1()) > 0. || fabs(theCircle.n2()) > 0.)
159  pt = maxPt ;// 10 TeV //else no pt
160  if(fabs(theCircle.n2()) > 0.) {
161  dydx = -theCircle.n1()/theCircle.n2(); //else px = 0
162  }
163  px = pt/sqrt(1. + dydx*dydx);
164  py = px*dydx;
165  // check sign with scalar product
166  if (px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
167  px *= -1.;
168  py *= -1.;
169  }
170 
171  //calculate z_0 and pz at vertex using weighted mean
172  //z = z(r) = z0 + (dz/dr)*r
173  //tan(theta) = dr/dz = (dz/dr)^-1
174  //theta = atan(1./dzdr)
175  //p = pt/sin(theta)
176  //pz = p*cos(theta) = pt/tan(theta)
177 
179  double dzdr = -flfit.n1()/flfit.n2();
180  double pz = pt*dzdr;
181 
182  TrackCharge q = 1;
183  //VI
184 
185  if ( useBasisVertex ) {
186  return FTS(basisVertex,
187  GlobalVector(px, py, pz),
188  q,
189  &(*pSetup)
190  );
191  } else {
192  double z_0 = -flfit.c()/flfit.n2();
193  return FTS(GlobalPoint(v.x(), v.y(), z_0),
194  GlobalVector(px, py, pz),
195  q,
196  &(*pSetup)
197  );
198  }
199 }
GlobalPoint theMiddleHit
Definition: FastHelix.h:88
FTS stateAtVertex() const
Definition: FastHelix.cc:7
GlobalPoint theVertex
Definition: FastHelix.h:89
bool isValid() const
Definition: FastHelix.h:73
FTS helixStateAtVertex() const
Definition: FastHelix.cc:16
double x0() const
Definition: FastCircle.h:50
Definition: DDAxes.h:10
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalPoint basisVertex
Definition: FastHelix.h:90
T y() const
Definition: PV3DBase.h:62
GlobalPoint theOuterHit
Definition: FastHelix.h:87
double n2() const
Definition: FastCircle.h:62
double rho() const
Definition: FastCircle.h:54
FastCircle theCircle
Definition: FastHelix.h:91
int TrackCharge
Definition: TrackCharge.h:4
double n1() const
Definition: FastCircle.h:60
T sqrt(T t)
Definition: SSEVec.h:46
T z() const
Definition: PV3DBase.h:63
double n1() const
Definition: FastLine.h:28
double c() const
Definition: FastLine.h:32
T perp2() const
Squared magnitude of transverse component.
FreeTrajectoryState FTS
Definition: FastHelix.h:32
double y0() const
Definition: FastCircle.h:52
double n2() const
Definition: FastLine.h:30
double maxRho
Definition: FastHelix.h:94
T x() const
Definition: PV3DBase.h:61
static constexpr double maxPt
Definition: FastHelix.h:85
edm::ESHandle< MagneticField > pSetup
Definition: FastHelix.h:92
mathSSE::Vec4< T > v
bool useBasisVertex
Definition: FastHelix.h:95
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double tesla0
Definition: FastHelix.h:93
FTS straightLineStateAtVertex() const
Definition: FastHelix.cc:148