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