diff --git a/__main__.py b/__main__.py index 523154dd5b10e79428f12fad550b3b4100fbe7e2..14a4fdbed0c29eae8ad231bf2a176ccec4ab2d90 100755 --- a/__main__.py +++ b/__main__.py @@ -59,11 +59,11 @@ parser_gen_signal.add_argument('-amp', '--amplifier', type=str, help='amplifier' parser_gen_signal.add_argument('-s', '--scan', type=int, help='instance number for scan mode') parser_gen_signal.add_argument('--job', type=int, help='flag of run in job') -parser_spaceres = subparsers.add_parser('spaceres', help='space resolution calculation') -parser_spaceres.add_argument('label', help='LABEL to identify spaceres files') +parser_telescope = subparsers.add_parser('telescope', help='telescope') +parser_telescope.add_argument('label', help='LABEL to identify telescope files') -parser_spaceres = subparsers.add_parser('timeres', help='time resolution calculation') -parser_spaceres.add_argument('det_name', help='name of the detector') +parser_telescope = subparsers.add_parser('resolution', help='resolution calculation for time, space and energy') +parser_telescope.add_argument('det_name', help='name of the detector') parser_tct = subparsers.add_parser('tct', help='TCT simulation') parser_tct.add_argument('label', help='LABEL to identify TCT options') @@ -87,11 +87,7 @@ if len(sys.argv) == 1: kwargs = vars(args) -submodules = ['asic', 'cce', 'cflm', 'current', 'draw', 'elec', 'field', 'fpga', 'gen_signal', 'particle', 'spaceres', 'tct', 'timeres', 'bmos'] - submodule = kwargs['subparser_name'] -if submodule not in submodules: - raise NameError(submodule) if kwargs['batch'] != 0: batch_level = kwargs['batch'] diff --git a/particle/g4_sic_energy_deposition.py b/particle/g4_sic_energy_deposition.py index eedaa719e0beb2bbfcdc1a401580d62f2aa6185a..f373d75db48c23ece8f18f649b691ffe8262a821 100755 --- a/particle/g4_sic_energy_deposition.py +++ b/particle/g4_sic_energy_deposition.py @@ -172,7 +172,7 @@ class SiC_LGAD_DetectorConstruction(g4b.G4VUserDetectorConstruction):#鏄痝4b.G4V self.fMagFieldMessenger = g4b.G4GlobalMagFieldMessenger(fieldValue) self.fMagFieldMessenger.SetVerboseLevel(1) #鍒涘缓绮掑瓙鍒濆鍖栦俊鎭紝鍖呮嫭浣嶇疆锛屽姩閲忥紝鑳介噺锛� -class SIC_LGAD_PrimaryGeneratorAction(g4b.G4VUserPrimaryGeneratorAction): +class SiC_LGAD_PrimaryGeneratorAction(g4b.G4VUserPrimaryGeneratorAction): def __init__(self): super().__init__() @@ -294,7 +294,7 @@ class SiC_LGAD_aActionInitialization(g4b.G4VUserActionInitialization): self.SetUserAction(SiC_LGAD_RunAction()) def Build(self): - self.SetUserAction(SIC_LGAD_PrimaryGeneratorAction()) + self.SetUserAction(SiC_LGAD_PrimaryGeneratorAction()) self.SetUserAction(SiC_LGAD_RunAction()) eventAction = SiC_LGAD_aEventAction() self.SetUserAction(eventAction) diff --git a/timeres/__init__.py b/resolution/__init__.py similarity index 100% rename from timeres/__init__.py rename to resolution/__init__.py diff --git a/timeres/add_noise.py b/resolution/add_noise.py similarity index 98% rename from timeres/add_noise.py rename to resolution/add_noise.py index b594633bf22d8b0ee5ceaa2719a641106bd46534..3b3cec6da3bfb80d6ac7f48c82ee88325f5cc625 100644 --- a/timeres/add_noise.py +++ b/resolution/add_noise.py @@ -769,7 +769,7 @@ def save_time_resolution(input_file,sigma,error,efficiency,sigma_jitter,Landau_t f.write(str(sigma) + "," + str(error) + "," + str(efficiency) + "," + str(sigma_jitter) + "," + str(Landau_timing) + "\n") -def save_gain_efficiency(input_file, max_voltage, error_max_voltage, current_integral, error_current_integral): +def save_charge(input_file, max_voltage, error_max_voltage, current_integral, error_current_integral): o_ls=input_file.split("/")[:] out_file=output(__file__, o_ls[2])+"/gain_efficiency_scan.csv" @@ -851,11 +851,10 @@ def main(kwargs): out_root_f.Close() save_time_resolution(input_file,sigma,error,efficiency,sigma_jit,Landau_timing) - if "lgad3D" in det_model: - # Draw gain efficiency, max voltage and current integral - max_voltage, error_max_voltage = draw_max_voltage(rset.max_voltage,output_path) - current_integral, error_current_integral = draw_current_integral(rset.current_integral,output_path) - save_gain_efficiency(input_file, max_voltage, error_max_voltage, current_integral, error_current_integral) + # Draw max voltage and current integral + max_voltage, error_max_voltage = draw_max_voltage(rset.max_voltage,output_path) + current_integral, error_current_integral = draw_current_integral(rset.current_integral,output_path) + save_charge(input_file, max_voltage, error_max_voltage, current_integral, error_current_integral) if __name__ == '__main__': args = sys.argv[1:] diff --git a/timeres/time_scan.py b/resolution/time_scan.py similarity index 100% rename from timeres/time_scan.py rename to resolution/time_scan.py diff --git a/tct/source.py b/tct/laser.py similarity index 91% rename from tct/source.py rename to tct/laser.py index 7acd15ef6ef97250f2ac3a6f578bb5f17a46485d..b4cdaac92e345ef3b0c4b0a3f220a2818424bca2 100644 --- a/tct/source.py +++ b/tct/laser.py @@ -6,7 +6,7 @@ import numpy as np from gen_signal.build_device import Detector -class TCTTracks(): +class LaserInjection(): """ Description: Transfer Carrier Distribution from Laser Coordinate System @@ -15,7 +15,7 @@ class TCTTracks(): --------- my_d : R3dDetector the Detector - laser : dict + laser_dic : dict the Parameter List of Your Laser x_rel,y_rel,z_rel: the Normalized Coordinate for Laser Focus @@ -24,42 +24,42 @@ class TCTTracks(): --------- 2021/09/13 """ - def __init__(self, my_d, laser): + def __init__(self, my_d: Detector, laser_dic: dict): #technique used - self.model = laser["laser_model"] - self.tech = laser["tech"] - self.direction = laser["direction"] + self.model = laser_dic["laser_model"] + self.tech = laser_dic["tech"] + self.direction = laser_dic["direction"] #material parameters to certain wavelength of the beam - self.refractionIndex = laser["refractionIndex"] + self.refractionIndex = laser_dic["refractionIndex"] if self.tech == "SPA": - self.alpha = laser["alpha"] # m^-1 + self.alpha = laser_dic["alpha"] # m^-1 if self.tech == "TPA": - self.beta_2 = laser["beta_2"] + self.beta_2 = laser_dic["beta_2"] #laser parameters - self.wavelength = laser["wavelength"]*1e-3 #um - self.temporal_FWHM = laser["temporal_FWHM"] - self.pulse_energy = laser["pulse_energy"] - self.spacial_FWHM = laser["spacial_FWHM"]#um - self.central_time = laser["central_time"] - if "l_Reyleigh" not in laser: + self.wavelength = laser_dic["wavelength"]*1e-3 #um + self.temporal_FWHM = laser_dic["temporal_FWHM"] + self.pulse_energy = laser_dic["pulse_energy"] + self.spacial_FWHM = laser_dic["spacial_FWHM"]#um + self.central_time = laser_dic["central_time"] + if "l_Reyleigh" not in laser_dic: w_0 = self.spacial_FWHM / (2 * np.log(2))**0.5 self.l_Rayleigh = np.pi*w_0**2*self.refractionIndex/self.wavelength else: - self.l_Rayleigh = laser["l_Rayleigh"]#um + self.l_Rayleigh = laser_dic["l_Rayleigh"]#um #the size of the detector self.lx = my_d.l_x#um self.ly = my_d.l_y self.lz = my_d.l_z #relative and absolute position of the focus - self.fx_rel = laser["fx_rel"] - self.fy_rel = laser["fy_rel"] - self.fz_rel = laser["fz_rel"] + self.fx_rel = laser_dic["fx_rel"] + self.fy_rel = laser_dic["fy_rel"] + self.fz_rel = laser_dic["fz_rel"] self.fx_abs = self.fx_rel * self.lx self.fy_abs = self.fy_rel * self.ly self.fz_abs = self.fz_rel * self.lz #accuracy parameters - self.r_step = laser["r_step"]#um - self.h_step = laser["h_step"]#um + self.r_step = laser_dic["r_step"]#um + self.h_step = laser_dic["h_step"]#um self.mesh_definition(my_d) diff --git a/tct/tct_signal.py b/tct/tct_signal.py index 36e2407cb4f3b20088dc0573d8536a2728c9de69..e6bf5f89f8d5fe5310fc2aa6072460fb382b4a24 100644 --- a/tct/tct_signal.py +++ b/tct/tct_signal.py @@ -16,7 +16,7 @@ from gen_signal import build_device as bdv from field import devsim_field as devfield from current import cal_current as ccrt from elec import readout as rdo -from .source import TCTTracks +from .laser import LaserInjection from util.output import output, create_path from gen_signal.draw_save import draw_current @@ -63,7 +63,7 @@ def main(kwargs): amplifier = my_d.amplifier my_f = devfield.DevsimField(my_d.device, my_d.dimension, voltage, my_d.read_out_contact, my_d.irradiation_flux) - my_l = TCTTracks(my_d, laser_dic) + my_l = LaserInjection(my_d, laser_dic) my_current = ccrt.CalCurrentLaser(my_d, my_f, my_l) path = output(__file__, my_d.det_name, my_l.model) diff --git a/tct/tct_signal_scan.py b/tct/tct_signal_scan.py index 9f87abf8549f0bd0251c30447d9143ab6393fc6a..6c2642de76a392eb7e1e1a4e2b1da647cf3c7cc3 100644 --- a/tct/tct_signal_scan.py +++ b/tct/tct_signal_scan.py @@ -24,7 +24,7 @@ from elec import readout as rdo from gen_signal import draw_save from util.output import output -from .source import TCTTracks +from .laser import LaserInjection def batch_loop(my_d, my_f, my_g4p, amplifier, g4_seed, total_events, instance_number): @@ -85,7 +85,7 @@ def job_main(kwargs): amplifier = my_d.amplifier my_f = devfield.DevsimField(my_d.device, my_d.dimension, voltage, my_d.read_out_contact, my_d.irradiation_flux) - my_l = TCTTracks(my_d, laser_dic) + my_l = LaserInjection(my_d, laser_dic) my_current = ccrt.CalCurrentLaser(my_d, my_f, my_l) path = output(__file__, my_d.det_name, my_l.model) diff --git a/spaceres/__init__.py b/telescope/__init__.py similarity index 100% rename from spaceres/__init__.py rename to telescope/__init__.py diff --git a/spaceres/telescope_acts.py b/telescope/telescope_acts.py similarity index 98% rename from spaceres/telescope_acts.py rename to telescope/telescope_acts.py index a007c578c63154f703cdfc079c9fd795ff4c9b32..3140a824e03b2eb1bee2cbb09d1ec9707a6a5b26 100755 --- a/spaceres/telescope_acts.py +++ b/telescope/telescope_acts.py @@ -47,7 +47,7 @@ def main(): field = acts.ConstantBField(acts.Vector3(0, 0, 1 * u.T)) - outputDir = Path.cwd() / "output/spaceres/telescope_acts" + outputDir = Path.cwd() / "output/telescope/telescope_acts" if not outputDir.exists(): outputDir.mkdir() inputDir = Path.cwd() / "setting/acts" diff --git a/spaceres/telescope_g4.py b/telescope/telescope_g4.py similarity index 100% rename from spaceres/telescope_g4.py rename to telescope/telescope_g4.py diff --git a/spaceres/telescope_signal.py b/telescope/telescope_signal.py similarity index 98% rename from spaceres/telescope_signal.py rename to telescope/telescope_signal.py index 14ba421a86d8a0d0436cce243d702b0794c44be8..7c4c5f016af80c47ab012fcf9f0cf96b04e7d796 100644 --- a/spaceres/telescope_signal.py +++ b/telescope/telescope_signal.py @@ -136,7 +136,7 @@ class Telescope: Name = "fit"+str(DUT) now = time.strftime("%Y_%m%d_%H%M") - path = os.path.join("output/spaceres/taichu_v1", str(now),'' ) + path = os.path.join("output/telescope/taichu_v1", str(now),'' ) #print(path) """ If the path does not exit, create the path""" @@ -228,7 +228,7 @@ class Telescope: label.Draw() now = time.strftime("%Y_%m%d_%H%M") - path = os.path.join("output/spaceres/taichu_v1", str(now),'' ) + path = os.path.join("output/telescope/taichu_v1", str(now),'' ) #print(path) """ If the path does not exit, create the path""" @@ -528,7 +528,7 @@ def taichu_v2(label=""): canvas.Draw() Name = "Res vs size" now = time.strftime("%Y_%m%d_%H%M") - path = os.path.join("output/spaceres/taichu_v2", str(now),'' ) + path = os.path.join("output/telescope/taichu_v2", str(now),'' ) """ If the path does not exit, create the path""" if not os.access(path, os.F_OK): os.makedirs(path) diff --git a/util/math.py b/util/math.py index 924fde902df31926a21803524401d18a5dd8d67b..019b475f6d745dbc0e780bf16826199a5aa87004 100644 --- a/util/math.py +++ b/util/math.py @@ -100,6 +100,7 @@ def get_common_interpolate_3d(data): return f def signal_convolution(signal_original: ROOT.TH1F, signal_convolved: ROOT.TH1F, pulse_responce_function_list: list[Callable[[float],float]]): + # assume so and sc share same bin width so = signal_original sc = signal_convolved st = ROOT.TH1F("signal_temp","signal_temp",so.GetNbinsX(),so.GetXaxis().GetXmin(),so.GetXaxis().GetXmax())