diff --git a/elec/ABCStar_fe_get_fig.py b/elec/ABCStar_fe_get_fig.py new file mode 100755 index 0000000000000000000000000000000000000000..dc634321bbdc4b3991e23cdf5f7872fffbad0a88 --- /dev/null +++ b/elec/ABCStar_fe_get_fig.py @@ -0,0 +1,59 @@ +#!/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() + diff --git a/elec/__init__.py b/elec/__init__.py index ff614828169ae4811e54fd79675cde78f013890c..3d9a1d6550ec630d49e63fd2fffe7f561c9af2f1 100644 --- a/elec/__init__.py +++ b/elec/__init__.py @@ -5,12 +5,18 @@ def main(kwargs): if label == 'ngspice_t1': import subprocess subprocess.run(['ngspice -b output/elec/T1_tmp.cir'], shell=True) + elif label == 'ngspice_ABCStar_fe': + import subprocess + subprocess.run(['ngspice -b param_file/circuit/ABCStar_fe.cir'], shell=True) elif label == 'drs4_get_analog': import subprocess subprocess.run(['ngspice -b param_file/circuit/drs4_analog.cir'], shell=True) elif label == 'drs4_get_fig': from . import drs4_get_fig drs4_get_fig.main() + elif label == 'ABCStar_fe_get_fig': + from . import ABCStar_fe_get_fig + ABCStar_fe_get_fig.main() else: from . import readout readout.main(label) diff --git a/elec/readout.py b/elec/readout.py index fe079a6b1f603231e3531ee8b1a3c0862f027724..a87d1dc8c15cc3edb65e06ecaabdc4165f0c34bf 100644 --- a/elec/readout.py +++ b/elec/readout.py @@ -160,16 +160,16 @@ class Amplifier: self.pulse_responce_list = [pulse_responce_BB] self.scale = scale_BB - elif self.amplifier_parameters['ele_name'] == 'ABCStar': - """ ABCStar parameter initialization""" + elif self.amplifier_parameters['ele_name'] == 'ABCStar_fe': + """ ABCStar_fe parameter initialization""" - def pulse_responce_ABCStar_input(t): + def pulse_responce_ABCStar_fe_input(t): if t < 0: return 0 input_res = self.amplifier_parameters['input_res'] return 1/(1e-12*CDet) * math.exp(-t/(1e-12*CDet*input_res)) - def pulse_responce_ABCStar_RCfeedback(t): + def pulse_responce_ABCStar_fe_RCfeedback(t): if t < 0: return 0 input_res = self.amplifier_parameters['input_res'] @@ -179,12 +179,12 @@ class Amplifier: tau_f = 1e-12 * Cf * Rf return 1/tau_amp * math.exp(-t/tau_f) - def scale_ABCStar(output_Q_max, input_Q_tot): - """ ABCStar scale function""" + def scale_ABCStar_fe(output_Q_max, input_Q_tot): + """ ABCStar_fe scale function""" return 1000.0 # V to mV - self.pulse_responce_list = [pulse_responce_ABCStar_input, pulse_responce_ABCStar_RCfeedback] - self.scale = scale_ABCStar + self.pulse_responce_list = [pulse_responce_ABCStar_fe_input, pulse_responce_ABCStar_fe_RCfeedback] + self.scale = scale_ABCStar_fe def fill_amplifier_output(self, currents: list[ROOT.TH1F]):