I need to draw a function from ntuple
data.root is the name of root file
vdMScanData is ntuple directory
SCANDATA is ntuple subdirectory where are stored “NominalSeparation” and “ScanLB” branches(variables)
This is what I tried:
from ROOT import TCanvas, TPad, TFile, TPaveText
from ROOT import gBenchmark, gStyle, gROOT
c1 = TCanvas(‘c1’,‘The Ntuple canvas’,200,10,700,780)
f1 = TFile(‘data.root’)
pad1 = TPad(‘pad1’,‘This is pad1’,0.02,0.52,0.48,0.98,21)
pad1.cd()
ntuple = gROOT.FindObject(‘vdMScanData’)
ntuple.Draw(‘NominalSeparation:ScanLB’)
You can see that the error says: attempt to access null-pointer which means the ntuple is not pointing to your SCANDATA branch.
The solution given by @pcanal should work.