GENFIT  Rev:NoNumberAvailable
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
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  virtual StateOnPlane* clone() const {return new StateOnPlane(*this);}
60 
61  const TVectorD& getState() const {return state_;}
62  TVectorD& getState() {return state_;}
63  const TVectorD& getAuxInfo() const {return auxInfo_;}
64  TVectorD& getAuxInfo() {return auxInfo_;}
65  const SharedPlanePtr& getPlane() const {return sharedPlane_;}
66  const AbsTrackRep* getRep() const {return rep_;}
67 
68  void setState(const TVectorD& state) {if(state_.GetNrows() == 0) state_.ResizeTo(state); state_ = state;}
69  void setPlane(const SharedPlanePtr& plane) {sharedPlane_ = plane;}
70  void setStatePlane(const TVectorD& state, const SharedPlanePtr& plane) {state_ = state; sharedPlane_ = plane;}
71  void setAuxInfo(const TVectorD& auxInfo) {if(auxInfo_.GetNrows() == 0) auxInfo_.ResizeTo(auxInfo); auxInfo_ = auxInfo;}
72  void setRep(const AbsTrackRep* rep) {rep_ = rep;}
73 
74  // Shortcuts to TrackRep functions
75  double extrapolateToPlane(const SharedPlanePtr& plane,
76  bool stopAtBoundary = false,
77  bool calcJacobianNoise = false) {return rep_->extrapolateToPlane(*this, plane, stopAtBoundary, calcJacobianNoise);}
78  double extrapolateToLine(const TVector3& linePoint,
79  const TVector3& lineDirection,
80  bool stopAtBoundary = false,
81  bool calcJacobianNoise = false) {return rep_->extrapolateToLine(*this, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);}
82  double extrapolateToPoint(const TVector3& point,
83  bool stopAtBoundary = false,
84  bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, stopAtBoundary, calcJacobianNoise);}
85  double extrapolateToPoint(const TVector3& point,
86  const TMatrixDSym& G, // weight matrix (metric)
87  bool stopAtBoundary = false,
88  bool calcJacobianNoise = false) {return rep_->extrapolateToPoint(*this, point, G, stopAtBoundary, calcJacobianNoise);}
89  double extrapolateToCylinder(double radius,
90  const TVector3& linePoint = TVector3(0.,0.,0.),
91  const TVector3& lineDirection = TVector3(0.,0.,1.),
92  bool stopAtBoundary = false,
93  bool calcJacobianNoise = false) {return rep_->extrapolateToCylinder(*this, radius, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);}
94  double extrapolateToCone(double openingAngle,
95  const TVector3& conePoint = TVector3(0.,0.,0.),
96  const TVector3& coneDirection = TVector3(0.,0.,1.),
97  bool stopAtBoundary = false,
98  bool calcJacobianNoise = false) {return rep_->extrapolateToCone(*this, openingAngle, conePoint, coneDirection, stopAtBoundary, calcJacobianNoise);}
99  double extrapolateToSphere(double radius,
100  const TVector3& point = TVector3(0.,0.,0.),
101  bool stopAtBoundary = false,
102  bool calcJacobianNoise = false) {return rep_->extrapolateToSphere(*this, radius, point, stopAtBoundary, calcJacobianNoise);}
103  double extrapolateBy(double step,
104  bool stopAtBoundary = false,
105  bool calcJacobianNoise = false) {return rep_->extrapolateBy(*this, step, stopAtBoundary, calcJacobianNoise);}
106  double extrapolateToMeasurement(const AbsMeasurement* measurement,
107  bool stopAtBoundary = false,
108  bool calcJacobianNoise = false) {return rep_->extrapolateToMeasurement(*this, measurement, stopAtBoundary, calcJacobianNoise);}
109 
110 
111  TVector3 getPos() const {return rep_->getPos(*this);}
112  TVector3 getMom() const {return rep_->getMom(*this);}
113  TVector3 getDir() const {return rep_->getDir(*this);}
114  void getPosMom(TVector3& pos, TVector3& mom) const {rep_->getPosMom(*this, pos, mom);}
115  void getPosDir(TVector3& pos, TVector3& dir) const {rep_->getPosDir(*this, pos, dir);}
116  TVectorD get6DState() const {return rep_->get6DState(*this);}
117  double getMomMag() const {return rep_->getMomMag(*this);}
118  int getPDG() const {return rep_->getPDG();}
119  double getCharge() const {return rep_->getCharge(*this);}
120  double getQop() const {return rep_->getQop(*this);}
121  double getMass() const {return rep_->getMass(*this);}
122  double getTime() const {return rep_->getTime(*this);}
123 
124  void setPosMom(const TVector3& pos, const TVector3& mom) {rep_->setPosMom(*this, pos, mom);}
125  void setPosMom(const TVectorD& state6) {rep_->setPosMom(*this, state6);}
126  void setChargeSign(double charge) {rep_->setChargeSign(*this, charge);}
127  void setQop(double qop) {rep_->setQop(*this, qop);}
128  void setTime(double time) {rep_->setTime(*this, time);}
129 
130 
131  virtual void Print(Option_t* option = "") const;
132 
133  protected:
134 
135  TVectorD state_; // state vector
136  TVectorD auxInfo_; // auxiliary information (e.g. charge, flight direction etc.)
138 
139  private:
140 
143  const AbsTrackRep* rep_;
144 
145  public:
146  ClassDef(StateOnPlane,2)
147  // Version history:
148  // ver 2: no longer derives from TObject (the TObject parts were not
149  // streamed, so no compatibility issues arise.)
150 };
151 
152 
154  state_(0), auxInfo_(0), sharedPlane_(), rep_(rep)
155 {
156  if (rep != NULL) {
157  state_.ResizeTo(rep->getDim());
158  }
159 }
160 
161 inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep) :
162  state_(state), auxInfo_(0), sharedPlane_(plane), rep_(rep)
163 {
164  assert(rep != NULL);
165  assert(sharedPlane_.get() != NULL);
166 }
167 
168 inline StateOnPlane::StateOnPlane(const TVectorD& state, const SharedPlanePtr& plane, const AbsTrackRep* rep, const TVectorD& auxInfo) :
169  state_(state), auxInfo_(auxInfo), sharedPlane_(plane), rep_(rep)
170 {
171  assert(rep != NULL);
172  assert(sharedPlane_.get() != NULL);
173 }
174 
176  swap(other);
177  return *this;
178 }
179 
180 inline void StateOnPlane::swap(StateOnPlane& other) {
181  this->state_.ResizeTo(other.state_);
182  std::swap(this->state_, other.state_);
183  this->auxInfo_.ResizeTo(other.auxInfo_);
184  std::swap(this->auxInfo_, other.auxInfo_);
185  this->sharedPlane_.swap(other.sharedPlane_);
186  std::swap(this->rep_, other.rep_);
187 }
188 
189 } /* End of namespace genfit */
192 #endif // genfit_StateOnPlane_h
TVector3 getDir(const StateOnPlane &state) const
Get the direction vector of a state.
Definition: AbsTrackRep.h:246
void setPosMom(const TVector3 &pos, const TVector3 &mom)
Definition: StateOnPlane.h:124
const AbsTrackRep * getRep() const
Definition: StateOnPlane.h:66
void setQop(double qop)
Definition: StateOnPlane.h:127
TVector3 getDir() const
Definition: StateOnPlane.h:113
Contains the measurement and covariance in raw detector coordinates.
void setState(const TVectorD &state)
Definition: StateOnPlane.h:68
void setStatePlane(const TVectorD &state, const SharedPlanePtr &plane)
Definition: StateOnPlane.h:70
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...
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
double getCharge() const
Definition: StateOnPlane.h:119
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, via reference, the extrapolated state.
double getMass(const StateOnPlane &state) const
Get tha particle mass in GeV/c^2.
Definition: AbsTrackRep.cc:100
double extrapolateToMeasurement(StateOnPlane &state, const AbsMeasurement *measurement, bool stopAtBoundary=false, bool calcJacobianNoise=false) const
extrapolate to an AbsMeasurement
Definition: AbsTrackRep.cc:50
virtual TVector3 getMom(const StateOnPlane &state) const =0
Get the cartesian momentum vector of a state.
const TVectorD & getState() const
Definition: StateOnPlane.h:61
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...
double extrapolateToLine(const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:78
StateOnPlane & operator=(StateOnPlane other)
Definition: StateOnPlane.h:175
virtual void Print(Option_t *option="") const
Definition: StateOnPlane.cc:30
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.
double extrapolateToPoint(const TVector3 &point, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:82
const TVectorD & getAuxInfo() const
Definition: StateOnPlane.h:63
double getQop() const
Definition: StateOnPlane.h:120
void setAuxInfo(const TVectorD &auxInfo)
Definition: StateOnPlane.h:71
void setPlane(const SharedPlanePtr &plane)
Definition: StateOnPlane.h:69
virtual void setPosMom(StateOnPlane &state, const TVector3 &pos, const TVector3 &mom) const =0
Set position and momentum of state.
void getPosDir(const StateOnPlane &state, TVector3 &pos, TVector3 &dir) const
Get cartesian position and direction vector of a state.
Definition: AbsTrackRep.h:252
virtual double getTime(const StateOnPlane &) const =0
Get the time corresponding to the StateOnPlane. Extrapolation.
double extrapolateBy(double step, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:103
StateOnPlane(const AbsTrackRep *rep=NULL)
Definition: StateOnPlane.h:153
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...
double extrapolateToMeasurement(const AbsMeasurement *measurement, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:106
void setRep(const AbsTrackRep *rep)
Definition: StateOnPlane.h:72
double extrapolateToPoint(const TVector3 &point, const TMatrixDSym &G, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:85
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 TVector3 getPos(const StateOnPlane &state) const =0
Get the cartesian position of a state.
virtual void setTime(StateOnPlane &state, double time) const =0
Set time at which the state was defined.
double getMass() const
Definition: StateOnPlane.h:121
void swap(StateOnPlane &other)
Definition: StateOnPlane.h:180
double getMomMag() const
Definition: StateOnPlane.h:117
const AbsTrackRep * rep_
Shared ownership. '!' in order to silence ROOT, custom streamer writes and reads this.
Definition: StateOnPlane.h:143
void setChargeSign(double charge)
Definition: StateOnPlane.h:126
TVectorD & getAuxInfo()
Definition: StateOnPlane.h:64
virtual void setQop(StateOnPlane &state, double qop) const =0
Set charge/momentum.
Abstract base class for a track representation.
Definition: AbsTrackRep.h:66
virtual void getPosMom(const StateOnPlane &state, TVector3 &pos, TVector3 &mom) const =0
Get cartesian position and momentum vector of a state.
void getPosMom(TVector3 &pos, TVector3 &mom) const
Definition: StateOnPlane.h:114
TVector3 getPos() const
Definition: StateOnPlane.h:111
TVectorD get6DState() const
Definition: StateOnPlane.h:116
virtual StateOnPlane * clone() const
Definition: StateOnPlane.h:59
double extrapolateToCone(double openingAngle, const TVector3 &conePoint=TVector3(0., 0., 0.), const TVector3 &coneDirection=TVector3(0., 0., 1.), bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:94
void setTime(double time)
Definition: StateOnPlane.h:128
void getPosDir(TVector3 &pos, TVector3 &dir) const
Definition: StateOnPlane.h:115
double extrapolateToPlane(const SharedPlanePtr &plane, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:75
virtual ~StateOnPlane()
Definition: StateOnPlane.h:58
const SharedPlanePtr & getPlane() const
Definition: StateOnPlane.h:65
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:45
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 getMomMag(const StateOnPlane &state) const =0
get the magnitude of the momentum in GeV.
double getTime() const
Definition: StateOnPlane.h:122
int getPDG() const
Definition: StateOnPlane.h:118
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:89
double extrapolateToSphere(double radius, const TVector3 &point=TVector3(0., 0., 0.), bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:99
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 getQop(const StateOnPlane &state) const =0
Get charge over momentum.
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:125
int getPDG() const
Get the pdg code.
Definition: AbsTrackRep.h:272
SharedPlanePtr sharedPlane_
Definition: StateOnPlane.h:137
TVectorD & getState()
Definition: StateOnPlane.h:62
virtual void setChargeSign(StateOnPlane &state, double charge) const =0
Set the sign of the charge according to charge.
Defines for I/O streams used for error and debug printing.
virtual unsigned int getDim() const =0
Get the dimension of the state vector used by the track representation.
TVector3 getMom() const
Definition: StateOnPlane.h:112