Draw "same" leaves canvas blank

I have two trees, in two different ROOT files, and I would like to superimpose two histograms. (note: both Trees are named “processed”, and both branches are Eg1).

I do something like:
TFile (“file1.root”);
TTree processed = (TTree)f->Get(“processed”);
processed.Draw(“Eg1>>h1(4096,0,4096)”,“some cut”);
TFile f(“file2.root”);
TTree processed = (TTree)f->Get(“processed”);
processed.Draw(“Eg1>>h2(4096,0,4096)”,“same cut”,“same”);

This outputs an empty canvas. If I take away the “same” in the second Draw, the script will output the second histogram as expected. But when the “same” is included, the canvas comes out blank.

I have searched numerous threads in the Roottalk digest, and found that these steps should work! I simply don’t know why I am getting a blank canvas. I have overlayed two histograms easily when they are in the same ROOT file, or the same tree.

I appreciate any help you can give.

Thank you!

I apologize, I found that I should do

TFile *f = new TFile(“file.root”);

instead of

TFile f(“file.root”);

And then everything works as expected.
Thank you, anyway!


TDirectory *where = gROOT; // or TFile::Open("output.root","RECREATE"); TFile ("file1.root"); TTree *processed = (TTree*)f->Get("processed"); processed.SetLineColor(kBlack); where->cd(); processed.Draw("Eg1>>h1(4096,0,4096)","some cut"); TFile f("file2.root"); TTree *processed = (TTree*)f->Get("processed"); processed.SetLineColor(kRed); where->cd(); processed.Draw("Eg1>>h2(4096,0,4096)","same cut","same");would also work.