Belle II Software  release-08-01-10
StateOnPlane.h
1 /* Copyright 2008-2010, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
24 #ifndef genfit_StateOnPlane_h
25 #define genfit_StateOnPlane_h
26 
27 #include "SharedPlanePtr.h"
28 #include "AbsTrackRep.h"
29 
30 #include <TObject.h>
31 #include <TVectorD.h>
32 
33 #include <cassert>
34 
35 
36 namespace genfit {
37 
47 class StateOnPlane {
48 
49  public:
50 
51  StateOnPlane(const genfit::StateOnPlane&) = default;
52 
53  StateOnPlane(const AbsTrackRep* rep = nullptr);
55  StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep);
56  StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo);
57 
58  StateOnPlane& operator=(StateOnPlane other);
59  void swap(StateOnPlane& other); // nothrow
60 
61  virtual ~StateOnPlane() {}
62  virtual StateOnPlane* clone() const {return new StateOnPlane(*this);}
63 
64  const TVectorD& getState() const {return state_;}
65  TVectorD& getState() {return state_;}
66  const TVectorD& getAuxInfo() const {return auxInfo_;}
67  TVectorD& getAuxInfo() {return auxInfo_;}
68  const SharedPlanePtr& getPlane() const {return sharedPlane_;}
69  const AbsTrackRep* getRep() const {return rep_;}
70 
71  void setState(const TVectorD& state) {if(state_.GetNrows() == 0) state_.ResizeTo(state); state_ = state;}
72  void setPlane(const SharedPlanePtr& plane) {sharedPlane_ = plane;}
73  void setStatePlane(const TVectorD& state, const SharedPlanePtr& plane) {state_ = state; sharedPlane_ = plane;}
74  void setAuxInfo(const TVectorD& auxInfo) {if(auxInfo_.GetNrows() == 0) auxInfo_.ResizeTo(auxInfo); auxInfo_ = auxInfo;}
75  void setRep(const AbsTrackRep* rep) {rep_ = rep;}
76 
77  // Shortcuts to TrackRep functions
78  double extrapolateToPlane(const SharedPlanePtr& plane,
79  bool stopAtBoundary = false,
80  bool calcJacobianNoise = false) {return rep_->extrapolateToPlane(*this, plane, stopAtBoundary, calcJacobianNoise);}
81  double extrapolateToLine(const TVector3& linePoint,
82  const TVector3& lineDirection,
83  bool stopAtBoundary = false,
84  bool calcJacobianNoise = false) {return rep_->extrapolateToLine(*this, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);}
85  double extrapolateToPoint(const TVector3& point,
86  bool stopAtBoundary = false,
87  bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, stopAtBoundary, calcJacobianNoise);}
88  double extrapolateToPoint(const TVector3& point,
89  const TMatrixDSym& G, // weight matrix (metric)
90  bool stopAtBoundary = false,
91  bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, G, stopAtBoundary, calcJacobianNoise);}
92  double extrapolateToCylinder(double radius,
93  const TVector3& linePoint = TVector3(0.,0.,0.),
94  const TVector3& lineDirection = TVector3(0.,0.,1.),
95  bool stopAtBoundary = false,
96  bool calcJacobianNoise = false) {return rep_->extrapolateToCylinder(*this, radius, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);}
97  double extrapolateToCone(double openingAngle,
98  const TVector3& conePoint = TVector3(0.,0.,0.),
99  const TVector3& coneDirection = TVector3(0.,0.,1.),
100  bool stopAtBoundary = false,
101  bool calcJacobianNoise = false) {return rep_->extrapolateToCone(*this, openingAngle, conePoint, coneDirection, stopAtBoundary, calcJacobianNoise);}
102  double extrapolateToSphere(double radius,
103  const TVector3& point = TVector3(0.,0.,0.),
104  bool stopAtBoundary = false,
105  bool calcJacobianNoise = false) {return rep_->extrapolateToSphere(*this, radius, point, stopAtBoundary, calcJacobianNoise);}
106  double extrapolateBy(double step,
107  bool stopAtBoundary = false,
108  bool calcJacobianNoise = false) {return rep_->extrapolateBy(*this, step, stopAtBoundary, calcJacobianNoise);}
109  double extrapolateToMeasurement(const AbsMeasurement* measurement,
110  bool stopAtBoundary = false,
111  bool calcJacobianNoise = false) {return rep_->extrapolateToMeasurement(*this, measurement, stopAtBoundary, calcJacobianNoise);}
112 
113 
114  TVector3 getPos() const {return rep_->getPos(*this);}
115  TVector3 getMom() const {return rep_->getMom(*this);}
116  TVector3 getDir() const {return rep_->getDir(*this);}
117  void getPosMom(TVector3& pos, TVector3& mom) const {rep_->getPosMom(*this, pos, mom);}
118  void getPosDir(TVector3& pos, TVector3& dir) const {rep_->getPosDir(*this, pos, dir);}
119  TVectorD get6DState() const {return rep_->get6DState(*this);}
120  double getMomMag() const {return rep_->getMomMag(*this);}
121  int getPDG() const {return rep_->getPDG();}
122  double getCharge() const {return rep_->getCharge(*this);}
123  double getQop() const {return rep_->getQop(*this);}
124  double getMass() const {return rep_->getMass(*this);}
125  double getTime() const {return rep_->getTime(*this);}
126 
127  void setPosMom(const TVector3& pos, const TVector3& mom) {rep_->setPosMom(*this, pos, mom);}
128  void setPosMom(const TVectorD& state6) {rep_->setPosMom(*this, state6);}
129  void setChargeSign(double charge) {rep_->setChargeSign(*this, charge);}
130  void setQop(double qop) {rep_->setQop(*this, qop);}
131  void setTime(double time) {rep_->setTime(*this, time);}
132 
133 
134  virtual void Print(Option_t* option = "") const;
135 
136  protected:
137 
138  TVectorD state_; // state vector
139  TVectorD auxInfo_; // auxiliary information (e.g. charge, flight direction etc.)
140  SharedPlanePtr sharedPlane_;
141 
142  private:
143 
146  const AbsTrackRep* rep_;
147 
148  public:
149  ClassDef(StateOnPlane,2)
150  // Version history:
151  // ver 2: no longer derives from TObject (the TObject parts were not
152  // streamed, so no compatibility issues arise.)
153 };
154 
155 
156 inline StateOnPlane::StateOnPlane(const AbsTrackRep* rep) :
157  state_(0), auxInfo_(0), sharedPlane_(), rep_(rep)
158 {
159  if (rep != nullptr) {
160  state_.ResizeTo(rep->getDim());
161  }
162 }
163 
164 inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep) :
165  state_(state), auxInfo_(0), sharedPlane_(plane), rep_(rep)
166 {
167  assert(rep != nullptr);
168  assert(sharedPlane_.get() != nullptr);
169 }
170 
171 inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo) :
172  state_(state), auxInfo_(auxInfo), sharedPlane_(plane), rep_(rep)
173 {
174  assert(rep != nullptr);
175  assert(sharedPlane_.get() != nullptr);
176 }
177 
178 inline StateOnPlane& StateOnPlane::operator=(StateOnPlane other) {
179  swap(other);
180  return *this;
181 }
182 
183 inline void StateOnPlane::swap(StateOnPlane& other) {
184  this->state_.ResizeTo(other.state_);
185  std::swap(this->state_, other.state_);
186  this->auxInfo_.ResizeTo(other.auxInfo_);
187  std::swap(this->auxInfo_, other.auxInfo_);
188  this->sharedPlane_.swap(other.sharedPlane_);
189  std::swap(this->rep_, other.rep_);
190 }
191 
192 } /* End of namespace genfit */
195 #endif // genfit_StateOnPlane_h
Contains the measurement and covariance in raw detector coordinates.
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
virtual void setTime(StateOnPlane &state, double time) const =0
Set time at which the state was defined.
double extrapolateToMeasurement(StateOnPlane &state, const AbsMeasurement *measurement, bool stopAtBoundary=false, bool calcJacobianNoise=false) const
extrapolate to an AbsMeasurement
Definition: AbsTrackRep.cc:50
virtual unsigned int getDim() const =0
Get the dimension of the state vector used by the track representation.
virtual double extrapolateToLine(StateOnPlane &state, const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the POCA to a line, and returns the extrapolation length and,...
virtual TVectorD get6DState(const StateOnPlane &state) const
Get the 6D state vector (x, y, z, p_x, p_y, p_z).
Definition: AbsTrackRep.cc:59
virtual double getTime(const StateOnPlane &) const =0
Get the time corresponding to the StateOnPlane. Extrapolation.
virtual double extrapolateToPoint(StateOnPlane &state, const TVector3 &point, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the POCA to a point, and returns the extrapolation length and,...
virtual TVector3 getMom(const StateOnPlane &state) const =0
Get the cartesian momentum vector of a state.
double getMass(const StateOnPlane &state) const
Get tha particle mass in GeV/c^2.
Definition: AbsTrackRep.cc:100
virtual double getMomMag(const StateOnPlane &state) const =0
get the magnitude of the momentum in GeV.
virtual double getCharge(const StateOnPlane &state) const =0
Get the (fitted) charge of a state.
virtual double getQop(const StateOnPlane &state) const =0
Get charge over momentum.
void getPosDir(const StateOnPlane &state, TVector3 &pos, TVector3 &dir) const
Get cartesian position and direction vector of a state.
Definition: AbsTrackRep.h:252
virtual void setChargeSign(StateOnPlane &state, double charge) const =0
Set the sign of the charge according to charge.
virtual void setQop(StateOnPlane &state, double qop) const =0
Set charge/momentum.
virtual void setPosMom(StateOnPlane &state, const TVector3 &pos, const TVector3 &mom) const =0
Set position and momentum of state.
virtual double extrapolateToSphere(StateOnPlane &state, double radius, const TVector3 &point=TVector3(0., 0., 0.), bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the sphere surface, and returns the extrapolation length and,...
virtual double extrapolateToCone(StateOnPlane &state, double radius, const TVector3 &linePoint=TVector3(0., 0., 0.), const TVector3 &lineDirection=TVector3(0., 0., 1.), bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the cone surface, and returns the extrapolation length and,...
virtual double extrapolateBy(StateOnPlane &state, double step, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state by step (cm) and returns the extrapolation length and, via reference,...
virtual double extrapolateToPlane(StateOnPlane &state, const genfit::SharedPlanePtr &plane, bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to plane, and returns the extrapolation length and, via reference,...
int getPDG() const
Get the pdg code.
Definition: AbsTrackRep.h:272
TVector3 getDir(const StateOnPlane &state) const
Get the direction vector of a state.
Definition: AbsTrackRep.h:246
virtual TVector3 getPos(const StateOnPlane &state) const =0
Get the cartesian position of a state.
virtual double extrapolateToCylinder(StateOnPlane &state, double radius, const TVector3 &linePoint=TVector3(0., 0., 0.), const TVector3 &lineDirection=TVector3(0., 0., 1.), bool stopAtBoundary=false, bool calcJacobianNoise=false) const =0
Extrapolates the state to the cylinder surface, and returns the extrapolation length and,...
virtual void getPosMom(const StateOnPlane &state, TVector3 &pos, TVector3 &mom) const =0
Get cartesian position and momentum vector of a state.
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:47
const AbsTrackRep * rep_
Shared ownership. '!' in order to silence ROOT, custom streamer writes and reads this.
Definition: StateOnPlane.h:146
Defines for I/O streams used for error and debug printing.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.