#!/usr/bin/env python

# ----------------------------------------------------------------------------------- #
#
#  Python/ROOT macro for reading data in exam problem 4.1.
#
#  Author: Troels C. Petersen (NBI)
#  Email:  petersen@nbi.dk
#  Date:   29th of October 2014
#
# ----------------------------------------------------------------------------------- #

from ROOT import *


# ----------------------------------------------------------------------------------- #

# Open file for reading:
f = open('data_problem41.txt', 'r')
Nread = 0

# Read and ignore header line
header1 = f.readline()

# Loop over lines and extract variables of interest
for line in f:
    line = line.strip()
    columns = line.split()

    logg  = float(columns[0])
    elogg = float(columns[1])
    pHT   = float(columns[2])
    epHT  = float(columns[3])
    print "  log(gamma) = %5.3f+-%5.3f    pHT = %5.3f+-%5.3f"%(logg, elogg, pHT, epHT)

    Nread += 1

f.close()

print "  Number of lines read: ", Nread



raw_input('Press Enter to exit')
