00001 #ifndef CommonDet_Trajectory_H
00002 #define CommonDet_Trajectory_H
00003
00004 #include "DataFormats/Common/interface/RefToBase.h"
00005 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
00006 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
00007 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00008 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00009
00010
00011 #include <vector>
00012 #include <algorithm>
00013
00037 class Trajectory
00038 {
00039 public:
00040
00041 typedef std::vector<TrajectoryMeasurement> DataContainer;
00042 typedef TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer;
00043 typedef ConstRecHitContainer RecHitContainer;
00044
00045
00051 Trajectory() : theChiSquared(0), theValid(true),
00052 theNumberOfFoundHits(0), theNumberOfLostHits(0),
00053 theDirection(alongMomentum), theDirectionValidity(false),
00054 theSeed(TrajectorySeed()), seedRef_()
00055 {}
00056
00057
00064 Trajectory( const TrajectorySeed& seed) :
00065 theChiSquared(0), theValid(true),
00066 theNumberOfFoundHits(0), theNumberOfLostHits(0),
00067 theDirection(alongMomentum), theDirectionValidity(false),
00068 theSeed(seed), seedRef_()
00069 {}
00070
00075 Trajectory( const TrajectorySeed& seed, PropagationDirection dir) :
00076 theChiSquared(0), theValid(true),
00077 theNumberOfFoundHits(0), theNumberOfLostHits(0),
00078 theDirection(dir), theDirectionValidity(true),
00079 theSeed(seed), seedRef_()
00080 {}
00081
00084 void reserve (unsigned int n) { theData.reserve(n); }
00085
00090 void push( const TrajectoryMeasurement& tm);
00091
00095 void push( const TrajectoryMeasurement& tm, double chi2Increment);
00096
00099 void pop();
00100
00106 TrajectoryMeasurement const & lastMeasurement() const {
00107 check(); return theData.back();
00108 }
00109
00116 TrajectoryMeasurement const & firstMeasurement() const {
00117 check(); return theData.front();
00118 }
00119
00122 DataContainer const & measurements() const { return theData;}
00124 DataContainer const & data() const { return measurements();}
00125
00128 ConstRecHitContainer recHits(bool splitting=false) const;
00129
00130 void recHitsV(ConstRecHitContainer & cont,bool splitting = false) const;
00131
00135 void validRecHits(ConstRecHitContainer & cont) const;
00136
00143 int foundHits() const { return theNumberOfFoundHits;}
00144
00150 int lostHits() const { return theNumberOfLostHits;}
00151
00153 bool empty() const { return theData.empty();}
00154
00156 double chiSquared() const { return theChiSquared;}
00157
00161 int ndof(bool bon = true) const;
00162
00163
00168 PropagationDirection const & direction() const;
00169
00173 bool isValid() const { return theValid;}
00174
00176 void invalidate() { theValid = false;}
00177
00179 TrajectorySeed const & seed() const { return theSeed;}
00180
00181
00184 static bool inactive(
00185 ){return false;}
00186
00190 static bool lost( const TransientTrackingRecHit& hit);
00191
00193 const DetLayer* lastLayer() const {
00194 check(); return theData.back().layer();
00195 }
00196
00202 edm::RefToBase<TrajectorySeed> seedRef(void) const { return seedRef_; }
00203
00204 void setSeedRef(const edm::RefToBase<TrajectorySeed> & seedRef) { seedRef_ = seedRef ; }
00205
00206 TrajectoryStateOnSurface geometricalInnermostState() const;
00207
00208 TrajectoryMeasurement const & closestMeasurement(GlobalPoint) const;
00209
00210 private:
00211
00213 struct LessMag {
00214 LessMag(GlobalPoint point) : thePoint(point) {}
00215 bool operator()(const TrajectoryMeasurement& lhs,
00216 const TrajectoryMeasurement& rhs) const{
00217 return (lhs.updatedState().globalPosition() - thePoint).mag() < (rhs.updatedState().globalPosition() -thePoint).mag();
00218 }
00219 GlobalPoint thePoint;
00220 };
00221
00222 DataContainer theData;
00223 double theChiSquared;
00224 bool theValid;
00225
00226 int theNumberOfFoundHits;
00227 int theNumberOfLostHits;
00228
00229 PropagationDirection theDirection;
00230 bool theDirectionValidity;
00231
00232 TrajectorySeed theSeed;
00233 edm::RefToBase<TrajectorySeed> seedRef_;
00234
00235 void check() const;
00236 };
00237
00238 #endif