[1199] | 1 | #!/usr/bin/env python |
---|
| 2 | |
---|
| 3 | import os, sys |
---|
| 4 | from ROOT import gROOT, gStyle, TFile, TCanvas, TGraph |
---|
| 5 | from array import array |
---|
| 6 | |
---|
| 7 | path1 = os.path.basename(sys.argv[1]) |
---|
| 8 | |
---|
| 9 | dirList=os.listdir(path1) |
---|
| 10 | for fname in dirList: |
---|
| 11 | print fname |
---|
| 12 | gROOT.Reset() |
---|
| 13 | |
---|
| 14 | # n = 1100 |
---|
| 15 | n = 35 |
---|
| 16 | En, Y1, Y2, diff, pres = array( 'd' ), array( 'd' ), array( 'd' ), array( 'd' ), array( 'd' ) |
---|
| 17 | |
---|
| 18 | c1 = TCanvas('c1', 'c1',6,6,800,600) |
---|
| 19 | gStyle.SetOptStat(0) |
---|
| 20 | c1.SetLogx() |
---|
| 21 | c1.SetFillColor(0) |
---|
| 22 | c1.SetBorderMode(0) |
---|
| 23 | c1.SetBorderSize(0) |
---|
| 24 | c1.SetFrameBorderMode(0) |
---|
| 25 | |
---|
| 26 | infile = open(fname, 'r') |
---|
| 27 | |
---|
| 28 | lines = infile.readlines() |
---|
| 29 | title = lines[0] |
---|
| 30 | |
---|
| 31 | for line in lines[1:]: |
---|
| 32 | e = (float(line.split() [0])) |
---|
| 33 | y1 = (float(line.split() [1])) |
---|
| 34 | y2 = (float(line.split() [2])) |
---|
| 35 | di = (float(line.split() [3])) |
---|
| 36 | if y2 == 0: |
---|
| 37 | pr = 0 |
---|
| 38 | else: |
---|
| 39 | pr = ((y1/y2 - 1)*100) |
---|
| 40 | En.append (e) |
---|
| 41 | Y1.append (y1) |
---|
| 42 | Y2.append (y2) |
---|
| 43 | diff.append (di) |
---|
| 44 | pres.append (pr) |
---|
| 45 | |
---|
| 46 | gr = TGraph(n,En,pres) |
---|
| 47 | grTit = fname + ' / 100 pts per order, Pb' |
---|
| 48 | gr.SetTitle(grTit) |
---|
| 49 | gr.SetMarkerStyle(22) |
---|
| 50 | gr.SetMarkerSize(0.8) |
---|
| 51 | gr.GetYaxis().SetLabelFont(132) |
---|
| 52 | gr.GetYaxis().SetLabelSize(0.04) |
---|
| 53 | gr.GetXaxis().SetLabelFont(132) |
---|
| 54 | gr.GetXaxis().SetLabelSize(0.04) |
---|
| 55 | gr.GetXaxis().SetTitle('E, MeV') |
---|
| 56 | gr.GetYaxis().SetTitle('(Y1/Y2 - 1), %') |
---|
| 57 | gr.GetXaxis().SetTitleOffset(1.2) |
---|
| 58 | gr.Draw('AP') |
---|
| 59 | |
---|
| 60 | c1.Modified() |
---|
| 61 | c1.cd() |
---|
| 62 | plNam = fname + '.png' |
---|
| 63 | c1.Print(plNam) |
---|