make_input_cov.py
Go to the documentation of this file.
1 import ROOT as RT
2 from argparse import ArgumentParser as ap
3 from array import array
4 
5 parser = ap()
6 
7 parser.add_argument("-i", type=str, help='Input file', default = "")
8 parser.add_argument("-o", type=str, help='Output file', default = "covariance.root")
9 args = parser.parse_args()
10 
11 input_file = open(args.i, "r")
12 
13 output_file = RT.TFile(args.o, "RECREATE")
14 
15 lines = input_file.readlines()
16 cov_vals = []
17 n = 0
18 for l in lines:
19  if "#" in l:
20  print(l)
21  continue
22  l = l.strip("\n")
23  l_split = l.split()
24  print(l_split)
25  #cov_vals.append([])
26  n += 1
27  for s in l_split:
28 # cov_vals[-1].append(float(s))
29  cov_vals.append(float(s))
30 
31 cov_matrix = RT.TMatrixD(n, n, array("d", cov_vals))
32 cov_matrix.Write("m")
33 output_file.Close()
int open(const char *, int)
Opens a file descriptor.
auto array(Array const &a)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:228