make_root_from_grid_output.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 from __future__ import print_function
4 
5 from array import array
6 
7 from ROOT import *
8 
9 import glob
10 
12 
13  with open(fn, 'r') as inf:
14 
15  for line in inf:
16 
17  line = line.rstrip('\n').rstrip(' ')
18 
19  values = line.split(' ')
20 
21  run[0] = int(values[0])
22 
23  subrun[0] = int(values[1])
24 
25  cycle[0] = int(values[2])
26 
27  evt[0] = int(values[3])
28 
29  subevt[0] = int(values[4])
30 
31  npng1gamma[0] = float(values[5])
32 
33  npng2gamma[0] = float(values[6])
34 
35  ncgappng1[0] = float(values[7])
36 
37  ncgappng2[0] = float(values[8])
38 
39  nc[0] = int(values[9])
40 
41  ispi0[0] = int(values[10])
42 
43  tr.Fill()
44 
45 
46 file_list = [name for name in glob.glob('/pnfs/nova/persistent/users/acedeno/ncpi0/nd_fhc_nc_selection_stride_FlatFluxdataset1_offset0*')]
47 #file_list1 = [name for name in glob.glob('/pnfs/nova/persistent/users/acedeno/ncpi0/nd_fhc_nc_selection_stride_FlatFluxdataset1_offset0*')]
48 #file_list2 = [name for name in glob.glob('/pnfs/nova/persistent/users/acedeno/ncpi0/nd_fhc_nc_selection_stride_GenieLikedataset1_offset0*')]
49 #file_list3 = [name for name in glob.glob('/pnfs/nova/persistent/users/acedeno/ncpi0/nd_fhc_nc_selection_stride_2viewdataset1_offset0*')]
50 
51 #file_list = [name for name in glob.glob('/pnfs/nova/persistent/users/acedeno/ncpi0/nd_fhc_nc_selection_stride_flatdataset1_offset*')]
52 #file_list = [name for name in glob.glob('/nova/app/users/acedeno/tag_releasesS18-06-14/NDAna/ncpi0_semi_inc_png_cvn/nd_fhc_nc_selection_stride_nominaldataset250_offset*')]
53 print(len(file_list))
54 #print(len(file_list1))
55 #print(len(file_list2))
56 #print(len(file_list3))
57 
58 #~ for name in glob.glob('grid_output/*.txt'):
59 
60 #~ for name in glob.glob('grid_output/nd_rhc_numubarcc_selection_stride2_offset0.1_of_200.txt'):
61 
62  #~ file_list.append(name)
63 
64 # make the tree
65 
66 outf = TFile('training_sample_FlatFlux.root', 'recreate')
67 #outf1 = TFile('training_sample_FlatFlux.root', 'recreate')
68 #outf2 = TFile('training_sample_GenieLike.root', 'recreate')
69 #outf3 = TFile('training_sample_2view.root', 'recreate')
70 
71 
72 tr = TTree('tr', 'tree of training sample')
73 
74 # tree leave
75 
76 run = array('i', [0])
77 
78 subrun = array('i', [0])
79 
80 cycle = array('i', [0])
81 
82 evt = array('i', [0])
83 
84 subevt = array('i', [0])
85 
86 npng1gamma = array('f', [0.])
87 
88 npng2gamma = array('f', [0.])
89 
90 ncgappng1 = array('f', [0.])
91 
92 ncgappng2 = array('f', [0.])
93 
94 nc = array('i',[0])
95 
96 ispi0 = array('i',[0])
97 
98 tr.Branch('run', run, 'run/I')
99 
100 tr.Branch('subrun', subrun, 'subrun/I')
101 
102 tr.Branch('cycle', cycle, 'cycle/I')
103 
104 tr.Branch('evt', evt, 'evt/I')
105 
106 tr.Branch('subevt', subevt, 'subevt/I')
107 
108 tr.Branch('npng1gamma', npng1gamma, 'npng1gamma/F')
109 
110 tr.Branch('npng2gamma', npng2gamma, 'npng2gamma/F')
111 
112 tr.Branch('ncgappng1', ncgappng1, 'ncgappng1/F')
113 
114 tr.Branch('ncgappng2', ncgappng2, 'ncgappng2/F')
115 
116 tr.Branch('nc', nc, 'nc/I')
117 
118 tr.Branch('ispi0', ispi0, 'nc/I')
119 
120 for f in file_list:
121 
123 
124 outf.Write()
125 
126 #for k in file_list1:
127 
128  # process_one_file(k)
129 
130 #outf1.Write()
131 
132 #for i in file_list2:
133 
134  # process_one_file(i)
135 
136 #outf2.Write()
137 
138 
139 #for j in file_list3:
140 
141  # process_one_file(j)
142 
143 #outf3.Write()
bool print
procfile open("FD_BRL_v0.txt")