Plotting Same Tree from two root files

Hello All,

I would like to get histograms from two different root files whose structures are identical. Here is what I tried to do:

[code]{
gROOT->Reset();
int a;

TFile f("File1.root");
//gROOT->cd();
BlackTree->Draw("energy>>heng(800,0,0.6)");
TH1F *heng = (TH1F*)gDirectory->Get("heng");
cout << heng->GetEntries() << endl;
//f.Close();
f->Delete();

TFile f1("File2.root");
//gROOT->cd();
BlackTree>Draw("energy>>heng1(800,0,0.6)");
TH1F *heng = (TH1F*)gDirectory->Get("heng1");
cout << heng->GetEntries() << endl;
//f1.Close();
f1->Delete();

for (a=0;a<800;a++) cout << heng->GetBinCenter(a) << " " << heng->GetBinContent(a) << " " << heng1->GetBinContent(a) << endl;

}[/code]

However this crashes with this error message:
129892
687021
SysError in TObject::(null): (No such file or directory)
Fatal in TObject::(null):
aborting

How do I fix this? Thanks in advance.

You have a syntax error:

   BlackTree>Draw("energy>>heng1(800,0,0.6)");

it should be:

   BlackTree->Draw("energy>>heng1(800,0,0.6)");

Sorry, that was caused during the cut and paste. The original code did not have that error. So that is not the cause of the problem

[quote=“couet”]You have a syntax error:

   BlackTree>Draw("energy>>heng1(800,0,0.6)");

it should be:

BlackTree->Draw("energy>>heng1(800,0,0.6)"); [/quote]