CMS 3D CMS Logo

PixelTrackBuilder.cc
Go to the documentation of this file.
2 
3 
7 
12 
17 
18 #include <sstream>
19 using namespace std;
20 using namespace reco;
21 
22 
23 template <class T> T inline sqr( T t) {return t*t;}
24 
25 namespace {
26  __attribute__((unused))
28  const Measurement1D & pt,
29  const Measurement1D & phi,
30  const Measurement1D & cotTheta,
31  const Measurement1D & tip,
32  const Measurement1D & zip,
33  float chi2,
34  int charge)
35  {
36  ostringstream str;
37  str <<"\t pt: " << pt.value() <<"+/-"<< pt.error()
38  <<"\t phi: " << phi.value() <<"+/-"<< phi.error()
39  <<"\t cot: " << cotTheta.value() <<"+/-"<< cotTheta.error()
40  <<"\t tip: " << tip.value() <<"+/-"<< tip.error()
41  <<"\t zip: " << zip.value() <<"+/-"<< zip.error()
42  <<"\t chi2: " << chi2
43  <<"\t charge: " << charge;
44  return str.str();
45  }
46 
47  __attribute__((unused))
48  std::string print(const reco::Track & track, const GlobalPoint & origin)
49  {
50 
51  math::XYZPoint bs(origin.x(), origin.y(), origin.z());
52 
53  Measurement1D phi( track.phi(), track.phiError());
54 
55  float theta = track.theta();
56  float cosTheta = cos(theta);
57  float sinTheta = sin(theta);
58  float errLambda2 = sqr( track.lambdaError() );
59  Measurement1D cotTheta(cosTheta/sinTheta, sqrt(errLambda2)/sqr(sinTheta));
60 
61  float pt_v = track.pt();
62  float errInvP2 = sqr(track.qoverpError());
63  float covIPtTheta = track.covariance(TrackBase::i_qoverp, TrackBase::i_lambda);
64  float errInvPt2 = ( errInvP2
65  + sqr(cosTheta/pt_v)*errLambda2
66  + 2*(cosTheta/pt_v)*covIPtTheta
67  ) / sqr(sinTheta);
68  Measurement1D pt(pt_v, sqr(pt_v)*sqrt(errInvPt2));
69 
70  Measurement1D tip(track.dxy(bs), track.d0Error());
71 
72  Measurement1D zip(track.dz(bs), track.dzError());
73 
74  return print(pt, phi, cotTheta, tip, zip, track.chi2(), track.charge());
75  }
76 
77  __attribute__((unused))
79  {
80  // TrajectoryStateOnSurface state(bstate);
81  float pt_v = state.globalMomentum().perp();
82  float phi_v = state.globalMomentum().phi();
83  float theta_v = state.globalMomentum().theta();
84 
86  float errPhi2 = curv.matrix()(3,3);
87  float errLambda2 = curv.matrix()(2,2);
88  float errInvP2 = curv.matrix()(1,1);
89  float covIPtTheta = curv.matrix()(1,2);
90  float cosTheta = cos(theta_v);
91  float sinTheta = sin(theta_v);
92  float errInvPt2 = ( errInvP2
93  + sqr(cosTheta/pt_v)*errLambda2
94  + 2*(cosTheta/pt_v)*covIPtTheta) / sqr(sinTheta);
95  float errCotTheta = sqrt(errLambda2)/sqr(sinTheta) ;
96  Measurement1D pt(pt_v, sqr(pt_v) * sqrt(errInvPt2));
97  Measurement1D phi(phi_v, sqrt(errPhi2) );
98  Measurement1D cotTheta(cosTheta/sinTheta, errCotTheta);
99 
100  float zip_v = state.globalPosition().z();
101  float zip_e = sqrt( state.localError().matrix()(4,4));
102  Measurement1D zip(zip_v, zip_e);
103 
104  float tip_v = state.localPosition().x();
105  int tip_sign = (state.localMomentum().y()*cotTheta.value() > 0) ? -1 : 1;
106  float tip_e = sqrt( state.localError().matrix()(3,3) );
107  Measurement1D tip( tip_sign*tip_v, tip_e);
108 
109  return print(pt, phi, cotTheta, tip, zip, 0., state.charge());
110  }
111 
112 
113 #ifdef DEBUG_STATE
114  inline void checkState(const BasicTrajectoryStateOnSurface & bstate, const MagneticField* mf, const GlobalPoint & origin)
115  {
116  TrajectoryStateOnSurface state(bstate.clone());
117 
118  LogTrace("") << " *** PixelTrackBuilder::checkState: ";
119  LogTrace("") << "INPUT, ROTATION" << '\n' << state.surface().rotation();
120  LogTrace("") << "INPUT, TSOS:"<< '\n' << state;
121 
123  TrajectoryStateOnSurface test= tipe.extrapolate(state, origin);
124  LogTrace("") << "CHECK-1 ROTATION" << '\n' << test.surface().rotation();
125  LogTrace("") << "CHECK-1 TSOS" << '\n' << test;
126 
127  TSCPBuilderNoMaterial tscpBuilder;
129  tscpBuilder(*(state.freeState()), origin);
130  const FreeTrajectoryState& fs = tscp.theState();
131  LogTrace("") << "CHECK-2 FTS: " << fs;
132  }
133 #endif
134 
135 }
136 
137 
139  const Measurement1D & pt,
140  const Measurement1D & phi,
141  const Measurement1D & cotTheta,
142  const Measurement1D & tip,
143  const Measurement1D & zip,
144  float chi2,
145  int charge,
146  const std::vector<const TrackingRecHit* >& hits,
147  const MagneticField * mf,
148  const GlobalPoint & origin) const
149 {
150 
151  LogDebug("PixelTrackBuilder::build");
152  LogTrace("") << "Reconstructed triplet kinematics: " << print(pt,phi,cotTheta,tip,zip,chi2,charge);
153 
154  double sinTheta = 1/std::sqrt(1+sqr(cotTheta.value()));
155  double cosTheta = cotTheta.value()*sinTheta;
156  int tipSign = tip.value() > 0 ? 1 : -1;
157 
159  double invPtErr = 1./sqr(pt.value()) * pt.error();
160  m(0,0) = sqr(sinTheta) * (
161  sqr(invPtErr)
162  + sqr(cotTheta.error()/pt.value()*cosTheta * sinTheta)
163  );
164  m(0,2) = sqr( cotTheta.error()) * cosTheta * sqr(sinTheta) / pt.value();
165  m(1,1) = sqr( phi.error() );
166  m(2,2) = sqr( cotTheta.error());
167  m(3,3) = sqr( tip.error() );
168  m(4,4) = sqr( zip.error() );
170 
172  LocalPoint(tipSign*tip.value(), -tipSign*zip.value(), 0),
173  LocalVector(0., -tipSign*pt.value()*cotTheta.value(), pt.value()),
174  charge);
175 
176 
177  float sp = std::sin(phi.value());
178  float cp = std::cos(phi.value());
180  sp*tipSign, -cp*tipSign, 0,
181  0 , 0, -tipSign,
182  cp , sp , 0);
183 
184  // BTSOS hold Surface in a shared pointer and will be autodeleted when BTSOS goes out of scope...
185  // to avoid memory churn we allocate it locally and just avoid it be deleted by refcount...
186  Plane impPointPlane(origin, rot);
187  // (twice just to be sure!)
188  impPointPlane.addReference(); impPointPlane.addReference();
189  // use Base (to avoid a useless new)
190  BasicTrajectoryStateOnSurface impactPointState( lpar , error, impPointPlane, mf);
191 
192 #ifdef DEBUG_STATE
193  checkState(impactPointState,mf);
194 #endif
195  LogTrace("") << "constructed TSOS:\n" << print(impactPointState);
196 
197  int ndof = 2*hits.size()-5;
198  GlobalPoint vv = impactPointState.globalPosition();
199  math::XYZPoint pos( vv.x(), vv.y(), vv.z() );
200  GlobalVector pp = impactPointState.globalMomentum();
201  math::XYZVector mom( pp.x(), pp.y(), pp.z() );
202 
203  reco::Track * track = new reco::Track( chi2, ndof, pos, mom,
204  impactPointState.charge(), impactPointState.curvilinearError());
205 
206 
207  return track;
208 }
209 
GlobalPoint globalPosition() const
#define LogDebug(id)
LocalPoint localPosition() const
double d0Error() const
error on d0
Definition: TrackBase.h:853
Local3DVector LocalVector
Definition: LocalVector.h:12
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:32
T perp() const
Definition: PV3DBase.h:72
const FreeTrajectoryState & theState() const
double theta() const
polar angle
Definition: TrackBase.h:618
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:63
double error() const
Definition: Measurement1D.h:27
float __attribute__((vector_size(8))) cms_float32x2_t
Definition: ExtVec.h:12
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:684
TrackCharge charge() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
Definition: Plane.h:17
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
const SurfaceType & surface() const
double chi2() const
chi-squared of the fit
Definition: TrackBase.h:588
const LocalTrajectoryError & localError() const
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
CovarianceMatrix covariance() const
return track covariance matrix
Definition: TrackBase.h:782
T sqrt(T t)
Definition: SSEVec.h:18
double pt() const
track transverse momentum
Definition: TrackBase.h:660
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
double phiError() const
error on phi
Definition: TrackBase.h:841
const AlgebraicSymMatrix55 & matrix() const
#define LogTrace(id)
double qoverpError() const
error on signed transverse curvature
Definition: TrackBase.h:808
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:648
double dzError() const
error on dz
Definition: TrackBase.h:865
T sqr(T t)
const SurfaceType & surface() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
double value() const
Definition: Measurement1D.h:25
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
void addReference() const
double lambdaError() const
error on lambda
Definition: TrackBase.h:829
GlobalVector globalMomentum() const
fixed size matrix
const AlgebraicSymMatrix55 & matrix() const
const RotationType & rotation() const
LocalVector localMomentum() const
int charge() const
track electric charge
Definition: TrackBase.h:606
const CurvilinearTrajectoryError & curvilinearError() const
#define str(s)
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:630
long double T
T x() const
Definition: PV3DBase.h:62