MINT2
HyperHistogram.h
Go to the documentation of this file.
1 
32 #ifndef HYPERHISTOGRAM_HH
33 #define HYPERHISTOGRAM_HH
34 
35 // HyperPlot includes
36 #include "Mint/MessageService.h"
37 #include "Mint/HistogramBase.h"
38 #include "Mint/HyperFunction.h"
39 #include "Mint/HyperName.h"
40 #include "Mint/BinningBase.h"
41 #include "Mint/HyperBinning.h"
44 
45 // Root includes
46 #include "TRandom.h"
47 
48 // std includes
49 #include <iostream>
50 #include <fstream>
51 #include <iomanip>
52 
53 class HyperHistogram : public HistogramBase, public HyperFunction {
54 
55  protected:
56 
60 
61  //BinningBase& getBinning() { return (*_binning); } /**< get the HyperVolumeBinning */
62 
63 
64  public:
65 
67  const HyperCuboid& binningRange,
68  const HyperPointSet& points,
69 
71 
72  AlgOption opt0 = AlgOption::Empty(),
73  AlgOption opt1 = AlgOption::Empty(),
74  AlgOption opt2 = AlgOption::Empty(),
75  AlgOption opt3 = AlgOption::Empty(),
76  AlgOption opt4 = AlgOption::Empty(),
77  AlgOption opt5 = AlgOption::Empty(),
78  AlgOption opt6 = AlgOption::Empty(),
79  AlgOption opt7 = AlgOption::Empty(),
80  AlgOption opt8 = AlgOption::Empty(),
82  );
83 
84  HyperHistogram(const BinningBase& binning);
85  HyperHistogram(TString filename, TString option = "MEMRES READ");
86  HyperHistogram(std::vector<TString> filename);
87  HyperHistogram(TString targetFilename, std::vector<TString> filename);
88 
89  HyperHistogram(const HyperHistogram& other);
90 
92 
93  int getDimension() const;
94 
95  void setNames( HyperName names );
96  HyperName getNames() const;
97 
98  int fill(const HyperPoint& coords, double weight);
99  int fill(const HyperPoint& coords);
100  void fill(const HyperPointSet& points);
101 
102  virtual void merge( const HistogramBase& other );
103 
104  void merge( TString filenameother );
105 
106 
107  int estimateCapacity(std::vector<TString> filename, TString binningType);
108 
109 
110  //Project the HyperHistograms down into one dimension
111 
112  void project(TH1D* histogram, const HyperCuboid& cuboid, double content, int dimension) const;
113  void project(TH1D* histogram, const HyperVolume& hyperVolume, double content, int dimension) const;
114  TH1D project(int dim = 0, int bins = 100, TString name = "projection") const;
115 
116  void drawProjection (TString path, int dim = 0, int bins = 100) const;
117  void drawAllProjections(TString path, int bins) const;
118 
119  void compareProjection (TString path, int dim, const HyperHistogram& other, int bins = 100) const;
120  void compareAllProjections(TString path, const HyperHistogram& other, int bins = 100) const;
121 
122 
123 
124  HyperHistogram slice(std::vector<int> sliceDims, const HyperPoint& slicePoint) const;
125  std::vector<HyperHistogram> slice(std::vector<int> sliceDims, const HyperPointSet& slicePoints) const;
126 
127  void draw2DSlice (TString path, int sliceDimX, int sliceDimY, const HyperPoint& slicePoint, TString options = "") const;
128  void draw2DSliceSet(TString path, int sliceDimX, int sliceDimY, int sliceSetDim, int nSlices, const HyperPoint& slicePoint, TString options = "") const;
129  void draw2DSliceSet(TString path, int sliceDimX, int sliceDimY, int nSlices, const HyperPoint& slicePoint, TString options = "") const;
130  void draw2DSliceSet(TString path, int nSlices, const HyperPoint& slicePoint, TString options = "") const;
131  void drawRandom2DSlice(TString path, TRandom* random = gRandom, TString options = "") const;
132 
133 
134  HyperCuboid getLimits() const;
135 
136 
137  const BinningBase& getBinning() const { return (*_binning); }
139  virtual double getVal(const HyperPoint& point) const;
140  std::vector<double> getVal(const HyperPointSet& points) const;
141 
142 
143  virtual double getBinVolume(int bin) const;
144 
145  void save(TString filename);
146 
147  TString getBinningType(TString filename);
148 
149  void load (TString filename, TString option = "MEMRES READ");
150  void loadEmpty(TString filename, TString option = "MEMRES READ", TString binningType = "HyperBinning");
151 
152 
153  void setContentsFromFunc(const HyperFunction& func);
154 
155  void printFull() const;
156 
157  void saveToTxtFile(TString filename, bool incError = true) const;
158  void saveToTxtFileNoLinks(TString filename, bool incError = true) const;
159 
160 
161  void draw(TString path, TString options = "");
162  void drawDensity(TString path, TString options = "");
163 
165 
166 
167  virtual ~HyperHistogram();
168 
169 };
170 
171 
172  //mutable double _nIntegrationsWtrick;
173  //mutable double _nIntegrationsWOtrick;
174 
175  //void printOptimisationStatistics();
176  //interpolation stuff
177  //HyperPointSet makePointsAtGaussianExtremes(const HyperPoint& mean, const HyperPoint& sigmas, double sigma) const;
178  //double intgrateGaussianOverHyperCuboid(const HyperPoint& mean , const HyperPoint& sigmas, const HyperCuboid& cuboid) const;
179  //double intgrateGaussianOverHyperVolume(const HyperPoint& point, const HyperPoint& sigmas, const HyperVolume& volume) const;
180  //double intgrateGaussianOverBin (const HyperPoint& point, const HyperPoint& sigmas, int bin) const;
181  //double gaussianKernal (const HyperPoint& point, const HyperPoint& sigmas) const;
182  //HyperPoint findAdaptiveSigma(const HyperPoint& point, const HyperPoint& sigmas) const;
183  //std::vector<int> findNHighestContributingKernalBins(const HyperPoint& point, const HyperPoint& sigmas, int n) const;
184  //double adaptiveGaussianKernal(const HyperPoint& point, double smoothing = 1.0) const;
185  //void reweightDatasetWithAdaptiveGaussianKernal(HyperPointSet& points, double smoothing = 1.0) const;
186 
187 
188 
189 #endif
190 
int getDimension() const
void loadEmpty(TString filename, TString option="MEMRES READ", TString binningType="HyperBinning")
void draw(TString path, TString options="")
void drawDensity(TString path, TString options="")
virtual void merge(const HistogramBase &other)
static AlgOption Empty()
void mergeBinsWithSameContent()
void draw2DSliceSet(TString path, int sliceDimX, int sliceDimY, int sliceSetDim, int nSlices, const HyperPoint &slicePoint, TString options="") const
void drawRandom2DSlice(TString path, TRandom *random=gRandom, TString options="") const
void drawProjection(TString path, int dim=0, int bins=100) const
void draw2DSlice(TString path, int sliceDimX, int sliceDimY, const HyperPoint &slicePoint, TString options="") const
HyperHistogram & operator=(const HyperHistogram &other)
void drawAllProjections(TString path, int bins) const
void setNames(HyperName names)
BinningBase * _binning
void printFull() const
int fill(const HyperPoint &coords, double weight)
HyperCuboid getLimits() const
void setContentsFromFunc(const HyperFunction &func)
void project(TH1D *histogram, const HyperCuboid &cuboid, double content, int dimension) const
virtual double getVal(const HyperPoint &point) const
int estimateCapacity(std::vector< TString > filename, TString binningType)
virtual ~HyperHistogram()
const BinningBase & getBinning() const
void save(TString filename)
void compareProjection(TString path, int dim, const HyperHistogram &other, int bins=100) const
void load(TString filename, TString option="MEMRES READ")
virtual double getBinVolume(int bin) const
HyperName getNames() const
void saveToTxtFileNoLinks(TString filename, bool incError=true) const
void compareAllProjections(TString path, const HyperHistogram &other, int bins=100) const
TString getBinningType(TString filename)
HyperHistogram slice(std::vector< int > sliceDims, const HyperPoint &slicePoint) const
void saveToTxtFile(TString filename, bool incError=true) const