Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:21

0001 /* Copyright 2008-2010, Technische Universitaet Muenchen,
0002    Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 /** @addtogroup genfit
0021  * @{
0022  */
0023 
0024 #ifndef genfit_StateOnPlane_h
0025 #define genfit_StateOnPlane_h
0026 
0027 #include "SharedPlanePtr.h"
0028 #include "AbsTrackRep.h"
0029 
0030 #include <TObject.h>
0031 #include <TVectorD.h>
0032 
0033 #include <cassert>
0034 
0035 
0036 namespace genfit {
0037 
0038 /**
0039  * @brief A state with arbitrary dimension defined in a DetPlane.
0040  *
0041  * The dimension and meaning of the #state_ vector are defined by the track parameterization of the #rep_.
0042  * #sharedPlane_ is a shared_pointer, the ownership over that plane is shared between all StateOnPlane objects defined in that plane.
0043  * The definition of the state is bound to the TrackRep #rep_. Therefore, the StateOnPlane contains a pointer to a AbsTrackRep.
0044  * It will provide functionality to extrapolate it and translate the state it into cartesian coordinates.
0045  * Shortcuts to all functions of the AbsTrackRep which use this StateOnPlane are also provided here.
0046  */
0047 class StateOnPlane {
0048 
0049  public:
0050 
0051   StateOnPlane(const genfit::StateOnPlane&) = default;
0052 
0053   StateOnPlane(const AbsTrackRep* rep = nullptr);
0054   //! state is defined by the TrackReps parameterization
0055   StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep);
0056   StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo);
0057 
0058   StateOnPlane& operator=(StateOnPlane other);
0059   void swap(StateOnPlane& other); // nothrow
0060 
0061   virtual ~StateOnPlane() {}
0062   virtual StateOnPlane* clone() const {return new StateOnPlane(*this);}
0063 
0064   const TVectorD& getState() const {return state_;}
0065   TVectorD& getState() {return state_;}
0066   const TVectorD& getAuxInfo() const {return auxInfo_;}
0067   TVectorD& getAuxInfo() {return auxInfo_;}
0068   const SharedPlanePtr& getPlane() const {return sharedPlane_;}
0069   const AbsTrackRep* getRep() const {return rep_;}
0070 
0071   void setState(const TVectorD& state) {if(state_.GetNrows() == 0) state_.ResizeTo(state); state_ = state;}
0072   void setPlane(const SharedPlanePtr& plane) {sharedPlane_ = plane;}
0073   void setStatePlane(const TVectorD& state, const SharedPlanePtr& plane) {state_ = state; sharedPlane_ = plane;}
0074   void setAuxInfo(const TVectorD& auxInfo) {if(auxInfo_.GetNrows() == 0) auxInfo_.ResizeTo(auxInfo); auxInfo_ = auxInfo;}
0075   void setRep(const AbsTrackRep* rep) {rep_ = rep;}
0076 
0077   // Shortcuts to TrackRep functions
0078   double extrapolateToPlane(const SharedPlanePtr& plane,
0079         bool stopAtBoundary = false,
0080         bool calcJacobianNoise = false) {return rep_->extrapolateToPlane(*this, plane, stopAtBoundary, calcJacobianNoise);}
0081   double extrapolateToLine(const TVector3& linePoint,
0082         const TVector3& lineDirection,
0083         bool stopAtBoundary = false,
0084         bool calcJacobianNoise = false) {return rep_->extrapolateToLine(*this, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);}
0085   double extrapolateToPoint(const TVector3& point,
0086         bool stopAtBoundary = false,
0087         bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, stopAtBoundary, calcJacobianNoise);}
0088   double extrapolateToPoint(const TVector3& point,
0089         const TMatrixDSym& G, // weight matrix (metric)
0090         bool stopAtBoundary = false,
0091         bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, G, stopAtBoundary, calcJacobianNoise);}
0092   double extrapolateToCylinder(double radius,
0093         const TVector3& linePoint = TVector3(0.,0.,0.),
0094         const TVector3& lineDirection = TVector3(0.,0.,1.),
0095         bool stopAtBoundary = false,
0096         bool calcJacobianNoise = false) {return rep_->extrapolateToCylinder(*this, radius, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);}
0097   double extrapolateToCone(double openingAngle,
0098         const TVector3& conePoint = TVector3(0.,0.,0.),
0099         const TVector3& coneDirection = TVector3(0.,0.,1.),
0100         bool stopAtBoundary = false,
0101         bool calcJacobianNoise = false) {return rep_->extrapolateToCone(*this, openingAngle, conePoint, coneDirection, stopAtBoundary, calcJacobianNoise);}
0102   double extrapolateToSphere(double radius,
0103         const TVector3& point = TVector3(0.,0.,0.),
0104         bool stopAtBoundary = false,
0105         bool calcJacobianNoise = false) {return rep_->extrapolateToSphere(*this, radius, point, stopAtBoundary, calcJacobianNoise);}
0106   double extrapolateBy(double step,
0107         bool stopAtBoundary = false,
0108         bool calcJacobianNoise = false) {return rep_->extrapolateBy(*this, step, stopAtBoundary, calcJacobianNoise);}
0109   double extrapolateToMeasurement(const AbsMeasurement* measurement,
0110         bool stopAtBoundary = false,
0111         bool calcJacobianNoise = false) {return rep_->extrapolateToMeasurement(*this, measurement, stopAtBoundary, calcJacobianNoise);}
0112 
0113 
0114   TVector3 getPos() const {return rep_->getPos(*this);}
0115   TVector3 getMom() const {return rep_->getMom(*this);}
0116   TVector3 getDir() const {return rep_->getDir(*this);}
0117   void getPosMom(TVector3& pos, TVector3& mom) const {rep_->getPosMom(*this, pos, mom);}
0118   void getPosDir(TVector3& pos, TVector3& dir) const {rep_->getPosDir(*this, pos, dir);}
0119   TVectorD get6DState() const {return rep_->get6DState(*this);}
0120   double getMomMag() const {return rep_->getMomMag(*this);}
0121   int getPDG() const {return rep_->getPDG();}
0122   double getCharge() const {return rep_->getCharge(*this);}
0123   double getQop() const {return rep_->getQop(*this);}
0124   double getMass() const {return rep_->getMass(*this);}
0125   double getTime() const {return rep_->getTime(*this);}
0126 
0127   void setPosMom(const TVector3& pos, const TVector3& mom) {rep_->setPosMom(*this, pos, mom);}
0128   void setPosMom(const TVectorD& state6) {rep_->setPosMom(*this, state6);}
0129   void setChargeSign(double charge) {rep_->setChargeSign(*this, charge);}
0130   void setQop(double qop) {rep_->setQop(*this, qop);}
0131   void setTime(double time) {rep_->setTime(*this, time);}
0132 
0133 
0134   virtual void Print(Option_t* option = "") const;
0135 
0136  protected:
0137 
0138   TVectorD state_; // state vector
0139   TVectorD auxInfo_; // auxiliary information (e.g. charge, flight direction etc.)
0140   SharedPlanePtr sharedPlane_; //! Shared ownership.  '!' in order to silence ROOT, custom streamer writes and reads this.
0141 
0142  private:
0143 
0144   /** Pointer to TrackRep with respect to which StateOnPlane is defined
0145    */
0146   const AbsTrackRep* rep_; //! No ownership
0147 
0148  public:
0149   ClassDef(StateOnPlane,2)
0150   // Version history:
0151   // ver 2: no longer derives from TObject (the TObject parts were not 
0152   //        streamed, so no compatibility issues arise.)
0153 };
0154 
0155 
0156 inline StateOnPlane::StateOnPlane(const AbsTrackRep* rep) :
0157   state_(0), auxInfo_(0), sharedPlane_(), rep_(rep)
0158 {
0159   if (rep != nullptr) {
0160     state_.ResizeTo(rep->getDim());
0161   }
0162 }
0163 
0164 inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep) :
0165   state_(state), auxInfo_(0), sharedPlane_(plane), rep_(rep)
0166 {
0167   assert(rep != nullptr);
0168   assert(sharedPlane_.get() != nullptr);
0169 }
0170 
0171 inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo) :
0172   state_(state), auxInfo_(auxInfo), sharedPlane_(plane), rep_(rep)
0173 {
0174   assert(rep != nullptr);
0175   assert(sharedPlane_.get() != nullptr);
0176 }
0177 
0178 inline StateOnPlane& StateOnPlane::operator=(StateOnPlane other) {
0179   swap(other);
0180   return *this;
0181 }
0182 
0183 inline void StateOnPlane::swap(StateOnPlane& other) {
0184   this->state_.ResizeTo(other.state_);
0185   std::swap(this->state_, other.state_);
0186   this->auxInfo_.ResizeTo(other.auxInfo_);
0187   std::swap(this->auxInfo_, other.auxInfo_);
0188   this->sharedPlane_.swap(other.sharedPlane_);
0189   std::swap(this->rep_, other.rep_);
0190 }
0191 
0192 } /* End of namespace genfit */
0193 /** @} */
0194 
0195 #endif // genfit_StateOnPlane_h