CMS 3D CMS Logo

PixelTrackBuilder.cc
Go to the documentation of this file.
2 
6 
11 
16 
17 #include <sstream>
18 using namespace std;
19 using namespace reco;
20 
21 template <class T>
22 T inline sqr(T t) {
23  return t * t;
24 }
25 
26 namespace {
28  const Measurement1D& phi,
29  const Measurement1D& cotTheta,
30  const Measurement1D& tip,
31  const Measurement1D& zip,
32  float chi2,
33  int charge) {
34  ostringstream str;
35  str << "\t pt: " << pt.value() << "+/-" << pt.error() << "\t phi: " << phi.value() << "+/-" << phi.error()
36  << "\t cot: " << cotTheta.value() << "+/-" << cotTheta.error() << "\t tip: " << tip.value() << "+/-"
37  << tip.error() << "\t zip: " << zip.value() << "+/-" << zip.error() << "\t chi2: " << chi2
38  << "\t charge: " << charge;
39  return str.str();
40  }
41 
42  __attribute__((unused)) std::string print(const reco::Track& track, const GlobalPoint& origin) {
43  math::XYZPoint bs(origin.x(), origin.y(), origin.z());
44 
45  Measurement1D phi(track.phi(), track.phiError());
46 
47  float theta = track.theta();
48  float cosTheta = cos(theta);
49  float sinTheta = sin(theta);
50  float errLambda2 = sqr(track.lambdaError());
51  Measurement1D cotTheta(cosTheta / sinTheta, sqrt(errLambda2) / sqr(sinTheta));
52 
53  float pt_v = track.pt();
54  float errInvP2 = sqr(track.qoverpError());
55  float covIPtTheta = track.covariance(TrackBase::i_qoverp, TrackBase::i_lambda);
56  float errInvPt2 =
57  (errInvP2 + sqr(cosTheta / pt_v) * errLambda2 + 2 * (cosTheta / pt_v) * covIPtTheta) / sqr(sinTheta);
58  Measurement1D pt(pt_v, sqr(pt_v) * sqrt(errInvPt2));
59 
60  Measurement1D tip(track.dxy(bs), track.d0Error());
61 
62  Measurement1D zip(track.dz(bs), track.dzError());
63 
64  return print(pt, phi, cotTheta, tip, zip, track.chi2(), track.charge());
65  }
66 
68  // TrajectoryStateOnSurface state(bstate);
69  float pt_v = state.globalMomentum().perp();
70  float phi_v = state.globalMomentum().phi();
71  float theta_v = state.globalMomentum().theta();
72 
73  CurvilinearTrajectoryError curv = state.curvilinearError();
74  float errPhi2 = curv.matrix()(3, 3);
75  float errLambda2 = curv.matrix()(2, 2);
76  float errInvP2 = curv.matrix()(1, 1);
77  float covIPtTheta = curv.matrix()(1, 2);
78  float cosTheta = cos(theta_v);
79  float sinTheta = sin(theta_v);
80  float errInvPt2 =
81  (errInvP2 + sqr(cosTheta / pt_v) * errLambda2 + 2 * (cosTheta / pt_v) * covIPtTheta) / sqr(sinTheta);
82  float errCotTheta = sqrt(errLambda2) / sqr(sinTheta);
83  Measurement1D pt(pt_v, sqr(pt_v) * sqrt(errInvPt2));
84  Measurement1D phi(phi_v, sqrt(errPhi2));
85  Measurement1D cotTheta(cosTheta / sinTheta, errCotTheta);
86 
87  float zip_v = state.globalPosition().z();
88  float zip_e = sqrt(state.localError().matrix()(4, 4));
89  Measurement1D zip(zip_v, zip_e);
90 
91  float tip_v = state.localPosition().x();
92  int tip_sign = (state.localMomentum().y() * cotTheta.value() > 0) ? -1 : 1;
93  float tip_e = sqrt(state.localError().matrix()(3, 3));
94  Measurement1D tip(tip_sign * tip_v, tip_e);
95 
96  return print(pt, phi, cotTheta, tip, zip, 0., state.charge());
97  }
98 
99 #ifdef DEBUG_STATE
100  inline void checkState(const BasicTrajectoryStateOnSurface& bstate,
101  const MagneticField* mf,
102  const GlobalPoint& origin) {
104 
105  LogTrace("") << " *** PixelTrackBuilder::checkState: ";
106  LogTrace("") << "INPUT, ROTATION" << '\n' << state.surface().rotation();
107  LogTrace("") << "INPUT, TSOS:" << '\n' << state;
108 
110  TrajectoryStateOnSurface test = tipe.extrapolate(state, origin);
111  LogTrace("") << "CHECK-1 ROTATION" << '\n' << test.surface().rotation();
112  LogTrace("") << "CHECK-1 TSOS" << '\n' << test;
113 
114  TSCPBuilderNoMaterial tscpBuilder;
115  TrajectoryStateClosestToPoint tscp = tscpBuilder(*(state.freeState()), origin);
116  const FreeTrajectoryState& fs = tscp.theState();
117  LogTrace("") << "CHECK-2 FTS: " << fs;
118  }
119 #endif
120 
121 } // namespace
122 
124  const Measurement1D& phi,
125  const Measurement1D& cotTheta,
126  const Measurement1D& tip,
127  const Measurement1D& zip,
128  float chi2,
129  int charge,
130  const std::vector<const TrackingRecHit*>& hits,
131  const MagneticField* mf,
132  const GlobalPoint& origin) const {
133  LogDebug("PixelTrackBuilder::build");
134  LogTrace("") << "Reconstructed triplet kinematics: " << print(pt, phi, cotTheta, tip, zip, chi2, charge);
135 
136  double sinTheta = 1 / std::sqrt(1 + sqr(cotTheta.value()));
137  double cosTheta = cotTheta.value() * sinTheta;
138  int tipSign = tip.value() > 0 ? 1 : -1;
139 
141  double invPtErr = 1. / sqr(pt.value()) * pt.error();
142  m(0, 0) = sqr(sinTheta) * (sqr(invPtErr) + sqr(cotTheta.error() / pt.value() * cosTheta * sinTheta));
143  m(0, 2) = sqr(cotTheta.error()) * cosTheta * sqr(sinTheta) / pt.value();
144  m(1, 1) = sqr(phi.error());
145  m(2, 2) = sqr(cotTheta.error());
146  m(3, 3) = sqr(tip.error());
147  m(4, 4) = sqr(zip.error());
149 
150  LocalTrajectoryParameters lpar(LocalPoint(tipSign * tip.value(), -tipSign * zip.value(), 0),
151  LocalVector(0., -tipSign * pt.value() * cotTheta.value(), pt.value()),
152  charge);
153 
154  float sp = std::sin(phi.value());
155  float cp = std::cos(phi.value());
156  Surface::RotationType rot(sp * tipSign, -cp * tipSign, 0, 0, 0, -tipSign, cp, sp, 0);
157 
158  // BTSOS hold Surface in a shared pointer and will be autodeleted when BTSOS goes out of scope...
159  // to avoid memory churn we allocate it locally and just avoid it be deleted by refcount...
160  Plane impPointPlane(origin, rot);
161  // (twice just to be sure!)
162  impPointPlane.addReference();
163  impPointPlane.addReference();
164  // use Base (to avoid a useless new)
165  BasicTrajectoryStateOnSurface impactPointState(lpar, error, impPointPlane, mf);
166 
167 #ifdef DEBUG_STATE
168  checkState(impactPointState, mf);
169 #endif
170  LogTrace("") << "constructed TSOS:\n" << print(impactPointState);
171 
172  int ndof = 2 * hits.size() - 5;
173  GlobalPoint vv = impactPointState.globalPosition();
174  math::XYZPoint pos(vv.x(), vv.y(), vv.z());
175  GlobalVector pp = impactPointState.globalMomentum();
176  math::XYZVector mom(pp.x(), pp.y(), pp.z());
177 
178  reco::Track* track =
179  new reco::Track(chi2, ndof, pos, mom, impactPointState.charge(), impactPointState.curvilinearError());
180 
181  return track;
182 }
Vector3DBase
Definition: Vector3DBase.h:8
BasicTrajectoryStateOnSurface.h
TkRotation< float >
TrajectoryStateOnSurface.h
LocalTrajectoryParameters.h
Measurement1D
Definition: Measurement1D.h:11
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11779
MessageLogger.h
BasicSingleTrajectoryState::clone
pointer clone() const override
Definition: BasicSingleTrajectoryState.h:18
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
TrackBase.h
Measurement1D::value
double value() const
Definition: Measurement1D.h:25
pos
Definition: PixelAliasList.h:18
BasicTrajectoryState::charge
TrackCharge charge() const
Definition: BasicTrajectoryState.h:193
TransverseImpactPointExtrapolator
Definition: TransverseImpactPointExtrapolator.h:26
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
relativeConstraints.error
error
Definition: relativeConstraints.py:53
funct::sin
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
ndof
Definition: HIMultiTrackSelector.h:49
LocalTrajectoryParameters
Definition: LocalTrajectoryParameters.h:25
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
cms::cuda::bs
bs
Definition: HistoContainer.h:127
test
Definition: SmallWORMDict.h:13
LocalTrajectoryError.h
ctpps_dqm_sourceclient-live_cfg.test
test
Definition: ctpps_dqm_sourceclient-live_cfg.py:7
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
LocalError.h
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
reco::Track
Definition: Track.h:27
str
#define str(s)
Definition: TestProcessor.cc:51
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
Point3DBase< float, GlobalTag >
sqr
T sqr(T t)
Definition: PixelTrackBuilder.cc:22
BasicReferenceCounted::addReference
void addReference() const
Definition: ReferenceCounted.h:42
BasicSingleTrajectoryState
Definition: BasicSingleTrajectoryState.h:10
Measurement1D::error
double error() const
Definition: Measurement1D.h:27
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
qcdUeDQM_cfi.tip
tip
Definition: qcdUeDQM_cfi.py:23
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
LocalTrajectoryError
Definition: LocalTrajectoryError.h:20
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
PVValHelper::phi
Definition: PVValidationHelpers.h:68
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
__attribute__
float __attribute__((vector_size(8))) cms_float32x2_t
Definition: ExtVec.h:12
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
LocalVector
Local3DVector LocalVector
Definition: LocalVector.h:12
BasicTrajectoryState::globalPosition
GlobalPoint globalPosition() const
Definition: BasicTrajectoryState.h:190
TrajectoryStateClosestToPoint
Definition: TrajectoryStateClosestToPoint.h:18
TSCPBuilderNoMaterial.h
ComparisonHelper::zip
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
Definition: L1TStage2CaloLayer1.h:41
PixelTrackBuilder::build
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
Definition: PixelTrackBuilder.cc:123
PixelTrackBuilder.h
std
Definition: JetResolutionObject.h:76
TSCPBuilderNoMaterial
Definition: TSCPBuilderNoMaterial.h:17
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
T
long double T
Definition: Basic3DVectorLD.h:48
Plane
Definition: Plane.h:16
TransverseImpactPointExtrapolator.h
makeMuonMisalignmentScenario.rot
rot
Definition: makeMuonMisalignmentScenario.py:322
BoundPlane.h
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
BasicTrajectoryState::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: BasicTrajectoryState.h:205
createTree.pp
pp
Definition: createTree.py:17
TrajectoryStateClosestToPoint::theState
const FreeTrajectoryState & theState() const
Definition: TrajectoryStateClosestToPoint.h:96
CommonMethods.cp
def cp(fromDir, toDir, listOfFiles, overwrite=False, smallList=False)
Definition: CommonMethods.py:192
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
MagneticField
Definition: MagneticField.h:19
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
GlobalPoint.h
CurvilinearTrajectoryError::matrix
const AlgebraicSymMatrix55 & matrix() const
Definition: CurvilinearTrajectoryError.h:61
BasicTrajectoryState::globalMomentum
GlobalVector globalMomentum() const
Definition: BasicTrajectoryState.h:191