CMS 3D CMS Logo

TrackFitter.cc
Go to the documentation of this file.
22 
23 using namespace std;
24 
25 namespace {
26 
27  int getCharge(const DynArray<GlobalPoint>& points) {
28  GlobalVector v21 = points[1] - points[0];
29  GlobalVector v32 = points[2] - points[1];
30  float dphi = v32.phi() - v21.phi();
31  while (dphi > M_PI)
32  dphi -= 2 * M_PI;
33  while (dphi < -M_PI)
34  dphi += 2 * M_PI;
35  return (dphi > 0) ? -1 : 1;
36  }
37 
38 } // namespace
39 
40 /*****************************************************************************/
41 std::unique_ptr<reco::Track> TrackFitter::run(const std::vector<const TrackingRecHit*>& hits,
42  const TrackingRegion& region) const {
43  std::unique_ptr<reco::Track> ret;
44 
45  int nhits = hits.size();
46  if (nhits < 2)
47  return ret;
48 
52 
53  unsigned int i = 0;
54  for (auto const& ih : hits) {
55  auto recHit = theTTRecHitBuilder->build(ih);
56 
57  points[i] = recHit->globalPosition();
58  errors[i] = recHit->globalPositionError();
59  isBarrel[++i] = recHit->detUnit()->type().isBarrel();
60  }
61 
62  CircleFromThreePoints circle = (nhits == 2) ? CircleFromThreePoints(GlobalPoint(0., 0., 0.), points[0], points[1])
63  : CircleFromThreePoints(points[0], points[1], points[2]);
64 
65  int charge = getCharge(points);
66  float curvature = circle.curvature();
67 
68  // pt
69  float invPt = PixelRecoUtilities::inversePt(curvature, *theField);
70  float valPt = (invPt > 1.e-4) ? 1. / invPt : 1.e4;
71  float errPt = 0.055 * valPt + 0.017 * valPt * valPt;
72 
73  CircleFromThreePoints::Vector2D center = circle.center();
74 
75  // tip
76  float valTip = charge * (center.mag() - 1 / curvature);
77  // zip
78  float valZip = getZip(valTip, curvature, points[0], points[1]);
79  // phi
80  float valPhi = getPhi(center.x(), center.y(), charge);
81  // cot(theta), update zip
82  float valCotTheta = getCotThetaAndUpdateZip(points[0], points[1], 1 / curvature, valPhi, valTip, valZip);
83 
84  // errors
85  float errTip, errZip;
86  getErrTipAndErrZip(valPt, points.back().eta(), errTip, errZip);
87  float errPhi = 0.002;
88  float errCotTheta = 0.002;
89 
90  float chi2 = 0;
91  if (nhits > 2) {
92  RZLine rzLine(points, errors, isBarrel);
93  chi2 = rzLine.chi2();
94  }
95 
96  // build pixel track
97  PixelTrackBuilder builder;
98 
99  Measurement1D pt(valPt, errPt);
100  Measurement1D phi(valPhi, errPhi);
101  Measurement1D cotTheta(valCotTheta, errCotTheta);
102  Measurement1D tip(valTip, errTip);
103  Measurement1D zip(valZip, errZip);
104 
105  ret.reset(builder.build(pt, phi, cotTheta, tip, zip, chi2, charge, hits, theField));
106  return ret;
107 }
108 
109 /*****************************************************************************/
111  const GlobalPoint& inner, const GlobalPoint& outer, float radius, float phi, float d0, float& zip) const {
112  float chi = phi - M_PI_2;
113  GlobalPoint IP(d0 * cos(chi), d0 * sin(chi), zip);
114 
115  float phi1 = 2 * asin(0.5 * (inner - IP).perp() / radius);
116  float phi2 = 2 * asin(0.5 * (outer - IP).perp() / radius);
117 
118  float dr = radius * (phi2 - phi1);
119  float dz = outer.z() - inner.z();
120 
121  // Recalculate ZIP
122  zip = (inner.z() * phi2 - outer.z() * phi1) / (phi2 - phi1);
123 
124  return (fabs(dr) > 1.e-3) ? dz / dr : 0;
125 }
126 
127 /*****************************************************************************/
128 float TrackFitter::getPhi(float xC, float yC, int charge) const {
129  float phiC;
130 
131  if (charge > 0)
132  phiC = atan2(xC, -yC);
133  else
134  phiC = atan2(-xC, yC);
135 
136  return phiC;
137 }
138 
139 /*****************************************************************************/
140 float TrackFitter::getZip(float d0, float curv, const GlobalPoint& inner, const GlobalPoint& outer) const {
141  // phi = asin(r*rho/2) with asin(x) ~= x+x**3/(2*3)
142  float rho3 = curv * curv * curv;
143 
144  float r1 = inner.perp();
145  double phi1 = r1 * curv / 2 + inner.perp2() * r1 * rho3 / 48.;
146 
147  float r2 = outer.perp();
148  double phi2 = r2 * curv / 2 + outer.perp2() * r2 * rho3 / 48.;
149 
150  double z1 = inner.z();
151  double z2 = outer.z();
152 
153  return z1 - phi1 / (phi1 - phi2) * (z1 - z2);
154 }
155 
156 /*****************************************************************************/
157 void TrackFitter::getErrTipAndErrZip(float pt, float eta, float& errTip, float& errZip) const {
158  float coshEta = cosh(eta);
159 
160  { // transverse
161  float c_ms = 0.0115; //0.0115;
162  float s_le = 0.0095; //0.0123;
163  float s_ms2 = c_ms * c_ms / (pt * pt) * coshEta;
164 
165  errTip = sqrt(s_le * s_le + s_ms2);
166  }
167 
168  { // z
169  float c_ms = 0.0070;
170  float s_le = 0.0135;
171 
172  errZip = sqrt((s_le * s_le + c_ms * c_ms / (pt * pt)) * coshEta * coshEta * coshEta);
173  }
174 }
std::unique_ptr< reco::Track > run(const std::vector< const TrackingRecHit *> &hits, const TrackingRegion &region) const override
Definition: TrackFitter.cc:41
ret
prodAgent to be discontinued
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
Definition: TracksSoA.h:90
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
float getZip(float d0, float curv, const GlobalPoint &inner, const GlobalPoint &outer) const
Definition: TrackFitter.cc:140
#define M_PI_2
T y() const
Cartesian y coordinate.
int getCharge(const SiStripCluster *cluster, int &nSatStrip, const GeomDetUnit &detUnit, const std::vector< std::vector< float >> &calibGains, const unsigned int &m_off)
float getPhi(float xC, float yC, int charge) const
Definition: TrackFitter.cc:128
T curvature(T InversePt, const MagneticField &field)
reco::Track * build(const Measurement1D &pt, const Measurement1D &phi, const Measurement1D &cotTheta, const Measurement1D &tip, const Measurement1D &zip, float chi2, int charge, const std::vector< const TrackingRecHit *> &hits, const MagneticField *mf, const GlobalPoint &reference=GlobalPoint(0, 0, 0)) const
void getErrTipAndErrZip(float pt, float eta, float &errZip, float &errTip) const
Definition: TrackFitter.cc:157
T sqrt(T t)
Definition: SSEVec.h:23
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
T inversePt(T curvature, const MagneticField &field)
T perp() const
Magnitude of transverse component.
#define M_PI
Definition: RZLine.h:12
static constexpr float d0
float chi2() const
Definition: RZLine.h:95
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
float getPhi(float x, float y)
Definition: Hit.h:34
float getCotThetaAndUpdateZip(const GlobalPoint &inner, const GlobalPoint &outer, float radius, float phi, float d0, float &zip) const
Definition: TrackFitter.cc:110
Definition: errors.py:1
#define declareDynArray(T, n, x)
Definition: DynArray.h:91
T x() const
Cartesian x coordinate.