MINT2
HyperBinningPainter1D.cpp
Go to the documentation of this file.
2 
5  HyperBinningPainter(histogram)
6 {
7  WELCOME_LOG << "Good day from the HyperBinningPainter1D() Constructor";
8 
9 }
10 
12 TH1D* HyperBinningPainter1D::getHistogram(TString histname){
13 
14  int nBins = _histogram->getBinning().getNumBins();
15 
16  std::vector<double> binEdges;
17  for (int i = 0; i < nBins; i++){
18  double min = _histogram->getBinning().getBinHyperVolume(i).getMin(0);
19  binEdges.push_back(min);
20  }
21  binEdges.push_back( _histogram->getBinning().getMax(0) );
22 
23  std::sort(binEdges.begin(), binEdges.end());
24 
25  double* aryBinEdges = new double [binEdges.size()];
26  for (unsigned i = 0; i < binEdges.size(); i++) {
27  VERBOSE_LOG << "Bin edge " << binEdges.at(i);
28  aryBinEdges[i] = binEdges.at(i);
29  }
30 
31  TH1D* tempHist = new TH1D(histname, histname, nBins, aryBinEdges);
32  tempHist->GetXaxis()->SetTitle("Val");
33  tempHist->GetYaxis()->SetTitle("Frequency");
34 
35  for (int i = 0; i < nBins; i++){
36  int bin = _histogram->getBinning().getBinNum( HyperPoint( tempHist->GetXaxis()->GetBinCenter(i+1) ) );
37 
38  if (_density == true) {
39  double volume = _histogram->getBinning().getBinHyperVolume(bin).volume();
40  tempHist->SetBinContent(i+1, _histogram->getBinContent(bin)/volume);
41  tempHist->SetBinError (i+1, _histogram->getBinError(bin )/volume);
42  }
43  else{
44  double val = _histogram->getBinContent(bin);
45  double err = _histogram->getBinError (bin);
46  tempHist->SetBinContent(i+1, val);
47  tempHist->SetBinError (i+1, err);
48  std::cout << "Bin " << i << ": Content = " << val << " Error = " << err << std::endl;
49  }
50  }
51 
52  return tempHist;
53 
54 }
55 
57 void HyperBinningPainter1D::draw(TString path, TString option){
58 
59  option = option; //remove conpilation warning
60 
61  TH1D* hist = getHistogram("tempToDraw");
62 
63  RootPlotter1D plotter(hist);
64  plotter.plot(path, "E");
65 
66  delete hist;
67 
68 }
69 
72 
73 }
74 
75 
76 
double getMax(int dimension) const
Definition: BinningBase.cpp:46
double getBinError(int bin) const
double getMin(int dimension) const
double getBinContent(int bin) const
virtual void draw(TString path="", TString option="")
#define VERBOSE_LOG
virtual int getNumBins() const =0
HyperBinningPainter1D(HyperHistogram *histogram)
virtual int getBinNum(const HyperPoint &coords) const =0
TH1D * getHistogram(TString histname)
virtual void plot(TString plotDirectory, TString plotOptions="", TPad *pad=0, double scaleFactor=1.0)
HyperHistogram * _histogram
double volume() const
#define WELCOME_LOG
const BinningBase & getBinning() const
virtual HyperVolume getBinHyperVolume(int binNumber) const =0