dumpEventsToText.py
Go to the documentation of this file.
1 from ROOT import *
2 import cvnie
3 
4 
5 
6 
7 import argparse
8 
9 parser = argparse.ArgumentParser(description='Dump a tree to text.')
10 parser.add_argument('input', type=str,
11  help="""
12  Input file. Will take "cvndump/CVNTrainTree" directory and dump it
13  to text.""")
14 
15 args = parser.parse_args()
16 
17 
18 infile = args.input
19 
20 outfileName = infile.replace(".root", ".cvnevents.txt")
21 
22 outfile = open(outfileName, "w")
23 
24 rootFile = TFile.Open(infile, "READ")
25 
26 
27 tree = rootFile.Get("cvndump/CVNTrainTree")
28 
29 numEntries = tree.GetEntries()
30 numInputs = None
31 numOutputs = 11 # Hard code this for now. Hopefully find a better way later?
32 
33 
34 
35 for entry in tree:
36  if not numInputs:
37  numInputs = entry.train.fPMap.fPE.size()
38  # Now we know everything, write the first line.
39  outfile.write(" ".join([str(numEntries), str(numInputs), str(numOutputs)]) + "\n")
40 
41  inputs = [str(pe) for pe in entry.train.fPMap.fPE]
42  outfile.write(" ".join(inputs) + "\n")
43  outputs = ["0"] * numOutputs
44  outputs[entry.train.fInt] = str(1)
45  outfile.write(" ".join(outputs) + "\n")
46 
47 
48 outfile.close()
49 
procfile open("FD_BRL_v0.txt")