#include "TCanvas.h" #include "TH1.h" Char_t amp_name[30]; Char_t hist_name[30]; Int_t Low, Up; Char_t chrange[10],go[5]; int compare() { cout << "compare histogrames with same name base from diffrent files" << endl; cout << "input the name_base: " << endl; cin >> name_base; cout << "input lower and upper limits of the histogram range:" << endl; cin >> Low; cin >> Up; /* open root files where historgrames are store */ TFile f4("4.hist"); TFile f51("51.hist"); for (int i=1; i<=10; i++) { sprintf(hist_name, "%s_%d", name_base, i); cout << hist_name << endl; f4.cd(); TH1D * hist1 = (TH1D *) f4.Get(hist_name); hist1->GetXaxis()->SetRange(Low,Up); hist1->SetLineColor(kRed); hist1->Draw(); /**** why no Canvas show up here ? ****/ f51.cd(); TH1D * hist2 = (TH1D *) f51.Get(hist_name); hist2->SetLineColor(kBlue); hist2->Draw("same"); /**** no Canvas shows up here as well ****/ cout << "Continue ?: (any character to contine)" << endl; cin >> go; } return 0; }