Go to the documentation of this file.00001 #include "RecoTracker/TkSeedGenerator/interface/SeedFromProtoTrack.h"
00002
00003 #include "FWCore/Framework/interface/EventSetup.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005
00006 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00007 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00008 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00009
00010 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00011 #include "TrackingTools/Records/interface/TrackingComponentsRecord.h"
00012
00013 #include "MagneticField/Engine/interface/MagneticField.h"
00014 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00015
00016 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00017 #include "DataFormats/TrackReco/interface/Track.h"
00018
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020
00021 SeedFromProtoTrack::SeedFromProtoTrack(const reco::Track & proto,
00022 const SeedingHitSet & hits, const edm::EventSetup& es)
00023 : theValid(true)
00024 {
00025 for (unsigned int i= 0, n = hits.size(); i< n; ++i) {
00026 const TrackingRecHit * trh = hits[i]->hit();
00027 theHits.push_back( trh->clone() );
00028 }
00029 init(proto, es);
00030 }
00031
00032 SeedFromProtoTrack::SeedFromProtoTrack(const reco::Track & proto, const edm::EventSetup& es)
00033 : theValid(true)
00034 {
00035 const TrackingRecHit* hit = 0;
00036 for (unsigned int iHit = 0, nHits = proto.recHitsSize(); iHit < nHits; ++iHit) {
00037 TrackingRecHitRef refHit = proto.recHit(iHit);
00038 hit = &(*refHit);
00039 theHits.push_back( hit->clone() );
00040 }
00041 init(proto,es);
00042 }
00043
00044
00045 void SeedFromProtoTrack::init(const reco::Track & proto, const edm::EventSetup& es)
00046 {
00047 edm::ESHandle<TrackerGeometry> tracker;
00048 es.get<TrackerDigiGeometryRecord>().get(tracker);
00049
00050 edm::ESHandle<Propagator> propagatorHandle;
00051 es.get<TrackingComponentsRecord>().get("PropagatorWithMaterial",propagatorHandle);
00052 const Propagator* propagator = &(*propagatorHandle);
00053
00054 edm::ESHandle<MagneticField> field;
00055 es.get<IdealMagneticFieldRecord>().get(field);
00056
00057 reco::TrackBase::Point vtx = proto.referencePoint();
00058 reco::TrackBase::Vector mom = proto.momentum();
00059 GlobalTrajectoryParameters gtp(
00060 GlobalPoint(vtx.x(),vtx.y(),vtx.z()),
00061 GlobalVector(mom.x(),mom.y(),mom.z()),
00062 proto.charge(), &(*field) );
00063
00064 CurvilinearTrajectoryError err = proto.covariance();
00065
00066 FreeTrajectoryState fts( gtp, err);
00067
00068 const TrackingRecHit & lastHit = theHits.back();
00069
00070 TrajectoryStateOnSurface outerState =
00071 propagator->propagate(fts, tracker->idToDet(lastHit.geographicalId())->surface());
00072
00073 if (!outerState.isValid()){
00074 const Surface & surface = tracker->idToDet(lastHit.geographicalId())->surface();
00075 edm::LogError("SeedFromProtoTrack")<<" was trying to create a seed from:\n"<<fts<<"\n propagating to: "<<lastHit.geographicalId()<<surface.position();
00076 theValid = false;
00077 return ;
00078 }
00079 theValid = true;
00080
00081 TrajectoryStateTransform transformer;
00082 thePTraj = boost::shared_ptr<PTrajectoryStateOnDet>(
00083 transformer.persistentState(outerState, lastHit.geographicalId().rawId()) );
00084
00085
00086 }
00087
00088 TrajectorySeed SeedFromProtoTrack::trajectorySeed() const
00089 {
00090 return TrajectorySeed( trajectoryState(), hits(), direction());
00091 }