PandaRoot
MeasuredStateOnPlane.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_MeasuredStateOnPlane_h
25 #define genfit_MeasuredStateOnPlane_h
26 
27 #include "StateOnPlane.h"
28 #include "AbsTrackRep.h"
29 
30 #include <TMatrixDSym.h>
31 
32 namespace genfit {
33 
38 
39  public:
40  MeasuredStateOnPlane(const AbsTrackRep *rep = nullptr);
41  MeasuredStateOnPlane(const TVectorD &state, const TMatrixDSym &cov, const genfit::SharedPlanePtr &plane, const AbsTrackRep *rep);
42  MeasuredStateOnPlane(const TVectorD &state, const TMatrixDSym &cov, const genfit::SharedPlanePtr &plane, const AbsTrackRep *rep, const TVectorD &auxInfo);
44  MeasuredStateOnPlane(const StateOnPlane &state, const TMatrixDSym &cov);
45 
47  void swap(MeasuredStateOnPlane &other); // nothrow
48 
49  virtual ~MeasuredStateOnPlane() {}
50 
51  const TMatrixDSym &getCov() const { return cov_; }
52  TMatrixDSym &getCov() { return cov_; }
53 
55  void blowUpCov(double blowUpFac, bool resetOffDiagonals = true, double maxVal = -1.);
56 
57  void setStateCov(const TVectorD &state, const TMatrixDSym &cov)
58  {
59  setState(state);
60  setCov(cov);
61  }
62  void setStateCovPlane(const TVectorD &state, const TMatrixDSym &cov, const SharedPlanePtr &plane)
63  {
64  setStatePlane(state, plane);
65  setCov(cov);
66  }
67  void setCov(const TMatrixDSym &cov)
68  {
69  if (cov_.GetNrows() == 0)
70  cov_.ResizeTo(cov);
71  cov_ = cov;
72  }
73 
74  // Shortcuts to TrackRep functions
75  TMatrixDSym get6DCov() const { return getRep()->get6DCov(*this); };
76  void getPosMomCov(TVector3 &pos, TVector3 &mom, TMatrixDSym &cov) const { getRep()->getPosMomCov(*this, pos, mom, cov); }
77  void get6DStateCov(TVectorD &stateVec, TMatrixDSym &cov) const { getRep()->get6DStateCov(*this, stateVec, cov); }
78  double getMomVar() const { return getRep()->getMomVar(*this); }
79 
80  void setPosMomErr(const TVector3 &pos, const TVector3 &mom, const TVector3 &posErr, const TVector3 &momErr) { getRep()->setPosMomErr(*this, pos, mom, posErr, momErr); }
81  void setPosMomCov(const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6) { getRep()->setPosMomCov(*this, pos, mom, cov6x6); }
82  void setPosMomCov(const TVectorD &state6, const TMatrixDSym &cov6x6) { getRep()->setPosMomCov(*this, state6, cov6x6); }
83 
84  virtual void Print(Option_t *option = "") const;
85 
86  protected:
87  TMatrixDSym cov_;
88 
89  public:
90  ClassDef(MeasuredStateOnPlane, 1)
91 };
92 
96 MeasuredStateOnPlane calcAverageState(const MeasuredStateOnPlane &forwardState, const MeasuredStateOnPlane &backwardState);
97 
99 {
100  StateOnPlane::swap(other);
101  this->cov_.ResizeTo(other.cov_);
102  std::swap(this->cov_, other.cov_);
103 }
104 
106 {
107  if (rep != nullptr) {
108  cov_.ResizeTo(rep->getDim(), rep->getDim());
109  }
110 }
111 
112 inline MeasuredStateOnPlane::MeasuredStateOnPlane(const TVectorD &state, const TMatrixDSym &cov, const SharedPlanePtr &plane, const AbsTrackRep *rep)
113  : StateOnPlane(state, plane, rep), cov_(cov)
114 {
115  assert(rep != nullptr);
116  // assert(cov_.GetNcols() == (signed)rep->getDim());
117 }
118 
119 inline MeasuredStateOnPlane::MeasuredStateOnPlane(const TVectorD &state, const TMatrixDSym &cov, const SharedPlanePtr &plane, const AbsTrackRep *rep, const TVectorD &auxInfo)
120  : StateOnPlane(state, plane, rep, auxInfo), cov_(cov)
121 {
122  assert(rep != nullptr);
123  // assert(cov_.GetNcols() == (signed)rep->getDim());
124 }
125 
127 
128 inline MeasuredStateOnPlane::MeasuredStateOnPlane(const StateOnPlane &state, const TMatrixDSym &cov) : StateOnPlane(state), cov_(cov)
129 {
130  // assert(cov_.GetNcols() == (signed)getRep()->getDim());
131 }
132 
134 {
135  swap(other);
136  return *this;
137 }
138 
139 } /* End of namespace genfit */
142 #endif // genfit_MeasuredStateOnPlane_h
void setPosMomCov(const TVectorD &state6, const TMatrixDSym &cov6x6)
void swap(MeasuredStateOnPlane &other)
void setPosMomErr(const TVector3 &pos, const TVector3 &mom, const TVector3 &posErr, const TVector3 &momErr)
void setStateCovPlane(const TVectorD &state, const TMatrixDSym &cov, const SharedPlanePtr &plane)
MeasuredStateOnPlane(const AbsTrackRep *rep=nullptr)
virtual unsigned int getDim() const =0
Get the dimension of the state vector used by the track representation.
Abstract base class for a track representation.
Definition: AbsTrackRep.h:62
StateOnPlane with additional covariance matrix.
void setPosMomCov(const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6)
void setState(const TVectorD &state)
Definition: StateOnPlane.h:64
void setStatePlane(const TVectorD &state, const SharedPlanePtr &plane)
Definition: StateOnPlane.h:71
virtual void getPosMomCov(const MeasuredStateOnPlane &state, TVector3 &pos, TVector3 &mom, TMatrixDSym &cov) const =0
Translates MeasuredStateOnPlane into 3D position, momentum and 6x6 covariance.
void setStateCov(const TVectorD &state, const TMatrixDSym &cov)
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:44
virtual void setPosMomErr(MeasuredStateOnPlane &state, const TVector3 &pos, const TVector3 &mom, const TVector3 &posErr, const TVector3 &momErr) const =0
Set position and momentum and error of state.
MeasuredStateOnPlane calcAverageState(const MeasuredStateOnPlane &forwardState, const MeasuredStateOnPlane &backwardState)
Calculate weighted average between two MeasuredStateOnPlanes.
void blowUpCov(double blowUpFac, bool resetOffDiagonals=true, double maxVal=-1.)
Blow up covariance matrix with blowUpFac. Per default, off diagonals are reset to 0 and the maximum v...
void swap(StateOnPlane &other)
Definition: StateOnPlane.h:182
const AbsTrackRep * getRep() const
Definition: StateOnPlane.h:62
void setCov(const TMatrixDSym &cov)
virtual void setPosMomCov(MeasuredStateOnPlane &state, const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6) const =0
Set position, momentum and covariance of state.
MeasuredStateOnPlane & operator=(MeasuredStateOnPlane other)
boost::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
virtual void Print(Option_t *option="") const
virtual double getMomVar(const MeasuredStateOnPlane &state) const =0
get the variance of the absolute value of the momentum .
void get6DStateCov(TVectorD &stateVec, TMatrixDSym &cov) const
void getPosMomCov(TVector3 &pos, TVector3 &mom, TMatrixDSym &cov) const
const TMatrixDSym & getCov() const
virtual TMatrixDSym get6DCov(const MeasuredStateOnPlane &state) const =0
Get the 6D covariance.
virtual void get6DStateCov(const MeasuredStateOnPlane &state, TVectorD &stateVec, TMatrixDSym &cov) const
Translates MeasuredStateOnPlane into 6D state vector (x, y, z, p_x, p_y, p_z) and 6x6 covariance...
Matrix inversion tools.
Definition: AbsBField.h:28