Plotting branches from different trees in same TFile

Hi, I’m tryiing to plot two histos in same canvas. There is one TFile objet, who has two trees (Wbb, ttvar) and each one has the branch HP_ENVERTEX_X. I’m only getting plotted one histo. What am i doing wrong?

Here is the code:

import ROOT
f=ROOT.TFile('MC_ntuples.root')


Wbb=f.Get('Wbb')
ttvar=f.Get('ttvar')

Wbb.Draw('HP_ENDVERTEX_X')
ttvar.Draw('HP_ENDVERTEX_X','same')

Thank you.

Got this error:

File "proba.py", line 11, in <module>
    ttvar.Draw('HP_ENDVERTEX_X','','same')
TypeError: void TObject::Draw(const char* option = "") =>
    takes at most 1 arguments (3 given)

Probably because ttvar has only 2 args, when at minimum 3 is needed to use “same”. Try with

ttvar.Draw("variable", "", "same")

Empty string in second arg just means no cut is applied.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.