CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/TrackingTools/TrajectoryState/interface/TrajectoryStateClosestToPoint.h

Go to the documentation of this file.
00001 #ifndef TrajectoryStateClosestToPoint_H
00002 #define TrajectoryStateClosestToPoint_H
00003 
00004 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
00005 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00006 #include "TrackingTools/TrajectoryParametrization/interface/PerigeeTrajectoryParameters.h"
00007 #include "TrackingTools/TrajectoryParametrization/interface/PerigeeTrajectoryError.h"
00008 #include "TrackingTools/TrajectoryState/interface/PerigeeConversions.h"
00009 #include "TrackingTools/TrajectoryParametrization/interface/TrajectoryStateExceptions.h"
00010 #include <vector>
00011 
00020 class TrajectoryStateClosestToPoint
00021 {
00022   typedef TrajectoryStateOnSurface      TSOS;
00023   typedef FreeTrajectoryState           FTS;
00025 
00026 public:
00027 
00028   TrajectoryStateClosestToPoint():
00029     valid(false), theFTSavailable(false), errorIsAvailable(false) {}
00030 
00037   TrajectoryStateClosestToPoint(const PerigeeTrajectoryParameters& perigeeParameters, double pt,
00038                                 const GlobalPoint& referencePoint, const MagneticField* field);
00039 
00046   TrajectoryStateClosestToPoint(const PerigeeTrajectoryParameters& perigeeParameters, double pt,
00047     const PerigeeTrajectoryError& perigeeError, const GlobalPoint& referencePoint,
00048     const MagneticField* field);
00049 
00050 
00057   const GlobalPoint & referencePoint() const {
00058     if(!isValid()) throw TrajectoryStateException(
00059         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00060     return theRefPoint;
00061   }
00062 
00063 
00069   const PerigeeTrajectoryParameters & perigeeParameters() const {
00070     if(!isValid()) throw TrajectoryStateException(
00071         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00072     return theParameters;
00073   }
00074 
00079   double pt() const {
00080     if(!isValid()) throw TrajectoryStateException(
00081         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00082     return thePt;
00083   }
00084 
00090   const PerigeeTrajectoryError & perigeeError() const {
00091     if(!isValid()) throw TrajectoryStateException(
00092         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00093     if (!errorIsAvailable) throw TrajectoryStateException(
00094       "TrajectoryStateClosestToPoint: attempt to access errors when none available");
00095     return thePerigeeError;
00096   }
00097 
00103   GlobalPoint position() const {
00104     if(!isValid()) throw TrajectoryStateException(
00105         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00106     return perigeeConversions.positionFromPerigee(theParameters, theRefPoint);
00107   }
00108 
00109 
00110   GlobalVector momentum() const {
00111     if(!isValid()) throw TrajectoryStateException(
00112         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00113     return perigeeConversions.momentumFromPerigee(theParameters, thePt, theRefPoint);
00114   }
00115 
00116 
00117   TrackCharge charge() const {
00118     if(!isValid()) throw TrajectoryStateException(
00119         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00120     return theParameters.charge();
00121   }
00122 
00123 
00124   const FreeTrajectoryState & theState() const {
00125     if(!isValid()) throw TrajectoryStateException(
00126         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00127     if (!theFTSavailable) calculateFTS();
00128     return theFTS;
00129   }
00130 
00131 
00137   bool hasError() const {
00138     if(!isValid()) throw TrajectoryStateException(
00139         "TrajectoryStateClosestToPoint is invalid and cannot return any parameters");
00140     return errorIsAvailable;
00141   }
00142 
00146   bool isValid() const {
00147     return valid;
00148   }
00149 
00150 
00151 private:
00152 
00153   friend class TrajectoryStateClosestToPointBuilder;
00154   friend class PerigeeConversions;
00155 
00161   TrajectoryStateClosestToPoint(const FTS& originalFTS, const GlobalPoint& referencePoint);
00162 
00163   void calculateFTS() const;
00164 
00165   bool valid;
00166   const MagneticField* theField;
00167 
00168   mutable FTS theFTS;
00169   mutable bool theFTSavailable;
00170   
00171   GlobalPoint theRefPoint;
00172   PerigeeTrajectoryParameters theParameters;
00173   double thePt;
00174   PerigeeTrajectoryError thePerigeeError;
00175   bool errorIsAvailable;
00176   PerigeeConversions perigeeConversions;
00177   
00178 };
00179 #endif