CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConversionFastHelix.cc
Go to the documentation of this file.
7 
8 
9 #include <cfloat>
10 
12  const GlobalPoint& middleHit,
13  const GlobalPoint& aVertex,
14  const MagneticField* field ) :
15  theOuterHit(outerHit),
16  theMiddleHit(middleHit),
17  theVertex(aVertex),
18  theCircle(outerHit,
19  middleHit,
20  aVertex),
21  mField(field) {
22 
23  validStateAtVertex=false;
24 
25 
26  makeHelix();
27 
28 
29 }
30 
31 
33 
34 
35  if( theCircle.isValid()) {
37  } else {
39  }
40 
41 
42 }
43 
44 
46 
47  return theHelix_;
48 
49 }
50 
51 
53 
54 
55 
58  FTS atVertex;
59 
60  double dydx = 0.;
61  double pt = 0., px = 0., py = 0.;
62 
63  //remember (radius rho in cm):
64  //rho =
65  //100. * pt *
66  //(10./(3.*MagneticField::inTesla(GlobalPoint(0., 0., 0.)).z()));
67 
68  double rho = theCircle.rho();
69  pt = 0.01 * rho * (0.3*mField->inTesla(GlobalPoint(0,0,0)).z());
70 
71  // (py/px)|x=v.x() = (dy/dx)|x=v.x()
72  //remember:
73  //y(x) = +-sqrt(rho^2 - (x-x0)^2) + y0
74  //y(x) = sqrt(rho^2 - (x-x0)^2) + y0 if y(x) >= y0
75  //y(x) = -sqrt(rho^2 - (x-x0)^2) + y0 if y(x) < y0
76  //=> (dy/dx) = -(x-x0)/sqrt(Q) if y(x) >= y0
77  // (dy/dx) = (x-x0)/sqrt(Q) if y(x) < y0
78  //with Q = rho^2 - (x-x0)^2
79 
80 
81  double arg=rho*rho - ( (v.x()-theCircle.x0())*(v.x()-theCircle.x0()) );
82 
83  if ( arg > 0 ) {
84 
85 
86  // double root = sqrt( rho*rho - ( (v.x()-theCircle.x0())*(v.x()-theCircle.x0()) ) );
87  double root = sqrt( arg );
88 
89  if((v.y() - theCircle.y0()) > 0.)
90  dydx = -(v.x() - theCircle.x0()) / root;
91  else
92  dydx = (v.x() - theCircle.x0()) / root;
93 
94  px = pt/sqrt(1. + dydx*dydx);
95  py = px*dydx;
96  // check sign with scalar product
97  if(px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
98  px *= -1.;
99  py *= -1.;
100  }
101 
102  //std::cout << " ConversionFastHelix:helixStateAtVertex rho " << rho << " pt " << pt << " v " << v << " theCircle.x0() " <<theCircle.x0() << " theCircle.y0() " << theCircle.y0() << " v.x()-theCircle.x0() " << v.x()-theCircle.x0() << " rho^2 " << rho*rho << " v.x()-theCircle.x0()^2 " << (v.x()-theCircle.x0())*(v.x()-theCircle.x0()) << " root " << root << " arg " << arg << " dydx " << dydx << std::endl;
103  //calculate z0, pz
104  //(z, R*phi) linear relation in a helix
105  //with R, phi defined as radius and angle w.r.t. centre of circle
106  //in transverse plane
107  //pz = pT*(dz/d(R*phi)))
108 
110 
111 
112 
113  double z_0 = 0;
114 
115  //std::cout << " ConversionFastHelix:helixStateAtVertex flfit.n2() " << flfit.n2() << " flfit.c() " << flfit.c() << " flfit.n2() " << flfit.n2() << std::endl;
116  if ( flfit.n2() !=0 && !edm::isNotFinite( flfit.c()) && !edm::isNotFinite(flfit.n2()) ) {
117  // std::cout << " Accepted " << std::endl;
118  z_0 = -flfit.c()/flfit.n2();
119  double dzdrphi = -flfit.n1()/flfit.n2();
120  double pz = pt*dzdrphi;
121 
122  //get sign of particle
123 
124  GlobalVector magvtx=mField->inTesla(v);
125  TrackCharge q =
126  ((theCircle.x0()*py - theCircle.y0()*px) /
127  (magvtx.z()) < 0.) ?
128  -1 : 1;
129 
130 
132  //MP
133 
134  atVertex = FTS(GlobalTrajectoryParameters(GlobalPoint(v.x(), v.y(), z_0),
135  GlobalVector(px, py, pz),
136  q,
137  mField),
139 
140  //std::cout << " ConversionFastHelix:helixStateAtVertex globalPoint " << GlobalPoint(v.x(), v.y(), z_0) << " GlobalVector " << GlobalVector(px, py, pz) << " q " << q << " MField " << mField->inTesla(v) << std::endl;
141  //std::cout << " ConversionFastHelix:helixStateAtVertex atVertex.transverseCurvature() " << atVertex.transverseCurvature() << std::endl;
142  if( atVertex.transverseCurvature() !=0 ) {
143 
144  validStateAtVertex=true;
145 
146  //std::cout << " ConversionFastHelix:helixStateAtVertex validHelixStateAtVertex status " << validStateAtVertex << std::endl;
147  return atVertex;
148  }else
149  return atVertex;
150  } else {
151  //std::cout << " ConversionFastHelix:helixStateAtVertex not accepted validHelixStateAtVertex status " << validStateAtVertex << std::endl;
152  return atVertex;
153  }
154 
155 
156 
157  } else {
158 
159  //std::cout << " ConversionFastHelix:helixStateAtVertex not accepted because arg <0 validHelixStateAtVertex status " << validStateAtVertex << std::endl;
160  return atVertex;
161  }
162 
163 
164 
165 
166 
167 }
168 
170 
171  FTS atVertex;
172 
173  //calculate FTS assuming straight line...
174 
177 
178  double dydx = 0.;
179  double pt = 0., px = 0., py = 0.;
180 
181  if(fabs(theCircle.n1()) > 0. || fabs(theCircle.n2()) > 0.)
182  pt = 1.e+4;// 10 TeV //else no pt
183  if(fabs(theCircle.n2()) > 0.) {
184  dydx = -theCircle.n1()/theCircle.n2(); //else px = 0
185  }
186 
187  if ( pt==0 && dydx==0. ) {
188  validStateAtVertex=false;
189  return atVertex;
190  }
191  px = pt/sqrt(1. + dydx*dydx);
192  py = px*dydx;
193 
194  // check sign with scalar product
195  if (px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
196  px *= -1.;
197  py *= -1.;
198  }
199 
200  //calculate z_0 and pz at vertex using weighted mean
201  //z = z(r) = z0 + (dz/dr)*r
202  //tan(theta) = dr/dz = (dz/dr)^-1
203  //theta = atan(1./dzdr)
204  //p = pt/sin(theta)
205  //pz = p*cos(theta) = pt/tan(theta)
206 
207 
209 
210  double z_0 = 0;
211  if (flfit.n2() !=0 && !edm::isNotFinite( flfit.c()) && !edm::isNotFinite(flfit.n2()) ) {
212  z_0 = -flfit.c()/flfit.n2();
213 
214  double dzdr = -flfit.n1()/flfit.n2();
215  double pz = pt*dzdr;
216 
217  TrackCharge q = 1;
218 
219  atVertex = FTS(GlobalPoint(v.x(), v.y(), z_0),
220  GlobalVector(px, py, pz),
221  q,
222  mField
223  );
224 
225  // std::cout << " ConversionFastHelix::straightLineStateAtVertex curvature " << atVertex.transverseCurvature() << " signedInverseMomentum " << atVertex.signedInverseMomentum() << std::endl;
226  if ( atVertex.transverseCurvature() == -0 ) {
227  return atVertex;
228  } else {
229  validStateAtVertex=true;
230  return atVertex;
231  }
232 
233  } else {
234 
235 
236  return atVertex;
237 
238  }
239 
240 }
double x0() const
Definition: FastCircle.h:50
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
FreeTrajectoryState FTS
Definition: DDAxes.h:10
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T y() const
Definition: PV3DBase.h:63
const MagneticField * mField
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
A arg
Definition: Factorize.h:36
double n2() const
Definition: FastCircle.h:62
double rho() const
Definition: FastCircle.h:54
tuple field
Definition: statics.py:62
bool isValid() const
Definition: FastCircle.h:56
ConversionFastHelix(const GlobalPoint &outerHit, const GlobalPoint &middleHit, const GlobalPoint &aVertex, const MagneticField *field)
int TrackCharge
Definition: TrackCharge.h:4
bool isNotFinite(T x)
Definition: isFinite.h:10
double n1() const
Definition: FastCircle.h:60
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
double n1() const
Definition: FastLine.h:28
double c() const
Definition: FastLine.h:32
double transverseCurvature() const
double y0() const
Definition: FastCircle.h:52
double n2() const
Definition: FastLine.h:30
T x() const
Definition: PV3DBase.h:62
Global3DVector GlobalVector
Definition: GlobalVector.h:10
string root
initialization
Definition: dbtoconf.py:70