CMS 3D CMS Logo

CRackTrajectoryBuilder.h
Go to the documentation of this file.
1 #ifndef CRackTrajectoryBuilder_h
2 #define CRackTrajectoryBuilder_h
3 
4 //
5 // Package: RecoTracker/SingleTrackPattern
6 // Class: CRackTrajectoryBuilder
7 // Original Author: Michele Pioppi-INFN perugia
8 
9 #include <string>
10 
14 
39 
40 //to sort hits by the det position
42 public:
44  bool operator()(const TrackingRecHit* rh1, const TrackingRecHit* rh2) {
45  const GeomDet* detPos1 = _tracker.idToDet(rh1->geographicalId());
46  const GeomDet* detPos2 = _tracker.idToDet(rh2->geographicalId());
47 
48  const GlobalPoint& gp1 = detPos1->position();
49  const GlobalPoint& gp2 = detPos2->position();
50 
51  if (gp1.y() > gp2.y())
52  return true;
53  if (gp1.y() < gp2.y())
54  return false;
55  // if (gp1.y()== gp2.y())
56  //
57  return (rh1->geographicalId() < rh2->geographicalId());
58  };
59 
60 private:
61  // edm::ESHandle<TrackerGeometry> _tracker;
63 };
64 
66 public:
68  bool operator()(const TrackingRecHit* rh1, const TrackingRecHit* rh2) {
69  const GeomDet* detPos1 = _tracker.idToDet(rh1->geographicalId());
70  const GeomDet* detPos2 = _tracker.idToDet(rh2->geographicalId());
71 
72  const GlobalPoint& gp1 = detPos1->position();
73  const GlobalPoint& gp2 = detPos2->position();
74 
75  if (gp1.y() < gp2.y())
76  return true;
77  if (gp1.y() > gp2.y())
78  return false;
79  // if (gp1.y()== gp2.y())
80  //
81  return (rh1->geographicalId() < rh2->geographicalId());
82  };
83 
84 private:
85  // edm::ESHandle<TrackerGeometry> _tracker;
87 };
88 
89 #ifndef TrajectoryBuilder_CompareHitY
90 #define TrajectoryBuilder_CompareHitY
91 
92 class CompareHitY {
93 public:
95  bool operator()(const TrackingRecHit* rh1, const TrackingRecHit* rh2) {
96  GlobalPoint gp1 = _tracker.idToDet(rh1->geographicalId())->surface().toGlobal(rh1->localPosition());
97  GlobalPoint gp2 = _tracker.idToDet(rh2->geographicalId())->surface().toGlobal(rh2->localPosition());
98  return gp1.y() < gp2.y();
99  };
100 
101 private:
102  // edm::ESHandle<TrackerGeometry> _tracker;
103  const TrackerGeometry& _tracker;
104 };
105 
106 class CompareHitY_plus {
107 public:
109  bool operator()(const TrackingRecHit* rh1, const TrackingRecHit* rh2) {
110  GlobalPoint gp1 = _tracker.idToDet(rh1->geographicalId())->surface().toGlobal(rh1->localPosition());
111  GlobalPoint gp2 = _tracker.idToDet(rh2->geographicalId())->surface().toGlobal(rh2->localPosition());
112  return gp1.y() > gp2.y();
113  };
114 
115 private:
116  // edm::ESHandle<TrackerGeometry> _tracker;
117  const TrackerGeometry& _tracker;
118 };
119 
120 #endif
121 
123  // using namespace std;
124 
127 
128  typedef std::vector<const TrackingRecHit*>::iterator TrackingRecHitIterator;
129 
130  typedef std::pair<TrackingRecHitIterator, TrackingRecHitIterator> TrackingRecHitRange;
131  typedef std::vector<TrackingRecHitRange>::iterator TrackingRecHitRangeIterator;
132 
133  // typedef std::pair<TrackingRecHitIterator, TSOS> PairTrackingRecHitTsos;
134  typedef std::pair<TrackingRecHitRangeIterator, TSOS> PairTrackingRecHitTsos;
135 
136 public:
138  friend class CompareDetByTraj;
139 
141  public:
142  CompareDetByTraj(const TSOS& tSos) : _tSos(tSos){};
143  bool operator()(const std::pair<TrackingRecHitRangeIterator, TSOS> rh1,
144  const std::pair<TrackingRecHitRangeIterator, TSOS> rh2) {
145  GlobalPoint gp1 = rh1.second.globalPosition();
146  GlobalPoint gp2 = rh2.second.globalPosition();
147 
149  GlobalVector gpDiff1 = gp1 - gpT;
150  GlobalVector gpDiff2 = gp2 - gpT;
151 
152  //this might have a better performance ...
153  // float dist1 = ( gp1.x()-gpT.x() ) * ( gp1.x()-gpT.x() ) + ( gp1.y()-gpT.y() ) * ( gp1.y()-gpT.y() ) + ( gp1.z()-gpT.z() ) * ( gp1.z()-gpT.z() );
154  // float dist2 = ( gp2.x()-gpT.x() ) * ( gp2.x()-gpT.x() ) + ( gp2.y()-gpT.y() ) * ( gp2.y()-gpT.y() ) + ( gp2.z()-gpT.z() ) * ( gp2.z()-gpT.z() );
155  //if ( dist1<dist2 )
156 
157  // if ( gpDiff1.mag2() < gpDiff2.mag2() )
158 
159  float dist1 = gpDiff1 * _tSos.globalDirection();
160  float dist2 = gpDiff2 * _tSos.globalDirection();
161 
162  if (dist1 < 0)
163  return false;
164  if (dist1 < dist2)
165  return true;
166 
167  return false;
168  };
169 
170  private:
172  };
173 
174 public:
177 
179 
180  void run(const TrajectorySeedCollection& collseed,
181  const SiStripRecHit2DCollection& collstereo,
182  const SiStripRecHit2DCollection& collrphi,
183  const SiStripMatchedRecHit2DCollection& collmatched,
184  const SiPixelRecHitCollection& collpixel,
185  const edm::EventSetup& es,
186  edm::Event& e,
187  std::vector<Trajectory>& trajoutput);
188 
189  void init(const edm::EventSetup& es, bool);
191 
193 
194 private:
195  std::vector<TrajectoryMeasurement> seedMeasurements(const TrajectorySeed& seed) const;
196 
197  std::vector<const TrackingRecHit*> SortHits(const SiStripRecHit2DCollection& collstereo,
198  const SiStripRecHit2DCollection& collrphi,
199  const SiStripMatchedRecHit2DCollection& collmatched,
200  const SiPixelRecHitCollection& collpixel,
201  const TrajectorySeed& seed,
202  const bool bAddSeedHits);
203 
204  // std::vector<TrackingRecHitRange> SortByTrajectory (const std::vector<TrackingRecHitRange>& inputHits);
205 
206  TSOS startingTSOS(const TrajectorySeed& seed) const;
207  void updateTrajectory(Trajectory& traj, const TM& tm, const TransientTrackingRecHit& hit) const;
208 
209  void AddHit(Trajectory& traj, const std::vector<const TrackingRecHit*>& Hits, Propagator* currPropagator);
210  // edm::OwnVector<TransientTrackingRecHit> hits);
211  bool qualityFilter(const Trajectory& traj);
212 
213  bool isDifferentStripReHit2D(const SiStripRecHit2D& hitA, const SiStripRecHit2D& hitB);
214 
215  std::pair<TrajectoryStateOnSurface, const GeomDet*> innerState(const Trajectory& traj) const;
216 
217 private:
223 
226 
227  // AnalyticalPropagator *thePropagator;
228  // AnalyticalPropagator *thePropagatorOp;
229 
235  // const KFTrajectoryFitter * theFitterOp;
236 
240 
242  double chi2cut;
243  std::vector<Trajectory> trajFit;
244  //RC edm::OwnVector<const TransientTrackingRecHit> hits;
246  bool seed_plus;
248  // TransientInitialStateEstimator* theInitialState;
249 };
250 
251 #endif
std::vector< TrackingRecHitRange >::iterator TrackingRecHitRangeIterator
bool operator()(const TrackingRecHit *rh1, const TrackingRecHit *rh2)
CompareHitY_plus(const TrackerGeometry &tracker)
Chi2MeasurementEstimator * theEstimator
const TrackerGeometry & _tracker
std::vector< ConstRecHitPointer > RecHitContainer
const TrackerGeometry & _tracker
const TransientTrackingRecHitBuilder * RHBuilder
std::pair< TrajectoryStateOnSurface, const GeomDet * > innerState(const Trajectory &traj) const
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magfieldToken_
TransientTrackingRecHit::RecHitContainer hits
void updateTrajectory(Trajectory &traj, const TM &tm, const TransientTrackingRecHit &hit) const
std::vector< const TrackingRecHit * >::iterator TrackingRecHitIterator
CompareDetY_minus(const TrackerGeometry &tracker)
const KFTrajectorySmoother * theSmoother
std::vector< Trajectory > trajFit
T y() const
Definition: PV3DBase.h:60
std::pair< TrackingRecHitRangeIterator, TSOS > PairTrackingRecHitTsos
bool qualityFilter(const Trajectory &traj)
const edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > builderToken_
GlobalPoint globalPosition() const
bool operator()(const TrackingRecHit *rh1, const TrackingRecHit *rh2)
std::vector< TrajectorySeed > TrajectorySeedCollection
void run(const TrajectorySeedCollection &collseed, const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const edm::EventSetup &es, edm::Event &e, std::vector< Trajectory > &trajoutput)
Runs the algorithm.
CompareDetY_plus(const TrackerGeometry &tracker)
void AddHit(Trajectory &traj, const std::vector< const TrackingRecHit *> &Hits, Propagator *currPropagator)
const TrackerGeometry * tracker
CompareHitY(const TrackerGeometry &tracker)
TSOS startingTSOS(const TrajectorySeed &seed) const
PropagatorWithMaterial * thePropagatorOp
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > trackerToken_
const TrackerGeomDet * idToDet(DetId) const override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
const TrajectoryStateOnSurface & _tSos
bool operator()(const TrackingRecHit *rh1, const TrackingRecHit *rh2)
std::vector< TrajectoryMeasurement > seedMeasurements(const TrajectorySeed &seed) const
const MagneticField * magfield
bool operator()(const std::pair< TrackingRecHitRangeIterator, TSOS > rh1, const std::pair< TrackingRecHitRangeIterator, TSOS > rh2)
DetId geographicalId() const
bool isDifferentStripReHit2D(const SiStripRecHit2D &hitA, const SiStripRecHit2D &hitB)
std::pair< TrackingRecHitIterator, TrackingRecHitIterator > TrackingRecHitRange
GlobalVector globalDirection() const
Trajectory createStartingTrajectory(const TrajectorySeed &seed) const
CRackTrajectoryBuilder(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
void init(const edm::EventSetup &es, bool)
TrajectoryStateOnSurface TSOS
PropagatorWithMaterial * thePropagator
const Surface::PositionType & position() const
The position (origin of the R.F.)
Definition: GeomDet.h:43
const KFTrajectoryFitter * theFitter
std::vector< const TrackingRecHit * > SortHits(const SiStripRecHit2DCollection &collstereo, const SiStripRecHit2DCollection &collrphi, const SiStripMatchedRecHit2DCollection &collmatched, const SiPixelRecHitCollection &collpixel, const TrajectorySeed &seed, const bool bAddSeedHits)
virtual LocalPoint localPosition() const =0
const TrackerGeometry & _tracker
const TrackerGeometry & _tracker
bool operator()(const TrackingRecHit *rh1, const TrackingRecHit *rh2)
TrajectoryMeasurement TM
const TransientTrackingRecHitBuilder * hitBuilder() const