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 00018 class TrajectoryStateClosestToPoint 00019 { 00020 typedef TrajectoryStateOnSurface TSOS; 00021 typedef FreeTrajectoryState FTS; 00023 00024 public: 00025 00026 TrajectoryStateClosestToPoint(): 00027 theFTSavailable(false), errorIsAvailable(false) {} 00028 00035 TrajectoryStateClosestToPoint(const PerigeeTrajectoryParameters& perigeeParameters, double pt, 00036 const GlobalPoint& referencePoint, const MagneticField* field); 00037 00044 TrajectoryStateClosestToPoint(const PerigeeTrajectoryParameters& perigeeParameters, double pt, 00045 const PerigeeTrajectoryError& perigeeError, const GlobalPoint& referencePoint, 00046 const MagneticField* field); 00047 00048 00055 const GlobalPoint referencePoint() const { 00056 return theRefPoint; 00057 } 00058 00059 00065 const PerigeeTrajectoryParameters & perigeeParameters() const { 00066 return theParameters; 00067 } 00068 00073 double pt() const { return thePt; } 00074 00080 const PerigeeTrajectoryError & perigeeError() const { 00081 if (!errorIsAvailable) throw TrajectoryStateException( 00082 "TrajectoryStateClosestToPoint: attempt to access errors when none available"); 00083 return thePerigeeError; 00084 } 00085 00091 GlobalPoint position() const { 00092 return perigeeConversions.positionFromPerigee(theParameters, theRefPoint); 00093 } 00094 00095 00096 GlobalVector momentum() const { 00097 return perigeeConversions.momentumFromPerigee(theParameters, thePt, theRefPoint); 00098 } 00099 00100 00101 TrackCharge charge() const { 00102 return theParameters.charge(); 00103 } 00104 00105 00106 const FreeTrajectoryState & theState() const { 00107 if (!theFTSavailable) calculateFTS(); 00108 return theFTS; 00109 } 00110 00111 00117 bool hasError() const { 00118 return errorIsAvailable; 00119 } 00120 00121 00122 private: 00123 00124 friend class TrajectoryStateClosestToPointBuilder; 00125 friend class PerigeeConversions; 00126 00132 TrajectoryStateClosestToPoint(const FTS& originalFTS, const GlobalPoint& referencePoint); 00133 00134 void calculateFTS() const; 00135 00136 const MagneticField* theField; 00137 00138 mutable FTS theFTS; 00139 mutable bool theFTSavailable; 00140 00141 GlobalPoint theRefPoint; 00142 PerigeeTrajectoryParameters theParameters; 00143 double thePt; 00144 PerigeeTrajectoryError thePerigeeError; 00145 bool errorIsAvailable; 00146 PerigeeConversions perigeeConversions; 00147 00148 }; 00149 #endif