I know there is the nice quick and easy way to plot branches from a root file, eg. a root file “MyFile.root” containing a tree named “MyTree”, which contains a branch named “MyVariable”, one could use the following small script in C++ or in root directly :
TFile *f = TFile::Open("MyFile.root") TTree *t = (TTree*)f->Get("MyTree") TH1D *h1 = new TH1D("h1", "h1", 100, 0.0, 100.0) t->Draw("MyVariable >> h1")
This plots all values of the variable into a defined histogram with given number of bins and plotrange.
I am creating a TTree in a python script and I would like to plot all branches of this tree in within the python script, so the question is if there is any way to port the script shown above into pyROOT, since this approach seems to be much faster than looping the events and filling the variable manually!?