CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/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),theNLoops(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),theNLoops(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),theNLoops(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),theNLoops(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),theNLoops(rh.theNLoops) 
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),theNLoops(rh.theNLoops)  
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     theNLoops=rh.theNLoops;  
00125     theNumberOfFoundHits=rh.theNumberOfFoundHits;
00126     theNumberOfLostHits=rh.theNumberOfLostHits;
00127     theDirection=rh.theDirection; 
00128     theDirectionValidity=rh.theDirectionValidity;
00129     swap(theSeed,rh.theSeed);
00130     swap(seedRef_,rh.seedRef_);
00131 
00132     return *this;
00133 
00134   }
00135 
00136  Trajectory & operator=(Trajectory const & rh) {
00137     theData = rh.theData;
00138     theChiSquared=rh.theChiSquared;
00139     theChiSquaredBad=rh.theChiSquaredBad;
00140     theValid=rh.theValid;
00141     theDPhiCache=rh.theDPhiCache; 
00142     theNLoops=rh.theNLoops;  
00143     theNumberOfFoundHits=rh.theNumberOfFoundHits;
00144     theNumberOfLostHits=rh.theNumberOfLostHits;
00145     theDirection=rh.theDirection;
00146     theDirectionValidity=rh.theDirectionValidity;
00147     theSeed = rh.theSeed;
00148     seedRef_ = rh.seedRef_;
00149 
00150     return *this;
00151 
00152   }
00153 
00154 
00155 #endif
00156 
00159   void reserve (unsigned int n) { theData.reserve(n); }
00160   
00165   void push( const TrajectoryMeasurement& tm);
00166 
00170   void push( const TrajectoryMeasurement& tm, double chi2Increment);
00171 
00174   void pop();
00175 
00181   TrajectoryMeasurement const & lastMeasurement() const {
00182     check(); 
00183     if (theData.back().recHit()->hit()!=0) return theData.back();
00184     else if (theData.size()>2) return *(theData.end()-2);
00185     else throw cms::Exception("TrajectoryMeasurement::lastMeasurement - Too few measurements in trajectory");
00186   }
00187 
00194   TrajectoryMeasurement const & firstMeasurement() const {
00195     check(); 
00196     if (theData.front().recHit()->hit()!=0) return theData.front();
00197     else if (theData.size()>2) return *(theData.begin()+1);
00198     else throw cms::Exception("TrajectoryMeasurement::firstMeasurement - Too few measurements in trajectory");
00199   }
00200   
00203   DataContainer const & measurements() const { return theData;}
00205   DataContainer const & data() const { return measurements();}
00206 
00209   ConstRecHitContainer recHits(bool splitting=false) const;
00210 
00211   void recHitsV(ConstRecHitContainer & cont,bool splitting = false) const;
00212 
00216   void validRecHits(ConstRecHitContainer & cont) const;
00217 
00224   int foundHits() const { return theNumberOfFoundHits;}
00225 
00231   int lostHits() const { return theNumberOfLostHits;}
00232   
00234   bool empty() const { return theData.empty();}
00235 
00242   double chiSquared() const { return (theNumberOfFoundHits ? theChiSquared : theChiSquaredBad);}
00243 
00247   int ndof(bool bon = true) const;
00248 
00249 
00254   PropagationDirection const & direction() const;
00255 
00259   bool isValid() const { return theValid;}
00260 
00262   void invalidate() { theValid = false;}
00263 
00265   TrajectorySeed const & seed() const { return *theSeed;}
00266 
00267 
00270   static bool inactive(//const Det& det
00271                        ){return false;}//FIXME
00272 
00276   static bool lost( const TransientTrackingRecHit& hit);
00277 
00281   static bool isBad( const TransientTrackingRecHit& hit);
00282 
00284   const DetLayer* lastLayer() const {
00285     check();
00286     if (theData.back().recHit()->hit()!=0) return theData.back().layer();
00287     else if (theData.size()>2) return (theData.end()-2)->layer();
00288     else throw cms::Exception("TrajectoryMeasurement::lastMeasurement - Too few measurements in trajectory");
00289   }
00290 
00296   edm::RefToBase<TrajectorySeed> seedRef(void) const { return seedRef_; }
00297   
00298   void setSeedRef(const edm::RefToBase<TrajectorySeed> & seedRef) { seedRef_ = seedRef ; } 
00299 
00300   TrajectoryStateOnSurface geometricalInnermostState() const;
00301 
00302   TrajectoryMeasurement const & closestMeasurement(GlobalPoint) const; 
00303 
00306   void reverse() ;
00307 
00308   const boost::shared_ptr<const TrajectorySeed> & sharedSeed() const { return theSeed; }
00309 
00312    float dPhiCacheForLoopersReconstruction() const { return theDPhiCache;}
00313 
00316    void setDPhiCacheForLoopersReconstruction(float dphi) {  theDPhiCache = dphi;}
00317 
00318    bool isLooper() const { return (theNLoops>0);}
00319    signed char nLoops() const {return theNLoops;}
00320 
00321    void setNLoops(signed char value) { theNLoops=value;}
00322    void incrementLoops() {theNLoops++;}
00323 
00324 private:
00325 
00326   boost::shared_ptr<const TrajectorySeed>    theSeed;
00327   edm::RefToBase<TrajectorySeed> seedRef_;
00328 
00329   DataContainer theData;
00330   float theChiSquared;
00331   float theChiSquaredBad;
00332 
00333   signed short theNumberOfFoundHits;
00334   signed short theNumberOfLostHits;
00335 
00336   PropagationDirection theDirection;
00337   bool                 theDirectionValidity;
00338   bool theValid;
00339 
00340   float theDPhiCache;
00341   signed char theNLoops;
00342 
00343   void check() const;
00344 };
00345 
00346 #endif