PandaRoot
StateOnPlane.h
Go to the documentation of this file.
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 namespace genfit {
34 
44 class StateOnPlane {
45 
46  public:
47  StateOnPlane(const AbsTrackRep *rep = nullptr);
49  StateOnPlane(const TVectorD &state, const SharedPlanePtr &plane, const AbsTrackRep *rep);
50  StateOnPlane(const TVectorD &state, const SharedPlanePtr &plane, const AbsTrackRep *rep, const TVectorD &auxInfo);
51 
53  void swap(StateOnPlane &other); // nothrow
54 
55  virtual ~StateOnPlane() {}
56 
57  const TVectorD &getState() const { return state_; }
58  TVectorD &getState() { return state_; }
59  const TVectorD &getAuxInfo() const { return auxInfo_; }
60  TVectorD &getAuxInfo() { return auxInfo_; }
61  const SharedPlanePtr &getPlane() const { return sharedPlane_; }
62  const AbsTrackRep *getRep() const { return rep_; }
63 
64  void setState(const TVectorD &state)
65  {
66  if (state_.GetNrows() == 0)
67  state_.ResizeTo(state);
68  state_ = state;
69  }
70  void setPlane(const SharedPlanePtr &plane) { sharedPlane_ = plane; }
71  void setStatePlane(const TVectorD &state, const SharedPlanePtr &plane)
72  {
73  state_ = state;
74  sharedPlane_ = plane;
75  }
76  void setAuxInfo(const TVectorD &auxInfo)
77  {
78  if (auxInfo_.GetNrows() == 0)
79  auxInfo_.ResizeTo(auxInfo);
80  auxInfo_ = auxInfo;
81  }
82  void setRep(const AbsTrackRep *rep) { rep_ = rep; }
83 
84  // Shortcuts to TrackRep functions
85  double extrapolateToPlane(const SharedPlanePtr &plane, bool stopAtBoundary = false, bool calcJacobianNoise = false)
86  {
87  return rep_->extrapolateToPlane(*this, plane, stopAtBoundary, calcJacobianNoise);
88  }
89  double extrapolateToLine(const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary = false, bool calcJacobianNoise = false)
90  {
91  return rep_->extrapolateToLine(*this, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);
92  }
93  double extrapolateToPoint(const TVector3 &point, bool stopAtBoundary = false, bool calcJacobianNoise = false)
94  {
95  return rep_->extrapolateToPoint(*this, point, stopAtBoundary, calcJacobianNoise);
96  }
97  double extrapolateToPoint(const TVector3 &point,
98  const TMatrixDSym &G, // weight matrix (metric)
99  bool stopAtBoundary = false, bool calcJacobianNoise = false)
100  {
101  return rep_->extrapolateToPoint(*this, point, G, stopAtBoundary, calcJacobianNoise);
102  }
103  double extrapolateToCylinder(double radius, const TVector3 &linePoint = TVector3(0., 0., 0.), const TVector3 &lineDirection = TVector3(0., 0., 1.), bool stopAtBoundary = false,
104  bool calcJacobianNoise = false)
105  {
106  return rep_->extrapolateToCylinder(*this, radius, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);
107  }
108  double extrapolateToSphere(double radius, const TVector3 &point = TVector3(0., 0., 0.), bool stopAtBoundary = false, bool calcJacobianNoise = false)
109  {
110  return rep_->extrapolateToSphere(*this, radius, point, stopAtBoundary, calcJacobianNoise);
111  }
112  double extrapolateBy(double step, bool stopAtBoundary = false, bool calcJacobianNoise = false) { return rep_->extrapolateBy(*this, step, stopAtBoundary, calcJacobianNoise); }
113  double extrapolateToMeasurement(const AbsMeasurement *measurement, bool stopAtBoundary = false, bool calcJacobianNoise = false)
114  {
115  return rep_->extrapolateToMeasurement(*this, measurement, stopAtBoundary, calcJacobianNoise);
116  }
117 
118  TVector3 getPos() const { return rep_->getPos(*this); }
119  TVector3 getMom() const { return rep_->getMom(*this); }
120  TVector3 getDir() const { return rep_->getDir(*this); }
121  void getPosMom(TVector3 &pos, TVector3 &mom) const { rep_->getPosMom(*this, pos, mom); }
122  void getPosDir(TVector3 &pos, TVector3 &dir) const { rep_->getPosDir(*this, pos, dir); }
123  TVectorD get6DState() const { return rep_->get6DState(*this); }
124  double getMomMag() const { return rep_->getMomMag(*this); }
125  int getPDG() const { return rep_->getPDG(); }
126  double getCharge() const { return rep_->getCharge(*this); }
127  double getQop() const { return rep_->getQop(*this); }
128  double getMass() const { return rep_->getMass(*this); }
129  double getTime() const { return rep_->getTime(*this); }
130 
131  void setPosMom(const TVector3 &pos, const TVector3 &mom) { rep_->setPosMom(*this, pos, mom); }
132  void setPosMom(const TVectorD &state6) { rep_->setPosMom(*this, state6); }
133  void setChargeSign(double charge) { rep_->setChargeSign(*this, charge); }
134  void setQop(double qop) { rep_->setQop(*this, qop); }
135  void setTime(double time) { rep_->setTime(*this, time); }
136 
137  virtual void Print(Option_t *option = "") const;
138 
139  protected:
140  TVectorD state_; // state vector
141  TVectorD auxInfo_; // auxiliary information (e.g. charge, flight direction etc.)
143 
144  private:
147  const AbsTrackRep *rep_;
148 
149  public:
150  ClassDef(StateOnPlane, 2)
151  // Version history:
152  // ver 2: no longer derives from TObject (the TObject parts were not
153  // streamed, so no compatibility issues arise.)
154 };
155 
156 inline StateOnPlane::StateOnPlane(const AbsTrackRep *rep) : state_(0), auxInfo_(0), sharedPlane_(), rep_(rep)
157 {
158  if (rep != nullptr) {
159  state_.ResizeTo(rep->getDim());
160  }
161 }
162 
163 inline StateOnPlane::StateOnPlane(const TVectorD &state, const SharedPlanePtr &plane, const AbsTrackRep *rep) : state_(state), auxInfo_(0), sharedPlane_(plane), rep_(rep)
164 {
165  assert(rep != nullptr);
166  assert(sharedPlane_.get() != nullptr);
167 }
168 
169 inline StateOnPlane::StateOnPlane(const TVectorD &state, const SharedPlanePtr &plane, const AbsTrackRep *rep, const TVectorD &auxInfo)
170  : state_(state), auxInfo_(auxInfo), sharedPlane_(plane), rep_(rep)
171 {
172  assert(rep != nullptr);
173  assert(sharedPlane_.get() != nullptr);
174 }
175 
177 {
178  swap(other);
179  return *this;
180 }
181 
182 inline void StateOnPlane::swap(StateOnPlane &other)
183 {
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
double extrapolateToMeasurement(StateOnPlane &state, const AbsMeasurement *measurement, bool stopAtBoundary=false, bool calcJacobianNoise=false) const
extrapolate to an AbsMeasurement
virtual void setTime(StateOnPlane &state, double time) const =0
Set time at which the state was defined.
const TVectorD & getState() const
Definition: StateOnPlane.h:57
TVector3 getMom() const
Definition: StateOnPlane.h:119
double getMass(const StateOnPlane &state) const
Get tha particle mass in GeV/c^2.
double extrapolateToCylinder(double radius, const TVector3 &linePoint=TVector3(0., 0., 0.), const TVector3 &lineDirection=TVector3(0., 0., 1.), bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:103
double getMomMag() const
Definition: StateOnPlane.h:124
double getCharge() const
Definition: StateOnPlane.h:126
void getPosDir(const StateOnPlane &state, TVector3 &pos, TVector3 &dir) const
Get cartesian position and direction vector of a state.
Definition: AbsTrackRep.h:201
double extrapolateToPlane(const SharedPlanePtr &plane, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:85
TVectorD & getAuxInfo()
Definition: StateOnPlane.h:60
double extrapolateBy(double step, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:112
TVectorD & getState()
Definition: StateOnPlane.h:58
double extrapolateToSphere(double radius, const TVector3 &point=TVector3(0., 0., 0.), bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:108
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 unsigned int getDim() const =0
Get the dimension of the state vector used by the track representation.
void setChargeSign(double charge)
Definition: StateOnPlane.h:133
StateOnPlane & operator=(StateOnPlane other)
Definition: StateOnPlane.h:176
virtual double getMomMag(const StateOnPlane &state) const =0
get the magnitude of the momentum in GeV.
Abstract base class for a track representation.
Definition: AbsTrackRep.h:62
virtual double getQop(const StateOnPlane &state) const =0
Get charge over momentum.
double extrapolateToMeasurement(const AbsMeasurement *measurement, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:113
void setState(const TVectorD &state)
Definition: StateOnPlane.h:64
void setStatePlane(const TVectorD &state, const SharedPlanePtr &plane)
Definition: StateOnPlane.h:71
virtual TVectorD get6DState(const StateOnPlane &state) const
Get the 6D state vector (x, y, z, p_x, p_y, p_z).
TVector3 getPos() const
Definition: StateOnPlane.h:118
double getTime() const
Definition: StateOnPlane.h:129
virtual double getTime(const StateOnPlane &) const =0
Get the time corresponding to the StateOnPlane. Extrapolation.
TVectorD get6DState() const
Definition: StateOnPlane.h:123
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...
void setPosMom(const TVector3 &pos, const TVector3 &mom)
Definition: StateOnPlane.h:131
virtual void Print(Option_t *option="") const
const TVectorD & getAuxInfo() const
Definition: StateOnPlane.h:59
virtual void setChargeSign(StateOnPlane &state, double charge) const =0
Set the sign of the charge according to charge.
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:44
StateOnPlane(const AbsTrackRep *rep=nullptr)
Definition: StateOnPlane.h:156
virtual ~StateOnPlane()
Definition: StateOnPlane.h:55
void swap(StateOnPlane &other)
Definition: StateOnPlane.h:182
double extrapolateToPoint(const TVector3 &point, const TMatrixDSym &G, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:97
double getQop() const
Definition: StateOnPlane.h:127
virtual double getCharge(const StateOnPlane &state) const =0
Get the (fitted) charge of a state. This is not always equal the pdg charge (e.g. if the charge sign ...
const AbsTrackRep * getRep() const
Definition: StateOnPlane.h:62
double getMass() const
Definition: StateOnPlane.h:128
void setPosMom(const TVectorD &state6)
Definition: StateOnPlane.h:132
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...
void setQop(double qop)
Definition: StateOnPlane.h:134
TVector3 getDir() const
Definition: StateOnPlane.h:120
virtual TVector3 getPos(const StateOnPlane &state) const =0
Get the cartesian position of a state.
int getPDG() const
Get the pdg code.
Definition: AbsTrackRep.h:225
void setPlane(const SharedPlanePtr &plane)
Definition: StateOnPlane.h:70
double extrapolateToLine(const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:89
virtual TVector3 getMom(const StateOnPlane &state) const =0
Get the cartesian momentum vector of a state.
virtual void getPosMom(const StateOnPlane &state, TVector3 &pos, TVector3 &mom) const =0
Get cartesian position and momentum vector of a state.
TVector3 getDir(const StateOnPlane &state) const
Get the direction vector of a state.
Definition: AbsTrackRep.h:195
void setRep(const AbsTrackRep *rep)
Definition: StateOnPlane.h:82
Contains the measurement and covariance in raw detector coordinates.
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
void setTime(double time)
Definition: StateOnPlane.h:135
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...
void getPosDir(TVector3 &pos, TVector3 &dir) const
Definition: StateOnPlane.h:122
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...
void setAuxInfo(const TVectorD &auxInfo)
Definition: StateOnPlane.h:76
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, the extrapolated state.
virtual void setQop(StateOnPlane &state, double qop) const =0
Set charge/momentum.
Matrix inversion tools.
Definition: AbsBField.h:28
double extrapolateToPoint(const TVector3 &point, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:93
const SharedPlanePtr & getPlane() const
Definition: StateOnPlane.h:61
virtual void setPosMom(StateOnPlane &state, const TVector3 &pos, const TVector3 &mom) const =0
Set position and momentum of state.
void getPosMom(TVector3 &pos, TVector3 &mom) const
Definition: StateOnPlane.h:121
SharedPlanePtr sharedPlane_
Definition: StateOnPlane.h:142