48 header_mapping_dictionary = {
49 'Date/Time' : (
'Datetime' , str) ,
50 'Synchro' : (
'Synchro' , int) ,
51 'Capacity' : (
'Capacitance' , float) ,
52 'Temp.Cold Head' : (
'TempColdHead' , float) ,
53 'Temp. Electrode' : (
'TempElectrode' , float) ,
54 'HV Supply Voltage' : (
'HVSupplyVoltage', float) ,
55 'Electrode 1' : (
'Electrode1' , int) ,
56 'Electrode 2' : (
'Electrode2' , int) ,
57 'Electrode 3' : (
'Electrode3' , int) ,
58 'Electrode 4' : (
'Electrode4' , int) ,
61 type_mapping_dictionary = {
81 header_row = open(afile).
readline().strip().split(
'\t')
83 branch_descriptor =
':'.join([header_mapping_dictionary[row][0]+
'/'+
84 type_mapping_dictionary[header_mapping_dictionary[row][1]]
85 for row
in header_row])
90 output_ROOT_file_name = os.path.splitext(afile)[0] +
'.root'
91 output_file = ROOT.TFile(output_ROOT_file_name,
'recreate')
92 print(
"Outputting %s -> %s" % (afile, output_ROOT_file_name))
94 output_tree = ROOT.TTree(tree_name, tree_name)
95 file_lines = open(afile).readlines()
103 file_lines = [
'\t'.join([val
if (val.find(
' ') == -1
and val !=
'')
104 else 'empty' for val
in line.split(
'\t')])
105 for line
in file_lines[1:]
if line[0] !=
'#' ]
109 file_as_string = (
'\n'.join(file_lines)).replace(
'NaN', str(0.0))
113 istring = ROOT.istringstream(file_as_string)
116 output_tree.ReadStream(istring, branch_descriptor)
122if __name__ ==
'__main__':
123 if len(sys.argv) < 2:
124 print(
"Usage: %s file_to_parse.dat" % sys.argv[0])
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len