Problem with Filling large tree with pyROOT

I am trying to fill a tree from a large dataset (about 2 GB) using pyROOT. The branches contain vector of vectors of double type. The code logic runs fine with a smaller data set but when I am running it with the actual large dataset the code exits with a “Killed” message at the tree.Fill() statement.

import numpy as np
import ROOT as rt
import sys
import operator
import collections

from collections import OrderedDict

infile_nm = sys.argv[1]

print infile_nm+" Reading\n"

data = np.loadtxt(infile_nm)

dec_nm = infile_nm.split("_")[1].split('.')[0]

rfile_nm = dec_nm+"_pulses_ordered.root"
dfile_nm = dec_nm+"_ordered.dat"

print "File READ\n"

t_vec = rt.std.vector(rt.std.vector("double"))()
w_vec = rt.std.vector(rt.std.vector("double"))()
v1  = rt.vector("double")()
v2  = rt.vector("double")()

rf = rt.TFile(rfile_nm,"RECREATE")

rtree = rt.TTree("Data","Pulse Tree")

rtree.Branch("Time",t_vec)
rtree.Branch("Wavelength",w_vec)

ddit = {}

fl1 = False
n = 1
p = 0

ofile = open(dfile_nm,'a')

for row in data:
    if(row[0] != 0):

        if(fl1 == False):
            p = p + 1
            fl1 = True
            ke, val = float(row[1]), float(row[0])
            ddit[ke] = val
            print "pulse found at " + str(n)

        else:
            ke, val = float(row[1]), float(row[0])
            ddit[ke] = val

    else:
        if(p > 0 and fl1 == True):
            s_ddit = sorted(ddit.items(), key=operator.itemgetter(0)) #new OrderedDict
            arr = np.asarray(s_ddit,dtype=np.float32)
            v1+=arr[:,0]
            v2+=arr[:,1]
            np.savetxt(ofile,arr,fmt='%f',newline='\n')
            #print np.asarray(v2)
            #ofile.write("0\t0")
            print "\n===============\n"
            t_vec.push_back(v1)
            w_vec.push_back(v2)
        fl1 = False
        ddit.clear()
        v1.clear()
        v2.clear()

    n = n + 1

print p

rtree.Fill()
rtree.Write()

_ROOT Version: 6.14/06
_Platform: Ubuntu 16.04
_Compiler: python 2.7


Hello,

You are using a fairly old ROOT version, could you try with a more recent one (e.g. 6.24/02)?

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