Go to the documentation of this file.00001 #include "TrackingTools/GsfTracking/interface/GsfConstraintAtVertex.h"
00002
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00007 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00008 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00009 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00010 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00011 #include "DataFormats/GeometrySurface/interface/Surface.h"
00012
00013
00014
00015 #include "TrackingTools/GsfTools/interface/GsfPropagatorAdapter.h"
00016 #include "TrackingTools/PatternTools/interface/TransverseImpactPointExtrapolator.h"
00017 #include "TrackingTools/GsfTracking/interface/GsfMultiStateUpdator.h"
00018 #include "DataFormats/GeometryCommonDetAlgo/interface/ErrorFrameTransformer.h"
00019
00020 GsfConstraintAtVertex::GsfConstraintAtVertex(const edm::EventSetup& setup)
00021 {
00022 edm::ESHandle<TrackerGeometry> geometryHandle;
00023 setup.get<TrackerDigiGeometryRecord>().get(geometryHandle);
00024 geometry_ = geometryHandle.product();
00025
00026 edm::ESHandle<MagneticField> magFieldHandle;
00027 setup.get<IdealMagneticFieldRecord>().get(magFieldHandle);
00028 magField_ = magFieldHandle.product();
00029
00030
00031
00032
00033 gsfPropagator_ = new GsfPropagatorAdapter(AnalyticalPropagator(magField_,anyDirection));
00034 tipExtrapolator_ = new TransverseImpactPointExtrapolator(*gsfPropagator_);
00035 }
00036
00037 GsfConstraintAtVertex::~GsfConstraintAtVertex ()
00038 {
00039 delete tipExtrapolator_;
00040 delete gsfPropagator_;
00041 }
00042
00043
00044 TrajectoryStateOnSurface
00045 GsfConstraintAtVertex::constrainAtBeamSpot (const reco::GsfTrack& track,
00046 const reco::BeamSpot& beamSpot) const
00047 {
00048
00049
00050
00051 GlobalPoint bsPosGlobal(beamSpot.x0(),beamSpot.y0(),beamSpot.z0());
00052 GlobalError bsCovGlobal(beamSpot.rotatedCovariance3D());
00053
00054 return constrainAtPoint(track,bsPosGlobal,bsCovGlobal);
00055 }
00056
00057 TrajectoryStateOnSurface
00058 GsfConstraintAtVertex::constrainAtVertex (const reco::GsfTrack& track,
00059 const reco::Vertex& vertex) const
00060 {
00061
00062
00063
00064 GlobalPoint vtxPosGlobal(vertex.position().x(),vertex.position().y(),vertex.position().z());
00065 GlobalError vtxCovGlobal(vertex.covariance());
00066
00067 return constrainAtPoint(track,vtxPosGlobal,vtxCovGlobal);
00068 }
00069
00070 TrajectoryStateOnSurface
00071 GsfConstraintAtVertex::constrainAtPoint (const reco::GsfTrack& track,
00072 const GlobalPoint& globalPosition,
00073 const GlobalError& globalError) const
00074 {
00075
00076
00077
00078 TrajectoryStateOnSurface innerState =
00079 multiStateTransformer_.innerStateOnSurface(track,*geometry_,magField_);
00080 if ( !innerState.isValid() ) return TrajectoryStateOnSurface();
00081 TrajectoryStateOnSurface tipState = tipExtrapolator_->extrapolate(innerState,globalPosition);
00082 if ( !tipState.isValid() ) return TrajectoryStateOnSurface();
00083
00084
00085
00086 LocalError bsCovLocal = ErrorFrameTransformer().transform(globalError,tipState.surface());
00087 TransientTrackingRecHit::RecHitPointer bsHit =
00088 TRecHit2DPosConstraint::build(tipState.surface().toLocal(globalPosition),
00089 bsCovLocal,&tipState.surface());
00090
00091
00092
00093 TrajectoryStateOnSurface updatedState = gsfUpdator_.update(tipState,*bsHit);
00094 if ( !updatedState.isValid() ) {
00095 edm::LogWarning("GsfConstraintAtVertex") << " GSF update with vertex constraint failed";
00096 return TrajectoryStateOnSurface();
00097 }
00098
00099 return updatedState;
00100 }
00101