forked from MarcoGitHubAccount/FccUGgroup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCurrent Plot Model.py
171 lines (140 loc) · 5.87 KB
/
Current Plot Model.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env python
# coding: utf-8
# In[18]:
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.colors as mcolors
def graphMaker():
fileType = int(input('What file would you like to look over, EE [1], E+Mu [2], E-Mu [3], MuMu [4]'))
graphType = int(input('What graph would you like to see, Pt Energy [1], Phi [2], Eta [3]'))
#Importing the data in
if fileType == 1:
Data = pd.read_csv('skimgen_ee_data.txt')
# Naming for the data and the chart
RealName = 'Electron'
AntiName = 'Positron'
elif fileType == 2:
Data = pd.read_csv('skimgen_e+mu_data.txt')
# Naming for the data and the chart
RealName = 'Muon'
AntiName = 'Positron'
elif fileType == 3:
Data = pd.read_csv('skimgen_e-mu_data.txt')
# Naming for the data and the chart
RealName = 'Electron'
AntiName = 'Anti-Muon'
elif fileType == 4:
Data = pd.read_csv('skimgen_mumu_data.txt')
# Naming for the data and the chart
RealName = 'Muon'
AntiName = 'Anti-Muon'
else:
print('Please choose your file type')
#Spliting up the data into its particles
# Electron Positron
if fileType == 1:
#Real Particle First (Electron)
RData = Data['pdgId'] == 11
ORData = Data[RData]
#Anti Particle Next (Positron)
AData = Data['pdgId'] == -11
OAData = Data[AData]
# Positron Muon
elif fileType == 2:
#Real Particle First (Muon)
RData = Data['pdgId'] == 13
ORData = Data[RData]
#Anti Particle Next (Positron)
AData = Data['pdgId'] == -11
OAData = Data[AData]
# Electron Anti-Muon
elif fileType == 3:
#Real Particle First (Electron)
RData = Data['pdgId'] == 11
ORData = Data[RData]
#Anti Particle Next (Anti-Muon)
AData = Data['pdgId'] == -13
OAData = Data[AData]
# Moun Anti-Muon
elif fileType == 4:
#Real Particle First (Muon)
RData = Data['pdgId'] == 13
ORData = Data[RData]
#Anti Particle Next (Anti-Muon)
AData = Data['pdgId'] == -13
OAData = Data[AData]
else:
print('Please choose your file type')
#Making our graphs
if graphType == 1:
#Making our Pt graph
#Sepreating our data to only the pt of the particle
ORpt = ORData['pT']
OApt = OAData['pT']
# Making our graph to compare the two energy levels and making them logrithmic for an easier viewing
plt.hist(x=ORpt,bins=int(np.floor(ORpt.size**(1/2))),color='dodgerblue' , alpha=0.4, label=RealName)
plt.xscale('log',base=10)
plt.hist(x=OApt,bins=int(np.floor(OApt.size**(1/2))),color='forestgreen', alpha=0.35, label=AntiName)
plt.xscale('log',base=10)
plt.legend(loc='upper right')
plt.title( RealName + ' ' + AntiName + ' Pt plot')
plt.xlabel('Pt')
plt.ylabel('Frequency')
plt.plot(graphType)
plt.show()
#Print off the list of important information for the energy
print('Pt |'+ RealName + ' ' + AntiName)
print('------------------------')
print('Avg |'+(str(ORpt.mean())[:10])+' '+(str(OApt.mean())[:10])+'|')
print('Med |'+(str(ORpt.median())[:10])+' '+(str(OApt.median())[:10])+'|')
print('Min |'+(str(ORpt.min())[:10])+' '+(str(OApt.min())[:10])+'|')
print('Max |'+(str(ORpt.max())[:10])+' '+(str(OApt.max())[:10])+'|')
if graphType == 2:
#Making our Phi graph
#Sepreating our data to only the phi of the particle
ORphi = ORData['phi']
OAphi = OAData['phi']
# Making our graph to compare the two phi values
plt.hist(ORphi,bins=int(np.floor(ORphi.size**(1/2))),color='dodgerblue' , alpha=0.6, label=RealName)
plt.hist(OAphi,bins=int(np.floor(OAphi.size**(1/2))),color='forestgreen', alpha=0.6, label=AntiName)
plt.legend(loc='upper right')
plt.title( RealName + ' ' + AntiName + ' Phi plot')
plt.ylabel('Phi')
plt.xlabel('Frequency')
plt.plot(graphType)
plt.show()
#Print off the list of important information for the energy
print('Phi |'+ RealName + ' ' + AntiName)
print('------------------------')
print('Avg |'+(str(ORphi.mean())[:10])+' '+(str(OAphi.mean())[:10])+'|')
print('Med |'+(str(ORphi.median())[:10])+' '+(str(OAphi.median())[:10])+'|')
print('Min |'+(str(ORphi.min())[:10])+' '+(str(OAphi.min())[:10])+'|')
print('Max |'+(str(ORphi.max())[:10])+' '+(str(OAphi.max())[:10])+'|')
if graphType == 3:
#Making our Eta graph
#Sepreating our data to only the eta of the particle
OReta = ORData['eta']
OAeta = OAData['eta']
# Making our graph to compare the two eta values
plt.hist(x=OReta,bins=int(np.floor(OReta.size**(1/2))),color='dodgerblue' , alpha=0.6, label=RealName)
plt.hist(x=OAeta,bins=int(np.floor(OAeta.size**(1/2))),color='forestgreen', alpha=0.6, label=AntiName)
plt.legend(loc='upper right')
plt.title( RealName + ' ' + AntiName + ' Eta plot')
plt.ylabel('Eta')
plt.xlabel('Frequency')
plt.plot(graphType)
plt.show()
#Print off the list of important information for the energy
print('Eta |'+ RealName + ' ' + AntiName)
print('------------------------')
print('Avg |'+(str(OReta.mean())[:10])+' '+(str(OAeta.mean())[:10])+'|')
print('Med |'+(str(OReta.median())[:10])+' '+(str(OAeta.median())[:10])+'|')
print('Min |'+(str(OReta.min())[:10])+' '+(str(OAeta.min())[:10])+'|')
print('Max |'+(str(OReta.max())[:10])+' '+(str(OAeta.max())[:10])+'|')
n = input('Would you like to make another [y] or [n]')
if n == 'y':
graphMaker()
else:
n = 0
graphMaker()