Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-02 03:46:14

0001 #include "TrackingTools/GsfTracking/interface/GsfConstraintAtVertex.h"
0002 
0003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0004 
0005 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
0006 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
0007 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
0008 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
0009 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0010 #include "DataFormats/GeometrySurface/interface/Surface.h"
0011 // #include "TrackingTools/GsfTools/interface/GaussianSumUtilities1D.h"
0012 // #include "TrackingTools/GsfTools/interface/MultiGaussianState1D.h"
0013 // #include "TrackingTools/GsfTools/interface/MultiGaussianStateTransform.h"
0014 #include "TrackingTools/GsfTools/interface/GsfPropagatorAdapter.h"
0015 #include "TrackingTools/PatternTools/interface/TransverseImpactPointExtrapolator.h"
0016 #include "TrackingTools/GsfTracking/interface/GsfMultiStateUpdator.h"
0017 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
0018 
0019 GsfConstraintAtVertex::GsfConstraintAtVertex(const TrackerGeometry* geometry, const MagneticField* magField)
0020     : geometry_(geometry),
0021       magField_(magField),
0022       gsfPropagator_(AnalyticalPropagator(magField, anyDirection)),
0023       tipExtrapolator_(gsfPropagator_) {}
0024 
0025 TrajectoryStateOnSurface GsfConstraintAtVertex::constrainAtBeamSpot(const reco::GsfTrack& track,
0026                                                                     const reco::BeamSpot& beamSpot) const {
0027   //
0028   // Beamspot (global co-ordinates)
0029   //
0030   GlobalPoint bsPosGlobal(beamSpot.x0(), beamSpot.y0(), beamSpot.z0());
0031   GlobalError bsCovGlobal(beamSpot.rotatedCovariance3D());
0032   //
0033   return constrainAtPoint(track, bsPosGlobal, bsCovGlobal);
0034 }
0035 
0036 TrajectoryStateOnSurface GsfConstraintAtVertex::constrainAtVertex(const reco::GsfTrack& track,
0037                                                                   const reco::Vertex& vertex) const {
0038   //
0039   // Beamspot (global co-ordinates)
0040   //
0041   GlobalPoint vtxPosGlobal(vertex.position().x(), vertex.position().y(), vertex.position().z());
0042   GlobalError vtxCovGlobal(vertex.covariance());
0043   //
0044   return constrainAtPoint(track, vtxPosGlobal, vtxCovGlobal);
0045 }
0046 
0047 TrajectoryStateOnSurface GsfConstraintAtVertex::constrainAtPoint(const reco::GsfTrack& track,
0048                                                                  const GlobalPoint& globalPosition,
0049                                                                  const GlobalError& globalError) const {
0050   //
0051   // Track on TIP plane
0052   //
0053   TrajectoryStateOnSurface innerState = multiStateTransformer_.innerStateOnSurface(track, *geometry_, magField_);
0054   if (!innerState.isValid())
0055     return TrajectoryStateOnSurface();
0056   TrajectoryStateOnSurface tipState = tipExtrapolator_.extrapolate(innerState, globalPosition);
0057   if (!tipState.isValid())
0058     return TrajectoryStateOnSurface();
0059   //
0060   // RecHit from beam spot
0061   //
0062   LocalError bsCovLocal = ErrorFrameTransformer().transform(globalError, tipState.surface());
0063   auto bsHit =
0064       TRecHit2DPosConstraint::build(tipState.surface().toLocal(globalPosition), bsCovLocal, &tipState.surface());
0065   //
0066   // update with constraint
0067   //
0068   TrajectoryStateOnSurface updatedState = gsfUpdator_.update(tipState, *bsHit);
0069   if (!updatedState.isValid()) {
0070     edm::LogWarning("GsfConstraintAtVertex") << " GSF update with vertex constraint failed";
0071     return TrajectoryStateOnSurface();
0072   }
0073 
0074   return updatedState;
0075 }