34 TFile *hsimple(Int_t getFile=0)
36 TString filename =
"hsimple.root";
37 TString dir = gROOT->GetTutorialDir();
38 dir.ReplaceAll(
"/./",
"/");
43 TString fullPath = dir+
"hsimple.root";
44 if (!gSystem->AccessPathName(fullPath,kFileExists)) {
45 hfile = TFile::Open(fullPath);
46 if (hfile)
return hfile;
49 if (!gSystem->AccessPathName(
"hsimple.root",kFileExists)) {
50 hfile = TFile::Open(
"hsimple.root");
51 if (hfile)
return hfile;
56 if (gSystem->AccessPathName(
".",kWritePermission)) {
57 printf(
"you must run the script in a directory with write access\n");
60 hfile = (TFile*)gROOT->FindObject(filename);
if (hfile) hfile->Close();
61 hfile =
new TFile(filename,
"RECREATE",
"Demo ROOT file with histograms");
64 TH1F *hpx =
new TH1F(
"hpx",
"This is the px distribution",100,-4,4);
65 hpx->SetFillColor(48);
66 TH2F *hpxpy =
new TH2F(
"hpxpy",
"py vs px",40,-4,4,40,-4,4);
67 TProfile *hprof =
new TProfile(
"hprof",
"Profile of pz versus px",100,-4,4,0,20);
68 TNtuple *ntuple =
new TNtuple(
"ntuple",
"Demo ntuple",
"px:py:pz:random:i");
70 gBenchmark->Start(
"hsimple");
73 TCanvas *c1 =
new TCanvas(
"c1",
"Dynamic Filling Example",200,10,700,500);
75 c1->GetFrame()->SetFillColor(21);
76 c1->GetFrame()->SetBorderSize(6);
77 c1->GetFrame()->SetBorderMode(-1);
83 const Int_t kUPDATE = 1000;
84 for (Int_t i = 0; i < 25000; i++) {
85 randomNum.Rannor(px,py);
87 Float_t rnd = randomNum.Rndm();
91 ntuple->Fill(px,py,pz,rnd,i);
92 if (i && (i%kUPDATE) == 0) {
93 if (i == kUPDATE) hpx->Draw();
96 if (gSystem->ProcessEvents())
100 gBenchmark->Show(
"hsimple");
103 hpx->SetFillColor(0);
105 hpx->SetFillColor(48);