Go to the documentation of this file.00001 #ifndef BasicSingleTrajectoryState_H
00002 #define BasicSingleTrajectoryState_H
00003
00004 #include "TrackingTools/TrajectoryState/interface/BasicTrajectoryState.h"
00005 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00006 #include "TrackingTools/TrajectoryParametrization/interface/LocalTrajectoryParameters.h"
00007 #include "TrackingTools/TrajectoryParametrization/interface/LocalTrajectoryError.h"
00008
00009 #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h"
00010
00011 #include "DataFormats/GeometryCommonDetAlgo/interface/DeepCopyPointer.h"
00012 #include "DataFormats/GeometrySurface/interface/Surface.h"
00013 #include "TrackingTools/TrajectoryParametrization/interface/TrajectoryStateExceptions.h"
00014
00016 #include <iostream>
00017
00018
00019 #include "MagneticField/Engine/interface/MagneticField.h"
00020
00024 class BasicSingleTrajectoryState : public BasicTrajectoryState {
00025 public:
00026
00030 BasicSingleTrajectoryState( const FreeTrajectoryState& fts,
00031 const Surface& aSurface,
00032 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
00036 BasicSingleTrajectoryState( const GlobalTrajectoryParameters& par,
00037 const Surface& aSurface,
00038 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
00042 BasicSingleTrajectoryState( const GlobalTrajectoryParameters& par,
00043 const CartesianTrajectoryError& err,
00044 const Surface& aSurface,
00045 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
00050 BasicSingleTrajectoryState( const GlobalTrajectoryParameters& par,
00051 const CurvilinearTrajectoryError& err,
00052 const Surface& aSurface,
00053 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface,
00054 double weight = 1.);
00059 BasicSingleTrajectoryState( const GlobalTrajectoryParameters& par,
00060 const CurvilinearTrajectoryError& err,
00061 const Surface& aSurface,
00062 double weight);
00066 BasicSingleTrajectoryState( const LocalTrajectoryParameters& par,
00067 const Surface& aSurface,
00068 const MagneticField* field,
00069 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
00074 BasicSingleTrajectoryState( const LocalTrajectoryParameters& par,
00075 const LocalTrajectoryError& err,
00076 const Surface& aSurface,
00077 const MagneticField* field,
00078 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface,
00079 double weight = 1.);
00084 BasicSingleTrajectoryState( const LocalTrajectoryParameters& par,
00085 const LocalTrajectoryError& err,
00086 const Surface& aSurface,
00087 const MagneticField* field,
00088 double weight);
00089
00091 BasicSingleTrajectoryState(const Surface& aSurface);
00092
00093 virtual ~BasicSingleTrajectoryState();
00094
00095 bool isValid() const {
00096 return theFreeState || theLocalParametersValid;
00097 }
00098 static void notValid();
00099
00100 bool hasError() const;
00101
00102 void missingError(char const * where) const;
00103
00104
00105 const GlobalTrajectoryParameters& globalParameters() const {
00106 return freeTrajectoryState(false)->parameters();
00107 }
00108 GlobalPoint globalPosition() const {
00109 return freeTrajectoryState(false)->position();
00110 }
00111 GlobalVector globalMomentum() const {
00112 return freeTrajectoryState(false)->momentum();
00113 }
00114 GlobalVector globalDirection() const {
00115 return freeTrajectoryState(false)->momentum().unit();
00116 }
00117 TrackCharge charge() const {
00118 return freeTrajectoryState(false)->charge();
00119 }
00120 double signedInverseMomentum() const {
00121 return freeTrajectoryState(false)->signedInverseMomentum();
00122 }
00123 double transverseCurvature() const {
00124 return freeTrajectoryState(false)->transverseCurvature();
00125 }
00126 const CartesianTrajectoryError& cartesianError() const {
00127 if(!hasError()) missingError(" accesing cartesian error.");
00128 return freeTrajectoryState()->cartesianError();
00129 }
00130 const CurvilinearTrajectoryError& curvilinearError() const {
00131 if(!hasError()) missingError(" accesing curvilinearerror.");
00132 return freeTrajectoryState()->curvilinearError();
00133 }
00134
00135
00136 FreeTrajectoryState* freeTrajectoryState(bool withErrors = true) const;
00137
00138 const MagneticField *magneticField() const { return theField; }
00139
00140
00141 const LocalTrajectoryParameters& localParameters() const {
00142 if (!isValid()) notValid();
00143 if (!theLocalParametersValid)
00144 createLocalParameters();
00145 return theLocalParameters;
00146 }
00147 LocalPoint localPosition() const {
00148 return localParameters().position();
00149 }
00150 LocalVector localMomentum() const {
00151 return localParameters().momentum();
00152 }
00153 LocalVector localDirection() const {
00154 return localMomentum().unit();
00155 }
00156
00157 const LocalTrajectoryError& localError() const {
00158 if (!hasError()) missingError(" accessing local error.");
00159 if (!theLocalErrorValid)
00160 createLocalError();
00161 return theLocalError;
00162 }
00163
00164 const Surface& surface() const {
00165 return *theSurfaceP;
00166 }
00167
00168 virtual double weight() const {return theWeight;}
00169
00170 void rescaleError(double factor);
00171
00172
00173 BasicSingleTrajectoryState* clone() const {
00174 return new BasicSingleTrajectoryState(*this);
00175 }
00176
00178 virtual SurfaceSide surfaceSide() const {
00179 return theSurfaceSide;
00180 }
00181
00182 virtual bool canUpdateLocalParameters() const { return true; }
00183 virtual void update( const LocalTrajectoryParameters& p,
00184 const Surface& aSurface,
00185 const MagneticField* field,
00186 const SurfaceSide side ) ;
00187 virtual void update( const LocalTrajectoryParameters& p,
00188 const LocalTrajectoryError& err,
00189 const Surface& aSurface,
00190 const MagneticField* field,
00191 const SurfaceSide side,
00192 double weight ) ;
00193 private:
00194
00195
00196 void checkGlobalParameters() const;
00197 void checkCurvilinError() const;
00198 void checkCartesianError() const;
00199
00200
00201 void createLocalParameters() const;
00202
00203 void createLocalError() const;
00204 void createLocalErrorFromCartesianError() const;
00205 void createLocalErrorFromCurvilinearError() const;
00206
00207 private:
00208
00209 mutable DeepCopyPointer<FreeTrajectoryState> theFreeState;
00210
00211 mutable LocalTrajectoryError theLocalError;
00212 mutable LocalTrajectoryParameters theLocalParameters;
00213 mutable bool theLocalParametersValid;
00214 mutable bool theLocalErrorValid;
00215
00216 mutable bool theGlobalParamsUp2Date;
00217 mutable bool theCartesianErrorUp2Date;
00218 mutable bool theCurvilinErrorUp2Date;
00219
00220
00221 SurfaceSide theSurfaceSide;
00222 ConstReferenceCountingPointer<Surface> theSurfaceP;
00223
00224 double theWeight;
00225 const MagneticField* theField;
00226
00227 };
00228
00229 #endif