ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
Sorry if my question is stupid. But understand that I am new to CERN-ROOT.
I am working with the latest version of root. Using a python code (attached in the end) I have converted CSV format files into ROOT files. I can also individually plot them.
But I want an accumulated plot of all the files (approximately 100). Can anyone help me with this?
Python Code:
#!/usr/bin/python
import sys, os, re
from ROOT import *
format is
#TIME,CH1,…
#,,,,
def do(ifname,ofname):
g = {}
g[0] = TGraph(0)
g[1] = TGraph(0)
g[2] = TGraph(0)
g[3] = TGraph(0)
sw = 0
for line in open(ifname).readlines():
m = str(line).replace('\n','')
if (sw == 1) and (len(m) > 5):
s = m.replace(',',' ')
ss = s.split()
if(len(ss)<2): continue
tm = float(ss[0])
v = map(float,ss[1:])
for i in range(len(ss)-1):
g[i].SetPoint( g[i].GetN(), tm, v[i] )
if re.search('TIME,CH1.*',m):
sw = 1
##
ofile = TFile(ofname,"RECREATE")
ofile.cd()
for i in range(4):
if g[i].GetN() > 0:
g[i].Write("g%d"%i)
ofile.Close()
if name == ‘main’:
if len(sys.argv) < 3:
print "Usage : “,sys.argv[0],” "
sys.exit()
ifname = str( sys.argv[1] )
ofname = str( sys.argv[2] )
do(ifname,ofname)