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
00015 #include "FWCore/Utilities/interface/Visibility.h"
00016 #include "FWCore/Utilities/interface/Likely.h"
00017
00019 #include <iostream>
00020
00021
00022 #include "MagneticField/Engine/interface/MagneticField.h"
00023
00027 class BasicSingleTrajectoryState : public BasicTrajectoryState {
00028 public:
00029
00033 BasicSingleTrajectoryState( const FreeTrajectoryState& fts,
00034 const Surface& aSurface,
00035 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
00039 BasicSingleTrajectoryState( const GlobalTrajectoryParameters& par,
00040 const Surface& aSurface,
00041 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
00045 BasicSingleTrajectoryState( const GlobalTrajectoryParameters& par,
00046 const CartesianTrajectoryError& err,
00047 const Surface& aSurface,
00048 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
00053 BasicSingleTrajectoryState( const GlobalTrajectoryParameters& par,
00054 const CurvilinearTrajectoryError& err,
00055 const Surface& aSurface,
00056 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface,
00057 double weight = 1.);
00062 BasicSingleTrajectoryState( const GlobalTrajectoryParameters& par,
00063 const CurvilinearTrajectoryError& err,
00064 const Surface& aSurface,
00065 double weight);
00069 BasicSingleTrajectoryState( const LocalTrajectoryParameters& par,
00070 const Surface& aSurface,
00071 const MagneticField* field,
00072 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
00077 BasicSingleTrajectoryState( const LocalTrajectoryParameters& par,
00078 const LocalTrajectoryError& err,
00079 const Surface& aSurface,
00080 const MagneticField* field,
00081 const SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface,
00082 double weight = 1.);
00087 BasicSingleTrajectoryState( const LocalTrajectoryParameters& par,
00088 const LocalTrajectoryError& err,
00089 const Surface& aSurface,
00090 const MagneticField* field,
00091 double weight);
00092
00094 explicit BasicSingleTrajectoryState(const Surface& aSurface);
00095
00096 virtual ~BasicSingleTrajectoryState();
00097
00098 bool isValid() const {
00099 return theFreeState || theLocalParametersValid;
00100 }
00101
00102
00103
00104 const GlobalTrajectoryParameters& globalParameters() const {
00105 return freeTrajectoryState(false)->parameters();
00106 }
00107 GlobalPoint globalPosition() const {
00108 return freeTrajectoryState(false)->position();
00109 }
00110 GlobalVector globalMomentum() const {
00111 return freeTrajectoryState(false)->momentum();
00112 }
00113 GlobalVector globalDirection() const {
00114 return freeTrajectoryState(false)->momentum().unit();
00115 }
00116 TrackCharge charge() const {
00117 return freeTrajectoryState(false)->charge();
00118 }
00119 double signedInverseMomentum() const {
00120 return freeTrajectoryState(false)->signedInverseMomentum();
00121 }
00122 double transverseCurvature() const {
00123 return freeTrajectoryState(false)->transverseCurvature();
00124 }
00125 const CartesianTrajectoryError& cartesianError() const {
00126 if unlikely(!hasError()) missingError(" accesing cartesian error.");
00127 return freeTrajectoryState()->cartesianError();
00128 }
00129 const CurvilinearTrajectoryError& curvilinearError() const {
00130 if unlikely(!hasError()) missingError(" accesing curvilinearerror.");
00131 return freeTrajectoryState()->curvilinearError();
00132 }
00133
00134
00135 FreeTrajectoryState* freeTrajectoryState(bool withErrors = true) const;
00136
00137 const MagneticField *magneticField() const { return theField; }
00138
00139
00140 const LocalTrajectoryParameters& localParameters() const {
00141 if unlikely(!isValid()) notValid();
00142 if unlikely(!theLocalParametersValid)
00143 createLocalParameters();
00144 return theLocalParameters;
00145 }
00146 LocalPoint localPosition() const {
00147 return localParameters().position();
00148 }
00149 LocalVector localMomentum() const {
00150 return localParameters().momentum();
00151 }
00152 LocalVector localDirection() const {
00153 return localMomentum().unit();
00154 }
00155
00156 const LocalTrajectoryError& localError() const {
00157 if unlikely(!hasError()) missingError(" accessing local error.");
00158 if unlikely(!theLocalErrorValid)
00159 createLocalError();
00160 return theLocalError;
00161 }
00162
00163 const Surface& surface() const {
00164 return *theSurfaceP;
00165 }
00166
00167 virtual double weight() const {return theWeight;}
00168
00169 void rescaleError(double factor);
00170
00171
00172 BasicSingleTrajectoryState* clone() const {
00173 return new BasicSingleTrajectoryState(*this);
00174 }
00175
00177 virtual SurfaceSide surfaceSide() const {
00178 return theSurfaceSide;
00179 }
00180
00181 virtual bool canUpdateLocalParameters() const { return true; }
00182 virtual void update( const LocalTrajectoryParameters& p,
00183 const Surface& aSurface,
00184 const MagneticField* field,
00185 const SurfaceSide side ) ;
00186 virtual void update( const LocalTrajectoryParameters& p,
00187 const LocalTrajectoryError& err,
00188 const Surface& aSurface,
00189 const MagneticField* field,
00190 const SurfaceSide side,
00191 double weight ) ;
00192 private:
00193
00194 static void notValid() dso_internal;
00195
00196 bool hasError() const;
00197
00198
00199
00200
00201
00202 void missingError(char const * where) const;
00203
00204
00205 void checkGlobalParameters() const dso_internal;
00206 void checkCurvilinError() const dso_internal;
00207 void checkCartesianError() const dso_internal;
00208
00209
00210 void createLocalParameters() const dso_internal;
00211
00212 void createLocalError() const dso_internal;
00213 void createLocalErrorFromCartesianError() const dso_internal;
00214 void createLocalErrorFromCurvilinearError() const dso_internal;
00215
00216 private:
00217
00218 mutable DeepCopyPointer<FreeTrajectoryState> theFreeState;
00219
00220 mutable LocalTrajectoryError theLocalError;
00221 mutable LocalTrajectoryParameters theLocalParameters;
00222 mutable bool theLocalParametersValid;
00223 mutable bool theLocalErrorValid;
00224
00225 mutable bool theGlobalParamsUp2Date;
00226 mutable bool theCartesianErrorUp2Date;
00227 mutable bool theCurvilinErrorUp2Date;
00228
00229
00230 SurfaceSide theSurfaceSide;
00231 ConstReferenceCountingPointer<Surface> theSurfaceP;
00232
00233 double theWeight;
00234 const MagneticField* theField;
00235
00236 };
00237
00238 #endif