diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.h b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.h index 779cce6d3efaf1e756d67b50633881f2f33898c5..fecffc63db7a5de63d85b6819910b986664f6262 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.h +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.h @@ -77,21 +77,27 @@ namespace Trk /** Move Constructor */ CurvilinearParametersT(CurvilinearParametersT<DIM,T,S>&&); - - /** Destructor */ - virtual ~CurvilinearParametersT()=default; - + /** Assignment operator*/ CurvilinearParametersT<DIM,T,S> &operator=(const CurvilinearParametersT<DIM,T,S>&); /** Move assignment operator*/ CurvilinearParametersT<DIM,T,S> &operator=(CurvilinearParametersT<DIM,T,S>&&); + + /** Destructor */ + virtual ~CurvilinearParametersT()=default; + + /** the curvilinear parameters identifier */ + unsigned int cIdentifier() const {return m_cIdentifier;} + + void setcIdentifier (unsigned int cIdentifier) + { m_cIdentifier = cIdentifier; } /** equality operator */ - virtual bool operator==(const ParametersBase<DIM,T>& rhs) const override final; + virtual bool operator==(const ParametersBase<DIM,T>& rhs) const override; /** Pseudo constructor */ - virtual CurvilinearParametersT<DIM,T,S>* clone() const override final + virtual CurvilinearParametersT<DIM,T,S>* clone() const override {return new CurvilinearParametersT<DIM,T,S>(*this);} /** Return the ParametersType enum */ @@ -99,33 +105,19 @@ namespace Trk {return Trk::Curvilinear;} /** Return the measurementFrame of the parameters */ - virtual Amg::RotationMatrix3D measurementFrame() const override final; + virtual Amg::RotationMatrix3D measurementFrame() const override; /**Dumps relevant information about the track parameters into the ostream.*/ virtual MsgStream& dump(MsgStream& out) const override; virtual std::ostream& dump(std::ostream& out) const override; - /** Update parameters and covariance */ - virtual void updateParameters(const AmgVector(DIM)&, AmgSymMatrix(DIM)* = nullptr) override; - - /** Update parameters and covariance , passing covariance by ref. A covariance - * is created if one does not exist. Otherwise in place update occurs*/ - virtual void updateParameters(const AmgVector(DIM)&, const AmgSymMatrix(DIM)&) override; - - /** the curvilinear parameters identifier */ - unsigned int cIdentifier() const {return m_cIdentifier;} - - void setcIdentifier (unsigned int cIdentifier) - { m_cIdentifier = cIdentifier; } - - /** DESIGN TO BE REVISITED */ protected: friend class MaterialEffectsEngine; private: /* Helper to factor in update of parameters*/ - void updateParametersHelper(const AmgVector(DIM)&); + virtual void updateParametersHelper(const AmgVector(DIM)&) override; /** return the curvilinear frame */ CurvilinearUVT curvilinearFrame() const; diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc index 84026ec3ab9acd6ed4030bd399b4495e103e60bc..621d7a0f735419bc38e3cdfa8513da6712ece64a 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/CurvilinearParametersT.icc @@ -263,34 +263,4 @@ namespace Trk this->m_surface.reset(new S(this->m_position, curvilinearFrame())); } - // Dedicated update method - template <int DIM,class T,class S> - void Trk::CurvilinearParametersT<DIM,T,S>::updateParameters(const AmgVector(DIM)& updatedParameters, - AmgSymMatrix(DIM)* updatedCovariance) - { - this->updateParametersHelper(updatedParameters); - // update the covariance - if (updatedCovariance) - { - //check if someone passed what we owm - if (updatedCovariance != this->m_covariance.get()){ - this->m_covariance.reset(updatedCovariance); - } - } - } - - // Dedicated update method - template <int DIM,class T,class S> - void Trk::CurvilinearParametersT<DIM,T,S>::updateParameters(const AmgVector(DIM)& updatedParameters, - const AmgSymMatrix(DIM)& updatedCovariance) - { - this->updateParametersHelper(updatedParameters); - // if the covariance is there update in place - if (this->m_covariance) { - (*(this->m_covariance)) = updatedCovariance; - } else { // otherwise create one - this->m_covariance = std::make_unique<AmgSymMatrix(DIM)>(updatedCovariance); - } - } - } // end of namespace Trk diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.h b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.h index f894892a96aedd644d0659ff2df3012156908f5a..0a82bbeb7c7ba1c58c79c6033469dd01b9cedcfd 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.h +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.h @@ -15,7 +15,6 @@ #include <memory> class MsgStream; - namespace Trk { class Surface; @@ -47,6 +46,7 @@ namespace Trk @tparam T charge of track (either <tt>Trk::Charged</tt> or <tt>Trk::Neutral</tt>) @author Andreas.Salzburger@cern.ch + @author Christos Anastopoulos (Athena MT modifications) */ template <int DIM,class T> @@ -82,16 +82,33 @@ namespace Trk /** Returns charge of concrete type (i.e. must be implemented in inheriting classes) */ double charge() const; - - /** Access method for the local coordinates, \f$(loc1,loc2)\f$ - local parameter definitions differ for each surface type. */ + + /** Access method for the local coordinates, \f$(loc1,loc2)\f$ + local parameter definitions differ for each surface type. */ Amg::Vector2D localPosition() const; - + + /** Update parameters and covariance. + * Uses NVI: Derived classes can override the + * implementation via updateParametersHelper + */ + void updateParameters(const AmgVector(DIM)&, AmgSymMatrix(DIM)* = nullptr); + + /** Update parameters and covariance , passing covariance by ref. A + * covariance is created if one does not exist. Otherwise in place update + * occurs via assignment. + * Uses NVI: Derived classes can override the + * implementation via updateParametersHelper + */ + void updateParameters(const AmgVector(DIM)&, const AmgSymMatrix(DIM)&); + + /** Access to the Surface method */ virtual const Surface& associatedSurface() const = 0; - - /** Return the measurement frame - this is needed for alignment, in particular for StraightLine and Perigee Surface - - the default implementation is the the RotationMatrix3D of the transform */ + + /** Return the measurement frame - this is needed for alignment, in + particular for StraightLine and Perigee Surface + - the default implementation is the RotationMatrix3D of the + transform */ virtual Amg::RotationMatrix3D measurementFrame() const = 0; /** Pseudo constructor - avoids excessive type-casting. @@ -104,21 +121,11 @@ namespace Trk /** Test to see if there's a surface there. */ virtual bool hasSurface() const = 0 ; - /** Update parameters and covariance */ - virtual void updateParameters(const AmgVector(DIM)&, AmgSymMatrix(DIM)* = nullptr) = 0; - - /** Update parameters and covariance , passing covariance by ref. A covariance - * is created if one does not exist. Otherwise in place update occurs*/ - virtual void updateParameters(const AmgVector(DIM)&, const AmgSymMatrix(DIM)&) = 0; - /** Dumps relevant information about the track parameters into the ostream */ virtual MsgStream& dump(MsgStream& out) const; virtual std::ostream& dump(std::ostream& out) const; - /** DESIGN TO BE REVISITED */ - friend class MaterialEffectsEngine; - - protected : + protected : /* * This has pure virtual functions * so it is abstract class and we can not instanticate objects directly. @@ -133,13 +140,17 @@ namespace Trk ParametersBase(ParametersBase&&)=default; ParametersBase& operator=(ParametersBase&&)=default; + /* Helper to factor in update of parameters*/ + virtual void updateParametersHelper(const AmgVector(DIM)&)=0; + AmgVector(DIM) m_parameters; //!< contains the n parameters std::unique_ptr<AmgSymMatrix(DIM)> m_covariance; //!< contains the n x n covariance matrix Amg::Vector3D m_position; //!< point on track Amg::Vector3D m_momentum; //!< momentum at this point on track T m_chargeDef; //!< charge definition for this track + }; /**Overload of << operator for both, MsgStream and std::ostream for debug output*/ diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.icc b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.icc index 0131e15552cb9808f3860571829d6a4eb45132b5..055366df6cb3904e3a02dba117c6c53c1f1a8e61 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.icc +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersBase.icc @@ -87,6 +87,36 @@ ParametersBase<DIM, T>::localPosition() const return Amg::Vector2D(parameters()[Trk::loc1], parameters()[Trk::loc2]); } +template<int DIM, class T> +void +ParametersBase<DIM, T>::updateParameters(const AmgVector(DIM) & updatedParameters, + AmgSymMatrix(DIM) * updatedCovariance) +{ + // update the covariance + if (updatedCovariance) { + // make sure we did not receive what we already hold + if (updatedCovariance != m_covariance.get()) { + m_covariance.reset(updatedCovariance); + } + } + this->updateParametersHelper(updatedParameters); +} + +// update function +template<int DIM, class T> +void +ParametersBase<DIM, T>::updateParameters(const AmgVector(DIM) & updatedParameters, + const AmgSymMatrix(DIM) & updatedCovariance) +{ + // if the covariance is there update in place + if (m_covariance) { + (*m_covariance) = updatedCovariance; + } else { // otherwise create one + m_covariance = std::make_unique<AmgSymMatrix(DIM)>(updatedCovariance); + } + this->updateParametersHelper(updatedParameters); +} + template<int DIM, class T> MsgStream& ParametersBase<DIM, T>::dump(MsgStream& sl) const diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.h b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.h index f2cddeed4375438638d2146f4ad5fc88d67fceaa..d3712c12a19a124d9682c052bc53dad3a589e8f3 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.h +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.h @@ -15,6 +15,11 @@ #include "GeoPrimitives/GeoPrimitives.h" #include "EventPrimitives/EventPrimitives.h" #include "TrkParametersBase/SurfaceUniquePtrT.h" + +/* + * Needed for persistency + * friends + */ template<typename T> class TrackParametersCovarianceCnv; class TrackParametersCnv_p2; @@ -22,6 +27,7 @@ class MeasuredPerigeeCnv_p1; template< class SURFACE_CNV, class ATA_SURFACE > class AtaSurfaceCnv_p1; + namespace Trk { class MaterialEffectsEngine; @@ -47,6 +53,7 @@ namespace Trk @tparam S type of surface @author edward.moyse@cern.ch, andreas.salzburger@cern.ch + @author Christos Anastopoulos (Athena MT modifications) */ template<int DIM,class T,class S> class ParametersT : public ParametersBase<DIM,T> @@ -116,19 +123,14 @@ namespace Trk /** Return the measurementFrame of the parameters */ virtual Amg::RotationMatrix3D measurementFrame() const override; - - /** Update parameters and covariance */ - virtual void updateParameters(const AmgVector(DIM)&, AmgSymMatrix(DIM)* = nullptr) override; - - /** Update parameters and covariance , passing covariance by ref. A covariance - * is created if one does not exist. Otherwise in place update occurs*/ - virtual void updateParameters(const AmgVector(DIM)&, const AmgSymMatrix(DIM)&) override; - + + private : /* Helper to factor in update of parameters*/ - void updateParametersHelper(const AmgVector(DIM)&); + virtual void updateParametersHelper(const AmgVector(DIM)&) override; protected: + /* * Add dependent names into scope */ @@ -138,26 +140,34 @@ namespace Trk using ParametersBase<DIM,T>::m_momentum; using ParametersBase<DIM,T>::m_chargeDef; SurfaceUniquePtrT<const S> m_surface; //!< surface template - - protected: + + /** + * @brief Constructor used by curvilinear + * Parameters + */ + ParametersT(const Amg::Vector3D& pos, + const Amg::Vector3D& mom, + AmgSymMatrix(DIM) * covariance = 0); + + /** + * @brief Constructor for persistency + */ + ParametersT (const AmgVector(DIM)& parameters, + const S* surface, + AmgSymMatrix(DIM)* covariance = 0); + + + /* + * friends needed for Persistency + */ template<typename pars> friend class ::TrackParametersCovarianceCnv; friend class ::TrackParametersCnv_p2; friend class ::MeasuredPerigeeCnv_p1; template <class SURFACE_CNV, class ATA_SURFACE> friend class ::AtaSurfaceCnv_p1; - - /** --- Protected constructors : for persistency purpose only */ - ParametersT (const AmgVector(DIM)& parameters, - const S* surface, - AmgSymMatrix(DIM)* covariance = 0); - - ParametersT (const Amg::Vector3D& pos, - const Amg::Vector3D& mom, - AmgSymMatrix(DIM)* covariance = 0); /** DESIGN TO BE REVISITED */ - protected: friend class MaterialEffectsEngine; }; } //end of namespace Trk diff --git a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc index 50a2b9ba6d65c1f044e0b1f2e8ee122cd816cacf..b4a43354e9c423410748692e11483d59a9fdf91d 100644 --- a/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc +++ b/Tracking/TrkEvent/TrkParametersBase/TrkParametersBase/ParametersT.icc @@ -117,8 +117,6 @@ ParametersT<DIM, T, S>::ParametersT(double loc1, charge) , m_surface(surface.isFree() ? surface.clone() : &surface) { - // m_chargeDef->setCharge(charge); - // get the local parameters via the surface Amg::Vector2D lPosition; const bool ok = @@ -130,7 +128,7 @@ ParametersT<DIM, T, S>::ParametersT(double loc1, // For a neutral particle, last parm should be 1/p rather than q/p. double qopnum = this->charge(); if (qopnum == 0) { qopnum = 1; -} + } // fill the vector now m_parameters << lPosition[Trk::loc1], lPosition[Trk::loc2], this->momentum().phi(), @@ -151,7 +149,7 @@ ParametersT<DIM, T, S>::ParametersT(double loc1, {}, 1.) , m_surface(surface.isFree() ? surface.clone() : &surface) - { + { // decide the sign of the charge if(qop<0.) { m_chargeDef.setCharge(-1); @@ -179,9 +177,9 @@ ParametersT<DIM, T, S>::ParametersT(double loc1, } // fill the vector now // cppcheck-suppress constStatement - m_parameters << lPosition[Trk::loc1], lPosition[Trk::loc2], phi, theta, qop; + m_parameters << lPosition[Trk::loc1], lPosition[Trk::loc2], phi, theta, qop; } - + // Copy constructor template<int DIM, class T, class S> ParametersT<DIM, T, S>::ParametersT(const ParametersT<DIM, T, S>& rhs) @@ -344,35 +342,6 @@ ParametersT<DIM, T, S>::ParametersT(double loc1, } } - // update function - template<int DIM, class T, class S> - void ParametersT<DIM, T, S>::updateParameters(const AmgVector(DIM) & updatedParameters, - AmgSymMatrix(DIM) * updatedCovariance) - { - this->updateParametersHelper(updatedParameters); - // update the covariance - if (updatedCovariance) { - //make sure we did not receive what we already hold - if (updatedCovariance != m_covariance.get()) { - m_covariance.reset(updatedCovariance); - } - } - } - - // update function - template<int DIM, class T, class S> - void ParametersT<DIM, T, S>::updateParameters(const AmgVector(DIM) & updatedParameters, - const AmgSymMatrix(DIM) & updatedCovariance) - { - this->updateParametersHelper(updatedParameters); - // if the covariance is there update in place - if (m_covariance) { - (*m_covariance) = updatedCovariance; - } else { // otherwise create one - m_covariance= std::make_unique<AmgSymMatrix(DIM)>(updatedCovariance); - } - } - // Default constructor only for POOL and derived classes template<int DIM, class T, class S> ParametersT<DIM, T, S>::ParametersT() @@ -430,6 +399,4 @@ ParametersT<DIM, T, S>::ParametersT(double loc1, m_position.setZero(); } } - - } // end of namespace Trk