Go to the documentation of this file.00001 #ifndef CRackTrajectoryBuilder_h
00002 #define CRackTrajectoryBuilder_h
00003
00004
00005
00006
00007
00008
00009 #include <string>
00010
00011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00012 #include "FWCore/Framework/interface/EventSetup.h"
00013
00014 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00015 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
00016 #include "DataFormats/TrackerRecHit2D/interface/SiStripMatchedRecHit2DCollection.h"
00017 #include "DataFormats/TrackerRecHit2D/interface/SiStripRecHit2DCollection.h"
00018 #include "DataFormats/TrackCandidate/interface/TrackCandidateCollection.h"
00019 #include "TrackingTools/PatternTools/interface/Trajectory.h"
00020 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00021 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00022 #include "TrackingTools/GeomPropagators/interface/AnalyticalPropagator.h"
00023 #include "TrackingTools/KalmanUpdators/interface/KFUpdator.h"
00024
00025 #include "TrackingTools/KalmanUpdators/interface/KFStripUpdator.h"
00026
00027 #include "TrackingTools/KalmanUpdators/interface/Chi2MeasurementEstimator.h"
00028 #include "MagneticField/Engine/interface/MagneticField.h"
00029 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00030 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
00031 #include "RecoTracker/Record/interface/TrackerRecoGeometryRecord.h"
00032 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHitBuilder.h"
00033 #include "DataFormats/TrackReco/interface/Track.h"
00034 #include "DataFormats/TrackReco/interface/TrackExtra.h"
00035 #include "TrackingTools/TrackFitters/interface/KFTrajectoryFitter.h"
00036 #include "TrackingTools/TrackFitters/interface/KFTrajectorySmoother.h"
00037 #include "TrackingTools/MeasurementDet/interface/LayerMeasurements.h"
00038 #include "RecoTracker/MeasurementDet/interface/MeasurementTracker.h"
00039 #include "TrackingTools/MaterialEffects/interface/PropagatorWithMaterial.h"
00040
00041 #include "FWCore/Framework/interface/ESHandle.h"
00042
00043
00044
00045 class CompareDetY_plus {
00046 public:
00047 CompareDetY_plus(const TrackerGeometry& tracker):_tracker(tracker){}
00048 bool operator()( const TrackingRecHit *rh1,
00049 const TrackingRecHit *rh2)
00050 {
00051 const GeomDet* detPos1 = _tracker.idToDet(rh1->geographicalId());
00052 const GeomDet* detPos2 = _tracker.idToDet(rh2->geographicalId());
00053
00054 GlobalPoint gp1 = detPos1->position();
00055 GlobalPoint gp2 = detPos2->position();
00056
00057 if (gp1.y()>gp2.y())
00058 return true;
00059 if (gp1.y()<gp2.y())
00060 return false;
00061
00062
00063 return (rh1->geographicalId() < rh2->geographicalId());
00064 };
00065 private:
00066
00067 const TrackerGeometry& _tracker;
00068 };
00069
00070 class CompareDetY_minus {
00071 public:
00072 CompareDetY_minus(const TrackerGeometry& tracker):_tracker(tracker){}
00073 bool operator()( const TrackingRecHit *rh1,
00074 const TrackingRecHit *rh2)
00075 {
00076 const GeomDet* detPos1 = _tracker.idToDet(rh1->geographicalId());
00077 const GeomDet* detPos2 = _tracker.idToDet(rh2->geographicalId());
00078
00079 GlobalPoint gp1 = detPos1->position();
00080 GlobalPoint gp2 = detPos2->position();
00081
00082 if (gp1.y()<gp2.y())
00083 return true;
00084 if (gp1.y()>gp2.y())
00085 return false;
00086
00087
00088 return (rh1->geographicalId() < rh2->geographicalId());
00089 };
00090 private:
00091
00092 const TrackerGeometry& _tracker;
00093 };
00094
00095 #ifndef TrajectoryBuilder_CompareHitY
00096 #define TrajectoryBuilder_CompareHitY
00097
00098 class CompareHitY {
00099 public:
00100 CompareHitY(const TrackerGeometry& tracker):_tracker(tracker){}
00101 bool operator()( const TrackingRecHit *rh1,
00102 const TrackingRecHit *rh2)
00103 {
00104 GlobalPoint gp1=_tracker.idToDet(rh1->geographicalId())->surface().toGlobal(rh1->localPosition());
00105 GlobalPoint gp2=_tracker.idToDet(rh2->geographicalId())->surface().toGlobal(rh2->localPosition());
00106 return gp1.y()<gp2.y();};
00107 private:
00108
00109 const TrackerGeometry& _tracker;
00110 };
00111
00112 class CompareHitY_plus {
00113 public:
00114 CompareHitY_plus(const TrackerGeometry& tracker):_tracker(tracker){}
00115 bool operator()( const TrackingRecHit *rh1,
00116 const TrackingRecHit *rh2)
00117 {
00118 GlobalPoint gp1=_tracker.idToDet(rh1->geographicalId())->surface().toGlobal(rh1->localPosition());
00119 GlobalPoint gp2=_tracker.idToDet(rh2->geographicalId())->surface().toGlobal(rh2->localPosition());
00120 return gp1.y()>gp2.y();};
00121 private:
00122
00123 const TrackerGeometry& _tracker;
00124 };
00125
00126 #endif
00127
00128 class CRackTrajectoryBuilder
00129 {
00130
00131
00132 typedef TrajectoryStateOnSurface TSOS;
00133 typedef TrajectoryMeasurement TM;
00134
00135 typedef std::vector<const TrackingRecHit*>::iterator TrackingRecHitIterator;
00136
00137 typedef std::pair<TrackingRecHitIterator, TrackingRecHitIterator> TrackingRecHitRange;
00138 typedef std::vector<TrackingRecHitRange>::iterator TrackingRecHitRangeIterator;
00139
00140
00141 typedef std::pair<TrackingRecHitRangeIterator, TSOS> PairTrackingRecHitTsos;
00142
00143 public:
00144 class CompareDetByTraj;
00145 friend class CompareDetByTraj;
00146
00147 class CompareDetByTraj {
00148 public:
00149 CompareDetByTraj(const TSOS& tSos ):_tSos(tSos)
00150 {};
00151 bool operator()( const std::pair<TrackingRecHitRangeIterator, TSOS> rh1,
00152 const std::pair<TrackingRecHitRangeIterator, TSOS> rh2)
00153 {
00154 GlobalPoint gp1 = rh1.second.globalPosition();
00155 GlobalPoint gp2 = rh2.second.globalPosition();
00156
00157 GlobalPoint gpT = _tSos.globalPosition();
00158 GlobalVector gpDiff1 = gp1-gpT;
00159 GlobalVector gpDiff2 = gp2-gpT;
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 float dist1 = gpDiff1 * _tSos.globalDirection();
00170 float dist2 = gpDiff2 * _tSos.globalDirection();
00171
00172 if (dist1 < 0)
00173 return false;
00174 if ( dist1<dist2 )
00175 return true;
00176
00177 return false;
00178 };
00179 private:
00180 const TrajectoryStateOnSurface& _tSos;
00181 };
00182
00183
00184
00185 public:
00186
00187 CRackTrajectoryBuilder(const edm::ParameterSet& conf);
00188 ~CRackTrajectoryBuilder();
00189
00191
00192 void run(const TrajectorySeedCollection &collseed,
00193 const SiStripRecHit2DCollection &collstereo,
00194 const SiStripRecHit2DCollection &collrphi ,
00195 const SiStripMatchedRecHit2DCollection &collmatched,
00196 const SiPixelRecHitCollection &collpixel,
00197 const edm::EventSetup& es,
00198 edm::Event& e,
00199 std::vector<Trajectory> &trajoutput);
00200
00201 void init(const edm::EventSetup& es,bool);
00202 Trajectory createStartingTrajectory( const TrajectorySeed& seed) const;
00203 private:
00204 std::vector<TrajectoryMeasurement> seedMeasurements(const TrajectorySeed& seed) const;
00205
00206
00207 std::vector<const TrackingRecHit*> SortHits(const SiStripRecHit2DCollection &collstereo,
00208 const SiStripRecHit2DCollection &collrphi ,
00209 const SiStripMatchedRecHit2DCollection &collmatched,
00210 const SiPixelRecHitCollection &collpixel,
00211 const TrajectorySeed &seed,
00212 const bool bAddSeedHits
00213 );
00214
00215
00216
00217
00218
00219 TSOS startingTSOS(const TrajectorySeed& seed)const;
00220 void updateTrajectory( Trajectory& traj,
00221 const TM& tm,
00222 const TransientTrackingRecHit& hit) const;
00223
00224 void AddHit(Trajectory &traj,
00225 std::vector<const TrackingRecHit*>Hits,
00226 Propagator *currPropagator
00227 );
00228
00229 bool qualityFilter(Trajectory traj);
00230
00231 bool isDifferentStripReHit2D (const SiStripRecHit2D& hitA, const SiStripRecHit2D& hitB );
00232
00233 std::pair<TrajectoryStateOnSurface, const GeomDet*>
00234 innerState( const Trajectory& traj) const;
00235
00236 private:
00237 edm::ESHandle<MagneticField> magfield;
00238 edm::ESHandle<TrackerGeometry> tracker;
00239 edm::ParameterSet conf_;
00240
00241 PropagatorWithMaterial *thePropagator;
00242 PropagatorWithMaterial *thePropagatorOp;
00243
00244
00245
00246
00247 KFUpdator *theUpdator;
00248 Chi2MeasurementEstimator *theEstimator;
00249 const TransientTrackingRecHitBuilder *RHBuilder;
00250 const KFTrajectorySmoother * theSmoother;
00251 const KFTrajectoryFitter * theFitter;
00252
00253
00254 bool debug_info;
00255 bool fastPropagation;
00256 bool useMatchedHits;
00257
00258 int theMinHits;
00259 double chi2cut;
00260 std::vector<Trajectory> trajFit;
00261
00262 TransientTrackingRecHit::RecHitContainer hits;
00263 bool seed_plus;
00264 std::string geometry;
00265
00266 };
00267
00268 #endif