Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-12 03:09:55

0001 #ifndef _TRACKER_FREETRAJECTORYSTATE_H_
0002 #define _TRACKER_FREETRAJECTORYSTATE_H_
0003 
0004 // base trajectory state class
0005 // track parameters and error covariance matrix
0006 
0007 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
0008 #include "TrackingTools/TrajectoryParametrization/interface/CartesianTrajectoryError.h"
0009 #include "TrackingTools/TrajectoryParametrization/interface/CurvilinearTrajectoryError.h"
0010 #include "DataFormats/TrajectoryState/interface/TrackCharge.h"
0011 #include "TrackingTools/TrajectoryParametrization/interface/TrajectoryStateExceptions.h"
0012 
0013 #include <iosfwd>
0014 
0015 #include "FWCore/Utilities/interface/Visibility.h"
0016 #include "FWCore/Utilities/interface/Likely.h"
0017 
0018 /** A 6-dimensional state vector of a helix given at some point in 
0019  *  space along the helix, and the associated error matrix.
0020  *  The error can be obtained in two different parametrizations:
0021  *  CurvilinearTrajectoryError and CartesianTrajectoryError
0022  *  (see descriptions of corresponding classes).
0023  *  The FreeTrajectoryState can be instantiated with either of these
0024  *  error parametrisations; it converts from one to the other internally.
0025  */
0026 
0027 class FreeTrajectoryState {
0028 public:
0029   // construst
0030   //default constructor - needed for Persistency
0031 
0032   FreeTrajectoryState() : theCurvilinearError(InvalidError()) {}
0033 
0034   FreeTrajectoryState(const GlobalTrajectoryParameters& aGlobalParameters)
0035       : theGlobalParameters(aGlobalParameters), theCurvilinearError(InvalidError()) {}
0036 
0037   FreeTrajectoryState(const GlobalPoint& aX,
0038                       const GlobalVector& aP,
0039                       TrackCharge aCharge,
0040                       const MagneticField* fieldProvider)
0041       : theGlobalParameters(aX, aP, aCharge, fieldProvider), theCurvilinearError(InvalidError()) {}
0042 
0043   FreeTrajectoryState(const GlobalPoint& aX,
0044                       const GlobalVector& aP,
0045                       TrackCharge aCharge,
0046                       const MagneticField* fieldProvider,
0047                       GlobalVector fieldValue)
0048       : theGlobalParameters(aX, aP, aCharge, fieldProvider, fieldValue), theCurvilinearError(InvalidError()) {}
0049 
0050   FreeTrajectoryState(const GlobalTrajectoryParameters& aGlobalParameters,
0051                       const CurvilinearTrajectoryError& aCurvilinearError)
0052       : theGlobalParameters(aGlobalParameters), theCurvilinearError(aCurvilinearError) {}
0053 
0054   FreeTrajectoryState(const GlobalTrajectoryParameters& aGlobalParameters,
0055                       const CartesianTrajectoryError& aCartesianError)
0056       : theGlobalParameters(aGlobalParameters) {
0057     createCurvilinearError(aCartesianError);
0058   }
0059 
0060   FreeTrajectoryState(const GlobalTrajectoryParameters& aGlobalParameters,
0061                       const CartesianTrajectoryError&,
0062                       const CurvilinearTrajectoryError& aCurvilinearError)
0063       : theGlobalParameters(aGlobalParameters), theCurvilinearError(aCurvilinearError) {}
0064 
0065   // access
0066   // propagate access to parameters
0067   GlobalPoint position() const { return theGlobalParameters.position(); }
0068   GlobalVector momentum() const { return theGlobalParameters.momentum(); }
0069   TrackCharge charge() const { return theGlobalParameters.charge(); }
0070   double signedInverseMomentum() const { return theGlobalParameters.signedInverseMomentum(); }
0071   double transverseCurvature() const { return theGlobalParameters.transverseCurvature(); }
0072 
0073   // direct access
0074 
0075   bool hasCurvilinearError() const { return theCurvilinearError.valid(); }
0076 
0077   bool hasError() const { return hasCurvilinearError(); }
0078 
0079   const GlobalTrajectoryParameters& parameters() const { return theGlobalParameters; }
0080 
0081   CartesianTrajectoryError cartesianError() const {
0082     if UNLIKELY (!hasError())
0083       missingError();
0084     CartesianTrajectoryError aCartesianError;
0085     createCartesianError(aCartesianError);
0086     return aCartesianError;
0087   }
0088 
0089   const CurvilinearTrajectoryError& curvilinearError() const {
0090     if UNLIKELY (!hasError())
0091       missingError();
0092     return theCurvilinearError;
0093   }
0094 
0095   void rescaleError(double factor);
0096 
0097   void setCartesianError(const CartesianTrajectoryError& err) { createCurvilinearError(err); }
0098   void setCartesianError(const AlgebraicSymMatrix66& err) { createCurvilinearError(CartesianTrajectoryError(err)); }
0099 
0100   CurvilinearTrajectoryError& setCurvilinearError() { return theCurvilinearError; }
0101 
0102   void setCurvilinearError(const CurvilinearTrajectoryError& err) { theCurvilinearError = err; }
0103   //  void setCurvilinearError(const AlgebraicSymMatrix55 &err) {
0104   //        theCurvilinearError = CurvilinearTrajectoryError(err);
0105   //  }
0106 
0107 private:
0108   void missingError() const;  // dso_internal;
0109 
0110   // convert curvilinear errors to cartesian
0111   void createCartesianError(CartesianTrajectoryError& aCartesianError) const;  // dso_internal;
0112 
0113   // convert cartesian errors to curvilinear
0114   void createCurvilinearError(CartesianTrajectoryError const& aCartesianError) const;  // dso_internal;
0115 
0116 private:
0117   GlobalTrajectoryParameters theGlobalParameters;
0118   mutable CurvilinearTrajectoryError theCurvilinearError;
0119 };
0120 
0121 std::ostream& operator<<(std::ostream& os, const FreeTrajectoryState& fts);
0122 
0123 #endif