SynAPSE  0.6.0
Synergistic Analysis of Phase Space Evolution
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
ProbabilityContour.hh
1 #ifndef PROBABILITYCONTOUR_HH
2 #define PROBABILITYCONTOUR_HH
3 
4 // C++ includes
5 #include <iostream>
6 #include <ctime>
7 #include <cmath>
8 #include <vector>
9 #include <algorithm>
10 
11 // ROOT includes
12 #include "TString.h"
13 #include "TLine.h"
14 #include "TPolyLine.h"
15 #include "TH1F.h"
16 #include "TH2F.h"
17 #include "TH3F.h"
18 #include "TMath.h"
19 
20 // Other includes
21 #include "Grid.hh"
22 #include "AlphaComplex.hh"
23 
32  public:
35 
42  ProbabilityContour(const std::vector<Vertex>& vertices,
43  const Grid grid=Grid(),
44  const std::string algo = "hull");
45 
51  ProbabilityContour(const Grid& grid,
52  const std::string algo = "rectangle");
53 
61  ProbabilityContour(const std::vector<Vertex>& vertices,
62  const std::vector<Vertex>& mcvertices,
63  const double& boxvol,
64  const Grid grid=Grid());
65 
68 
71 
74 
81  TH1F* Contour1D(size_t idx=0) const;
82 
90  TH2F* Contour2D(size_t idx=0, size_t idy=1) const;
91 
100  TH3F* Contour3D(size_t idx=0, size_t idy=1, size_t idz=2) const;
101 
109  void Evaluate(double alpha, double eps = 1e-3);
110 
112  bool IsInitialized() const { return _vertices.size(); }
113 
115  const double& GetAlpha() const { return _alpha; }
116 
118  const double& GetBoxVolume() const { return _boxvol; }
119 
121  const double& GetContourVolume() const { return _volume; }
122 
124  double GetContourVolumeError() const;
125 
127  const std::vector<std::vector<size_t>>& GetIndexArray() const { return _indices; }
128 
130  const std::vector<Vertex>& GetMCVertexArray() const { return _mcvertices; }
131 
133  const std::vector<Vertex>& GetVertexArray() const { return _vertices; }
134 
136  const double& GetVolume() const { return _volume; }
137 
139  void SetMCVertexArray(const std::vector<Vertex>& mcvertices) { _mcvertices = mcvertices; }
140 
142  void SetVertexArray(const std::vector<Vertex>& vertices) { _vertices = vertices; }
143 
145  void SetBoxVolume(const double& boxvol) { _boxvol = boxvol; }
146 
147  private:
148 
154  void AlphaComplexMethod(double alpha, double eps);
155 
161  void HullMethod(double alpha, double eps);
162 
168  void MCMethod(double alpha, double eps);
169 
175  void RectangleMethod(double alpha, double);
176 
182  void TrapezoidMethod(double alpha, double eps = 1e-3);
183 
184 
185  std::string _algo;
187  std::vector<std::vector<size_t>> _indices;
188  double _alpha;
189  double _volume;
190  double _level;
191  std::vector<Vertex> _vertices;
192  std::vector<Vertex> _mcvertices;
193  double _boxvol;
194 };
195 
196 #endif
std::vector< Vertex > _vertices
Density estimation input vertices.
Definition: ProbabilityContour.hh:191
Grid _grid
Grid of points are their value.
Definition: ProbabilityContour.hh:186
void AlphaComplexMethod(double alpha, double eps)
Computes the optimal contour using the "alphac" method.
Definition: ProbabilityContour.cc:244
double _boxvol
Volume of the box in which the MC is run.
Definition: ProbabilityContour.hh:193
void HullMethod(double alpha, double eps)
Computes the optimal contour using the "hull" method.
Definition: ProbabilityContour.cc:264
std::vector< Vertex > _mcvertices
Monte Carlo vertices on a box.
Definition: ProbabilityContour.hh:192
~ProbabilityContour()
Destructor.
Definition: ProbabilityContour.cc:68
double _volume
Volume of the contour.
Definition: ProbabilityContour.hh:189
Data structure for a grid of points and their mapping onto a scalar field.
Definition: Grid.hh:19
double GetContourVolumeError() const
Returns the volume of the current contour.
Definition: ProbabilityContour.cc:230
const double & GetBoxVolume() const
Returns the volume of the box containing the MC vertices.
Definition: ProbabilityContour.hh:118
const std::vector< std::vector< size_t > > & GetIndexArray() const
Returns the array of indices of grid cells used to build the contour.
Definition: ProbabilityContour.hh:127
const double & GetAlpha() const
Returns the fraction of the function for which the contour was computed.
Definition: ProbabilityContour.hh:115
const double & GetContourVolume() const
Returns the volume of the current contour.
Definition: ProbabilityContour.hh:121
TH3F * Contour3D(size_t idx=0, size_t idy=1, size_t idz=2) const
Returns the requested 2D contour on a function.
Definition: ProbabilityContour.cc:157
ProbabilityContour & operator=(const ProbabilityContour &cont)
Equality operator.
Definition: ProbabilityContour.cc:51
TH1F * Contour1D(size_t idx=0) const
Returns segments that represent the 1D contour on a function.
Definition: ProbabilityContour.cc:70
TH2F * Contour2D(size_t idx=0, size_t idy=1) const
Returns the requested 2D contour on a function.
Definition: ProbabilityContour.cc:114
double _level
Level of the contour.
Definition: ProbabilityContour.hh:190
std::string _algo
Contour computation algorithm.
Definition: ProbabilityContour.hh:185
bool IsInitialized() const
Returns the array of indices of the vertices used.
Definition: ProbabilityContour.hh:112
void SetVertexArray(const std::vector< Vertex > &vertices)
Sets the array of input vertices.
Definition: ProbabilityContour.hh:142
Reconstructs the optimal α-contour of a Probability Density Function.
Definition: ProbabilityContour.hh:31
const std::vector< Vertex > & GetMCVertexArray() const
Returns the array of MC vertices used to determine the contour.
Definition: ProbabilityContour.hh:130
void TrapezoidMethod(double alpha, double eps=1e-3)
Computes the optimal contour using the "trapezoid" method.
Definition: ProbabilityContour.cc:334
void SetMCVertexArray(const std::vector< Vertex > &mcvertices)
Sets the array of MC vertices used to determine the contour.
Definition: ProbabilityContour.hh:139
void Evaluate(double alpha, double eps=1e-3)
Computes the optimal contour using the specified algorithm.
Definition: ProbabilityContour.cc:203
void SetBoxVolume(const double &boxvol)
Sets the array of input vertices.
Definition: ProbabilityContour.hh:145
double _alpha
Fraction of the function.
Definition: ProbabilityContour.hh:188
void RectangleMethod(double alpha, double)
Computes the optimal contour using the "rectangle" method.
Definition: ProbabilityContour.cc:298
std::vector< std::vector< size_t > > _indices
Vector of indices of the vertices used.
Definition: ProbabilityContour.hh:187
const double & GetVolume() const
Returns the volume of the contour.
Definition: ProbabilityContour.hh:136
const std::vector< Vertex > & GetVertexArray() const
Returns the array of input vertices.
Definition: ProbabilityContour.hh:133
ProbabilityContour()
Default constructor, initilizes everything to 0.
Definition: ProbabilityContour.cc:3
void MCMethod(double alpha, double eps)
Computes the optimal contour using the "mc" method.
Definition: ProbabilityContour.cc:282