38from __future__ 
import print_function
 
   49    header_mapping_dictionary = {
 
   50               'Date/Time'         : (
'Datetime'       , str) ,
 
   51               'Synchro'           : (
'Synchro'        , int) ,
 
   52               'Capacity'          : (
'Capacitance'    , float) ,
 
   53               'Temp.Cold Head'    : (
'TempColdHead'   , float) ,
 
   54               'Temp. Electrode'   : (
'TempElectrode'  , float) ,
 
   55               'HV Supply Voltage' : (
'HVSupplyVoltage', float) ,
 
   56               'Electrode 1'       : (
'Electrode1'     , int) ,
 
   57               'Electrode 2'       : (
'Electrode2'     , int) ,
 
   58               'Electrode 3'       : (
'Electrode3'     , int) ,
 
   59               'Electrode 4'       : (
'Electrode4'     , int) ,
 
   62    type_mapping_dictionary = {
 
   82    header_row        = open(afile).
readline().strip().split(
'\t')
 
   84    branch_descriptor = 
':'.join([header_mapping_dictionary[row][0]+
'/'+
 
   85                           type_mapping_dictionary[header_mapping_dictionary[row][1]]
 
   86                           for row 
in header_row])
 
   91    output_ROOT_file_name  = os.path.splitext(afile)[0] + 
'.root' 
   92    output_file            = ROOT.TFile(output_ROOT_file_name, 
'recreate')
 
   93    print(
"Outputting %s -> %s" % (afile, output_ROOT_file_name))
 
   95    output_tree            = ROOT.TTree(tree_name, tree_name)
 
   96    file_lines             = open(afile).readlines()
 
  104    file_lines     = [
'\t'.join([val 
if (val.find(
' ') == -1 
and val != 
'')
 
  105                                else 'empty' for val 
in line.split(
'\t')])
 
  106                             for line 
in file_lines[1:] 
if line[0] != 
'#' ]
 
  110    file_as_string = (
'\n'.join(file_lines)).replace(
'NaN', str(0.0))
 
  114    istring        = ROOT.istringstream(file_as_string)
 
  117    output_tree.ReadStream(istring, branch_descriptor)
 
  123if __name__ == 
'__main__':
 
  124    if len(sys.argv) < 2:
 
  125        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