CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/TrackingTools/PatternTools/interface/Trajectory.h

Go to the documentation of this file.
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 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 
00011 #include <vector>
00012 #include <algorithm>
00013 #include <boost/shared_ptr.hpp>
00014 
00038 class Trajectory
00039 {
00040 public:
00041 
00042   typedef std::vector<TrajectoryMeasurement>                   DataContainer;
00043   typedef TransientTrackingRecHit::ConstRecHitContainer        ConstRecHitContainer;
00044   typedef ConstRecHitContainer                                 RecHitContainer;
00045 
00046 
00052   Trajectory() : 
00053     theSeed(), seedRef_(),
00054     theChiSquared(0), theChiSquaredBad(0),
00055     theNumberOfFoundHits(0), theNumberOfLostHits(0),
00056     theDirection(alongMomentum), theDirectionValidity(false), theValid(true),theDPhiCache(0)
00057     {}
00058 
00059 
00066   Trajectory( const TrajectorySeed& seed) : 
00067     theSeed( new TrajectorySeed(seed) ), seedRef_(),
00068     theChiSquared(0), theChiSquaredBad(0),
00069     theNumberOfFoundHits(0), theNumberOfLostHits(0),
00070     theDirection(alongMomentum), theDirectionValidity(false), theValid(true),theDPhiCache(0)
00071   {}
00072 
00077   Trajectory( const TrajectorySeed& seed, PropagationDirection dir) : 
00078     theSeed( new TrajectorySeed(seed) ), seedRef_(),
00079     theChiSquared(0), theChiSquaredBad(0),
00080     theNumberOfFoundHits(0), theNumberOfLostHits(0),
00081     theDirection(dir), theDirectionValidity(true), theValid(true),theDPhiCache(0)
00082    
00083   {}
00084 
00089   Trajectory( const boost::shared_ptr<const TrajectorySeed> & seed, PropagationDirection dir) : 
00090     theSeed( seed ), seedRef_(),
00091     theChiSquared(0), theChiSquaredBad(0),
00092     theNumberOfFoundHits(0), theNumberOfLostHits(0),
00093     theDirection(dir), theDirectionValidity(true), theValid(true),theDPhiCache(0)
00094   {}
00095 
00096 
00097 #if defined( __GXX_EXPERIMENTAL_CXX0X__)
00098  Trajectory(Trajectory const & rh) :
00099    theSeed(rh.theSeed), seedRef_(rh.seedRef_),
00100     theData(rh.theData),
00101     theChiSquared(rh.theChiSquared), theChiSquaredBad(rh.theChiSquaredBad),
00102     theNumberOfFoundHits(rh.theNumberOfFoundHits), theNumberOfLostHits(rh.theNumberOfLostHits),
00103     theDirection(rh.theDirection), theDirectionValidity(rh.theDirectionValidity), theValid(rh.theValid),
00104     theDPhiCache(rh.theDPhiCache) 
00105   {}
00106 
00107 
00108   Trajectory(Trajectory && rh) : 
00109     theSeed(std::move(rh.theSeed)), seedRef_(std::move(rh.seedRef_)),
00110     theData(std::move(rh.theData)),
00111     theChiSquared(rh.theChiSquared), theChiSquaredBad(rh.theChiSquaredBad),
00112     theNumberOfFoundHits(rh.theNumberOfFoundHits), theNumberOfLostHits(rh.theNumberOfLostHits),
00113     theDirection(rh.theDirection), theDirectionValidity(rh.theDirectionValidity), theValid(rh.theValid),
00114     theDPhiCache(rh.theDPhiCache) 
00115   {}
00116 
00117   Trajectory & operator=(Trajectory && rh) {
00118     using std::swap;
00119     swap(theData,rh.theData);
00120     theChiSquared=rh.theChiSquared;
00121     theChiSquaredBad=rh.theChiSquaredBad;
00122     theValid=rh.theValid;
00123     theDPhiCache=rh.theDPhiCache; 
00124     theNumberOfFoundHits=rh.theNumberOfFoundHits;
00125     theNumberOfLostHits=rh.theNumberOfLostHits;
00126     theDirection=rh.theDirection; 
00127     theDirectionValidity=rh.theDirectionValidity;
00128     swap(theSeed,rh.theSeed);
00129     swap(seedRef_,rh.seedRef_);
00130 
00131     return *this;
00132 
00133   }
00134 
00135  Trajectory & operator=(Trajectory const & rh) {
00136     theData = rh.theData;
00137     theChiSquared=rh.theChiSquared;
00138     theChiSquaredBad=rh.theChiSquaredBad;
00139     theValid=rh.theValid;
00140     theDPhiCache=rh.theDPhiCache; 
00141     theNumberOfFoundHits=rh.theNumberOfFoundHits;
00142     theNumberOfLostHits=rh.theNumberOfLostHits;
00143     theDirection=rh.theDirection;
00144     theDirectionValidity=rh.theDirectionValidity;
00145     theSeed = rh.theSeed;
00146     seedRef_ = rh.seedRef_;
00147 
00148     return *this;
00149 
00150   }
00151 
00152 
00153 #endif
00154 
00157   void reserve (unsigned int n) { theData.reserve(n); }
00158   
00163   void push( const TrajectoryMeasurement& tm);
00164 
00168   void push( const TrajectoryMeasurement& tm, double chi2Increment);
00169 
00172   void pop();
00173 
00179   TrajectoryMeasurement const & lastMeasurement() const {
00180     check(); 
00181     if (theData.back().recHit()->hit()!=0) return theData.back();
00182     else if (theData.size()>2) return *(theData.end()-2);
00183     else throw cms::Exception("TrajectoryMeasurement::lastMeasurement - Too few measurements in trajectory");
00184   }
00185 
00192   TrajectoryMeasurement const & firstMeasurement() const {
00193     check(); 
00194     if (theData.front().recHit()->hit()!=0) return theData.front();
00195     else if (theData.size()>2) return *(theData.begin()+1);
00196     else throw cms::Exception("TrajectoryMeasurement::firstMeasurement - Too few measurements in trajectory");
00197   }
00198   
00201   DataContainer const & measurements() const { return theData;}
00203   DataContainer const & data() const { return measurements();}
00204 
00207   ConstRecHitContainer recHits(bool splitting=false) const;
00208 
00209   void recHitsV(ConstRecHitContainer & cont,bool splitting = false) const;
00210 
00214   void validRecHits(ConstRecHitContainer & cont) const;
00215 
00222   int foundHits() const { return theNumberOfFoundHits;}
00223 
00229   int lostHits() const { return theNumberOfLostHits;}
00230   
00232   bool empty() const { return theData.empty();}
00233 
00240   double chiSquared() const { return (theNumberOfFoundHits ? theChiSquared : theChiSquaredBad);}
00241 
00245   int ndof(bool bon = true) const;
00246 
00247 
00252   PropagationDirection const & direction() const;
00253 
00257   bool isValid() const { return theValid;}
00258 
00260   void invalidate() { theValid = false;}
00261 
00263   TrajectorySeed const & seed() const { return *theSeed;}
00264 
00265 
00268   static bool inactive(//const Det& det
00269                        ){return false;}//FIXME
00270 
00274   static bool lost( const TransientTrackingRecHit& hit);
00275 
00279   static bool isBad( const TransientTrackingRecHit& hit);
00280 
00282   const DetLayer* lastLayer() const {
00283     check();
00284     if (theData.back().recHit()->hit()!=0) return theData.back().layer();
00285     else if (theData.size()>2) return (theData.end()-2)->layer();
00286     else throw cms::Exception("TrajectoryMeasurement::lastMeasurement - Too few measurements in trajectory");
00287   }
00288 
00294   edm::RefToBase<TrajectorySeed> seedRef(void) const { return seedRef_; }
00295   
00296   void setSeedRef(const edm::RefToBase<TrajectorySeed> & seedRef) { seedRef_ = seedRef ; } 
00297 
00298   TrajectoryStateOnSurface geometricalInnermostState() const;
00299 
00300   TrajectoryMeasurement const & closestMeasurement(GlobalPoint) const; 
00301 
00304   void reverse() ;
00305 
00306   const boost::shared_ptr<const TrajectorySeed> & sharedSeed() const { return theSeed; }
00307 
00310    float dPhiCacheForLoopersReconstruction() const { return theDPhiCache;}
00311 
00314    void setDPhiCacheForLoopersReconstruction(float dphi) {  theDPhiCache = dphi;}
00315 
00316 private:
00317 
00318   boost::shared_ptr<const TrajectorySeed>    theSeed;
00319   edm::RefToBase<TrajectorySeed> seedRef_;
00320 
00321   DataContainer theData;
00322   float theChiSquared;
00323   float theChiSquaredBad;
00324 
00325   signed short theNumberOfFoundHits;
00326   signed short theNumberOfLostHits;
00327 
00328   PropagationDirection theDirection;
00329   bool                 theDirectionValidity;
00330   bool theValid;
00331 
00332   float theDPhiCache;
00333 
00334   void check() const;
00335 };
00336 
00337 #endif