#!/usr/bin/env python # ----------------------------------------------------------------------------------- # # # ROOT macro for reading data for the Applied Statistics exam 2016 problem 5.2. # # Author: Troels C. Petersen (NBI) # Email: petersen@nbi.dk # Date: 11th of January 2017 # # ----------------------------------------------------------------------------------- # from ROOT import * from array import array import math def sqr(a) : return a*a # ----------------------------------------------------------------------------------- # # ----------------------------------------------------------------------------------- # # Setting what to be shown in statistics box: gStyle.SetOptStat("eMR") gStyle.SetOptFit(1111) # Text to write on the plot: text = TLatex() text.SetNDC() pi = TMath.Pi() SavePlots = False # ----------------------------------------------------------------------------------- # # Read data: # ----------------------------------------------------------------------------------- # data = [] counter = 0 hist_tres = TH1F("hist_tres", ";Residual (s);Frequency", 100, -1.0, 1.0) with open( "data_TimingResiduals.txt", 'r' ) as infile : for line in infile: line = line.strip().split() data.append(float(line[0])) hist_tres.Fill(data[-1]) print " %4d %6.3f seconds"%(counter, data[-1]) counter += 1 canvas = TCanvas("canvas", "", 20, 20, 1000, 600) hist_tres.Draw() canvas.Update() #---------------------------------------------------------------------------------- # End program... #---------------------------------------------------------------------------------- raw_input('Press Enter to exit')