CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
KFBasedPixelFitter Class Reference

#include <KFBasedPixelFitter.h>

Inheritance diagram for KFBasedPixelFitter:
PixelFitterBase

Classes

class  MyBeamSpotGeomDet
 
class  MyBeamSpotHit
 

Public Member Functions

 KFBasedPixelFitter (const Propagator *propagator, const Propagator *opropagator, const TransientTrackingRecHitBuilder *ttrhBuilder, const TrackerGeometry *tracker, const MagneticField *field, const reco::BeamSpot *beamSpot)
 
std::unique_ptr< reco::Trackrun (const std::vector< const TrackingRecHit *> &hits, const TrackingRegion &region) const override
 
 ~KFBasedPixelFitter () override
 
- Public Member Functions inherited from PixelFitterBase
virtual ~PixelFitterBase ()
 

Private Attributes

const reco::BeamSpottheBeamSpot
 
const MagneticFieldtheField
 
const PropagatortheOPropagator
 
const PropagatorthePropagator
 
const TrackerGeometrytheTracker
 
const TransientTrackingRecHitBuildertheTTRHBuilder
 

Detailed Description

Definition at line 22 of file KFBasedPixelFitter.h.

Constructor & Destructor Documentation

◆ KFBasedPixelFitter()

KFBasedPixelFitter::KFBasedPixelFitter ( const Propagator propagator,
const Propagator opropagator,
const TransientTrackingRecHitBuilder ttrhBuilder,
const TrackerGeometry tracker,
const MagneticField field,
const reco::BeamSpot beamSpot 
)

Definition at line 55 of file KFBasedPixelFitter.cc.

62  theOPropagator(opropagator),
63  theTTRHBuilder(ttrhBuilder),
65  theField(field),
const Propagator * theOPropagator
const Propagator * thePropagator
const TrackerGeometry * theTracker
const MagneticField * theField
const reco::BeamSpot * theBeamSpot
const TransientTrackingRecHitBuilder * theTTRHBuilder

◆ ~KFBasedPixelFitter()

KFBasedPixelFitter::~KFBasedPixelFitter ( )
inlineoverride

Definition at line 30 of file KFBasedPixelFitter.h.

30 {}

Member Function Documentation

◆ run()

std::unique_ptr< reco::Track > KFBasedPixelFitter::run ( const std::vector< const TrackingRecHit *> &  hits,
const TrackingRegion region 
) const
overridevirtual

Implements PixelFitterBase.

Definition at line 68 of file KFBasedPixelFitter.cc.

References Matriplex::atan2(), TransientTrackingRecHitBuilder::build(), Plane::build(), correctionTermsCaloMet_cff::C, CircleFromThreePoints::center(), ALCARECOTkAlJpsiMuMu_cff::charge, isoTrack_cff::chi2, funct::cos(), CircleFromThreePoints::curvature(), GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::czz(), TransverseImpactPointExtrapolator::extrapolate(), hfClusterShapes_cfi::hits, TrackerGeometry::idToDet(), PixelRecoUtilities::inversePt(), TrajectoryStateOnSurface::isValid(), WZElectronSkims53X_cff::max, PixelVertexMonitor_cff::ndof, TrackingDataMCValidation_Standalone_cff::nhits, PV3DBase< T, PVType, FrameType >::perp(), createTree::pp, Propagator::propagate(), ptMin, rpcPointValidation_cfi::recHit, nano_mu_digi_cff::region, TrajectoryStateOnSurface::rescaleError(), runTheMatrix::ret, funct::sin(), sqr(), GeomDet::surface(), funct::tan(), theBeamSpot, theField, theOPropagator, thePropagator, tauSpinnerTable_cfi::theta, PV3DBase< T, PVType, FrameType >::theta(), theTracker, theTTRHBuilder, GeomDet::toGlobal(), HLT_2024v14_cff::updator, x, PV3DBase< T, PVType, FrameType >::x(), Basic2DVector< T >::x(), y, PV3DBase< T, PVType, FrameType >::y(), Basic2DVector< T >::y(), and PV3DBase< T, PVType, FrameType >::z().

69  {
70  std::unique_ptr<reco::Track> ret;
71 
72  int nhits = hits.size();
73  if (nhits < 2)
74  return ret;
75 
76  float ptMin = region.ptMin();
77 
78  const GlobalPoint &vertexPos = region.origin();
79  GlobalError vertexErr(sqr(region.originRBound()), 0, sqr(region.originRBound()), 0, 0, sqr(region.originZBound()));
80 
81  std::vector<GlobalPoint> points(nhits);
82  points[0] = theTracker->idToDet(hits[0]->geographicalId())->toGlobal(hits[0]->localPosition());
83  points[1] = theTracker->idToDet(hits[1]->geographicalId())->toGlobal(hits[1]->localPosition());
84  points[2] = theTracker->idToDet(hits[2]->geographicalId())->toGlobal(hits[2]->localPosition());
85 
86  //
87  //initial Kinematics
88  //
89  GlobalVector initMom;
90  int charge;
91  float theta;
92  CircleFromThreePoints circle(points[0], points[1], points[2]);
93  if (circle.curvature() > 1.e-4) {
94  float invPt = PixelRecoUtilities::inversePt(circle.curvature(), *theField);
95  float valPt = 1.f / invPt;
96  float chargeTmp = (points[1].x() - points[0].x()) * (points[2].y() - points[1].y()) -
97  (points[1].y() - points[0].y()) * (points[2].x() - points[1].x());
98  charge = (chargeTmp > 0) ? -1 : 1;
99  float valPhi = (charge > 0) ? std::atan2(circle.center().x(), -circle.center().y())
100  : std::atan2(-circle.center().x(), circle.center().y());
101  theta = GlobalVector(points[1] - points[0]).theta();
102  initMom = GlobalVector(valPt * cos(valPhi), valPt * sin(valPhi), valPt / tan(theta));
103  } else {
104  initMom = GlobalVector(points[1] - points[0]);
105  initMom *= 10000. / initMom.perp();
106  charge = 1;
107  theta = initMom.theta();
108  }
109  GlobalTrajectoryParameters initialKine(vertexPos, initMom, TrackCharge(charge), theField);
110 
111  //
112  // initial error
113  //
114  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
115  float sin2th = sqr(sin(theta));
116  float minC00 = 1.0;
117  C[0][0] = std::max(sin2th / sqr(ptMin), minC00);
118  float zErr = vertexErr.czz();
119  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
120  C[3][3] = transverseErr;
121  C[4][4] = zErr * sin2th + transverseErr * (1 - sin2th);
122  CurvilinearTrajectoryError initialError(C);
123 
124  FreeTrajectoryState fts(initialKine, initialError);
125 
126  // get updator
128 
129  // Now update initial state track using information from hits.
130  TrajectoryStateOnSurface outerState;
131  DetId outerDetId = 0;
132  const TrackingRecHit *hit = nullptr;
133  for (unsigned int iHit = 0; iHit < hits.size(); iHit++) {
134  hit = hits[iHit];
135  if (iHit == 0)
136  outerState = thePropagator->propagate(fts, theTracker->idToDet(hit->geographicalId())->surface());
137  outerDetId = hit->geographicalId();
139  if (!state.isValid())
140  return ret;
141  // TransientTrackingRecHit::RecHitPointer recHit = (theTTRHBuilder->build(hit))->clone(state);
143  outerState = updator.update(state, *recHit);
144  if (!outerState.isValid())
145  return ret;
146  }
147 
148  TrajectoryStateOnSurface innerState = outerState;
149  DetId innerDetId = 0;
150  innerState.rescaleError(100000.);
151  for (int iHit = 2; iHit >= 0; --iHit) {
152  hit = hits[iHit];
153  innerDetId = hit->geographicalId();
155  if (!state.isValid())
156  return ret;
157  // TransientTrackingRecHit::RecHitPointer recHit = (theTTRHBuilder->build(hit))->clone(state);
159  innerState = updator.update(state, *recHit);
160  if (!innerState.isValid())
161  return ret;
162  }
163 
164  // extrapolate to vertex
165  auto impactPointState = TransverseImpactPointExtrapolator(theField).extrapolate(innerState, vertexPos);
166  if (!impactPointState.isValid())
167  return ret;
168 
169  //
170  // optionally update impact point state with Bs constraint
171  // using this potion makes sense if vertexPos (from TrackingRegion is centerewd at BeamSpot).
172  //
173  if (theBeamSpot) {
174  MyBeamSpotGeomDet bsgd(Plane::build(impactPointState.surface().position(), impactPointState.surface().rotation()));
175  MyBeamSpotHit bsrh(*theBeamSpot, &bsgd);
176  impactPointState = updator.update(impactPointState, bsrh); //update
177  impactPointState =
178  TransverseImpactPointExtrapolator(theField).extrapolate(impactPointState, vertexPos); //reextrapolate
179  if (!impactPointState.isValid())
180  return ret;
181  }
182 
183  int ndof = 2 * hits.size() - 5;
184  GlobalPoint vv = impactPointState.globalPosition();
185  math::XYZPoint pos(vv.x(), vv.y(), vv.z());
186  GlobalVector pp = impactPointState.globalMomentum();
187  math::XYZVector mom(pp.x(), pp.y(), pp.z());
188 
189  float chi2 = 0.;
190  ret = std::make_unique<reco::Track>(
191  chi2, ndof, pos, mom, impactPointState.charge(), impactPointState.curvilinearError());
192 
193  /*
194  vv = outerState.globalPosition();
195  pp = outerState.globalMomentum();
196  math::XYZPoint outerPosition( vv.x(), vv.y(), vv.z());
197  math::XYZVector outerMomentum( pp.x(), pp.y(), pp.z());
198  vv = innerState.globalPosition();
199  pp = innerState.globalMomentum();
200  math::XYZPoint innerPosition( vv.x(), vv.y(), vv.z());
201  math::XYZVector innerMomentum( pp.x(), pp.y(), pp.z());
202 
203  reco::TrackExtra extra( outerPosition, outerMomentum, true,
204  innerPosition, innerMomentum, true,
205  outerState.curvilinearError(), outerDetId,
206  innerState.curvilinearError(), innerDetId,
207  anyDirection);
208 */
209 
210  // std::cout <<"TRACK CREATED" << std::endl;
211  return ret;
212 }
const Propagator * theOPropagator
T perp() const
Definition: PV3DBase.h:69
const Propagator * thePropagator
T z() const
Definition: PV3DBase.h:61
ret
prodAgent to be discontinued
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
const TrackerGeometry * theTracker
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
constexpr float ptMin
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
const MagneticField * theField
static PlanePointer build(Args &&... args)
Definition: Plane.h:33
int TrackCharge
Definition: TrackCharge.h:4
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqr(T t)
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
T inversePt(T curvature, const MagneticField &field)
const TrackerGeomDet * idToDet(DetId) const override
std::shared_ptr< TrackingRecHit const > RecHitPointer
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
const reco::BeamSpot * theBeamSpot
const TransientTrackingRecHitBuilder * theTTRHBuilder
Definition: DetId.h:17
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:37
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Global3DVector GlobalVector
Definition: GlobalVector.h:10
Geom::Theta< T > theta() const
Definition: PV3DBase.h:72
MPlex< T, D1, D2, N > atan2(const MPlex< T, D1, D2, N > &y, const MPlex< T, D1, D2, N > &x)
Definition: Matriplex.h:648

Member Data Documentation

◆ theBeamSpot

const reco::BeamSpot* KFBasedPixelFitter::theBeamSpot
private

Definition at line 69 of file KFBasedPixelFitter.h.

Referenced by run().

◆ theField

const MagneticField* KFBasedPixelFitter::theField
private

Definition at line 68 of file KFBasedPixelFitter.h.

Referenced by run().

◆ theOPropagator

const Propagator* KFBasedPixelFitter::theOPropagator
private

Definition at line 65 of file KFBasedPixelFitter.h.

Referenced by run().

◆ thePropagator

const Propagator* KFBasedPixelFitter::thePropagator
private

Definition at line 64 of file KFBasedPixelFitter.h.

Referenced by run().

◆ theTracker

const TrackerGeometry* KFBasedPixelFitter::theTracker
private

Definition at line 67 of file KFBasedPixelFitter.h.

Referenced by run().

◆ theTTRHBuilder

const TransientTrackingRecHitBuilder* KFBasedPixelFitter::theTTRHBuilder
private

Definition at line 66 of file KFBasedPixelFitter.h.

Referenced by run().