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