Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ############## Part 4 ###########################
- #Energy Calibration y=mx+b in keV
- m = 0.4830
- b = 8.7016 #keV
- ChannelEnergy = []
- AlTargetCounts = []
- BGCounts = []
- with open('PairBackground.txt','r') as csvfile:
- xdata = csv.reader(csvfile)
- for row in xdata:
- BGCounts.append(float(row[0]))
- with open('PairAl.txt','r') as csvfile:
- xdata = csv.reader(csvfile)
- for row in xdata:
- AlTargetCounts.append(float(row[0]))
- ChannelEnergy.append(b+m*(len(AlTargetCounts)-1))
- CuTargetCounts = []
- with open('PairCu.txt','r') as csvfile:
- xdata = csv.reader(csvfile)
- for row in xdata:
- CuTargetCounts.append(float(row[0]))
- PbTargetCounts = []
- with open('PairPb.txt','r') as csvfile:
- xdata = csv.reader(csvfile)
- for row in xdata:
- PbTargetCounts.append(float(row[0]))
- CoCounts = []
- with open('PairCo.txt','r') as csvfile:
- xdata = csv.reader(csvfile)
- for row in xdata:
- CoCounts.append(float(row[0]))
- TimeBG = BGCounts[0]
- TimeAl = AlTargetCounts[0]
- TimeCu = CuTargetCounts[0]
- TimePb = PbTargetCounts[0]
- TimeCo = CoCounts[0]
- """#1018,1060
- for i in range(len(ChannelEnergy)):
- if i < 1080:
- BGCounts.pop(0)
- AlTargetCounts.pop(0)
- CuTargetCounts.pop(0)
- PbTargetCounts.pop(0)
- CoCounts.pop(0)
- ChannelEnergy.pop(0)
- """
- """
- plt.plot(ChannelEnergy,AlTargetCounts,label='Al Target')
- plt.plot(ChannelEnergy,CuTargetCounts,label='Cu Target')
- plt.plot(ChannelEnergy,PbTargetCounts,label='Pb Target')
- plt.plot(ChannelEnergy,BGCounts,label='No Target')
- plt.legend()
- """
- #Räknehastigheter
- SAl = []
- SCu = []
- SPb = []
- SCo = []
- SBG = []
- SCH = []
- for i in range(1018,1061):
- SAl.append(AlTargetCounts[i]/2700)
- SCu.append(CuTargetCounts[i]/2700)
- SPb.append(PbTargetCounts[i]/2700)
- SBG.append(BGCounts[i]/2700)
- SCo.append(CoCounts[i]/2700)
- SCH.append(ChannelEnergy[i])
- #First Interval
- FirstAl = []
- FirstCu = []
- FirstPb = []
- FirstCo = []
- FirstBG = []
- FirstCH = []
- for i in range(0,15):
- FirstAl.append(SAl[i]/SBG[i])
- FirstCu.append(SCu[i]/SBG[i])
- FirstPb.append(SPb[i]/SBG[i])
- FirstBG.append(SBG[i])
- FirstCo.append(SCo[i])
- FirstCH.append(SCH[i])
- #Second Interval
- for i in range(34,41):
- FirstAl.append(SAl[i]/SBG[i])
- FirstCu.append(SCu[i]/SBG[i])
- FirstPb.append(SPb[i]/SBG[i])
- FirstBG.append(SBG[i])
- FirstCo.append(SCo[i])
- FirstCH.append(SCH[i])
- #
- AvgAl = 0
- AvgCu = 0
- AvgPb = 0
- AvgCo = 0
- AvgBG = 0
- AvgCH = 0
- for i in range(len(FirstCH)):
- AvgAl = AvgAl + FirstAl[i]
- AvgCu = AvgCu + FirstCu[i]
- AvgPb = AvgPb + FirstPb[i]
- AvgAl = AvgAl/len(FirstCH)
- AvgCu = AvgCu/len(FirstCH)
- AvgPb = AvgPb/len(FirstCH)
- #AvgCo = AvgCo/len(FirstCH)
- #AvgCH = AvgAl/len(FirstCH)
- IntAl = []
- IntCu = []
- IntPb = []
- for i in range(1018,1061):
- IntAl.append((AlTargetCounts[i]/2700)/AvgAl)
- IntCu.append((CuTargetCounts[i]/2700)/AvgCu)
- IntPb.append((PbTargetCounts[i]/2700)/AvgPb)
- #print(len(IntAl))
- plt.plot(SCH,IntAl,label='Al')
- plt.plot(SCH,IntCu,label='Cu')
- plt.plot(SCH,IntPb,label='Pb')
- plt.legend()
- ###################### Nya Delen (Area under the graph reduction) #################################
- AreaUnderAl = 0
- AreaUnderPb = 0
- AreaUnderCu = 0
- ASumAl = 0
- ASumPb = 0
- ASumCu = 0
- Antal = 0
- for i in range(0,17):
- ASumAl = ASumAl + IntAl[i]
- ASumPb = ASumPb + IntPb[i]
- ASumCu = ASumCu + IntCu[i]
- Antal = Antal +1
- for i in range(30,43):
- ASumAl = ASumAl + IntAl[i]
- ASumPb = ASumPb + IntPb[i]
- ASumCu = ASumCu + IntCu[i]
- Antal = Antal +1
- AreaUnderAl = (ASumAl/Antal)*12
- AreaUnderPb = (ASumPb/Antal)*12
- AreaUnderCu = (ASumCu/Antal)*12
- NDetAl = 0
- NDetPb = 0
- NDetCu = 0
- for i in range(17,29):
- NDetAl = NDetAl + IntAl[i]
- NDetPb = NDetPb + IntPb[i]
- NDetCu = NDetCu + IntCu[i]
- NDetAl = NDetAl - AreaUnderAl
- NDetPb = NDetPb - AreaUnderPb
- NDetCu = NDetCu - AreaUnderCu
- print(NDetAl/NDetPb,'NDetAl/NDetPb')
- print(NDetCu/NDetPb,'NDetCu/NDetPb')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement