CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/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(anyDirection), theDirectionValidity(false), theValid(false),theDPhiCache(0),theNLoops(0)
00057     {}
00058 
00059 
00066   explicit Trajectory( const TrajectorySeed& seed) : 
00067     theSeed( new TrajectorySeed(seed) ), seedRef_(),
00068     theChiSquared(0), theChiSquaredBad(0),
00069     theNumberOfFoundHits(0), theNumberOfLostHits(0),
00070     theDirection(anyDirection), 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 
00100   explicit Trajectory(PropagationDirection dir) : 
00101     theSeed(), seedRef_(),
00102     theChiSquared(0), theChiSquaredBad(0),
00103     theNumberOfFoundHits(0), theNumberOfLostHits(0),
00104     theDirection(dir), theDirectionValidity(true), theValid(true),theDPhiCache(0),theNLoops(0)
00105    
00106   {}
00107 
00108 
00109 #if defined( __GXX_EXPERIMENTAL_CXX0X__)
00110  Trajectory(Trajectory const & rh) :
00111    theSeed(rh.theSeed), seedRef_(rh.seedRef_),
00112     theData(rh.theData),
00113     theChiSquared(rh.theChiSquared), theChiSquaredBad(rh.theChiSquaredBad),
00114     theNumberOfFoundHits(rh.theNumberOfFoundHits), theNumberOfLostHits(rh.theNumberOfLostHits),
00115     theDirection(rh.theDirection), theDirectionValidity(rh.theDirectionValidity), theValid(rh.theValid),
00116      theDPhiCache(rh.theDPhiCache),theNLoops(rh.theNLoops) 
00117   {}
00118 
00119 
00120   Trajectory(Trajectory && rh) : 
00121     theSeed(std::move(rh.theSeed)), seedRef_(std::move(rh.seedRef_)),
00122     theData(std::move(rh.theData)),
00123     theChiSquared(rh.theChiSquared), theChiSquaredBad(rh.theChiSquaredBad),
00124     theNumberOfFoundHits(rh.theNumberOfFoundHits), theNumberOfLostHits(rh.theNumberOfLostHits),
00125     theDirection(rh.theDirection), theDirectionValidity(rh.theDirectionValidity), theValid(rh.theValid),
00126     theDPhiCache(rh.theDPhiCache),theNLoops(rh.theNLoops)  
00127   {}
00128 
00129   Trajectory & operator=(Trajectory && rh) {
00130     using std::swap;
00131     swap(theData,rh.theData);
00132     theChiSquared=rh.theChiSquared;
00133     theChiSquaredBad=rh.theChiSquaredBad;
00134     theValid=rh.theValid;
00135     theDPhiCache=rh.theDPhiCache;
00136     theNLoops=rh.theNLoops;  
00137     theNumberOfFoundHits=rh.theNumberOfFoundHits;
00138     theNumberOfLostHits=rh.theNumberOfLostHits;
00139     theDirection=rh.theDirection; 
00140     theDirectionValidity=rh.theDirectionValidity;
00141     swap(theSeed,rh.theSeed);
00142     swap(seedRef_,rh.seedRef_);
00143 
00144     return *this;
00145 
00146   }
00147 
00148  Trajectory & operator=(Trajectory const & rh) {
00149     theData = rh.theData;
00150     theChiSquared=rh.theChiSquared;
00151     theChiSquaredBad=rh.theChiSquaredBad;
00152     theValid=rh.theValid;
00153     theDPhiCache=rh.theDPhiCache; 
00154     theNLoops=rh.theNLoops;  
00155     theNumberOfFoundHits=rh.theNumberOfFoundHits;
00156     theNumberOfLostHits=rh.theNumberOfLostHits;
00157     theDirection=rh.theDirection;
00158     theDirectionValidity=rh.theDirectionValidity;
00159     theSeed = rh.theSeed;
00160     seedRef_ = rh.seedRef_;
00161 
00162     return *this;
00163 
00164   }
00165 
00166 
00167 #endif
00168 
00171   void reserve (unsigned int n) { theData.reserve(n); }
00172   
00177   void push( const TrajectoryMeasurement& tm);
00178 
00182   void push( const TrajectoryMeasurement& tm, double chi2Increment);
00183 
00186   void pop();
00187 
00193   TrajectoryMeasurement const & lastMeasurement() const {
00194     check(); 
00195     if (theData.back().recHitR().hit()!=0) return theData.back();
00196     else if (theData.size()>2) return *(theData.end()-2);
00197     else throw cms::Exception("TrajectoryMeasurement::lastMeasurement - Too few measurements in trajectory");
00198   }
00199 
00206   TrajectoryMeasurement const & firstMeasurement() const {
00207     check(); 
00208     if (theData.front().recHitR().hit()!=0) return theData.front();
00209     else if (theData.size()>2) return *(theData.begin()+1);
00210     else throw cms::Exception("TrajectoryMeasurement::firstMeasurement - Too few measurements in trajectory");
00211   }
00212   
00215   DataContainer const & measurements() const { return theData;}
00217   DataContainer const & data() const { return measurements();}
00218 
00221   ConstRecHitContainer recHits(bool splitting=false) const;
00222 
00223   void recHitsV(ConstRecHitContainer & cont,bool splitting = false) const;
00224 
00228   void validRecHits(ConstRecHitContainer & cont) const;
00229 
00236   int foundHits() const { return theNumberOfFoundHits;}
00237 
00243   int lostHits() const { return theNumberOfLostHits;}
00244   
00246   bool empty() const { return theData.empty();}
00247 
00254   double chiSquared() const { return (theNumberOfFoundHits ? theChiSquared : theChiSquaredBad);}
00255 
00259   int ndof(bool bon = true) const;
00260 
00261 
00266   PropagationDirection const & direction() const;
00267 
00271   bool isValid() const { return theValid;}
00272 
00274   void invalidate() { theValid = false;}
00275 
00277   TrajectorySeed const & seed() const { return *theSeed;}
00278 
00279 
00282   static bool inactive(//const Det& det
00283                        ){return false;}//FIXME
00284 
00288   static bool lost( const TransientTrackingRecHit& hit);
00289 
00293   static bool isBad( const TransientTrackingRecHit& hit);
00294 
00296   const DetLayer* lastLayer() const {
00297     check();
00298     if (theData.back().recHit()->hit()!=0) return theData.back().layer();
00299     else if (theData.size()>2) return (theData.end()-2)->layer();
00300     else throw cms::Exception("TrajectoryMeasurement::lastMeasurement - Too few measurements in trajectory");
00301   }
00302 
00308   edm::RefToBase<TrajectorySeed> seedRef(void) const { return seedRef_; }
00309   
00310   void setSeedRef(const edm::RefToBase<TrajectorySeed> & seedRef) { seedRef_ = seedRef ; } 
00311 
00312   TrajectoryStateOnSurface geometricalInnermostState() const;
00313 
00314   TrajectoryMeasurement const & closestMeasurement(GlobalPoint) const; 
00315 
00318   void reverse() ;
00319 
00320   const boost::shared_ptr<const TrajectorySeed> & sharedSeed() const { return theSeed; }
00321   void setSharedSeed(const boost::shared_ptr<const TrajectorySeed> & seed) { theSeed=seed;}
00322 
00325    float dPhiCacheForLoopersReconstruction() const { return theDPhiCache;}
00326 
00329    void setDPhiCacheForLoopersReconstruction(float dphi) {  theDPhiCache = dphi;}
00330 
00331    bool isLooper() const { return (theNLoops>0);}
00332    signed char nLoops() const {return theNLoops;}
00333 
00334    void setNLoops(signed char value) { theNLoops=value;}
00335    void incrementLoops() {theNLoops++;}
00336 
00337 private:
00338 
00339   boost::shared_ptr<const TrajectorySeed>    theSeed;
00340   edm::RefToBase<TrajectorySeed> seedRef_;
00341 
00342   DataContainer theData;
00343   float theChiSquared;
00344   float theChiSquaredBad;
00345 
00346   signed short theNumberOfFoundHits;
00347   signed short theNumberOfLostHits;
00348 
00349   PropagationDirection theDirection;
00350   bool                 theDirectionValidity;
00351   bool theValid;
00352 
00353   float theDPhiCache;
00354   signed char theNLoops;
00355 
00356   void check() const;
00357 };
00358 
00359 #endif