Dividing histograms

I have one very beginner question, namely, if I call two histograms in this way:

  TFile f("example1.root")
  run.Draw("ex-1.1>>hsqrt(200,0,2.6)","cut && qx<-0.9 && qx>-1.3")
  TFile f("t.root")

what would be command line to divide them bin by bin and result show in new canvas?

Thank you.

Something like

TFile f("example1.root") run.Draw("ex-1.1>>hsqrt1(200,0,2.6)","cut && qx<-0.9 && qx>-1.3") TFile f("t.root") h.Draw("e1-1.1>>hsqrt2(200,0,2.6)"); TH1D *h = (TH1D*) hsqrt1->Clone(); h->Divide(hsqrt2); h->Draw();

when I apply this, I receive an error:
Error: Symbol hsqrt1 is not defined in current scope (tmpfile):1:
Error: Failed to evaluate hsqrt1->Clone()

I should be fine… Can you post the exact commands (macro) you performed ?

root [0] TFile *cutfile = new TFile (“cut_be7_c4.root”)
root [1] cut_be7_c4.Print()
root [2] TFile f(“c4.root”)
root [5] run.Draw(“e12v3x-1.145>>hsqrt1(200,0,2.6)”,“cut_be7_c4 && q3v3x<-0.9 && q3v3x>-1.3 && pp3xx<40 && pp3xx>-40”)
root [6] TFile f(“bt.root”)
root [7] h50.Draw(“e12-1.145>>hsqrt2(200,0,2.6)”,“p3<40 && p3>-40”)
root [8] TH1D h = (TH1D) hsqrt1->Clone()

I tried to reproduce you problem with hsimple.root produce by hsimple.C. It is fine … I do not get any error message:

root [0] ntuple->Draw("px >> hx(100,-100,100)");
Info in <TCanvas::MakeDefCanvas>:  created default TCanvas with name c1
root [1] ntuple->Draw("py >> hy(100,-100,100)");
root [2] TH1D *h = (TH1D*) hy->Clone()
(TH1D *) 0x7fe7dc0cf1e0
root [3] 

I understand, but for me does not work. Where I made mistake?

Also, my histograms are in two different root files.

Which ROOT version are you using ?

I think I found problem. Namely, after reading first root file I use this command TH1D h = (TH1D) hsqrt1->Clone(); then I read second file and then I proceeded with h->Divide(hsqrt2);
h->Draw(); instead of reading both files and then typing TH1D h = (TH1D) hsqrt1->Clone(); as I did first and occurred mentioned error.