-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_root2npz.cpp
82 lines (62 loc) · 1.89 KB
/
test_root2npz.cpp
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
#include "root2npz.h"
#include <iostream>
#include <TFile.h>
using namespace std;
int main()
{
TFile output("TEST.root", "RECREATE");
int bin;
//////////////////////////////////////////
TNumpy npz("TEST_th1d.lib.npz");
double xbins[5] = { -2, -0.5, 3, 6, 7 };
TH1D plot_th1d("TEST_th1d", "TEST", 4, xbins);
bin = plot_th1d.FindBin(-1);
plot_th1d.SetBinContent(bin, 10);
plot_th1d.SetBinError(bin, 2);
bin = plot_th1d.FindBin(0);
plot_th1d.SetBinContent(bin, 5);
plot_th1d.SetBinError(bin, 1);
bin = plot_th1d.FindBin(5);
plot_th1d.SetBinContent(bin, 1);
plot_th1d.SetBinError(bin, 0.5);
plot_th1d.Write();
npz.Add(&plot_th1d);
npz.Write();
//////////////////////////////////////////
TNumpy npz_profile("TEST_tprofile.lib.npz");
TProfile plot_tprofile("TEST_tprofile", "TEST", 5, 0, 10, "s");
plot_tprofile.Fill(1, 1, 2);
plot_tprofile.Fill(2, 3, 1);
plot_tprofile.Fill(2, 3, 1);
plot_tprofile.Fill(6, 2, 1);
plot_tprofile.Fill(6, 4, 1);
plot_tprofile.Write();
npz_profile.Add(&plot_tprofile);
npz_profile.Write();
//////////////////////////////////////////
TNumpy npz_th2d("TEST_th2d.lib.npz");
double ybins[4] = { -1, 0, 2, 5 };
TH2D plot_th2d("TEST_th2d", "TEST", 4, xbins, 3, ybins);
bin = plot_th2d.FindBin(-1, -0.5);
plot_th2d.SetBinContent(bin, 10);
bin = plot_th2d.FindBin(-1, 0.5);
plot_th2d.SetBinContent(bin, 6);
bin = plot_th2d.FindBin(-1, 3);
plot_th2d.SetBinContent(bin, 2);
bin = plot_th2d.FindBin(0, -0.25);
plot_th2d.SetBinContent(bin, 5);
bin = plot_th2d.FindBin(0, 4);
plot_th2d.SetBinContent(bin, 3);
bin = plot_th2d.FindBin(5, 1);
plot_th2d.SetBinContent(bin, 2);
bin = plot_th2d.FindBin(5, 2);
plot_th2d.SetBinContent(bin, 1);
bin = plot_th2d.FindBin(6.5, -0.5);
plot_th2d.SetBinContent(bin, 1);
bin = plot_th2d.FindBin(6.5, 3);
plot_th2d.SetBinContent(bin, -1);
plot_th2d.Write();
npz_th2d.Add(&plot_th2d);
npz_th2d.Write();
return 0;
}