CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Public Attributes | Private Attributes
KFBasedPixelFitter Class Reference

#include <KFBasedPixelFitter.h>

Inheritance diagram for KFBasedPixelFitter:
PixelFitter

Classes

class  MyBeamSpotGeomDet
 
class  MyBeamSpotHit
 

Public Member Functions

 KFBasedPixelFitter (const edm::ParameterSet &cfg)
 
virtual reco::Trackrun (const edm::Event &ev, const edm::EventSetup &es, const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region) const
 
virtual ~KFBasedPixelFitter ()
 
- Public Member Functions inherited from PixelFitter
virtual reco::Trackrun (const edm::EventSetup &es, const std::vector< const TrackingRecHit * > &hits, const TrackingRegion &region) const
 
virtual ~PixelFitter ()
 

Public Attributes

tuple KFBasedPixelFitter
 

Private Attributes

edm::InputTag theBeamSpot
 
std::string thePropagatorLabel
 
std::string thePropagatorOppositeLabel
 
std::string theTTRHBuilderName
 
bool theUseBeamSpot
 

Detailed Description

Definition at line 21 of file KFBasedPixelFitter.h.

Constructor & Destructor Documentation

KFBasedPixelFitter::KFBasedPixelFitter ( const edm::ParameterSet cfg)
virtual KFBasedPixelFitter::~KFBasedPixelFitter ( )
inlinevirtual

Definition at line 24 of file KFBasedPixelFitter.h.

24 {}

Member Function Documentation

reco::Track * KFBasedPixelFitter::run ( const edm::Event ev,
const edm::EventSetup es,
const std::vector< const TrackingRecHit * > &  hits,
const TrackingRegion region 
) const
virtual

Reimplemented from PixelFitter.

Definition at line 95 of file KFBasedPixelFitter.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, newFWLiteAna::build, funct::C, CircleFromThreePoints::center(), RecoTauCleanerPlugins::charge, TrajectoryStateOnSurface::charge(), funct::cos(), CircleFromThreePoints::curvature(), TrajectoryStateOnSurface::curvilinearError(), GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::czz(), TransverseImpactPointExtrapolator::extrapolate(), TrackingRecHit::geographicalId(), edm::EventSetup::get(), edm::Event::getByLabel(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), PixelRecoUtilities::inversePt(), TrajectoryStateOnSurface::isValid(), bookConverter::max, TrackingRegion::origin(), TrackingRegion::originRBound(), TrackingRegion::originZBound(), PV3DBase< T, PVType, FrameType >::perp(), GloballyPositioned< T >::position(), createTree::pp, HLT_25ns14e33_v1_cff::propagator, PtMinSelector_cfg::ptMin, TrackingRegion::ptMin(), TrajectoryStateOnSurface::rescaleError(), GloballyPositioned< T >::rotation(), funct::sin(), funct::sqr(), TrajectoryStateOnSurface::surface(), funct::tan(), thePropagatorLabel, thePropagatorOppositeLabel, PV3DBase< T, PVType, FrameType >::theta(), theta(), theTTRHBuilderName, theUseBeamSpot, patCandidatesForDimuonsSequences_cff::tracker, KFUpdator::update(), HLT_25ns14e33_v1_cff::updator, x, PV3DBase< T, PVType, FrameType >::x(), Basic2DVector< T >::x(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), Basic2DVector< T >::y(), and PV3DBase< T, PVType, FrameType >::z().

100 {
101  int nhits = hits.size();
102  if (nhits <2) return 0;
103 
105  es.get<TrackerDigiGeometryRecord>().get(tracker);
106 
108  es.get<IdealMagneticFieldRecord>().get(field);
109 
111  es.get<TransientRecHitRecord>().get( theTTRHBuilderName, ttrhb);
112 
113  float ptMin = region.ptMin();
114 
115  const GlobalPoint vertexPos = region.origin();
116  GlobalError vertexErr( sqr(region.originRBound()), 0, sqr(region.originRBound()), 0, 0, sqr(region.originZBound()));
117 
118  std::vector<GlobalPoint> points(nhits);
119  points[0] = tracker->idToDet(hits[0]->geographicalId())->toGlobal(hits[0]->localPosition());
120  points[1] = tracker->idToDet(hits[1]->geographicalId())->toGlobal(hits[1]->localPosition());
121  points[2] = tracker->idToDet(hits[2]->geographicalId())->toGlobal(hits[2]->localPosition());
122 
123  //
124  //initial Kinematics
125  //
126  GlobalVector initMom;
127  int charge;
128  float theta;
129  CircleFromThreePoints circle(points[0], points[1], points[2]);
130  if (circle.curvature() > 1.e-4) {
131  float invPt = PixelRecoUtilities::inversePt( circle.curvature(), es);
132  float valPt = 1.f/invPt;
133  float chargeTmp = (points[1].x()-points[0].x())*(points[2].y()-points[1].y())
134  - (points[1].y()-points[0].y())*(points[2].x()-points[1].x());
135  charge = (chargeTmp>0) ? -1 : 1;
136  float valPhi = (charge>0) ? std::atan2(circle.center().x(),-circle.center().y()) : std::atan2(-circle.center().x(),circle.center().y());
137  theta = GlobalVector(points[1]-points[0]).theta();
138  initMom = GlobalVector(valPt*cos(valPhi), valPt*sin(valPhi), valPt/tan(theta));
139  }
140  else {
141  initMom = GlobalVector(points[1]-points[0]);
142  initMom *= 10000./initMom.perp();
143  charge = 1;
144  theta = initMom.theta();
145  }
146  GlobalTrajectoryParameters initialKine(vertexPos, initMom, TrackCharge(charge), &*field);
147 
148  //
149  // initial error
150  //
151  AlgebraicSymMatrix55 C = ROOT::Math::SMatrixIdentity();
152  float sin2th = sqr(sin(theta));
153  float minC00 = 1.0;
154  C[0][0] = std::max(sin2th/sqr(ptMin), minC00);
155  float zErr = vertexErr.czz();
156  float transverseErr = vertexErr.cxx(); // assume equal cxx cyy
157  C[3][3] = transverseErr;
158  C[4][4] = zErr*sin2th + transverseErr*(1-sin2th);
159  CurvilinearTrajectoryError initialError(C);
160 
161  FreeTrajectoryState fts(initialKine, initialError);
162 
163  // get propagator
165  es.get<TrackingComponentsRecord>().get(thePropagatorLabel, propagator);
166 
167  // get updator
169 
170  // Now update initial state track using information from hits.
171  TrajectoryStateOnSurface outerState;
172  DetId outerDetId = 0;
173  const TrackingRecHit* hit = 0;
174  for ( unsigned int iHit = 0; iHit < hits.size(); iHit++) {
175  hit = hits[iHit];
176  if (iHit==0) outerState = propagator->propagate(fts,tracker->idToDet(hit->geographicalId())->surface());
177  outerDetId = hit->geographicalId();
178  TrajectoryStateOnSurface state = propagator->propagate(outerState, tracker->idToDet(outerDetId)->surface());
179  if (!state.isValid()) return 0;
180 // TransientTrackingRecHit::RecHitPointer recHit = (ttrhb->build(hit))->clone(state);
181  TransientTrackingRecHit::RecHitPointer recHit = ttrhb->build(hit);
182  outerState = updator.update(state, *recHit);
183  if (!outerState.isValid()) return 0;
184  }
185 
186 
187 
188  // get propagator
189  edm::ESHandle<Propagator> opropagator;
191  TrajectoryStateOnSurface innerState = outerState;
192  DetId innerDetId = 0;
193  innerState.rescaleError(100000.);
194  for ( int iHit = 2; iHit >= 0; --iHit) {
195  hit = hits[iHit];
196  innerDetId = hit->geographicalId();
197  TrajectoryStateOnSurface state = opropagator->propagate(innerState, tracker->idToDet(innerDetId)->surface());
198  if (!state.isValid()) return 0;
199 // TransientTrackingRecHit::RecHitPointer recHit = (ttrhb->build(hit))->clone(state);
200  TransientTrackingRecHit::RecHitPointer recHit = ttrhb->build(hit);
201  innerState = updator.update(state, *recHit);
202  if (!innerState.isValid()) return 0;
203  }
204 
205 
206  // extrapolate to vertex
207  TrajectoryStateOnSurface impactPointState = TransverseImpactPointExtrapolator(&*field).extrapolate( innerState, vertexPos);
208  if (!impactPointState.isValid()) return 0;
209 
210  //
211  // optionally update impact point state with Bs constraint
212  // using this potion makes sense if vertexPos (from TrackingRegion is centerewd at BeamSpot).
213  //
214  if (theUseBeamSpot) {
216  ev.getByLabel( "offlineBeamSpot", beamSpot);
217  MyBeamSpotGeomDet bsgd(Plane::build(impactPointState.surface().position(), impactPointState.surface().rotation()));
218  MyBeamSpotHit bsrh(*beamSpot, &bsgd);
219  impactPointState = updator.update(impactPointState, bsrh); //update
220  impactPointState = TransverseImpactPointExtrapolator(&*field).extrapolate( impactPointState, vertexPos); //reextrapolate
221  if (!impactPointState.isValid()) return 0;
222  }
223 
224  int ndof = 2*hits.size()-5;
225  GlobalPoint vv = impactPointState.globalPosition();
226  math::XYZPoint pos( vv.x(), vv.y(), vv.z() );
227  GlobalVector pp = impactPointState.globalMomentum();
228  math::XYZVector mom( pp.x(), pp.y(), pp.z() );
229 
230  float chi2 = 0.;
231  reco::Track * track = new reco::Track( chi2, ndof, pos, mom,
232  impactPointState.charge(), impactPointState.curvilinearError());
233 
234 /*
235  vv = outerState.globalPosition();
236  pp = outerState.globalMomentum();
237  math::XYZPoint outerPosition( vv.x(), vv.y(), vv.z());
238  math::XYZVector outerMomentum( pp.x(), pp.y(), pp.z());
239  vv = innerState.globalPosition();
240  pp = innerState.globalMomentum();
241  math::XYZPoint innerPosition( vv.x(), vv.y(), vv.z());
242  math::XYZVector innerMomentum( pp.x(), pp.y(), pp.z());
243 
244  reco::TrackExtra extra( outerPosition, outerMomentum, true,
245  innerPosition, innerMomentum, true,
246  outerState.curvilinearError(), outerDetId,
247  innerState.curvilinearError(), innerDetId,
248  anyDirection);
249 */
250 
251 // std::cout <<"TRACK CREATED" << std::endl;
252  return track;
253 }
float originRBound() const
bounds the particle vertex in the transverse plane
std::string thePropagatorLabel
T perp() const
Definition: PV3DBase.h:72
GlobalPoint const & origin() const
tuple pp
Definition: createTree.py:15
const CurvilinearTrajectoryError & curvilinearError() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
T y() const
Definition: PV3DBase.h:63
GlobalPoint globalPosition() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T inversePt(T curvature, const edm::EventSetup &iSetup)
int TrackCharge
Definition: TrackCharge.h:4
const SurfaceType & surface() const
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const
Definition: KFUpdator.cc:75
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:405
float originZBound() const
bounds the particle vertex in the longitudinal plane
std::shared_ptr< TrackingRecHit const > RecHitPointer
Definition: DetId.h:18
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
const T & get() const
Definition: EventSetup.h:55
float ptMin() const
minimal pt of interest
TrajectoryStateOnSurface extrapolate(const FreeTrajectoryState &fts, const GlobalPoint &vtx) const
extrapolation with default (=geometrical) propagator
GlobalVector globalMomentum() const
Square< F >::type sqr(const F &f)
Definition: Square.h:13
const RotationType & rotation() const
DetId geographicalId() const
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
std::string thePropagatorOppositeLabel
const PositionType & position() const
std::string theTTRHBuilderName
Global3DVector GlobalVector
Definition: GlobalVector.h:10

Member Data Documentation

KFBasedPixelFitter.KFBasedPixelFitter
Initial value:
1 = cms.PSet(
2  ComponentName = cms.string('KFBasedPixelFitter'),
3  useBeamSpotConstraint = cms.bool(True),
4  beamSpotConstraint = cms.InputTag('offlineBeamSpot'),
5  propagator = cms.string('PropagatorWithMaterial'),
6  propagatorOpposite = cms.string('PropagatorWithMaterialOpposite'),
7  TTRHBuilder = cms.string('PixelTTRHBuilderWithoutAngle')
8 )

Definition at line 3 of file KFBasedPixelFitter.py.

edm::InputTag KFBasedPixelFitter::theBeamSpot
private

Definition at line 63 of file KFBasedPixelFitter.h.

std::string KFBasedPixelFitter::thePropagatorLabel
private

Definition at line 60 of file KFBasedPixelFitter.h.

Referenced by run().

std::string KFBasedPixelFitter::thePropagatorOppositeLabel
private

Definition at line 61 of file KFBasedPixelFitter.h.

Referenced by run().

std::string KFBasedPixelFitter::theTTRHBuilderName
private

Definition at line 64 of file KFBasedPixelFitter.h.

Referenced by run().

bool KFBasedPixelFitter::theUseBeamSpot
private

Definition at line 62 of file KFBasedPixelFitter.h.

Referenced by run().