Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:41

0001 #ifndef TrajectoryStateOnSurface_H
0002 #define TrajectoryStateOnSurface_H
0003 
0004 #include "TrackingTools/TrajectoryState/interface/BasicTrajectoryState.h"
0005 #include "TrackingTools/TrajectoryState/interface/SurfaceSideDefinition.h"
0006 #include "TrackingTools/TrajectoryState/interface/BasicSingleTrajectoryState.h"
0007 
0008 #include <iosfwd>
0009 
0010 /** As the class name suggests, this class encapsulates the state of a
0011  *  trajectory on a surface.
0012  *  The class is a reference counting proxy to the actual state, in other words
0013  *  it takes no more space than a pointer. Therefore it should be used by value.
0014  */
0015 
0016 class TrajectoryStateOnSurface : private BasicTrajectoryState::Proxy {
0017   typedef BasicTrajectoryState BTSOS;
0018   typedef BasicTrajectoryState::SurfaceType SurfaceType;
0019   typedef BasicTrajectoryState::SurfaceSide SurfaceSide;
0020   typedef BasicTrajectoryState::Proxy Base;
0021 
0022 public:
0023   // construct
0024   TrajectoryStateOnSurface() {}
0025   /// Constructor from one of the basic states
0026   explicit TrajectoryStateOnSurface(Base::pointer p) : Base(p) {}
0027   explicit TrajectoryStateOnSurface(BasicTrajectoryState* p) : Base(p) {}
0028   explicit TrajectoryStateOnSurface(BasicSingleTrajectoryState* p) : Base(p) {}
0029 
0030   ~TrajectoryStateOnSurface() {}
0031 
0032   TrajectoryStateOnSurface(TrajectoryStateOnSurface& rh) noexcept : Base(rh) {}
0033 
0034   TrajectoryStateOnSurface(TrajectoryStateOnSurface const& rh) noexcept : Base(rh) {}
0035 
0036   TrajectoryStateOnSurface(TrajectoryStateOnSurface&& rh) noexcept : Base(std::forward<Base>(rh)) {}
0037 
0038   TrajectoryStateOnSurface& operator=(TrajectoryStateOnSurface&& rh) noexcept {
0039     Base::swap(rh);
0040     return *this;
0041   }
0042 
0043   TrajectoryStateOnSurface& operator=(TrajectoryStateOnSurface const& rh) noexcept {
0044     Base::operator=(rh);
0045     return *this;
0046   }
0047 
0048   template <typename... Args>
0049   explicit TrajectoryStateOnSurface(Args&&... args)
0050       : Base(BTSOS::churn<BasicSingleTrajectoryState>(std::forward<Args>(args)...)) {}
0051 
0052   void swap(TrajectoryStateOnSurface& rh) noexcept { Base::swap(rh); }
0053 
0054   bool isValid() const { return Base::isValid() && data().isValid(); }
0055 
0056   bool hasError() const { return data().hasError(); }
0057 
0058   FreeTrajectoryState const* freeState(bool withErrors = true) const { return data().freeTrajectoryState(); }
0059 
0060   FreeTrajectoryState const* freeTrajectoryState(bool withErrors = true) const { return freeState(); }
0061 
0062   const MagneticField* magneticField() const { return data().magneticField(); }
0063 
0064   const GlobalTrajectoryParameters& globalParameters() const { return data().globalParameters(); }
0065   GlobalPoint globalPosition() const { return data().globalPosition(); }
0066   GlobalVector globalMomentum() const { return data().globalMomentum(); }
0067   GlobalVector globalDirection() const { return data().globalDirection(); }
0068   TrackCharge charge() const { return data().charge(); }
0069   double signedInverseMomentum() const { return data().signedInverseMomentum(); }
0070   double transverseCurvature() const { return data().transverseCurvature(); }
0071   const CartesianTrajectoryError cartesianError() const { return data().cartesianError(); }
0072   const CurvilinearTrajectoryError& curvilinearError() const { return data().curvilinearError(); }
0073   const LocalTrajectoryParameters& localParameters() const { return data().localParameters(); }
0074   LocalPoint localPosition() const { return data().localPosition(); }
0075   LocalVector localMomentum() const { return data().localMomentum(); }
0076   LocalVector localDirection() const { return data().localDirection(); }
0077   const LocalTrajectoryError& localError() const { return data().localError(); }
0078   const SurfaceType& surface() const { return data().surface(); }
0079 
0080   double weight() const { return data().weight(); }
0081 
0082   void rescaleError(double factor) { unsharedData().rescaleError(factor); }
0083 
0084   using Components = BasicTrajectoryState::Components;
0085   Components const& components() const { return data().components(); }
0086   bool singleState() const { return data().singleState(); }
0087 
0088   /// Position relative to material, defined relative to momentum vector.
0089   SurfaceSide surfaceSide() const { return data().surfaceSide(); }
0090 
0091   /** Mutator from local parameters, errors and surface. For surfaces 
0092    *  with material the side of the surface should be specified explicitely.
0093    *  If the underlying trajectory state supports updates, it will be updated, otherwise this method will
0094    *  just behave like creating a new TSOS (which will make a new BasicSingleTrajectoryState)
0095    */
0096   void update(const LocalTrajectoryParameters& p,
0097               const SurfaceType& aSurface,
0098               const MagneticField* field,
0099               SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
0100 
0101   void update(const LocalTrajectoryParameters& p, SurfaceSide side) { unsharedData().update(p, side); }
0102 
0103   void update(const LocalTrajectoryParameters& p, const LocalTrajectoryError& err, SurfaceSide side) {
0104     unsharedData().update(p, err, side);
0105   }
0106 
0107   /** Mutator from local parameters, errors and surface. For surfaces 
0108    *  with material the side of the surface should be specified explicitely. 
0109    *  For multi-states the weight should be specified explicitely.
0110    *  If the underlying trajectory state supports updates, it will be updated, otherwise this method will
0111    *  just behave like creating a new TSOS (which will make a new BasicSingleTrajectoryState)
0112    */
0113   void update(const LocalTrajectoryParameters& p,
0114               const LocalTrajectoryError& err,
0115               const SurfaceType& aSurface,
0116               const MagneticField* field,
0117               SurfaceSide side = SurfaceSideDefinition::atCenterOfSurface);
0118 
0119   CurvilinearTrajectoryError& setCurvilinearError() { return sharedData().setCurvilinearError(); }
0120 };
0121 
0122 inline void swap(TrajectoryStateOnSurface& rh, TrajectoryStateOnSurface& lh) {
0123   // use base swap
0124   rh.swap(lh);
0125 }
0126 
0127 std::ostream& operator<<(std::ostream& os, const TrajectoryStateOnSurface& tsos);
0128 #endif