MINT2
Public Member Functions | List of all members
HyperBinningPainter1D Class Reference

#include <HyperBinningPainter1D.h>

Inheritance diagram for HyperBinningPainter1D:
HyperBinningPainter

Public Member Functions

 HyperBinningPainter1D (HyperHistogram *histogram)
 
TH1D * getHistogram (TString histname)
 
virtual void draw (TString path="", TString option="")
 
virtual ~HyperBinningPainter1D ()
 
- Public Member Functions inherited from HyperBinningPainter
 HyperBinningPainter (HyperHistogram *histogram)
 
void useDensity (bool val)
 
virtual ~HyperBinningPainter ()
 

Additional Inherited Members

- Protected Attributes inherited from HyperBinningPainter
HyperHistogram_histogram
 
bool _density
 

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

Class plotting 1D HyperBinningHistograms

Definition at line 29 of file HyperBinningPainter1D.h.

Constructor & Destructor Documentation

◆ HyperBinningPainter1D()

HyperBinningPainter1D::HyperBinningPainter1D ( HyperHistogram histogram)

Construct a 1D HyperBinningPainter for a given HyperBinningHistogram

Definition at line 4 of file HyperBinningPainter1D.cpp.

4  :
5  HyperBinningPainter(histogram)
6 {
7  WELCOME_LOG << "Good day from the HyperBinningPainter1D() Constructor";
8 
9 }
HyperBinningPainter(HyperHistogram *histogram)
#define WELCOME_LOG

◆ ~HyperBinningPainter1D()

HyperBinningPainter1D::~HyperBinningPainter1D ( )
virtual

Destructor

Definition at line 71 of file HyperBinningPainter1D.cpp.

71  {
72 
73 }

Member Function Documentation

◆ draw()

void HyperBinningPainter1D::draw ( TString  path = "",
TString  option = "" 
)
virtual

Draw the HyperBinningHistogram

Reimplemented from HyperBinningPainter.

Definition at line 57 of file HyperBinningPainter1D.cpp.

57  {
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 }
TH1D * getHistogram(TString histname)

◆ getHistogram()

TH1D * HyperBinningPainter1D::getHistogram ( TString  histname)

Turn the HyperBinningHistogram into a TH1D

Definition at line 12 of file HyperBinningPainter1D.cpp.

12  {
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 }
double getMax(int dimension) const
Definition: BinningBase.cpp:46
double getBinError(int bin) const
double getMin(int dimension) const
double getBinContent(int bin) const
#define VERBOSE_LOG
virtual int getNumBins() const =0
virtual int getBinNum(const HyperPoint &coords) const =0
HyperHistogram * _histogram
double volume() const
const BinningBase & getBinning() const
virtual HyperVolume getBinHyperVolume(int binNumber) const =0

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