20void write_histograms()
27 TFile f(
"ht.root",
"recreate");
28 auto T =
new TTree(
"T",
"test");
30 auto hpxpy =
new TH2F(
"hpxpy",
"py vs px", 40, -4, 4, 40, -4, 4);
31 auto hprof =
new TProfile(
"hprof",
"Profile of pz versus px", 100, -4, 4, 0, 20);
32 T->Branch(
"hpx",
"TH1F", &hpx, 32000, 0);
33 T->Branch(
"hpxpy",
"TH2F", &hpxpy, 32000, 0);
34 T->Branch(
"hprof",
"TProfile", &hprof, 32000, 0);
36 for (
Int_t i = 0; i < 25000; i++) {
38 printf(
"at entry: %d\n", i);
40 pz = px * px + py * py;
55 auto T =
f->Get<
TTree>(
"T");
57 TH2F *hpxpy =
nullptr;
59 T->SetBranchAddress(
"hpx", &hpx);
60 T->SetBranchAddress(
"hpxpy", &hpxpy);
61 T->SetBranchAddress(
"hprof", &hprof);
63 auto c1 =
new TCanvas(
"c1",
"test", 10, 10, 600, 1000);
71 c1->Print(
"htr1.png");
79 auto T =
f->Get<
TTree>(
"T");
80 auto c1 =
new TCanvas(
"c1",
"test", 10, 10, 600, 1000);
83 T->Draw(
"hpx.Draw()",
"",
"goff", 1, 12345);
85 T->Draw(
"hpxpy.Draw()",
"",
"goff", 1, 12345);
87 T->Draw(
"hprof.Draw()",
"",
"goff", 1, 12345);
88 c1->Print(
"htr2.png");
97 auto T =
f->Get<
TTree>(
"T");
98 auto c1 =
new TCanvas(
"c1",
"test", 10, 10, 600, 400);
99 T->Draw(
"hpx.GetRMS():hprof.GetMean()");
100 c1->Print(
"htr3.png");
103void tree201_histograms()
int Int_t
Signed integer 4 bytes (int).
float Float_t
Float 4 bytes (float).
externTBenchmark * gBenchmark
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
1-D histogram with a float per channel (see TH1 documentation)
void Draw(Option_t *option="") override
Draw this histogram with options.
2-D histogram with a float per channel (see TH1 documentation)
A TTree represents a columnar dataset.