PandaRoot
MeasuredStateOnPlane.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_MeasuredStateOnPlane_h
37 #define genfit_MeasuredStateOnPlane_h
38 
39 #include "StateOnPlane.h"
40 #include "AbsTrackRep.h"
41 
42 #include <TMatrixDSym.h>
43 
44 namespace genfit {
45 
50 
51  public:
52  MeasuredStateOnPlane(const AbsTrackRep *rep = nullptr);
53  MeasuredStateOnPlane(const TVectorD &state, const TMatrixDSym &cov, const genfit::SharedPlanePtr &plane, const AbsTrackRep *rep);
54  MeasuredStateOnPlane(const TVectorD &state, const TMatrixDSym &cov, const genfit::SharedPlanePtr &plane, const AbsTrackRep *rep, const TVectorD &auxInfo);
56  MeasuredStateOnPlane(const StateOnPlane &state, const TMatrixDSym &cov);
57 
59  void swap(MeasuredStateOnPlane &other); // nothrow
60 
61  virtual ~MeasuredStateOnPlane() {}
62 
63  const TMatrixDSym &getCov() const { return cov_; }
64  TMatrixDSym &getCov() { return cov_; }
65 
67  void blowUpCov(double blowUpFac, bool resetOffDiagonals = true, double maxVal = -1.);
68 
69  void setStateCov(const TVectorD &state, const TMatrixDSym &cov)
70  {
71  setState(state);
72  setCov(cov);
73  }
74  void setStateCovPlane(const TVectorD &state, const TMatrixDSym &cov, const SharedPlanePtr &plane)
75  {
76  setStatePlane(state, plane);
77  setCov(cov);
78  }
79  void setCov(const TMatrixDSym &cov)
80  {
81  if (cov_.GetNrows() == 0)
82  cov_.ResizeTo(cov);
83  cov_ = cov;
84  }
85 
86  // Shortcuts to TrackRep functions
87  TMatrixDSym get6DCov() const { return getRep()->get6DCov(*this); };
88  void getPosMomCov(TVector3 &pos, TVector3 &mom, TMatrixDSym &cov) const { getRep()->getPosMomCov(*this, pos, mom, cov); }
89  void get6DStateCov(TVectorD &stateVec, TMatrixDSym &cov) const { getRep()->get6DStateCov(*this, stateVec, cov); }
90  double getMomVar() const { return getRep()->getMomVar(*this); }
91 
92  void setPosMomErr(const TVector3 &pos, const TVector3 &mom, const TVector3 &posErr, const TVector3 &momErr) { getRep()->setPosMomErr(*this, pos, mom, posErr, momErr); }
93  void setPosMomCov(const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6) { getRep()->setPosMomCov(*this, pos, mom, cov6x6); }
94  void setPosMomCov(const TVectorD &state6, const TMatrixDSym &cov6x6) { getRep()->setPosMomCov(*this, state6, cov6x6); }
95 
96  virtual void Print(Option_t *option = "") const;
97 
98  protected:
99  TMatrixDSym cov_;
100 
101  public:
102  ClassDef(MeasuredStateOnPlane, 1)
103 };
104 
108 MeasuredStateOnPlane calcAverageState(const MeasuredStateOnPlane &forwardState, const MeasuredStateOnPlane &backwardState);
109 
111 {
112  StateOnPlane::swap(other);
113  this->cov_.ResizeTo(other.cov_);
114  std::swap(this->cov_, other.cov_);
115 }
116 
118 {
119  if (rep != nullptr) {
120  cov_.ResizeTo(rep->getDim(), rep->getDim());
121  }
122 }
123 
124 inline MeasuredStateOnPlane::MeasuredStateOnPlane(const TVectorD &state, const TMatrixDSym &cov, const SharedPlanePtr &plane, const AbsTrackRep *rep)
125  : StateOnPlane(state, plane, rep), cov_(cov)
126 {
127  assert(rep != nullptr);
128  // assert(cov_.GetNcols() == (signed)rep->getDim());
129 }
130 
131 inline MeasuredStateOnPlane::MeasuredStateOnPlane(const TVectorD &state, const TMatrixDSym &cov, const SharedPlanePtr &plane, const AbsTrackRep *rep, const TVectorD &auxInfo)
132  : StateOnPlane(state, plane, rep, auxInfo), cov_(cov)
133 {
134  assert(rep != nullptr);
135  // assert(cov_.GetNcols() == (signed)rep->getDim());
136 }
137 
139 
140 inline MeasuredStateOnPlane::MeasuredStateOnPlane(const StateOnPlane &state, const TMatrixDSym &cov) : StateOnPlane(state), cov_(cov)
141 {
142  // assert(cov_.GetNcols() == (signed)getRep()->getDim());
143 }
144 
146 {
147  swap(other);
148  return *this;
149 }
150 
151 } /* End of namespace genfit */
154 #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:74
StateOnPlane with additional covariance matrix.
void setPosMomCov(const TVector3 &pos, const TVector3 &mom, const TMatrixDSym &cov6x6)
void setState(const TVectorD &state)
Definition: StateOnPlane.h:76
void setStatePlane(const TVectorD &state, const SharedPlanePtr &plane)
Definition: StateOnPlane.h:83
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:56
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:194
const AbsTrackRep * getRep() const
Definition: StateOnPlane.h:74
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:40