CMS 3D CMS Logo

KFBasedPixelFitter.cc
Go to the documentation of this file.
2 
4 
6 
9 
11 
15 
17 
20 
23 
25 
26 template <class T>
27 inline T sqr(T t) {
28  return t * t;
29 }
30 
33  localPosition_ = LocalPoint(0., 0., 0.);
34  //neglect XY differences and BS slope
35  localError_ = LocalError(sqr(beamSpot.BeamWidthX()), 0.0, sqr(beamSpot.sigmaZ()));
36 }
37 
40  result[0] = localPosition().x();
41  return result;
42 }
44  LocalError le = localPositionError();
46  m[0][0] = le.xx();
47  return m;
48 }
50  AlgebraicMatrix matrix(1, 5, 0);
51  matrix[0][3] = 1;
52  return matrix;
53 }
54 
56  const Propagator *opropagator,
57  const TransientTrackingRecHitBuilder *ttrhBuilder,
58  const TrackerGeometry *tracker,
59  const MagneticField *field,
60  const reco::BeamSpot *beamSpot)
62  theOPropagator(opropagator),
63  theTTRHBuilder(ttrhBuilder),
65  theField(field),
67 
68 std::unique_ptr<reco::Track> KFBasedPixelFitter::run(const std::vector<const TrackingRecHit *> &hits,
69  const TrackingRegion &region,
70  const edm::EventSetup &setup) const {
71  std::unique_ptr<reco::Track> ret;
72 
73  int nhits = hits.size();
74  if (nhits < 2)
75  return ret;
76 
77  float ptMin = region.ptMin();
78 
79  const GlobalPoint &vertexPos = region.origin();
80  GlobalError vertexErr(sqr(region.originRBound()), 0, sqr(region.originRBound()), 0, 0, sqr(region.originZBound()));
81 
82  std::vector<GlobalPoint> points(nhits);
83  points[0] = theTracker->idToDet(hits[0]->geographicalId())->toGlobal(hits[0]->localPosition());
84  points[1] = theTracker->idToDet(hits[1]->geographicalId())->toGlobal(hits[1]->localPosition());
85  points[2] = theTracker->idToDet(hits[2]->geographicalId())->toGlobal(hits[2]->localPosition());
86 
87  //
88  //initial Kinematics
89  //
90  GlobalVector initMom;
91  int charge;
92  float theta;
93  CircleFromThreePoints circle(points[0], points[1], points[2]);
94  if (circle.curvature() > 1.e-4) {
95  float invPt = PixelRecoUtilities::inversePt(circle.curvature(), setup);
96  float valPt = 1.f / invPt;
97  float chargeTmp = (points[1].x() - points[0].x()) * (points[2].y() - points[1].y()) -
98  (points[1].y() - points[0].y()) * (points[2].x() - points[1].x());
99  charge = (chargeTmp > 0) ? -1 : 1;
100  float valPhi = (charge > 0) ? std::atan2(circle.center().x(), -circle.center().y())
101  : std::atan2(-circle.center().x(), circle.center().y());
102  theta = GlobalVector(points[1] - points[0]).theta();
103  initMom = GlobalVector(valPt * cos(valPhi), valPt * sin(valPhi), valPt / tan(theta));
104  } else {
105  initMom = GlobalVector(points[1] - points[0]);
106  initMom *= 10000. / initMom.perp();
107  charge = 1;
108  theta = initMom.theta();
109  }
110  GlobalTrajectoryParameters initialKine(vertexPos, initMom, TrackCharge(charge), theField);
111 
112  //
113  // initial error
114  //
115  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
116  float sin2th = sqr(sin(theta));
117  float minC00 = 1.0;
118  C[0][0] = std::max(sin2th / sqr(ptMin), minC00);
119  float zErr = vertexErr.czz();
120  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
121  C[3][3] = transverseErr;
122  C[4][4] = zErr * sin2th + transverseErr * (1 - sin2th);
123  CurvilinearTrajectoryError initialError(C);
124 
125  FreeTrajectoryState fts(initialKine, initialError);
126 
127  // get updator
129 
130  // Now update initial state track using information from hits.
131  TrajectoryStateOnSurface outerState;
132  DetId outerDetId = 0;
133  const TrackingRecHit *hit = nullptr;
134  for (unsigned int iHit = 0; iHit < hits.size(); iHit++) {
135  hit = hits[iHit];
136  if (iHit == 0)
137  outerState = thePropagator->propagate(fts, theTracker->idToDet(hit->geographicalId())->surface());
138  outerDetId = hit->geographicalId();
140  if (!state.isValid())
141  return ret;
142  // TransientTrackingRecHit::RecHitPointer recHit = (theTTRHBuilder->build(hit))->clone(state);
144  outerState = updator.update(state, *recHit);
145  if (!outerState.isValid())
146  return ret;
147  }
148 
149  TrajectoryStateOnSurface innerState = outerState;
150  DetId innerDetId = 0;
151  innerState.rescaleError(100000.);
152  for (int iHit = 2; iHit >= 0; --iHit) {
153  hit = hits[iHit];
154  innerDetId = hit->geographicalId();
156  if (!state.isValid())
157  return ret;
158  // TransientTrackingRecHit::RecHitPointer recHit = (theTTRHBuilder->build(hit))->clone(state);
160  innerState = updator.update(state, *recHit);
161  if (!innerState.isValid())
162  return ret;
163  }
164 
165  // extrapolate to vertex
166  auto impactPointState = TransverseImpactPointExtrapolator(theField).extrapolate(innerState, vertexPos);
167  if (!impactPointState.isValid())
168  return ret;
169 
170  //
171  // optionally update impact point state with Bs constraint
172  // using this potion makes sense if vertexPos (from TrackingRegion is centerewd at BeamSpot).
173  //
174  if (theBeamSpot) {
175  MyBeamSpotGeomDet bsgd(Plane::build(impactPointState.surface().position(), impactPointState.surface().rotation()));
176  MyBeamSpotHit bsrh(*theBeamSpot, &bsgd);
177  impactPointState = updator.update(impactPointState, bsrh); //update
178  impactPointState =
179  TransverseImpactPointExtrapolator(theField).extrapolate(impactPointState, vertexPos); //reextrapolate
180  if (!impactPointState.isValid())
181  return ret;
182  }
183 
184  int ndof = 2 * hits.size() - 5;
185  GlobalPoint vv = impactPointState.globalPosition();
186  math::XYZPoint pos(vv.x(), vv.y(), vv.z());
187  GlobalVector pp = impactPointState.globalMomentum();
188  math::XYZVector mom(pp.x(), pp.y(), pp.z());
189 
190  float chi2 = 0.;
191  ret = std::make_unique<reco::Track>(
192  chi2, ndof, pos, mom, impactPointState.charge(), impactPointState.curvilinearError());
193 
194  /*
195  vv = outerState.globalPosition();
196  pp = outerState.globalMomentum();
197  math::XYZPoint outerPosition( vv.x(), vv.y(), vv.z());
198  math::XYZVector outerMomentum( pp.x(), pp.y(), pp.z());
199  vv = innerState.globalPosition();
200  pp = innerState.globalMomentum();
201  math::XYZPoint innerPosition( vv.x(), vv.y(), vv.z());
202  math::XYZVector innerMomentum( pp.x(), pp.y(), pp.z());
203 
204  reco::TrackExtra extra( outerPosition, outerMomentum, true,
205  innerPosition, innerMomentum, true,
206  outerState.curvilinearError(), outerDetId,
207  innerState.curvilinearError(), innerDetId,
208  anyDirection);
209 */
210 
211  // std::cout <<"TRACK CREATED" << std::endl;
212  return ret;
213 }
Vector3DBase
Definition: Vector3DBase.h:8
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:543
TrackerGeometry::idToDet
const TrackerGeomDet * idToDet(DetId) const override
Definition: TrackerGeometry.cc:193
KFBasedPixelFitter::MyBeamSpotGeomDet
Definition: KFBasedPixelFitter.h:41
Propagator.h
DDAxes::y
TrajectoryStateOnSurface.h
CircleFromThreePoints
Definition: CircleFromThreePoints.h:18
KFBasedPixelFitter::MyBeamSpotHit::projectionMatrix
AlgebraicMatrix projectionMatrix() const override
Definition: KFBasedPixelFitter.cc:49
pwdgSkimBPark_cfi.beamSpot
beamSpot
Definition: pwdgSkimBPark_cfi.py:5
TrackCharge
int TrackCharge
Definition: TrackCharge.h:4
TrackerGeometry.h
GeomDet
Definition: GeomDet.h:27
makeMuonMisalignmentScenario.matrix
list matrix
Definition: makeMuonMisalignmentScenario.py:141
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
HLT_FULL_cff.points
points
Definition: HLT_FULL_cff.py:21469
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
CircleFromThreePoints::curvature
float curvature() const
Definition: CircleFromThreePoints.h:42
PV3DBase::theta
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
pos
Definition: PixelAliasList.h:18
ptMin
constexpr float ptMin
Definition: PhotonIDValueMapProducer.cc:155
PixelRecoUtilities::inversePt
T inversePt(T curvature, const edm::EventSetup &iSetup)
Definition: PixelRecoUtilities.h:48
KFBasedPixelFitter::theOPropagator
const Propagator * theOPropagator
Definition: KFBasedPixelFitter.h:69
DDAxes::x
TransverseImpactPointExtrapolator
Definition: TransverseImpactPointExtrapolator.h:26
align::LocalPoint
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
TrackingRecHit::RecHitPointer
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: TrackingRecHit.h:24
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
hltPixelTracks_cff.chi2
chi2
Definition: hltPixelTracks_cff.py:25
TransientTrackingRecHitBuilder::build
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
KFBasedPixelFitter::MyBeamSpotHit::parametersError
AlgebraicSymMatrix parametersError() const override
Definition: KFBasedPixelFitter.cc:43
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
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
Propagator
Definition: Propagator.h:44
DetId
Definition: DetId.h:17
GeomDet::surface
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
KFBasedPixelFitter::theBeamSpot
const reco::BeamSpot * theBeamSpot
Definition: KFBasedPixelFitter.h:73
TrackingRecHit.h
funct::cos
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Track.h
Basic2DVector::y
T y() const
Cartesian y coordinate.
Definition: extBasic2DVector.h:67
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
BeamSpot.h
AlgebraicVector
CLHEP::HepVector AlgebraicVector
Definition: AlgebraicObjects.h:13
LocalError::xx
float xx() const
Definition: LocalError.h:22
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:79
KFBasedPixelFitter::MyBeamSpotHit::localPosition_
LocalPoint localPosition_
Definition: KFBasedPixelFitter.h:63
reco::BeamSpot
Definition: BeamSpot.h:21
Basic2DVector::x
T x() const
Cartesian x coordinate.
Definition: extBasic2DVector.h:64
relativeConstraints.geom
geom
Definition: relativeConstraints.py:72
CircleFromThreePoints.h
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
sqr
T sqr(T t)
Definition: KFBasedPixelFitter.cc:27
PixelRecoUtilities.h
Point3DBase< float, GlobalTag >
nhits
Definition: HIMultiTrackSelector.h:42
GlobalErrorBase::cxx
T cxx() const
Definition: GlobalErrorBase.h:97
CircleFromThreePoints::center
Vector2D center() const
Definition: CircleFromThreePoints.h:50
Plane::build
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
PbPb_ZMuSkimMuonDPG_cff.tracker
tracker
Definition: PbPb_ZMuSkimMuonDPG_cff.py:60
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
HLT_FULL_cff.updator
updator
Definition: HLT_FULL_cff.py:123
KFBasedPixelFitter::theTTRHBuilder
const TransientTrackingRecHitBuilder * theTTRHBuilder
Definition: KFBasedPixelFitter.h:70
GeomDet::toGlobal
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
KFUpdator.h
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
Event.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
LocalError
Definition: LocalError.h:12
KFBasedPixelFitter::theField
const MagneticField * theField
Definition: KFBasedPixelFitter.h:72
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
KFBasedPixelFitter::run
std::unique_ptr< reco::Track > run(const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region, const edm::EventSetup &setup) const override
Definition: KFBasedPixelFitter.cc:68
HLT_FULL_cff.region
region
Definition: HLT_FULL_cff.py:88286
GlobalErrorBase< double, ErrorMatrixTag >
AlgebraicSymMatrix
CLHEP::HepSymMatrix AlgebraicSymMatrix
Definition: AlgebraicObjects.h:15
KFBasedPixelFitter::MyBeamSpotHit
Definition: KFBasedPixelFitter.h:48
MagneticField.h
edm::EventSetup
Definition: EventSetup.h:58
KFBasedPixelFitter::MyBeamSpotHit::MyBeamSpotHit
MyBeamSpotHit(const reco::BeamSpot &beamSpot, const GeomDet *geom)
Definition: KFBasedPixelFitter.cc:31
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
TrajectoryStateOnSurface::rescaleError
void rescaleError(double factor)
Definition: TrajectoryStateOnSurface.h:82
TrackingRecHit
Definition: TrackingRecHit.h:21
AlgebraicMatrix
CLHEP::HepMatrix AlgebraicMatrix
Definition: AlgebraicObjects.h:14
RunInfoPI::state
state
Definition: RunInfoPayloadInspectoHelper.h:16
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
gen::C
C
Definition: PomwigHadronizer.cc:78
T
long double T
Definition: Basic3DVectorLD.h:48
KFBasedPixelFitter::MyBeamSpotHit::localError_
LocalError localError_
Definition: KFBasedPixelFitter.h:64
KFBasedPixelFitter::KFBasedPixelFitter
KFBasedPixelFitter(const Propagator *propagator, const Propagator *opropagator, const TransientTrackingRecHitBuilder *ttrhBuilder, const TrackerGeometry *tracker, const MagneticField *field, const reco::BeamSpot *beamSpot)
Definition: KFBasedPixelFitter.cc:55
TransverseImpactPointExtrapolator.h
TValidTrackingRecHit
Definition: TValidTrackingRecHit.h:12
TransverseImpactPointExtrapolator::extrapolate
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
Definition: TransverseImpactPointExtrapolator.cc:23
KFBasedPixelFitter.h
GlobalErrorBase::czz
T czz() const
Definition: GlobalErrorBase.h:107
TrackingRegion
Definition: TrackingRegion.h:41
TransientTrackingRecHitBuilder.h
mps_fire.result
result
Definition: mps_fire.py:311
TrackingRegion.h
createTree.pp
pp
Definition: createTree.py:17
KFBasedPixelFitter::thePropagator
const Propagator * thePropagator
Definition: KFBasedPixelFitter.h:68
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
TransientTrackingRecHitBuilder
Definition: TransientTrackingRecHitBuilder.h:6
KFBasedPixelFitter::MyBeamSpotHit::parameters
AlgebraicVector parameters() const override
Definition: KFBasedPixelFitter.cc:38
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69
KFUpdator
Definition: KFUpdator.h:32
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
hit
Definition: SiStripHitEffFromCalibTree.cc:88
KFBasedPixelFitter::theTracker
const TrackerGeometry * theTracker
Definition: KFBasedPixelFitter.h:71
TrackerGeometry
Definition: TrackerGeometry.h:14