{ TFile *f1 = new TFile("HLT_PTMultiplicity208.root"); TDirectory *d1=(TDirectory*)f1->Get("demo"); TFile *f2 = new TFile("HLTminBias208.root"); TDirectory *d2=(TDirectory*)f2->Get("demo"); TIter next(d1->GetListOfKeys()); TKey *key; int Hist_num=0; while ((key = (TKey*)next())) { TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1") && !cl->InheritsFrom("TH2")) continue; TH1 *h1 = (TH1*)key->ReadObj(); char *H_name = h1->GetName(); TH1 *h2=(TH1*)d2->Get(H_name); TCanvas *c=new TCanvas(); c->Divide(3,1); TH1 hd = h1->Clone()-(*h2); c->cd(1); hd.Draw(); TH1 hf=(*h1)/(*h2); c->cd(2); hf.Draw(); TH1 hr= ((*h1)-(*h2))/(*h2); c->cd(3); hr.Draw(); } }