I tried to run simple python script on Windows with ROOT 6.26.02 and python 3.8.10 and noticed that I can not create more than two canvas. Python simply hangs when 3rd canvas is created. Is it known feature ?
Code is given below and input file can be found in ~solodkov/public/pyroot on AFS at CERN
########### cut here ###################
import os,sys
if os.name == 'nt':
sys.path.append(r'C:\root_v6.26.02\bin')
import ROOT
ncanvas = 4
timesleep = 5
inputfile = 'cs11828.root'
print('Opening %s' % inputfile)
file = ROOT.TFile(inputfile)
file.cd("RawData")
ps_names=['10A','14A','18A','22A','46A','50A','34A','54A']
cc = []
adc = []
for i in range(ncanvas):
adcname = 'Cs.ADC.%s' % ps_names[i]
print('Looking for %s' % adcname)
adc += [ROOT.gDirectory.Get(adcname)]
nm = "c%d" % (i+1)
cc += [ROOT.TCanvas(nm,nm,50*i,50*i,800,600)]
adc[i].Draw('value')
cc[i].Update()
if timesleep>0:
import time
print('Sleeping %d sec' % timesleep)
time.sleep(timesleep)
###################### cut here ##########################
ROOT Version: 6.26.02 Platform: Windows Compiler: Not Provided
On WSL, without your file and only opening (but not using) hsimple.root, these lines work, creating 4 empty canvases:
import os,sys
if os.name == 'nt':
sys.path.append(r'C:\root_v6.26.02\bin')
import ROOT
ncanvas = 4
timesleep = 5
inputfile = 'hsimple.root'
print('Opening %s' % inputfile)
file = ROOT.TFile(inputfile)
ps_names=['10A','14A','18A','22A','46A','50A','34A','54A']
cc = []
adc = []
for i in range(ncanvas):
adcname = 'Cs.ADC.%s' % ps_names[i]
print('Looking for %s' % adcname)
nm = "c%d" % (i+1)
cc += [ROOT.TCanvas(nm,nm,50*i,50*i,800,600)]
print('nm = %s' % nm)
if timesleep>0:
import time
print('Sleeping %d sec' % timesleep)
time.sleep(timesleep)
Maybe the problem is with your root file, maybe it does not contain some of the objects you are trying to get, or there is a problem drawing them. Try checking that.