Redirect branch into histogram?

Hi,

I would like to redirect a branch with some contraints into an existing histogram as in cint
I have a tree called rootTree with several branches and would like to script the creation of plots including some constraints. Thus, I tried to create a histogram with the right binning and redirect the drawn branch into it like with CINT – however the histogram stays empty

import ROOT canvas = ROOT.TCanvas("canvas","Canvas Title") canvas.cd() histo = ROOT.TH1D("histo","test",100,0.,30.) rootTree.Draw("myBranch>>histo","anotherBranch==1") histo.Draw() canvas.Update() canvas.Print("foo.pdf" )

Is there a way to draw the branch into my histogram?

Cheers and thanks for ideas,
Thomas

Hi,
you could do the following:

import ROOT
canvas = ROOT.TCanvas("canvas","Canvas Title")
canvas.cd()
rootTree.Draw("myBranch>>histo(100.,0.,30.)","anotherBranch==1")
histo=ROOT.gROOT.FindObject("histo")
histo.Draw()
canvas.Update()
canvas.Print("foo.pdf" )