make_x_csv.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import ROOT as RT
4 import os
5 from glob import glob as ls
6 from argparse import ArgumentParser as ap
7 
8 parser = ap()
9 
10 parser.add_argument( "-p", type=str, help='Path to files', default='./')
11 args = parser.parse_args()
12 
13 #print(ls(args.p))
14 
15 all_files = [i.split("/")[-1] for i in ls(args.p + "*")]
16 #files = []
17 #Xcalos = []
18 for p in all_files:
19  if 'Xcalo_mich' in p:
20  print(p)
21  if not os.path.islink(p):
22  #Xcalos.append(p)
23  os.system('ConvertXCorrection '+p)
24  else:
25  print(p+' is a link.')
26 #runs = set([i.replace(".root", "").split("_")[-1] for i in Xcalos])
27 #print(runs)
28 
29 #for r in runs:
30 # f0 = open(args.p + 'global_median_0_' + r + '.txt', 'r')
31 # f1 = open(args.p + 'global_median_1_' + r + '.txt', 'r')
32 # f2 = open(args.p + 'global_median_2_' + r + '.txt', 'r')
33 #
34 # info_0 = f0.readlines()[0]
35 # info_1 = f1.readlines()[0]
36 # info_2 = f2.readlines()[0]
37 # print(info_0)
38 # print(info_1)
39 # print(info_2)
40 #
41 # run_num = info_0.split()[0]
42 # norm_0 = info_0.split()[1]
43 # norm_err_0 = str(float(norm_0)/10.)
44 # print(run_num, norm_0, norm_err_0)
45 #
46 # norm_1 = info_1.split()[1]
47 # norm_err_1 = str(float(norm_1)/10.)
48 #
49 # norm_2 = info_2.split()[1]
50 # norm_err_2 = str(float(norm_2)/10.)
51 #
52 #
53 # output = [
54 # 'channel,tv,norm,norm_err\n',
55 # ','.join(['0', run_num, norm_0, norm_err_0+"\n" ]),
56 # ','.join(['1', run_num, norm_1, norm_err_1+"\n" ]),
57 # ','.join(['2', run_num, norm_2, norm_err_2+"\n" ])
58 # ]
59 # print(output)
60 # outfile = open('globalmedians_run' + run_num + '.csv', 'w')
61 # outfile.writelines(output)
62 # outfile.close()