-
Notifications
You must be signed in to change notification settings - Fork 0
/
Test.cxx
100 lines (79 loc) · 2.53 KB
/
Test.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// std
#include <iostream>
// Throw
#include "Throw.h"
//std
using std::cout;
using std::endl;
// Throw
using Throw::Plotter1D;
using Throw::Plotter2D;
void testPlotter1D() {
TH1D* testHistI = new TH1D("testHistI", "Test Histogram I;label x;label y",
20, -5, 8);
testHistI->FillRandom("gaus", 1000);
TH1D* testHistII = new TH1D("testHistII", "Test Histogram II;label x;label y",
20, -5, 8);
testHistII->FillRandom("gaus", 4000);
TGraphAsymmErrors* testGraph = new TGraphAsymmErrors(5);
testGraph->SetPoint(0, -2, 200);
testGraph->SetPoint(1, -1, 250);
testGraph->SetPoint(2, 0, 300);
testGraph->SetPoint(3, 1, 350);
testGraph->SetPoint(4, 2, 400);
Plotter1D* testPlot = new Plotter1D("testPlot1D");
testPlot->addHist(testHistI);
testPlot->addHist(testHistII);
testPlot->addGraph(testGraph);
testPlot->setLogY(false);
testPlot->draw();
delete testHistI;
delete testHistII;
delete testGraph;
delete testPlot;
}
void testPlotter2D() {
TF2 *gaus2D = new TF2("gaus2D", "xygaus", -10, 10 , -10, 10);
gaus2D->SetParameters(1, 0, 2, 0, 2);
TH2D* testHist = new TH2D("testHist", "Test Histogram;label x;label y",
20, -5, 8, 20, -5, 8);
testHist->FillRandom("gaus2D", 1000 * 1000);
TGraph2D* testGraph = new TGraph2D(testHist);
testGraph->SetTitle("Test Graph;label x;label y");
Plotter2D* testPlotHist = new Plotter2D("testPlot2Dhist");
testPlotHist->addHist(testHist);
testPlotHist->draw();
Plotter2D* testPlotGraph = new Plotter2D("testPlot2Dgraph");
testPlotGraph->addGraph(testGraph);
testPlotGraph->draw();
delete gaus2D;
delete testHist;
delete testGraph;
delete testPlotHist;
delete testPlotGraph;
}
void testGraphSection() {
TF2 *gaus2D = new TF2("gaus2D", "xygaus", -10, 10 , -10, 10);
gaus2D->SetParameters(1, 0, 2, 0, 2);
TH2D* testHist = new TH2D("testHist", "Test Histogram;label x;label y",
300, -5, 8, 300, -5, 8);
testHist->FillRandom("gaus2D", 10000 * 10000);
TGraph2D* testGraph = new TGraph2D(testHist);
testGraph->SetTitle("Test Graph;label x;label y");
TGraphAsymmErrors* section = Throw::MakeSection(testGraph, 100., 1.);
Plotter1D* sectionPlot = new Plotter1D("sectionPlot");
sectionPlot->addGraph(section);
sectionPlot->setDrawLegend(false);
sectionPlot->draw();
delete gaus2D;
delete testHist;
delete testGraph;
delete section;
delete sectionPlot;
}
int main() {
testPlotter1D();
testPlotter2D();
testGraphSection();
return 0;
}