This program creates :
- a one dimensional histogram
- a two dimensional histogram
- a profile histogram
- a memory-resident ntuple
These objects are filled with some random numbers and saved on a file. If get=1 the macro returns a pointer to the TFile of "hsimple.root" if this file exists, otherwise it is created. The file "hsimple.root" is created in $ROOTSYS/tutorials if the caller has write access to this directory, otherwise the file is created in $PWD
Processing /mnt/build/workspace/root-makedoc-v608/rootspi/rdoc/src/v6-08-00-patches/tutorials/hsimple.C...
hsimple : Real Time = 0.07 seconds Cpu Time = 0.07 seconds
(TFile *) 0x55d6467d5d60
{
if (getFile) {
TString fullPath = dir+
"hsimple.root";
if (hfile) return hfile;
}
if (hfile) return hfile;
}
}
printf("you must run the script in a directory with write access\n");
return 0;
}
hfile =
new TFile(filename,
"RECREATE",
"Demo ROOT file with histograms");
TH1F *hpx =
new TH1F(
"hpx",
"This is the px distribution",100,-4,4);
TH2F *hpxpy =
new TH2F(
"hpxpy",
"py vs px",40,-4,4,40,-4,4);
TProfile *hprof =
new TProfile(
"hprof",
"Profile of pz versus px",100,-4,4,0,20);
TNtuple *ntuple =
new TNtuple(
"ntuple",
"Demo ntuple",
"px:py:pz:random:i");
TCanvas *c1 =
new TCanvas(
"c1",
"Dynamic Filling Example",200,10,700,500);
const Int_t kUPDATE = 1000;
for (
Int_t i = 0; i < 25000; i++) {
pz = px*px + py*py;
ntuple->
Fill(px,py,pz,rnd,i);
if (i && (i%kUPDATE) == 0) {
if (i == kUPDATE) hpx->
Draw();
break;
}
}
return hfile;
}
- Author
- Rene Brun
Definition in file hsimple.C.