-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfogplot.py
92 lines (71 loc) · 2.61 KB
/
fogplot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import ROOT as r
import sys
#plofile plots, averaging over all points
r.gStyle.SetOptStat(0)
botfog = r.TProfile("botfog","Fog plot of bot layer;z[#mum];fog(1/1000#mum^3)",40,150,550,0.,50.)#19
topfog = r.TProfile("topfog","Fog plot of top layer;z[#mum];fog(1/1000#mum^3)",40,150,550,0.,50.)#19
#botfog = r.TProfile("botfog","Fog plot of bot layer;z[#mum];fog(1/1000#mum^3)",40,150,559,0.,50.)#49
#topfog = r.TProfile("topfog","Fog plot of top layer;z[#mum];fog(1/1000#mum^3)",40,150,559,0.,50.)#49
endoffile = False
filepath = sys.argv[1]
ntotview = 0
with open(filepath,"r") as fogfile:
while (endoffile == False): #reading file continuously
viewheader = fogfile.readline()
try:
nlinesview = int(viewheader.split()[0])
for iline in range(nlinesview):
viewdata = fogfile.readline().split()
if (float(viewdata[0]) < 300.):
botfog.Fill(float(viewdata[0]),float(viewdata[3])*1e+3)
else:
topfog.Fill(float(viewdata[0]),float(viewdata[3])*1e+3)
ntotview = ntotview+1/2.
except IndexError: #we have reached end of file
endoffile = True
print("we have in total {} views".format(int(ntotview)))
cfogall = r.TCanvas()
#cfogall.Divide(2,1)
#cfogall.cd(1)
botfog.Draw("hist C*")
#cfogall.cd(2)
topfog.Draw("hist C* SAME")
#graphs for singlew view
botviewgraph = r.TGraph()
topviewgraph = r.TGraph()
cbotview = r.TCanvas()
ctopview = r.TCanvas()
def plotview(myview):
''' reading view number myview'''
#clearing graphs
botviewgraph.Clear()
topviewgraph.Clear()
with open(filepath,"r") as fogfile:
iview = 0
ipointbot = 0
ipointtop = 0
while (iview <= myview):
#reading view bot
viewheader = fogfile.readline()
nlinesview = int(viewheader.split()[0])
for iline in range(nlinesview):
viewdata = fogfile.readline().split()
if (iview==myview): #plotting only points of view equal to the desired one myview
botviewgraph.SetPoint(ipointbot, float(viewdata[0]),float(viewdata[3])*1e+3)
ipointbot+=1
#reading view top
viewheader = fogfile.readline()
nlinesview = int(viewheader.split()[0])
for iline in range(nlinesview):
viewdata = fogfile.readline().split()
if (iview==myview): #plotting only points of view equal to the desired one myview
topviewgraph.SetPoint(ipointtop, float(viewdata[0]),float(viewdata[3])*1e+3)
ipointtop+=1
iview += 1
cbotview.cd()
botviewgraph.SetTitle("Fog plot of bot layer for view {};z[#mum];fog(1/1000#mum^3)".format(myview))
botviewgraph.Draw("AP*")
ctopview.cd()
topviewgraph.SetTitle("Fog plot of top layer for view {};z[#mum];fog(1/1000#mum^3)".format(myview))
topviewgraph.Draw("AP*")
plotview(1)