MINT2
Public Member Functions | Private Attributes | List of all members
HyperFunction Class Referenceabstract

#include <HyperFunction.h>

Inheritance diagram for HyperFunction:
HyperHistogram

Public Member Functions

 HyperFunction ()
 
 HyperFunction (const HyperCuboid &limits)
 
virtual double getVal (const HyperPoint &point) const =0
 
void reweightDataset (HyperPointSet &points)
 
void setFuncLimits (const HyperCuboid &limits)
 
const HyperCuboidgetFuncLimits () const
 
TH2D make2DFuncSlice (TString name, int sliceDimX, int sliceDimY, const HyperPoint &slicePoint, int nbins=100) const
 
void draw2DFuncSlice (TString path, int sliceDimX, int sliceDimY, const HyperPoint &slicePoint, int nbins=100) const
 
void draw2DFuncSliceSet (TString path, int sliceDimX, int sliceDimY, int sliceSetDim, int nSlices, const HyperPoint &slicePoint, int nbins=100) const
 
void draw2DFuncSliceSet (TString path, int sliceDimX, int sliceDimY, int nSlices, const HyperPoint &slicePoint, int nbins=100) const
 
void draw2DFuncSliceSet (TString path, int nSlices, const HyperPoint &slicePoint, int nbins=100) const
 
double getDifference (const HyperFunction &other, const HyperPoint &point)
 
void fillCorrelations (TH2D &hist, const HyperFunction &other, const HyperPointSet &points)
 
virtual ~HyperFunction ()
 

Private Attributes

HyperCuboid _limits
 

Detailed Description

HyperPlot, Author: Sam Harnew, sam.h.nosp@m.arne.nosp@m.w@gma.nosp@m.il.c.nosp@m.om , Date: Dec 2015

HyperFunction takes a HyperPoint and returns a double. This can be used to reweight HyperPointSets etc.

Definition at line 27 of file HyperFunction.h.

Constructor & Destructor Documentation

◆ HyperFunction() [1/2]

HyperFunction::HyperFunction ( )

Constructor

Definition at line 4 of file HyperFunction.cpp.

4  :
6 {
7 
8 
9 
10 
11 }
HyperCuboid _limits
Definition: HyperFunction.h:31

◆ HyperFunction() [2/2]

HyperFunction::HyperFunction ( const HyperCuboid limits)

Constructor

Definition at line 13 of file HyperFunction.cpp.

13  :
14  _limits(limits)
15 {
16 
17 }
HyperCuboid _limits
Definition: HyperFunction.h:31

◆ ~HyperFunction()

virtual HyperFunction::~HyperFunction ( )
inlinevirtual

Destructor

Definition at line 58 of file HyperFunction.h.

Member Function Documentation

◆ draw2DFuncSlice()

void HyperFunction::draw2DFuncSlice ( TString  path,
int  sliceDimX,
int  sliceDimY,
const HyperPoint slicePoint,
int  nbins = 100 
) const

Definition at line 90 of file HyperFunction.cpp.

90  {
91 
92  TH2D hist = make2DFuncSlice("temp", sliceDimX, sliceDimY, slicePoint, nbins);
93  RootPlotter2D plotter(&hist);
94  plotter.plot(path, "COLZ");
95 
96 }
TH2D make2DFuncSlice(TString name, int sliceDimX, int sliceDimY, const HyperPoint &slicePoint, int nbins=100) const

◆ draw2DFuncSliceSet() [1/3]

void HyperFunction::draw2DFuncSliceSet ( TString  path,
int  sliceDimX,
int  sliceDimY,
int  sliceSetDim,
int  nSlices,
const HyperPoint slicePoint,
int  nbins = 100 
) const

Definition at line 98 of file HyperFunction.cpp.

98  {
99 
100  if (_limits.getDimension() == 0){
101  ERROR_LOG << "You need to set the domain of the fuction with setFuncLimits(const HyperCuboid& limits) to draw slices" << std::endl;
102  }
103  if (slicePoint.getDimension() != _limits.getDimension()){
104  ERROR_LOG << "Your slice point has different dimensions to the function domain" << std::endl;
105  }
106  if (_limits.inVolume(slicePoint) == false){
107  ERROR_LOG << "Your slice point in not within the function domain" << std::endl;
108  }
109 
110  HyperPoint slicePointCp(slicePoint);
111 
112  double min = _limits.getLowCorner ().at(sliceSetDim);
113  double max = _limits.getHighCorner().at(sliceSetDim);
114  double width = (max - min)/double(nSlices);
115 
116  for (int i = 0; i < nSlices; i++){
117  double val = min + width*(i + 0.5);
118  slicePointCp.at(sliceSetDim) = val;
119 
120  TString uniquePath = path;
121  uniquePath += "_sliceNum";
122  uniquePath += i;
123  draw2DFuncSlice(uniquePath, sliceDimX, sliceDimY, slicePointCp, nbins);
124 
125  }
126 
127 
128 }
#define ERROR_LOG
const int & getDimension() const
Definition: HyperCuboid.h:45
void draw2DFuncSlice(TString path, int sliceDimX, int sliceDimY, const HyperPoint &slicePoint, int nbins=100) const
HyperCuboid _limits
Definition: HyperFunction.h:31
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87
int getDimension() const
Definition: HyperPoint.h:99
bool inVolume(const HyperPoint &coords) const

◆ draw2DFuncSliceSet() [2/3]

void HyperFunction::draw2DFuncSliceSet ( TString  path,
int  sliceDimX,
int  sliceDimY,
int  nSlices,
const HyperPoint slicePoint,
int  nbins = 100 
) const

Definition at line 130 of file HyperFunction.cpp.

130  {
131 
132 
133 
134  for (int i = 0; i < slicePoint.getDimension(); i++){
135 
136  if (i == sliceDimX) continue;
137  if (i == sliceDimY) continue;
138 
139  TString thsPath = path;
140  thsPath += "_scanDim";
141  thsPath += i;
142 
143  draw2DFuncSliceSet(thsPath, sliceDimX, sliceDimY, i, nSlices, slicePoint, nbins);
144 
145  }
146 
147 
148 }
void draw2DFuncSliceSet(TString path, int sliceDimX, int sliceDimY, int sliceSetDim, int nSlices, const HyperPoint &slicePoint, int nbins=100) const
int getDimension() const
Definition: HyperPoint.h:99

◆ draw2DFuncSliceSet() [3/3]

void HyperFunction::draw2DFuncSliceSet ( TString  path,
int  nSlices,
const HyperPoint slicePoint,
int  nbins = 100 
) const

Definition at line 150 of file HyperFunction.cpp.

150  {
151 
152 
153 
154  for (int i = 0; i < slicePoint.getDimension(); i++){
155  for (int j = 0; j < slicePoint.getDimension(); j++){
156 
157  if (i >= j) continue;
158 
159  TString thsPath = path;
160  thsPath += "_";
161  thsPath += i;
162  thsPath += "vs";
163  thsPath += j;
164 
165  draw2DFuncSliceSet(thsPath, i, j, nSlices, slicePoint, nbins);
166  }
167  }
168 
169 
170 }
void draw2DFuncSliceSet(TString path, int sliceDimX, int sliceDimY, int sliceSetDim, int nSlices, const HyperPoint &slicePoint, int nbins=100) const
int getDimension() const
Definition: HyperPoint.h:99

◆ fillCorrelations()

void HyperFunction::fillCorrelations ( TH2D &  hist,
const HyperFunction other,
const HyperPointSet points 
)

Definition at line 181 of file HyperFunction.cpp.

181  {
182 
183  for (unsigned i = 0; i < points.size(); i++){
184  double val = getVal(points.at(i));
185  double valother = other.getVal(points.at(i));
186  hist.Fill( val, valother, points.at(i).getWeight() );
187  }
188 
189  int nBinsX = hist.GetXaxis()->GetNbins();
190  int nBinsY = hist.GetYaxis()->GetNbins();
191 
192  for (int i = 1; i <= nBinsX; i++){
193  double sumY = 0.0;
194  for (int j = 1; j <= nBinsY; j++){
195  sumY += hist.GetBinContent(i,j);
196  }
197  for (int j = 1; j <= nBinsY; j++){
198  double val = hist.GetBinContent(i,j);
199  val = (val / sumY)*100.0;
200  if (sumY == 0.0) val = 0.0;
201  hist.SetBinContent(i, j, val);
202  }
203  }
204 
205 }
const HyperPoint & at(int i) const
virtual double getVal(const HyperPoint &point) const =0
unsigned int size() const
double getWeight(int i=0) const
Definition: Weights.cpp:40

◆ getDifference()

double HyperFunction::getDifference ( const HyperFunction other,
const HyperPoint point 
)

Get the difference between this HyperFunction and another HyperFunction at a point in n-dim space. (diff = this - other)

Definition at line 174 of file HyperFunction.cpp.

174  {
175  double val = getVal(point);
176  double valother = other.getVal(point);
177  return val - valother;
178 }
virtual double getVal(const HyperPoint &point) const =0

◆ getFuncLimits()

const HyperCuboid& HyperFunction::getFuncLimits ( ) const
inline

Definition at line 44 of file HyperFunction.h.

44 {return _limits;}
HyperCuboid _limits
Definition: HyperFunction.h:31

◆ getVal()

virtual double HyperFunction::getVal ( const HyperPoint point) const
pure virtual

Virtual function that defines a HyperFunction (Map from HyperPoint -> double)

Implemented in HyperHistogram.

◆ make2DFuncSlice()

TH2D HyperFunction::make2DFuncSlice ( TString  name,
int  sliceDimX,
int  sliceDimY,
const HyperPoint slicePoint,
int  nbins = 100 
) const

Definition at line 54 of file HyperFunction.cpp.

54  {
55 
56  if (_limits.getDimension() == 0){
57  ERROR_LOG << "You need to set the domain of the fuction with setFuncLimits(const HyperCuboid& limits) to draw slices" << std::endl;
58  }
59  if (slicePoint.getDimension() != _limits.getDimension()){
60  ERROR_LOG << "Your slice point has different dimensions to the function domain" << std::endl;
61  }
62  if (_limits.inVolume(slicePoint) == false){
63  ERROR_LOG << "Your slice point in not within the function domain" << std::endl;
64  }
65 
66  double minX = _limits.getLowCorner ().at(sliceDimX);
67  double maxX = _limits.getHighCorner().at(sliceDimX);
68 
69  double minY = _limits.getLowCorner ().at(sliceDimY);
70  double maxY = _limits.getHighCorner().at(sliceDimY);
71 
72  TH2D hist(name, name, nbins, minX, maxX, nbins, minY, maxY);
73 
74  for (int i = 1; i <= nbins; i++){
75  for (int j = 1; j <= nbins; j++){
76  double x = hist.GetXaxis()->GetBinCenter(i);
77  double y = hist.GetYaxis()->GetBinCenter(j);
78  HyperPoint point(slicePoint);
79  point.at(sliceDimX) = x;
80  point.at(sliceDimY) = y;
81  double val = getVal(point);
82  hist.SetBinContent(i,j,val);
83  }
84  }
85 
86  return hist;
87 
88 }
#define ERROR_LOG
const int & getDimension() const
Definition: HyperCuboid.h:45
HyperCuboid _limits
Definition: HyperFunction.h:31
const HyperPoint & getHighCorner() const
Definition: HyperCuboid.h:89
virtual double getVal(const HyperPoint &point) const =0
const double & at(int i) const
Definition: HyperPoint.cpp:433
const HyperPoint & getLowCorner() const
Definition: HyperCuboid.h:87
int getDimension() const
Definition: HyperPoint.h:99
bool inVolume(const HyperPoint &coords) const

◆ reweightDataset()

void HyperFunction::reweightDataset ( HyperPointSet points)

Reweight a HyperPointSet by the HyperFunction. If weights already exist, the existing weights are mulitplied by the HyperFunction evaluation. If not, a the HyperFunction evaluation is added as the zeroth weight.

Definition at line 24 of file HyperFunction.cpp.

24  {
25 
26  int npoints = points.size();
27 
28  for (int i = 0; i < npoints; i++){
29 
30  HyperPoint& point = points.at(i);
31 
32  double val = this->getVal(point);
33 
34  int nW = point.numWeights();
35 
36  for (int w = 0; w < nW; w++){
37  double oldW = point.getWeight(w);
38  double newW = oldW*val;
39  point.setWeight(w, newW);
40  }
41 
42  if (nW == 0) point.addWeight(val);
43 
44  }
45 
46 
47 }
void setWeight(int i, double w)
Definition: Weights.cpp:52
void addWeight(const double &weight)
Definition: Weights.cpp:71
const HyperPoint & at(int i) const
int numWeights() const
Definition: Weights.cpp:20
virtual double getVal(const HyperPoint &point) const =0
unsigned int size() const
double getWeight(int i=0) const
Definition: Weights.cpp:40

◆ setFuncLimits()

void HyperFunction::setFuncLimits ( const HyperCuboid limits)

Definition at line 49 of file HyperFunction.cpp.

49  {
50  _limits = limits;
51 }
HyperCuboid _limits
Definition: HyperFunction.h:31

Member Data Documentation

◆ _limits

HyperCuboid HyperFunction::_limits
private

Definition at line 31 of file HyperFunction.h.


The documentation for this class was generated from the following files: