Save histograms in Tree branches.
More...
Go to the source code of this file.
Save histograms in Tree branches.
To run this example, do
root > .L htest.C
root > htw()
root > htr1()
root > htr2()
root > htr3()
void htw() {
TFile f(
"ht.root",
"recreate");
auto T =
new TTree(
"T",
"test");
auto hpx =
new TH1F(
"hpx",
"This is the px distribution",100,-4,4);
auto hpxpy =
new TH2F(
"hpxpy",
"py vs px",40,-4,4,40,-4,4);
auto hprof =
new TProfile(
"hprof",
"Profile of pz versus px",100,-4,4,0,20);
for (
Int_t i = 0; i < 25000; i++) {
if (i%1000 == 0)
printf(
"at entry: %d\n",i);
}
}
void htr1() {
auto f =
new TFile(
"ht.root");
auto c1 =
new TCanvas(
"c1",
"test",10,10,600,1000);
}
void htr2() {
auto f =
new TFile(
"ht.root");
auto c1 =
new TCanvas(
"c1",
"test",10,10,600,1000);
T->
Draw(
"hpx.Draw()",
"",
"goff",1,12345);
T->
Draw(
"hpxpy.Draw()",
"",
"goff",1,12345);
T->
Draw(
"hprof.Draw()",
"",
"goff",1,12345);
}
void htr3() {
auto f =
new TFile(
"ht.root");
T->
Draw(
"hpx.GetRMS():hprof.GetMean()");
}
void htest() {
htw();
htr1();
htr2();
htr3();
}
- Author
- Rene Brun
Definition in file htest.C.