00001 #ifndef TrackProducerAlgorithm_h 00002 #define TrackProducerAlgorithm_h 00003 00012 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00013 #include "FWCore/Framework/interface/Event.h" 00014 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h" 00015 #include "DataFormats/TrackReco/interface/Track.h" 00016 #include "DataFormats/TrackReco/interface/TrackExtra.h" 00017 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h" 00018 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h" 00019 #include "TrackingTools/PatternTools/interface/TrackConstraintAssociation.h" 00020 #include "DataFormats/BeamSpot/interface/BeamSpot.h" 00021 00022 class MagneticField; 00023 class TrackingGeometry; 00024 class TrajectoryFitter; 00025 class Propagator; 00026 class Trajectory; 00027 class TrajectoryStateOnSurface; 00028 class TransientTrackingRecHitBuilder; 00029 00030 00031 template <class T> 00032 class TrackProducerAlgorithm { 00033 public: 00034 typedef std::vector<T> TrackCollection; 00035 typedef std::pair<Trajectory*, std::pair<T*,PropagationDirection> > AlgoProduct; 00036 typedef std::vector< AlgoProduct > AlgoProductCollection; 00037 typedef edm::RefToBase<TrajectorySeed> SeedRef; 00038 typedef edm::AssociationMap<edm::OneToOne<std::vector<T>,std::vector<VertexConstraint> > > 00039 VtxConstraintAssociationCollection; 00040 public: 00041 00043 TrackProducerAlgorithm(const edm::ParameterSet& conf) : 00044 conf_(conf), 00045 algoName_(conf_.getParameter<std::string>( "AlgorithmName" )), 00046 algo_(reco::TrackBase::algoByName(algoName_)), 00047 reMatchSplitHits_(false) 00048 { 00049 if (conf_.exists("reMatchSplitHits")) 00050 reMatchSplitHits_=conf_.getParameter<bool>("reMatchSplitHits"); 00051 } 00052 00054 ~TrackProducerAlgorithm() {} 00055 00057 void runWithCandidate(const TrackingGeometry *, 00058 const MagneticField *, 00059 const TrackCandidateCollection&, 00060 const TrajectoryFitter *, 00061 const Propagator *, 00062 const TransientTrackingRecHitBuilder*, 00063 const reco::BeamSpot&, 00064 AlgoProductCollection &); 00065 00067 void runWithTrack(const TrackingGeometry *, 00068 const MagneticField *, 00069 const TrackCollection&, 00070 const TrajectoryFitter *, 00071 const Propagator *, 00072 const TransientTrackingRecHitBuilder*, 00073 const reco::BeamSpot&, 00074 AlgoProductCollection &); 00075 00077 void runWithMomentum(const TrackingGeometry *, 00078 const MagneticField *, 00079 const TrackMomConstraintAssociationCollection&, 00080 const TrajectoryFitter *, 00081 const Propagator *, 00082 const TransientTrackingRecHitBuilder*, 00083 const reco::BeamSpot&, 00084 AlgoProductCollection &); 00085 00088 void runWithVertex(const TrackingGeometry *, 00089 const MagneticField *, 00090 const VtxConstraintAssociationCollection&, 00091 const TrajectoryFitter *, 00092 const Propagator *, 00093 const TransientTrackingRecHitBuilder*, 00094 const reco::BeamSpot&, 00095 AlgoProductCollection &); 00096 00098 bool buildTrack(const TrajectoryFitter *, 00099 const Propagator *, 00100 AlgoProductCollection& , 00101 TransientTrackingRecHit::RecHitContainer&, 00102 TrajectoryStateOnSurface& , 00103 const TrajectorySeed&, 00104 float, 00105 const reco::BeamSpot&, 00106 SeedRef seedRef = SeedRef(), 00107 int qualityMask=0); 00108 00109 private: 00110 edm::ParameterSet conf_; 00111 std::string algoName_; 00112 reco::TrackBase::TrackAlgorithm algo_; 00113 bool reMatchSplitHits_; 00114 00115 TrajectoryStateOnSurface getInitialState(const T * theT, 00116 TransientTrackingRecHit::RecHitContainer& hits, 00117 const TrackingGeometry * theG, 00118 const MagneticField * theMF); 00119 00120 }; 00121 00122 #include "RecoTracker/TrackProducer/interface/TrackProducerAlgorithm.icc" 00123 00124 template <> bool 00125 TrackProducerAlgorithm<reco::Track>::buildTrack(const TrajectoryFitter *, 00126 const Propagator *, 00127 AlgoProductCollection& , 00128 TransientTrackingRecHit::RecHitContainer&, 00129 TrajectoryStateOnSurface& , 00130 const TrajectorySeed&, 00131 float, 00132 const reco::BeamSpot&, 00133 SeedRef seedRef, 00134 int qualityMask); 00135 00136 00137 template <> bool 00138 TrackProducerAlgorithm<reco::GsfTrack>::buildTrack(const TrajectoryFitter *, 00139 const Propagator *, 00140 AlgoProductCollection& , 00141 TransientTrackingRecHit::RecHitContainer&, 00142 TrajectoryStateOnSurface& , 00143 const TrajectorySeed&, 00144 float, 00145 const reco::BeamSpot&, 00146 SeedRef seedRef, 00147 int qualityMask); 00148 00149 #endif