Skip to content
Snippets Groups Projects
Commit 2b44b0a5 authored by Yanpeng Li's avatar Yanpeng Li
Browse files
parents 24171ecf 9bb9acc6
No related branches found
No related tags found
2 merge requests!30更改json路径及模拟10个电子撞击束流管,!29CFLM:10个粒子击中束流管
#!/usr/bin/env python3
# TODO: Need to be TOTALLY rewritten
import ROOT
import numpy
def read_file(file_path,file_name):
with open(file_path + file_name) as f:
lines = f.readlines()
time,volt = [],[]
for line in lines:
time.append(float(line.split()[0])*1e9)
volt.append(float(line.split()[1]))
time = numpy.array(time,dtype='float64')
volt = numpy.array(volt,dtype='float64')
return time,volt
def main():
file_path = 'output/elec/'
#file_name = 'drs4_analog.raw'
file_name = 'ABCStar_fe.raw'
com_name=file_name.split('.')[0]
fig_name=file_path + com_name + '.pdf'
time,volt = [],[]
time,volt = read_file(file_path,file_name)
length = len(time)
ROOT.gROOT.SetBatch()
c = ROOT.TCanvas('c','c',700,600)
f1 = ROOT.TGraph(length,time,volt)
f1.SetTitle(' ')
f1.SetLineColor(2)
f1.SetLineWidth(2)
f1.GetXaxis().SetTitle('Time [ns]')
# f1.GetXaxis().SetLimits(0,5)
f1.GetXaxis().SetLimits(0,30)
f1.GetXaxis().CenterTitle()
f1.GetXaxis().SetTitleSize(0.05)
f1.GetXaxis().SetTitleOffset(0.8)
f1.GetYaxis().SetTitle('Voltage [V]')
f1.GetYaxis().SetLimits(0,-1)
f1.GetYaxis().CenterTitle()
f1.GetYaxis().SetTitleSize(0.05)
f1.GetYaxis().SetTitleOffset(0.93)
c.cd()
f1.Draw('AL')
c.SaveAs(fig_name)
print("figure has been saved in " , fig_name)
if __name__ == '__main__':
main()
import os
def main(kwargs): def main(kwargs):
label = kwargs['label'] label = kwargs['label']
os.makedirs('output/elec', exist_ok=True)
if label == 'ngspice_t1': if label == 'ngspice_t1':
import subprocess import subprocess
subprocess.run(['ngspice -b output/elec/T1_tmp.cir'], shell=True) subprocess.run(['ngspice -b output/elec/T1_tmp.cir'], shell=True)
elif label == 'ngspice_ABCStar_fe': elif label.startswith('ngspice_'):
import subprocess
subprocess.run(['ngspice -b param_file/circuit/ABCStar_fe.cir'], shell=True)
elif label == 'drs4_get_analog':
import subprocess import subprocess
subprocess.run(['ngspice -b param_file/circuit/drs4_analog.cir'], shell=True) elec_name = label.replace('ngspice_', '')
elif label == 'drs4_get_fig': subprocess.run(['ngspice -b param_file/circuit/{}.cir'.format(elec_name)], shell=True)
from . import drs4_get_fig elif label.endswith('_get_fig'):
drs4_get_fig.main() from . import ngspice_get_fig
elif label == 'ABCStar_fe_get_fig': ngspice_get_fig.main(label.replace('_get_fig', ''))
from . import ABCStar_fe_get_fig
ABCStar_fe_get_fig.main()
else: else:
from . import readout from . import readout
readout.main(label) readout.main(label)
#!/usr/bin/env python3
# TODO: Need to be TOTALLY rewritten
import ROOT
import numpy
def read_file(file_path,file_name):
with open(file_path + file_name) as f:
lines = f.readlines()
time,volt = [],[]
for line in lines:
time.append(float(line.split()[0])*1e9)
volt.append(float(line.split()[1]))
time = numpy.array(time,dtype='float64')
volt = numpy.array(volt,dtype='float64')
return time,volt
def main():
file_path = 'output/elec/'
file_name = 'drs4_analog.raw'
com_name=file_name.split('.')[0]
fig_name=file_path + com_name + '.pdf'
time,volt = [],[]
time,volt = read_file(file_path,file_name)
length = len(time)
ROOT.gROOT.SetBatch()
c = ROOT.TCanvas('c','c',700,600)
f1 = ROOT.TGraph(length,time,volt)
f1.SetTitle(' ')
f1.SetLineColor(2)
f1.SetLineWidth(2)
f1.GetXaxis().SetTitle('Time [ns]')
f1.GetXaxis().SetLimits(0,5)
f1.GetXaxis().CenterTitle()
f1.GetXaxis().SetTitleSize(0.05)
f1.GetXaxis().SetTitleOffset(0.8)
f1.GetYaxis().SetTitle('Voltage [V]')
f1.GetYaxis().SetLimits(0,-1)
f1.GetYaxis().CenterTitle()
f1.GetYaxis().SetTitleSize(0.05)
f1.GetYaxis().SetTitleOffset(0.93)
c.cd()
f1.Draw('AL')
c.SaveAs(fig_name)
print("figure has been saved in " , fig_name)
if __name__ == '__main__':
main()
#!/usr/bin/env python3 #!/usr/bin/env python3
import ROOT
import sys import sys
import os
import numpy import numpy
import ROOT
from util.output import output
# TODO: Need to be TOTALLY rewritten # TODO: Need to be TOTALLY rewritten
def read_file(file_path,file_name): def read_file(file_path,file_name):
with open(file_path + '/' + file_name) as f: with open(file_path + '/' + file_name) as f:
...@@ -18,15 +23,14 @@ def read_file(file_path,file_name): ...@@ -18,15 +23,14 @@ def read_file(file_path,file_name):
return time,volt return time,volt
def main(): def main(elec_name):
file_path = 'output/elec/ngspice_fig' file_path = output(__file__)
file_name = sys.argv[1] fig_name = os.path.join(file_path, elec_name+'.pdf')
com_name=file_name.split('.')[0]
fig_name=file_path + com_name + '.pdf'
time,volt = [],[] time,volt = [],[]
time,volt = read_file(file_path,file_name) time,volt = read_file(file_path, elec_name+'.raw')
length = len(time) length = len(time)
t_min, t_max = time[0], time[-1]
ROOT.gROOT.SetBatch() ROOT.gROOT.SetBatch()
c = ROOT.TCanvas('c','c',700,600) c = ROOT.TCanvas('c','c',700,600)
...@@ -37,13 +41,12 @@ def main(): ...@@ -37,13 +41,12 @@ def main():
f1.SetLineWidth(2) f1.SetLineWidth(2)
f1.GetXaxis().SetTitle('Time [ns]') f1.GetXaxis().SetTitle('Time [ns]')
f1.GetXaxis().SetLimits(0,20) f1.GetXaxis().SetLimits(t_min, t_max)
f1.GetXaxis().CenterTitle() f1.GetXaxis().CenterTitle()
f1.GetXaxis().SetTitleSize(0.05) f1.GetXaxis().SetTitleSize(0.05)
f1.GetXaxis().SetTitleOffset(0.8) f1.GetXaxis().SetTitleOffset(0.8)
f1.GetYaxis().SetTitle('Voltage [mV]') f1.GetYaxis().SetTitle('Voltage [mV]')
f1.GetYaxis().SetLimits(0,-5)
f1.GetYaxis().CenterTitle() f1.GetYaxis().CenterTitle()
f1.GetYaxis().SetTitleSize(0.05) f1.GetYaxis().SetTitleSize(0.05)
f1.GetYaxis().SetTitleOffset(0.7) f1.GetYaxis().SetTitleOffset(0.7)
...@@ -51,7 +54,6 @@ def main(): ...@@ -51,7 +54,6 @@ def main():
c.cd() c.cd()
f1.Draw('AL') f1.Draw('AL')
c.SaveAs(fig_name) c.SaveAs(fig_name)
print("figure has been saved in " , fig_name)
if __name__ == '__main__': if __name__ == '__main__':
main() main()
......
...@@ -78,7 +78,7 @@ def main(kwargs): ...@@ -78,7 +78,7 @@ def main(kwargs):
my_current = ccrt.CalCurrentLaser(my_d, my_f, my_l) my_current = ccrt.CalCurrentLaser(my_d, my_f, my_l)
if 'ngspice' in amplifier: if 'ngspice' in amplifier:
save_current(my_d, my_current,my_f = devfield.DevsimField(my_d.device, my_d.dimension, voltage, 1, my_d.l_z), key=None) save_current(my_d, my_current, key=None)
input_p=ngsip.set_input(my_current, my_d, key=None) input_p=ngsip.set_input(my_current, my_d, key=None)
input_c=','.join(input_p) input_c=','.join(input_p)
ng.ngspice_t0(input_c, input_p) ng.ngspice_t0(input_c, input_p)
...@@ -102,7 +102,7 @@ def main(kwargs): ...@@ -102,7 +102,7 @@ def main(kwargs):
print("total time used:%s"%(time.time()-start)) print("total time used:%s"%(time.time()-start))
#TODO: move this to calcurrent #TODO: move this to calcurrent
def save_current(my_d,my_current,my_f,key): def save_current(my_d,my_current,key):
if "planar3D" in my_d.det_model or "planarRing" in my_d.det_model: if "planar3D" in my_d.det_model or "planarRing" in my_d.det_model:
path = os.path.join('output', 'pintct', my_d.det_name, ) path = os.path.join('output', 'pintct', my_d.det_name, )
elif "lgad3D" in my_d.det_model: elif "lgad3D" in my_d.det_model:
......
...@@ -28,7 +28,7 @@ my_l = raser.TCTTracks(my_d, dset.laser) ...@@ -28,7 +28,7 @@ my_l = raser.TCTTracks(my_d, dset.laser)
my_current = raser.CalCurrentLaser(my_d, my_f, my_l) my_current = raser.CalCurrentLaser(my_d, my_f, my_l)
ele_current = raser.Amplifier(my_current.sum_cu, dset.amplifier) ele_current = raser.Amplifier(my_current.sum_cu, dset.amplifier)
save_TTree.save_signal_TTree(dset,my_d,my_l.fx_rel,ele_current,my_f) save_TTree.save_signal_TTree(dset,my_d,my_l.fx_rel,ele_current,my_f)
my_current.save_current(dset,my_d,my_l,my_f,"fx_rel") my_current.save_current(dset,my_d,my_l,"fx_rel")
current_SiC = array("d") current_SiC = array("d")
T_SiC = array("d") T_SiC = array("d")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment