EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StateOnPlane.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 
52  StateOnPlane(const AbsTrackRep* rep = nullptr);
54  StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep);
55  StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo);
56 
58  void swap(StateOnPlane& other); // nothrow
59 
60  virtual ~StateOnPlane() {}
61  virtual StateOnPlane* clone() const {return new StateOnPlane(*this);}
62 
63  const TVectorD& getState() const {return state_;}
64  TVectorD& getState() {return state_;}
65  const TVectorD& getAuxInfo() const {return auxInfo_;}
66  TVectorD& getAuxInfo() {return auxInfo_;}
67  const SharedPlanePtr& getPlane() const {return sharedPlane_;}
68  const AbsTrackRep* getRep() const {return rep_;}
69 
70  void setState(const TVectorD& state) {if(state_.GetNrows() == 0) state_.ResizeTo(state); state_ = state;}
71  void setPlane(const SharedPlanePtr& plane) {sharedPlane_ = plane;}
72  void setStatePlane(const TVectorD& state, const SharedPlanePtr& plane) {state_ = state; sharedPlane_ = plane;}
73  void setAuxInfo(const TVectorD& auxInfo) {if(auxInfo_.GetNrows() == 0) auxInfo_.ResizeTo(auxInfo); auxInfo_ = auxInfo;}
74  void setRep(const AbsTrackRep* rep) {rep_ = rep;}
75 
76  // Shortcuts to TrackRep functions
77  double extrapolateToPlane(const SharedPlanePtr& plane,
78  bool stopAtBoundary = false,
79  bool calcJacobianNoise = false) {return rep_->extrapolateToPlane(*this, plane, stopAtBoundary, calcJacobianNoise);}
80  double extrapolateToLine(const TVector3& linePoint,
81  const TVector3& lineDirection,
82  bool stopAtBoundary = false,
83  bool calcJacobianNoise = false) {return rep_->extrapolateToLine(*this, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);}
84  double extrapolateToPoint(const TVector3& point,
85  bool stopAtBoundary = false,
86  bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, stopAtBoundary, calcJacobianNoise);}
87  double extrapolateToPoint(const TVector3& point,
88  const TMatrixDSym& G, // weight matrix (metric)
89  bool stopAtBoundary = false,
90  bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, G, stopAtBoundary, calcJacobianNoise);}
92  const TVector3& linePoint = TVector3(0.,0.,0.),
93  const TVector3& lineDirection = TVector3(0.,0.,1.),
94  bool stopAtBoundary = false,
95  bool calcJacobianNoise = false) {return rep_->extrapolateToCylinder(*this, radius, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);}
96  double extrapolateToCone(double openingAngle,
97  const TVector3& conePoint = TVector3(0.,0.,0.),
98  const TVector3& coneDirection = TVector3(0.,0.,1.),
99  bool stopAtBoundary = false,
100  bool calcJacobianNoise = false) {return rep_->extrapolateToCone(*this, openingAngle, conePoint, coneDirection, stopAtBoundary, calcJacobianNoise);}
101  double extrapolateToSphere(double radius,
102  const TVector3& point = TVector3(0.,0.,0.),
103  bool stopAtBoundary = false,
104  bool calcJacobianNoise = false) {return rep_->extrapolateToSphere(*this, radius, point, stopAtBoundary, calcJacobianNoise);}
105  double extrapolateBy(double step,
106  bool stopAtBoundary = false,
107  bool calcJacobianNoise = false) {return rep_->extrapolateBy(*this, step, stopAtBoundary, calcJacobianNoise);}
108  double extrapolateToMeasurement(const AbsMeasurement* measurement,
109  bool stopAtBoundary = false,
110  bool calcJacobianNoise = false) {return rep_->extrapolateToMeasurement(*this, measurement, stopAtBoundary, calcJacobianNoise);}
111 
112 
113  TVector3 getPos() const {return rep_->getPos(*this);}
114  TVector3 getMom() const {return rep_->getMom(*this);}
115  TVector3 getDir() const {return rep_->getDir(*this);}
116  void getPosMom(TVector3& pos, TVector3& mom) const {rep_->getPosMom(*this, pos, mom);}
117  void getPosDir(TVector3& pos, TVector3& dir) const {rep_->getPosDir(*this, pos, dir);}
118  TVectorD get6DState() const {return rep_->get6DState(*this);}
119  double getMomMag() const {return rep_->getMomMag(*this);}
120  int getPDG() const {return rep_->getPDG();}
121  double getCharge() const {return rep_->getCharge(*this);}
122  double getQop() const {return rep_->getQop(*this);}
123  double getMass() const {return rep_->getMass(*this);}
124  double getTime() const {return rep_->getTime(*this);}
125 
126  void setPosMom(const TVector3& pos, const TVector3& mom) {rep_->setPosMom(*this, pos, mom);}
127  void setPosMom(const TVectorD& state6) {rep_->setPosMom(*this, state6);}
128  void setChargeSign(double charge) {rep_->setChargeSign(*this, charge);}
129  void setQop(double qop) {rep_->setQop(*this, qop);}
130  void setTime(double time) {rep_->setTime(*this, time);}
131 
132 
133  virtual void Print(Option_t* option = "") const;
134 
135  protected:
136 
137  TVectorD state_; // state vector
138  TVectorD auxInfo_; // auxiliary information (e.g. charge, flight direction etc.)
140 
141  private:
142 
145  const AbsTrackRep* rep_;
146 
147  public:
148  ClassDef(StateOnPlane,2)
149  // Version history:
150  // ver 2: no longer derives from TObject (the TObject parts were not
151  // streamed, so no compatibility issues arise.)
152 };
153 
154 
156  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) :
164  state_(state), auxInfo_(0), sharedPlane_(plane), rep_(rep)
165 {
166  assert(rep != nullptr);
167  assert(sharedPlane_.get() != nullptr);
168 }
169 
170 inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo) :
171  state_(state), auxInfo_(auxInfo), sharedPlane_(plane), rep_(rep)
172 {
173  assert(rep != nullptr);
174  assert(sharedPlane_.get() != nullptr);
175 }
176 
178  swap(other);
179  return *this;
180 }
181 
182 inline void StateOnPlane::swap(StateOnPlane& other) {
183  this->state_.ResizeTo(other.state_);
184  std::swap(this->state_, other.state_);
185  this->auxInfo_.ResizeTo(other.auxInfo_);
186  std::swap(this->auxInfo_, other.auxInfo_);
187  this->sharedPlane_.swap(other.sharedPlane_);
188  std::swap(this->rep_, other.rep_);
189 }
190 
191 } /* End of namespace genfit */
194 #endif // genfit_StateOnPlane_h