PandaRoot
StateOnPlane.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /* Copyright 2008-2010, Technische Universitaet Muenchen,
14  Authors: Christian Hoeppner & Sebastian Neubert & Johannes Rauch
15 
16  This file is part of GENFIT.
17 
18  GENFIT is free software: you can redistribute it and/or modify
19  it under the terms of the GNU Lesser General Public License as published
20  by the Free Software Foundation, either version 3 of the License, or
21  (at your option) any later version.
22 
23  GENFIT is distributed in the hope that it will be useful,
24  but WITHOUT ANY WARRANTY; without even the implied warranty of
25  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26  GNU Lesser General Public License for more details.
27 
28  You should have received a copy of the GNU Lesser General Public License
29  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
30 */
31 
36 #ifndef genfit_StateOnPlane_h
37 #define genfit_StateOnPlane_h
38 
39 #include "SharedPlanePtr.h"
40 #include "AbsTrackRep.h"
41 
42 #include <TObject.h>
43 #include <TVectorD.h>
44 
45 namespace genfit {
46 
56 class StateOnPlane {
57 
58  public:
59  StateOnPlane(const AbsTrackRep *rep = nullptr);
61  StateOnPlane(const TVectorD &state, const SharedPlanePtr &plane, const AbsTrackRep *rep);
62  StateOnPlane(const TVectorD &state, const SharedPlanePtr &plane, const AbsTrackRep *rep, const TVectorD &auxInfo);
63 
65  void swap(StateOnPlane &other); // nothrow
66 
67  virtual ~StateOnPlane() {}
68 
69  const TVectorD &getState() const { return state_; }
70  TVectorD &getState() { return state_; }
71  const TVectorD &getAuxInfo() const { return auxInfo_; }
72  TVectorD &getAuxInfo() { return auxInfo_; }
73  const SharedPlanePtr &getPlane() const { return sharedPlane_; }
74  const AbsTrackRep *getRep() const { return rep_; }
75 
76  void setState(const TVectorD &state)
77  {
78  if (state_.GetNrows() == 0)
79  state_.ResizeTo(state);
80  state_ = state;
81  }
82  void setPlane(const SharedPlanePtr &plane) { sharedPlane_ = plane; }
83  void setStatePlane(const TVectorD &state, const SharedPlanePtr &plane)
84  {
85  state_ = state;
86  sharedPlane_ = plane;
87  }
88  void setAuxInfo(const TVectorD &auxInfo)
89  {
90  if (auxInfo_.GetNrows() == 0)
91  auxInfo_.ResizeTo(auxInfo);
92  auxInfo_ = auxInfo;
93  }
94  void setRep(const AbsTrackRep *rep) { rep_ = rep; }
95 
96  // Shortcuts to TrackRep functions
97  double extrapolateToPlane(const SharedPlanePtr &plane, bool stopAtBoundary = false, bool calcJacobianNoise = false)
98  {
99  return rep_->extrapolateToPlane(*this, plane, stopAtBoundary, calcJacobianNoise);
100  }
101  double extrapolateToLine(const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary = false, bool calcJacobianNoise = false)
102  {
103  return rep_->extrapolateToLine(*this, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);
104  }
105  double extrapolateToPoint(const TVector3 &point, bool stopAtBoundary = false, bool calcJacobianNoise = false)
106  {
107  return rep_->extrapolateToPoint(*this, point, stopAtBoundary, calcJacobianNoise);
108  }
109  double extrapolateToPoint(const TVector3 &point,
110  const TMatrixDSym &G, // weight matrix (metric)
111  bool stopAtBoundary = false, bool calcJacobianNoise = false)
112  {
113  return rep_->extrapolateToPoint(*this, point, G, stopAtBoundary, calcJacobianNoise);
114  }
115  double extrapolateToCylinder(double radius, const TVector3 &linePoint = TVector3(0., 0., 0.), const TVector3 &lineDirection = TVector3(0., 0., 1.), bool stopAtBoundary = false,
116  bool calcJacobianNoise = false)
117  {
118  return rep_->extrapolateToCylinder(*this, radius, linePoint, lineDirection, stopAtBoundary, calcJacobianNoise);
119  }
120  double extrapolateToSphere(double radius, const TVector3 &point = TVector3(0., 0., 0.), bool stopAtBoundary = false, bool calcJacobianNoise = false)
121  {
122  return rep_->extrapolateToSphere(*this, radius, point, stopAtBoundary, calcJacobianNoise);
123  }
124  double extrapolateBy(double step, bool stopAtBoundary = false, bool calcJacobianNoise = false) { return rep_->extrapolateBy(*this, step, stopAtBoundary, calcJacobianNoise); }
125  double extrapolateToMeasurement(const AbsMeasurement *measurement, bool stopAtBoundary = false, bool calcJacobianNoise = false)
126  {
127  return rep_->extrapolateToMeasurement(*this, measurement, stopAtBoundary, calcJacobianNoise);
128  }
129 
130  TVector3 getPos() const { return rep_->getPos(*this); }
131  TVector3 getMom() const { return rep_->getMom(*this); }
132  TVector3 getDir() const { return rep_->getDir(*this); }
133  void getPosMom(TVector3 &pos, TVector3 &mom) const { rep_->getPosMom(*this, pos, mom); }
134  void getPosDir(TVector3 &pos, TVector3 &dir) const { rep_->getPosDir(*this, pos, dir); }
135  TVectorD get6DState() const { return rep_->get6DState(*this); }
136  double getMomMag() const { return rep_->getMomMag(*this); }
137  int getPDG() const { return rep_->getPDG(); }
138  double getCharge() const { return rep_->getCharge(*this); }
139  double getQop() const { return rep_->getQop(*this); }
140  double getMass() const { return rep_->getMass(*this); }
141  double getTime() const { return rep_->getTime(*this); }
142 
143  void setPosMom(const TVector3 &pos, const TVector3 &mom) { rep_->setPosMom(*this, pos, mom); }
144  void setPosMom(const TVectorD &state6) { rep_->setPosMom(*this, state6); }
145  void setChargeSign(double charge) { rep_->setChargeSign(*this, charge); }
146  void setQop(double qop) { rep_->setQop(*this, qop); }
147  void setTime(double time) { rep_->setTime(*this, time); }
148 
149  virtual void Print(Option_t *option = "") const;
150 
151  protected:
152  TVectorD state_; // state vector
153  TVectorD auxInfo_; // auxiliary information (e.g. charge, flight direction etc.)
155 
156  private:
159  const AbsTrackRep *rep_;
160 
161  public:
162  ClassDef(StateOnPlane, 2)
163  // Version history:
164  // ver 2: no longer derives from TObject (the TObject parts were not
165  // streamed, so no compatibility issues arise.)
166 };
167 
168 inline StateOnPlane::StateOnPlane(const AbsTrackRep *rep) : state_(0), auxInfo_(0), sharedPlane_(), rep_(rep)
169 {
170  if (rep != nullptr) {
171  state_.ResizeTo(rep->getDim());
172  }
173 }
174 
175 inline StateOnPlane::StateOnPlane(const TVectorD &state, const SharedPlanePtr &plane, const AbsTrackRep *rep) : state_(state), auxInfo_(0), sharedPlane_(plane), rep_(rep)
176 {
177  assert(rep != nullptr);
178  assert(sharedPlane_.get() != nullptr);
179 }
180 
181 inline StateOnPlane::StateOnPlane(const TVectorD &state, const SharedPlanePtr &plane, const AbsTrackRep *rep, const TVectorD &auxInfo)
182  : state_(state), auxInfo_(auxInfo), sharedPlane_(plane), rep_(rep)
183 {
184  assert(rep != nullptr);
185  assert(sharedPlane_.get() != nullptr);
186 }
187 
189 {
190  swap(other);
191  return *this;
192 }
193 
194 inline void StateOnPlane::swap(StateOnPlane &other)
195 {
196  this->state_.ResizeTo(other.state_);
197  std::swap(this->state_, other.state_);
198  this->auxInfo_.ResizeTo(other.auxInfo_);
199  std::swap(this->auxInfo_, other.auxInfo_);
200  this->sharedPlane_.swap(other.sharedPlane_);
201  std::swap(this->rep_, other.rep_);
202 }
203 
204 } /* End of namespace genfit */
207 #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:69
TVector3 getMom() const
Definition: StateOnPlane.h:131
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:115
double getMomMag() const
Definition: StateOnPlane.h:136
double getCharge() const
Definition: StateOnPlane.h:138
void getPosDir(const StateOnPlane &state, TVector3 &pos, TVector3 &dir) const
Get cartesian position and direction vector of a state.
Definition: AbsTrackRep.h:213
double extrapolateToPlane(const SharedPlanePtr &plane, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:97
TVectorD & getAuxInfo()
Definition: StateOnPlane.h:72
double extrapolateBy(double step, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:124
TVectorD & getState()
Definition: StateOnPlane.h:70
double extrapolateToSphere(double radius, const TVector3 &point=TVector3(0., 0., 0.), bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:120
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:145
StateOnPlane & operator=(StateOnPlane other)
Definition: StateOnPlane.h:188
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:74
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:125
void setState(const TVectorD &state)
Definition: StateOnPlane.h:76
void setStatePlane(const TVectorD &state, const SharedPlanePtr &plane)
Definition: StateOnPlane.h:83
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:130
double getTime() const
Definition: StateOnPlane.h:141
virtual double getTime(const StateOnPlane &) const =0
Get the time corresponding to the StateOnPlane. Extrapolation.
TVectorD get6DState() const
Definition: StateOnPlane.h:135
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:143
virtual void Print(Option_t *option="") const
const TVectorD & getAuxInfo() const
Definition: StateOnPlane.h:71
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:56
StateOnPlane(const AbsTrackRep *rep=nullptr)
Definition: StateOnPlane.h:168
virtual ~StateOnPlane()
Definition: StateOnPlane.h:67
void swap(StateOnPlane &other)
Definition: StateOnPlane.h:194
double extrapolateToPoint(const TVector3 &point, const TMatrixDSym &G, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:109
double getQop() const
Definition: StateOnPlane.h:139
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:74
double getMass() const
Definition: StateOnPlane.h:140
void setPosMom(const TVectorD &state6)
Definition: StateOnPlane.h:144
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:146
TVector3 getDir() const
Definition: StateOnPlane.h:132
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:237
void setPlane(const SharedPlanePtr &plane)
Definition: StateOnPlane.h:82
double extrapolateToLine(const TVector3 &linePoint, const TVector3 &lineDirection, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:101
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:207
void setRep(const AbsTrackRep *rep)
Definition: StateOnPlane.h:94
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:147
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:134
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:88
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:40
double extrapolateToPoint(const TVector3 &point, bool stopAtBoundary=false, bool calcJacobianNoise=false)
Definition: StateOnPlane.h:105
const SharedPlanePtr & getPlane() const
Definition: StateOnPlane.h:73
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:133
SharedPlanePtr sharedPlane_
Definition: StateOnPlane.h:154