pyROOT doesn't recognize "SAME" in histogram plot

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.26.10
Platform: Windows

Hi everyone!
I was trying to plot two histograms on the same canvas in python:

canvas = ROOT.TCanvas(“canvas”)
hist1 = ROOT.TH1F(“hist1”, “Ei_histogram;Ei”, 30,0,4)
gst.Draw(“Ei>>hist1”, “colz”)
hist2 = ROOT.TH1F(“hist2”, “Ef_histogram;Ef”, 30,0,4)
gst.Draw(“Ef>>hist2”, “SAME”)

But for some reason it complains about the “SAME”:
Error in TTreeFormula::Compile: Bad numerical expression : “SAME”
Info in TSelectorDraw::AbortProcess: Variable compilation failed: {Ef,SAME}

Can someone please explain to me what was my mistake here?

Thank you in advance!!!

Hi Kirill,

SAME is supposed to be the third parameter of TTree::Draw, and you put it as a second one. The “selection” should go second, see ROOT: TTree Class Reference for details.


Thank you for your help, I fixed it and it works now:)