Go to the documentation of this file.00001 {
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 gROOT->Reset();
00018
00019
00020 c1 = new TCanvas("c1","Dynamic Filling Example",200,10,700,500);
00021 c1->SetFillColor(42);
00022 c1->GetFrame()->SetFillColor(21);
00023 c1->GetFrame()->SetBorderSize(6);
00024 c1->GetFrame()->SetBorderMode(-1);
00025
00026
00027
00028
00029
00030
00031 TFile *hfile = (TFile*)gROOT->FindObject("hsimple.root"); if (hfile) hfile->Close();
00032 hfile = TFile::Open("hsimple.root","RECREATE","Demo ROOT file with histograms");
00033
00034
00035 hpx = new TH1F("hpx","This is the px distribution",100,-4,4);
00036 hpxpy = new TH2F("hpxpy","py vs px",40,-4,4,40,-4,4);
00037 hprof = new TProfile("hprof","Profile of pz versus px",100,-4,4,0,20);
00038 ntuple = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i");
00039
00040
00041 hpx->SetFillColor(48);
00042
00043
00044
00045 go4RegisterAll();
00046
00047 gBenchmark->Start("hsimple");
00048
00049
00050 gRandom->SetSeed();
00051 Float_t px, py, pz;
00052 const Int_t kUPDATE = 1000;
00053 for (Int_t i = 0; i < 25000000; i++) {
00054 gRandom->Rannor(px,py);
00055 pz = px*px + py*py;
00056 Float_t random = gRandom->Rndm(1);
00057 hpx->Fill(px);
00058 hpxpy->Fill(px,py);
00059 hprof->Fill(px,pz);
00060 ntuple->Fill(px,py,pz,random,i);
00061 if (i && (i%kUPDATE) == 0) {
00062 if (i == kUPDATE) hpx->Draw();
00063 c1->Modified();
00064 c1->Update();
00065 if (gSystem->ProcessEvents())
00066 break;
00067 }
00068 }
00069 gBenchmark->Show("hsimple");
00070
00071
00072 hpx->SetFillColor(0);
00073 hfile->Write();
00074 hpx->SetFillColor(48);
00075 c1->Modified();
00076
00077
00078
00079 }