TCanvas *c1; TTimer *t; void fr1() { if (gROOT->GetListOfFiles()->FindObject("hsi.root")) { gDirectory->ReadKeys(); gDirectory->GetList()->Delete(); } else { //TFile *file = TFile::Open("http://root.cern.ch/files/hsi.root"); TFile *file = TFile::Open("hsi.root"); } TNtuple *ntuple = (TNtuple*)gDirectory->Get("ntuple"); if (ntuple) { c1->cd(1); Long64_t nentries = ntuple->GetEntries(); //if (nentries >= 2500000) t->TurnOff(); ntuple->Draw("pz","","",1000,nentries-1000); delete ntuple; } TH1 *hpx = (TH1*)gDirectory->Get("hpx"); if (hpx) { c1->cd(2); hpx->Draw(); } c1->Update(); } void fr() { c1 = new TCanvas("c1","c1",10,10,1000,400); c1->Divide(2,1); t = new TTimer("fr1()",1000); //fr1 will be called every 1000ms t->TurnOn(); }