CMS 3D CMS Logo

ConversionFastHelix.cc
Go to the documentation of this file.
7 
8 #include <cfloat>
9 
11  const GlobalPoint& middleHit,
12  const GlobalPoint& aVertex,
13  const MagneticField* field)
14  : theOuterHit(outerHit),
15  theMiddleHit(middleHit),
16  theVertex(aVertex),
17  theCircle(outerHit, middleHit, aVertex),
18  mField(field) {
19  validStateAtVertex = false;
20 
21  makeHelix();
22 }
23 
25  if (theCircle.isValid()) {
27  } else {
29  }
30 }
31 
33 
37  FTS atVertex;
38 
39  double dydx = 0.;
40  double pt = 0., px = 0., py = 0.;
41 
42  //remember (radius rho in cm):
43  //rho =
44  //100. * pt *
45  //(10./(3.*MagneticField::inTesla(GlobalPoint(0., 0., 0.)).z()));
46 
47  double rho = theCircle.rho();
48  pt = 0.01 * rho * (0.3 * mField->inTesla(GlobalPoint(0, 0, 0)).z());
49 
50  // (py/px)|x=v.x() = (dy/dx)|x=v.x()
51  //remember:
52  //y(x) = +-sqrt(rho^2 - (x-x0)^2) + y0
53  //y(x) = sqrt(rho^2 - (x-x0)^2) + y0 if y(x) >= y0
54  //y(x) = -sqrt(rho^2 - (x-x0)^2) + y0 if y(x) < y0
55  //=> (dy/dx) = -(x-x0)/sqrt(Q) if y(x) >= y0
56  // (dy/dx) = (x-x0)/sqrt(Q) if y(x) < y0
57  //with Q = rho^2 - (x-x0)^2
58 
59  double arg = rho * rho - ((v.x() - theCircle.x0()) * (v.x() - theCircle.x0()));
60 
61  if (arg > 0) {
62  // double root = sqrt( rho*rho - ( (v.x()-theCircle.x0())*(v.x()-theCircle.x0()) ) );
63  double root = sqrt(arg);
64 
65  if ((v.y() - theCircle.y0()) > 0.)
66  dydx = -(v.x() - theCircle.x0()) / root;
67  else
68  dydx = (v.x() - theCircle.x0()) / root;
69 
70  px = pt / sqrt(1. + dydx * dydx);
71  py = px * dydx;
72  // check sign with scalar product
73  if (px * (pMid.x() - v.x()) + py * (pMid.y() - v.y()) < 0.) {
74  px *= -1.;
75  py *= -1.;
76  }
77 
78  //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;
79  //calculate z0, pz
80  //(z, R*phi) linear relation in a helix
81  //with R, phi defined as radius and angle w.r.t. centre of circle
82  //in transverse plane
83  //pz = pT*(dz/d(R*phi)))
84 
86 
87  double z_0 = 0;
88 
89  //std::cout << " ConversionFastHelix:helixStateAtVertex flfit.n2() " << flfit.n2() << " flfit.c() " << flfit.c() << " flfit.n2() " << flfit.n2() << std::endl;
90  if (flfit.n2() != 0 && !edm::isNotFinite(flfit.c()) && !edm::isNotFinite(flfit.n2())) {
91  // std::cout << " Accepted " << std::endl;
92  z_0 = -flfit.c() / flfit.n2();
93  double dzdrphi = -flfit.n1() / flfit.n2();
94  double pz = pt * dzdrphi;
95 
96  //get sign of particle
97 
98  GlobalVector magvtx = mField->inTesla(v);
99  TrackCharge q = ((theCircle.x0() * py - theCircle.y0() * px) / (magvtx.z()) < 0.) ? -1 : 1;
100 
102  //MP
103 
104  atVertex = FTS(GlobalTrajectoryParameters(GlobalPoint(v.x(), v.y(), z_0), GlobalVector(px, py, pz), q, mField),
106 
107  //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;
108  //std::cout << " ConversionFastHelix:helixStateAtVertex atVertex.transverseCurvature() " << atVertex.transverseCurvature() << std::endl;
109  if (atVertex.transverseCurvature() != 0) {
110  validStateAtVertex = true;
111 
112  //std::cout << " ConversionFastHelix:helixStateAtVertex validHelixStateAtVertex status " << validStateAtVertex << std::endl;
113  return atVertex;
114  } else
115  return atVertex;
116  } else {
117  //std::cout << " ConversionFastHelix:helixStateAtVertex not accepted validHelixStateAtVertex status " << validStateAtVertex << std::endl;
118  return atVertex;
119  }
120 
121  } else {
122  //std::cout << " ConversionFastHelix:helixStateAtVertex not accepted because arg <0 validHelixStateAtVertex status " << validStateAtVertex << std::endl;
123  return atVertex;
124  }
125 }
126 
128  FTS atVertex;
129 
130  //calculate FTS assuming straight line...
131 
134 
135  double dydx = 0.;
136  double pt = 0., px = 0., py = 0.;
137 
138  if (fabs(theCircle.n1()) > 0. || fabs(theCircle.n2()) > 0.)
139  pt = 1.e+4; // 10 TeV //else no pt
140  if (fabs(theCircle.n2()) > 0.) {
141  dydx = -theCircle.n1() / theCircle.n2(); //else px = 0
142  }
143 
144  if (pt == 0 && dydx == 0.) {
145  validStateAtVertex = false;
146  return atVertex;
147  }
148  px = pt / sqrt(1. + dydx * dydx);
149  py = px * dydx;
150 
151  // check sign with scalar product
152  if (px * (pMid.x() - v.x()) + py * (pMid.y() - v.y()) < 0.) {
153  px *= -1.;
154  py *= -1.;
155  }
156 
157  //calculate z_0 and pz at vertex using weighted mean
158  //z = z(r) = z0 + (dz/dr)*r
159  //tan(theta) = dr/dz = (dz/dr)^-1
160  //theta = atan(1./dzdr)
161  //p = pt/sin(theta)
162  //pz = p*cos(theta) = pt/tan(theta)
163 
165 
166  double z_0 = 0;
167  if (flfit.n2() != 0 && !edm::isNotFinite(flfit.c()) && !edm::isNotFinite(flfit.n2())) {
168  z_0 = -flfit.c() / flfit.n2();
169 
170  double dzdr = -flfit.n1() / flfit.n2();
171  double pz = pt * dzdr;
172 
173  TrackCharge q = 1;
174 
175  atVertex = FTS(GlobalPoint(v.x(), v.y(), z_0), GlobalVector(px, py, pz), q, mField);
176 
177  // std::cout << " ConversionFastHelix::straightLineStateAtVertex curvature " << atVertex.transverseCurvature() << " signedInverseMomentum " << atVertex.signedInverseMomentum() << std::endl;
178  if (atVertex.transverseCurvature() == -0) {
179  return atVertex;
180  } else {
181  validStateAtVertex = true;
182  return atVertex;
183  }
184 
185  } else {
186  return atVertex;
187  }
188 }
T z() const
Definition: PV3DBase.h:61
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
FreeTrajectoryState FTS
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const MagneticField * mField
A arg
Definition: Factorize.h:31
ConversionFastHelix(const GlobalPoint &outerHit, const GlobalPoint &middleHit, const GlobalPoint &aVertex, const MagneticField *field)
int TrackCharge
Definition: TrackCharge.h:4
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
bool isValid() const
Definition: FastCircle.h:49
T sqrt(T t)
Definition: SSEVec.h:23
double n2() const
Definition: FastCircle.h:57
double c() const
Definition: FastLine.h:27
double transverseCurvature() const
double y0() const
Definition: FastCircle.h:45
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
double n2() const
Definition: FastLine.h:25
double n1() const
Definition: FastCircle.h:55
double rho() const
Definition: FastCircle.h:47
double x0() const
Definition: FastCircle.h:43
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double n1() const
Definition: FastLine.h:23