CMS 3D CMS Logo

GaussianSumUtilities.h
Go to the documentation of this file.
1 #ifndef GaussianSumUtilities_h_
2 #define GaussianSumUtilities_h_
3 
7 #include <vector>
8 
14 template <unsigned int N>
16 public:
19 // typedef ROOT::Math::SVector<double, N> Vector;
20  typedef ROOT::Math::SMatrix<double,N,N,ROOT::Math::MatRepStd<double,N> > GenMatrix;
21 
22  typedef typename SingleState::Vector Vector;
23  typedef typename SingleState::Matrix Matrix;
26 
27 private:
29 
30 public:
32  theState(state),
34  }
36  }
37 
39  inline unsigned int size () const {
40  return components().size();
41  }
43  const SingleStateContainer& components () const {
44  return theState.components();
45  }
47  const MultiState& state () const {
48  return theState;
49  }
51  inline double weight (unsigned int i) const {
52  return components()[i]->weight();
53  }
55  inline const Vector& mean (unsigned int i) const {
56  return components()[i]->mean();
57  }
59  inline const Matrix& covariance (unsigned int i) const {
60  return components()[i]->covariance();
61  }
63  bool modeIsValid () const;
66  const SingleGaussianState<N>& mode () const;
68  double pdf (const Vector&) const;
70  Vector d1Pdf (const Vector&) const;
72  Matrix d2Pdf (const Vector&) const;
74  double lnPdf (const Vector&) const;
76  Vector d1LnPdf (const Vector&) const;
78  Matrix d2LnPdf (const Vector&) const;
79 
81  double weight () const {
82  return theState.weight();
83  }
85  const Vector& mean () const {
86  return theState.mean();
87  }
89  const Matrix& covariance () const {
90  return theState.covariance();
91  }
92 
93 
94 protected:
97 
98 private:
100  Matrix tensorProduct (const Vector&) const;
102  double gauss (const double&, const double&, const double&) const;
104  double gauss (const Vector&,
105  const Vector&,
106  const Matrix&) const;
108  bool findMode (Vector& mode, double& pdfAtMode,
109  const Vector& xStart) const;
111  void computeMode () const;
114  const Vector& x0) const;
115 // /// replacement of CLHEP determinant (which rounds off small values)
116 // double determinant (const Matrix& matrix) const;
119  Matrix localCovariance (const Vector& x) const;
121  void setMode (const Vector& mode) const;
123  void setInvalidMode () const;
124 
126  std::vector<double> pdfComponents (const Vector&) const;
128  double pdf (const Vector&, const std::vector<double>&) const;
130  Vector d1Pdf (const Vector&, const std::vector<double>&) const;
132  Matrix d2Pdf (const Vector&, const std::vector<double>&) const;
134  double lnPdf (const Vector&, const std::vector<double>&) const;
136  Vector d1LnPdf (const Vector&, const std::vector<double>&) const;
138  Matrix d2LnPdf (const Vector&, const std::vector<double>&) const;
139 
140 
141 
142 private:
144 // int theDimension;
145 
147 // mutable Vector theMode;
149 
150 };
151 
152 #include "TrackingTools/GsfTools/interface/GaussianSumUtilities.icc"
153 
154 #endif
GaussianSumUtilities::size
unsigned int size() const
number of components
Definition: GaussianSumUtilities.h:39
GaussianSumUtilities::theMode
SingleGaussianState< N > theMode
Definition: GaussianSumUtilities.h:148
GaussianSumUtilities::tensorProduct
Matrix tensorProduct(const Vector &) const
Symmetric Tensor Product (not recognized by standard ROOT Math)
mps_fire.i
i
Definition: mps_fire.py:355
GaussianSumUtilities::SingleState
SingleGaussianState< N > SingleState
Definition: GaussianSumUtilities.h:17
GaussianSumUtilities::GenMatrix
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepStd< double, N > > GenMatrix
Definition: GaussianSumUtilities.h:20
GaussianSumUtilities::NotComputed
Definition: GaussianSumUtilities.h:28
GaussianSumUtilities::weight
double weight() const
combined weight
Definition: GaussianSumUtilities.h:81
GaussianSumUtilities::setInvalidMode
void setInvalidMode() const
set mode "state" in case of failure
MultiGaussianState.h
GaussianSumUtilities::pdfComponents
std::vector< double > pdfComponents(const Vector &) const
pdf components
GaussianSumUtilities::weight
double weight(unsigned int i) const
weight of a component
Definition: GaussianSumUtilities.h:51
MultiGaussianState
Mixture of multi-variate gaussian states.
Definition: MultiGaussianState.h:18
GaussianSumUtilities::constrainedState
MultiGaussianState1D constrainedState(const Vector &d, const Vector &x0) const
state constrained to a line x = s*d+x0
GaussianSumUtilities::lnPdf
double lnPdf(const Vector &) const
value of ln(pdf)
GaussianSumUtilities::theModeStatus
ModeStatus theModeStatus
Definition: GaussianSumUtilities.h:146
GaussianSumUtilities::computeMode
void computeMode() const
calculation of mode with transformation of pdf
DDAxes::x
GaussianSumUtilities::modeIsValid
bool modeIsValid() const
mode status
GaussianSumUtilities::components
const SingleStateContainer & components() const
components
Definition: GaussianSumUtilities.h:43
GaussianSumUtilities::computeModeWithoutTransform
Vector computeModeWithoutTransform() const
calculation of mode
Vector
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
MultiGaussianState1D.h
GaussianSumUtilities::GaussianSumUtilities
GaussianSumUtilities(const MultiState &state)
Definition: GaussianSumUtilities.h:31
GaussianSumUtilities::Matrix
SingleState::Matrix Matrix
Definition: GaussianSumUtilities.h:23
GaussianSumUtilities::~GaussianSumUtilities
~GaussianSumUtilities()
Definition: GaussianSumUtilities.h:35
GaussianSumUtilities::d2LnPdf
Matrix d2LnPdf(const Vector &) const
Hessian of ln(pdf)
GaussianSumUtilities::SingleStateContainer
MultiState::SingleStateContainer SingleStateContainer
Definition: GaussianSumUtilities.h:25
GaussianSumUtilities::SingleStatePtr
MultiState::SingleStatePtr SingleStatePtr
Definition: GaussianSumUtilities.h:24
GaussianSumUtilities::d1Pdf
Vector d1Pdf(const Vector &) const
gradient
GaussianSumUtilities::mode
const SingleGaussianState< N > & mode() const
GaussianSumUtilities::pdf
double pdf(const Vector &) const
value of the p.d.f.
MultiGaussianState1D
Definition: MultiGaussianState1D.h:12
GaussianSumUtilities::setMode
void setMode(const Vector &mode) const
set mode "state" from solution of mode finding
SingleGaussianState::Matrix
ROOT::Math::SMatrix< double, N, N, ROOT::Math::MatRepSym< double, N > > Matrix
Definition: SingleGaussianState.h:17
GaussianSumUtilities::mean
const Vector & mean(unsigned int i) const
mean value of a component
Definition: GaussianSumUtilities.h:55
GaussianSumUtilities::NotValid
Definition: GaussianSumUtilities.h:28
GaussianSumUtilities::d2Pdf
Matrix d2Pdf(const Vector &) const
Hessian.
SingleGaussianState
Definition: SingleGaussianState.h:14
MultiGaussianState::SingleStatePtr
std::shared_ptr< SingleState > SingleStatePtr
Definition: MultiGaussianState.h:23
GaussianSumUtilities::ModeStatus
ModeStatus
Definition: GaussianSumUtilities.h:28
SingleGaussianState::Vector
ROOT::Math::SVector< double, N > Vector
Definition: SingleGaussianState.h:16
GaussianSumUtilities::theState
const MultiState & theState
Definition: GaussianSumUtilities.h:143
GaussianSumUtilities::Vector
SingleState::Vector Vector
Definition: GaussianSumUtilities.h:22
GaussianSumUtilities::MultiState
MultiGaussianState< N > MultiState
Definition: GaussianSumUtilities.h:18
GaussianSumUtilities::d1LnPdf
Vector d1LnPdf(const Vector &) const
gradient of ln(pdf)
GaussianSumUtilities::covariance
const Matrix & covariance() const
combined covariance
Definition: GaussianSumUtilities.h:89
MultiGaussianState::SingleStateContainer
std::vector< SingleStatePtr > SingleStateContainer
Definition: MultiGaussianState.h:25
GaussianSumUtilities::mean
const Vector & mean() const
combined mean
Definition: GaussianSumUtilities.h:85
GaussianSumUtilities::localCovariance
Matrix localCovariance(const Vector &x) const
ztail.d
d
Definition: ztail.py:151
GaussianSumUtilities
Definition: GaussianSumUtilities.h:15
GaussianSumUtilities::gauss
double gauss(const double &, const double &, const double &) const
value of gaussian distribution
SingleGaussianState.h
GaussianSumUtilities::Valid
Definition: GaussianSumUtilities.h:28
GaussianSumUtilities::covariance
const Matrix & covariance(unsigned int i) const
covariance matrix of a component
Definition: GaussianSumUtilities.h:59
GaussianSumUtilities::findMode
bool findMode(Vector &mode, double &pdfAtMode, const Vector &xStart) const
mode from starting value in ln(pdf); returns true on success
GaussianSumUtilities::state
const MultiState & state() const
multi-state
Definition: GaussianSumUtilities.h:47