diff --git a/__main__.py b/__main__.py index 00b81dc1a736b7ccee38de73c6caee41c2dbaf50..49777f5263f1d64f45601286dde25fdcc44b22d0 100755 --- a/__main__.py +++ b/__main__.py @@ -25,9 +25,6 @@ parser_asic.add_argument('label', help='LABEL to identify ASIC design') parser_draw = subparsers.add_parser('current', help='calculate drift current') parser_draw.add_argument('label', help='LABEL to identify root files') -parser_draw = subparsers.add_parser('draw', help='draw figures') -parser_draw.add_argument('label', help='LABEL to identify root files') - parser_gsignal = subparsers.add_parser('elec', help='electronic readout') parser_gsignal.add_argument('label', help='LABEL to identify electronics files') @@ -49,9 +46,6 @@ parser_gen_signal.add_argument('-abs', '--absorber', type=str, help='model of pa 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_root = subparsers.add_parser('root', help='root files conversion') -parser_root.add_argument('label', help='LABEL to identify root files') - parser_spaceres = subparsers.add_parser('spaceres', help='space resolution calculation') parser_spaceres.add_argument('label', help='LABEL to identify spaceres files') @@ -74,7 +68,7 @@ if len(sys.argv) == 1: kwargs = vars(args) -submodules = ['asic', 'current', 'draw', 'elec', 'field', 'fpga', 'gen_signal', 'particle', 'root', 'spaceres','tct', 'timeres'] +submodules = ['asic', 'current', 'draw', 'elec', 'field', 'fpga', 'gen_signal', 'particle', 'spaceres', 'tct', 'timeres'] submodule = kwargs['subparser_name'] if submodule not in submodules: @@ -90,7 +84,7 @@ if kwargs['batch'] == True: elif kwargs['shell'] == False: # not in shell try: - for package in ['ROOT', 'geant4_pybind', 'devsim']: + for package in ['ROOT', 'geant4_pybind', 'devsim', 'numpy', 'scipy']: # package dependency check import package submodule = importlib.import_module(submodule) diff --git a/control/kei_2026_bias_control.py b/control/kei_2026_bias_control.py deleted file mode 100644 index e829f045bbc82fec3fc7ea8d060c4d0f5b2f292b..0000000000000000000000000000000000000000 --- a/control/kei_2026_bias_control.py +++ /dev/null @@ -1,97 +0,0 @@ -import visa -import time -import warnings - -class keithley2026: - def __init__(self): - instlist=visa.ResourceManager() - print(instlist.list_resources()) - self.kei026=instlist.open_resource("GPIB1::4::INSTR") - self.timedelay=1 - - def testIO(self): - message=self.kei026.ask('*IDN?') - print(message) - - def set_voltage(self,vol): - if vol > 5.0: - warnings.warn("Warning High Voltage!!!!") - self.kei026.write("smua.source.limiti=5E-7") - self.kei026.write("smua.source.func=smua.OUTPUT_DCVOLTS") - vols=self.show_voltage() - self.sweep(vols,vol,0.1) - vols=self.show_voltage() - return vols - - def show_voltage(self): - self.kei026.write("voltagea=smua.measure.v()") - voltage=self.kei026.ask("printnumber(voltagea)") - print("voltage [V]: " + str(voltage)) - return float(str(voltage)) - - def sweep(self, vols, vole, step): - if vols < vole: - self.sweep_forward(vols,vole,step) - else: - self.sweep_backward(vols,vole,step) - - def sweep_forward(self, vols, vole, step): - # Conveter from V to mV - mvols=vols*1000 - mvole=vole*1000 - mstep=step*1000 - - for mvol in range(int(mvols),int(mvole),int(mstep)): - vol=mvol/1000 # mV -> V - self.kei026.write("smua.source.levelv="+str(vol)) - self.kei026.write("smua.source.limiti=5E-7") - self.show_voltage() - time.sleep(self.timedelay) - self.kei026.write("smua.source.levelv="+str(vole)) - self.show_voltage() - - def sweep_backward(self, vols, vole, step): - # Conveter from V to mV - mvols=vols*1000 - mvole=vole*1000 - mstep=step*1000 - - for mvol in range(int(mvols),int(mvole), -int(mstep)): - vol=mvol/1000 # mV -> V - self.kei026.write("smua.source.levelv="+str(vol)) - self.kei026.write("smua.source.limiti=5E-7") - self.show_voltage() - time.sleep(self.timedelay) - self.kei026.write("smua.source.levelv="+str(vole)) - self.show_voltage() - - def display_current(self): - self.kei026.write("display.smua.measure.func=display.MEASURE_DCAMPS") - self.kei026.write("smua.measure.rangei=1E-6") - self.kei026.write("smua.measure.rel.enablei=1") - self.kei026.write("currenta=smua.measure.i()") - current=self.kei026.ask("printnumber(currenta)") - print("current [A]: " + str(current)) - - time.sleep(self.timedelay) - self.kei026.write("currenta=smua.measure.i()") - current=self.kei026.ask("printnumber(currenta)") - return float(str(current)) - - def output_on(self): - self.kei026.write("smua.source.output=smua.OUTPUT_ON") - print("On") - - def output_off(self): - self.kei026.write("smua.source.output=smua.OUTPUT_OFF") - print("Off") - - -if __name__=="__main__": - kei026=keithley2026() - kei026.output_on() - kei026.set_voltage(0.1) - current=kei026.display_current() - print(current) - #kei026.output_off() - diff --git a/control/kei_2400b_bias_control.py b/control/kei_2400b_bias_control.py deleted file mode 100644 index 2391685f775ae7a15a295a14e53df70147ecf589..0000000000000000000000000000000000000000 --- a/control/kei_2400b_bias_control.py +++ /dev/null @@ -1,104 +0,0 @@ -import visa -import time -import warnings - -class keithley2400B: - def __init__(self): - instlist=visa.ResourceManager() - print(instlist.list_resources()) - self.kei2400b=instlist.open_resource("GPIB0::24::INSTR") - self.timedelay=5 - - def testIO(self): - message=self.kei2400b.ask('*IDN?') - print(message) - - def set_voltage(self,vol): - if vol > 105: - warnings.warn("Warning High Voltage!!!!") - - self.kei2400b.write(":sense:current:protection 1.05E-4") - self.kei2400b.write(":source:function voltage") - self.kei2400b.write(":source:voltage:mode fixed") - vols=self.show_voltage() - self.sweep(vols,vol,1) - vols=self.show_voltage() - return vols - - def show_voltage(self): - self.kei2400b.write(":source:voltage:mode fixed") - self.kei2400b.write(":form:elem voltage") - voltage=self.kei2400b.ask(":read?") - print("voltage [V]: " + str(voltage)) - return float(str(voltage)) - - def sweep(self, vols, vole, step): - if vols < vole: - self.sweep_forward(vols,vole,step) - else: - self.sweep_backward(vols,vole,step) - - def sweep_forward(self, vols, vole, step): - # Conveter from V to mV - mvols=vols*1000 - mvole=vole*1000 - mstep=step*1000 - - for mvol in range(int(mvols),int(mvole),int(mstep)): - vol=mvol/1000 # mV -> V - self.kei2400b.write(":source:voltage:level "+str(vol)) - self.kei2400b.write(":sense:current:protection 1.05E-4") - self.show_voltage() - time.sleep(self.timedelay) - - self.kei2400b.write(":source:voltage:level "+str(vole)) - self.show_voltage() - - def sweep_backward(self, vols, vole, step): - # Conveter from V to mV - mvols=vols*1000 - mvole=vole*1000 - mstep=step*1000 - - for mvol in range(int(mvols),int(mvole), -int(mstep)): - vol=mvol/1000 # mV -> V - self.kei2400b.write(":source:voltage:level "+str(vol)) - self.kei2400b.write(":sense:current:protection 1.05E-4") - self.show_voltage() - time.sleep(self.timedelay) - - self.kei2400b.write(":source:voltage:level "+str(vole)) - self.show_voltage() - - def display_current(self): - self.kei2400b.write(":sense:function 'current'") - self.kei2400b.write(":sense:current:range 1.05E-4") - self.kei2400b.write(":display:enable on") - self.kei2400b.write(":display:digits 7") - self.kei2400b.write(":form:elem current") - current=self.kei2400b.ask(":read?") - print("instant current [A]: " + str(current)) - - time.sleep(self.timedelay) - self.kei2400b.write(":form:elem current") - current=self.kei2400b.ask(":read?") - print("long current [A]: " + str(current)) - return float(str(current)) - - def output_on(self): - self.kei2400b.write(":output on") - print("On") - - def output_off(self): - self.kei2400b.write(":output off") - print("Off") - - -if __name__=="__main__": - kei2400b=keithley2400b() - kei2400b.output_on() - kei2400b.set_voltage(1) - current=kei2400b.display_current() - print(current) - kei2400b.output_off() - diff --git a/control/kei_2400c_bias_control.py b/control/kei_2400c_bias_control.py deleted file mode 100644 index 80d4b134bba39fbe733a2e0029e8664c3208f201..0000000000000000000000000000000000000000 --- a/control/kei_2400c_bias_control.py +++ /dev/null @@ -1,103 +0,0 @@ -import visa -import time -import warnings - -class keithley2400c: - def __init__(self): - instlist=visa.ResourceManager() - print(instlist.list_resources()) - self.kei2400c=instlist.open_resource("GPIB0::24::INSTR") - self.timedelay=1 - - def testIO(self): - message=self.kei2400c.ask('*IDN?') - print(message) - - def set_voltage(self,vol): - if vol > 2.0: - warnings.warn("Warning High Voltage!!!!") - - self.kei2400c.write(":sense:current:protection 1E-6") - self.kei2400c.write(":source:function voltage") - self.kei2400c.write(":source:voltage:mode fixed") - vols=self.show_voltage() - self.sweep(vols,vol,0.1) - vols=self.show_voltage() - return vols - - def show_voltage(self): - self.kei2400c.write(":source:voltage:mode fixed") - self.kei2400c.write(":form:elem voltage") - voltage=self.kei2400c.ask(":read?") - print("voltage [V]: " + str(voltage)) - return float(str(voltage)) - - def sweep(self, vols, vole, step): - if vols < vole: - self.sweep_forward(vols,vole,step) - else: - self.sweep_backward(vols,vole,step) - - def sweep_forward(self, vols, vole, step): - # Conveter from V to mV - mvols=vols*1000 - mvole=vole*1000 - mstep=step*1000 - - for mvol in range(int(mvols),int(mvole),int(mstep)): - vol=mvol/1000 # mV -> V - self.kei2400c.write(":source:voltage:level "+str(vol)) - self.kei2400c.write(":sense:current:protection 1E-6") - self.show_voltage() - time.sleep(self.timedelay) - - self.kei2400c.write(":source:voltage:level "+str(vole)) - self.show_voltage() - - def sweep_backward(self, vols, vole, step): - # Conveter from V to mV - mvols=vols*1000 - mvole=vole*1000 - mstep=step*1000 - - for mvol in range(int(mvols),int(mvole), -int(mstep)): - vol=mvol/1000 # mV -> V - self.kei2400c.write(":source:voltage:level "+str(vol)) - self.kei2400c.write(":sense:current:protection 1E-6") - self.show_voltage() - time.sleep(self.timedelay) - - self.kei2400c.write(":source:voltage:level "+str(vole)) - self.show_voltage() - - def display_current(self): - self.kei2400c.write(":sense:function 'current'") - self.kei2400c.write(":sense:current:range 1E-6") - self.kei2400c.write(":display:enable on") - self.kei2400c.write(":display:digits 7") - self.kei2400c.write(":form:elem current") - current=self.kei2400c.ask(":read?") - print("current [A]: " + str(current)) - - time.sleep(self.timedelay) - self.kei2400c.write(":form:elem current") - current=self.kei2400c.ask(":read?") - return float(str(current)) - - def output_on(self): - self.kei2400c.write(":output on") - print("On") - - def output_off(self): - self.kei2400c.write(":output off") - print("Off") - - -if __name__=="__main__": - kei2400c=keithley2400c() - kei2400c.output_on() - kei2400c.set_voltage(1) - current=kei2400c.display_current() - print(current) - kei2400c.output_off() - diff --git a/control/kei_2470c_bias_control.py b/control/kei_2470c_bias_control.py deleted file mode 100644 index 05dff6b61f559144a0d12efe80836be3bfdd31ff..0000000000000000000000000000000000000000 --- a/control/kei_2470c_bias_control.py +++ /dev/null @@ -1,128 +0,0 @@ -import pyvisa as visa -import time -import warnings - -class Keithley2470: - def __init__(self, resource_name): - instlist = visa.ResourceManager() - print(instlist.list_resources()) - self.kei2470 = instlist.open_resource(resource_name) - self.kei2470.timeout = 25000 - self.cmpl = '105E-6' - def testIO(self): - message = self.kei2470.query('*IDN?') - print(message) - - def set_current_protection(self, current): - self.cmpl = str(current) - self.kei2470.write(":SENSe:CURRent:RANGe " + str(current)) - - - def set_voltage_protection(self, vol): - self.kei2470.write(":SOURce:VOLTage:RANGe " + str(vol)) - - - def set_voltage(self, vol, speed=0.2): - self.kei2470.write(":SENSe:CURRent:RANGe " + self.cmpl) - self.kei2470.write(":SOURce:FUNCtion VOLTage") - - if(abs(vol)>=1): - if(vol>0):vols = vol - 1 - else: vols = vol + 1 - else: vols = self.show_voltage() - print("vols="+str(vols)) - self.sweep(vols, vol, 0.25, speed) - - vols = vol - return vols - - def show_voltage(self): - - - self.kei2470.write(":SOURce:FUNCtion VOLTage") - self.kei2470.write(":DISPlay:READing:FORMat PREFix") - voltage = self.kei2470.query(":READ?") - - print("voltage [V]: " + str(voltage)) - return float(str(voltage)) - - def sweep(self, vols, vole, step, speed): - if vols < vole: - self.sweep_forward(vols,vole,step,speed) - else: - self.sweep_backward(vols,vole,step,speed) - - def sweep_forward(self, vols, vole, step,speed): - - mvols=vols*1000 - mvole=vole*1000+1 - mstep=step*1000 - for mvol in range(int(mvols),int(mvole),int(mstep)): - vol=mvol/1000 - self.kei2470.write(":SOURce:VOLTage:LEVel "+str(vol)) - time.sleep(0.1/speed) - - def sweep_backward(self, vols, vole, step,speed): - - mvols=vols*1000 - mvole=vole*1000-1 - mstep=step*1000 - - for mvol in range(int(mvols),int(mvole), -int(mstep)): - vol=mvol/1000 - self.kei2470.write(":SOURce:VOLTage:LEVel "+str(vol)) - time.sleep(0.1/speed) - - def display_current(self): - self.kei2470.write(":SENSe:FUNCtion 'CURRent'") - - - self.kei2470.write(":SENS:CURR:RANG:AUTO ON") - - self.kei2470.write(":DISPlay:READing:FORMat PREFix") - - current=self.kei2470.query(":READ?") - - print("current [A]: " + str(current)) - return float(str(current)) - - def hit_compliance(self): - tripped=int(str(self.kei2470.query("SOUR:CURR:VLIM:TRIP?"))) - - if tripped: - print("Hit the compliance "+self.cmpl+"A.") - return tripped - - def output_on(self): - self.kei2470.write(":OUTPut:STATe ON") - - print("On") - - def output_off(self): - self.kei2470.write(":OUTPut:STATe OFF") - print("Off") - - def beep(self, freq=1046.50, duration=0.3): - self.kei2470.write(":SYSTem:BEEPer "+str(freq)+", "+str(duration)) - - time.sleep(duration) - - def filter_on(self, count=20, mode="REPeat"): - - self.kei2470.write(":SENSe:CURRent:AVERage:COUNt "+str(count)) - - self.kei2470.write(":SENSe:CURRent:AVERage:TCONtrol "+mode) - - self.kei2470.write(":SENSe:CURRent:AVERage:STATe ON") - - def filter_off(self): - - self.kei2400c.write("[:SENSe[1]]:CURRent[:DC]:AVERage:STATe OFF") - - def __del__(self): - self.kei2470.close() - - -if __name__ == "__main__": - kei2470 = Keithley2470("USB0::0x05E6::0x2470::04554700::INSTR") - kei2470.testIO() diff --git a/control/key_e4980a_bias_control.py b/control/key_e4980a_bias_control.py deleted file mode 100644 index bf3dc11142b171608b97db210406d23efe661c5b..0000000000000000000000000000000000000000 --- a/control/key_e4980a_bias_control.py +++ /dev/null @@ -1,41 +0,0 @@ -import pyvisa as visa -import time -import warnings - -class keysight_e4980a: - def __init__(self,resource_name): - instlist=visa.ResourceManager() - print(instlist.list_resources()) - self.lcr=instlist.open_resource(resource_name) - self.lcr.write(":function:impedance:type CPRP") - self.lcr.write(":format:ascii:long on") - self.lcr.write(":aperture medium") - - def testIO(self): - message=self.lcr.query('*IDN?') - print(message) - - def set_voltage_level(self, vol): - self.lcr.write(":voltage:level "+str(vol)) - - def set_frequency(self, freq): - self.lcr.write(":frequency "+freq) - - def set_trigger_remote(self): - self.lcr.write("trigger:source bus") - - def set_trigger_internal(self): - self.lcr.write("trigger:source internal") - - def get_capacitance(self): - res=self.lcr.write("trigger:immediate") - res=self.lcr.query("fetch?") - reslist=res.split(",") - cap=reslist[0] - print("capacitance [F]: " + cap) - return float(cap) - -if __name__=="__main__": - lcr=keysight_e4980a("USB0::0x2A8D::0x2F01::MY46516486::INSTR") - lcr.testIO() - lcr.set_trigger_internal() diff --git a/control/mdo_3034_scope_control.py b/control/mdo_3034_scope_control.py deleted file mode 100644 index 0152585299c4540de52b070791cb870c24a4bd3a..0000000000000000000000000000000000000000 --- a/control/mdo_3034_scope_control.py +++ /dev/null @@ -1,110 +0,0 @@ -import numpy as np -import pandas as pd -import pylab -import re -import time - -try: - import visa -except ImportError as err: - print(err) - exit() - -class MDO3034C: - def __init__(self, resource_name): - instlist=visa.ResourceManager() - #print(instlist.list_resources()) - self.my_resource=instlist.open_resource(resource_name) - - def write_command(self,command): - self.my_resource.write(command) - time.sleep(0.5) - def testIO(self): - #self.my_resource.write('*RST') - self.my_resource.write('*CLS') - #self.my_resource.query_delay = 10.0 - message=self.my_resource.query('*IDN?') - time.sleep(1) - print("ocsilloscope information:" + message) - - def readSet(self,ch,point_number): - self.my_resource.write(":DATA:SOU "+ ch) - self.my_resource.write(':DATA:START 1') - self.my_resource.write(':DATA:STOP ' + point_number) - self.my_resource.write(':WFMOutpre:ENCdg BINARY') - self.my_resource.write(":WFMOutpre:BYT_Nr 1") - self.my_resource.write(":HEADer 0") - self.my_resource.write(":WFMOutpre?") - - def readOffset(self): - self.write_command('WFMPRE:YMULT?') - ymult = float(self.my_resource.read_raw()) - print("ymult = " + repr(ymult) + '\n') - self.write_command('WFMPRE:YZERO?') - yzero = float(self.my_resource.read_raw()) - print("yzero = " + repr(yzero) + '\n') - self.write_command('WFMPRE:YOFF?') - yoff = float(self.my_resource.read_raw()) - print("yoff = " + repr(yoff) + '\n') - self.write_command('WFMPRE:XINCR?') - xincr = float(self.my_resource.read_raw()) - print("xincr = " + repr(xincr) + '\n') - self.write_command('WFMPRE:XZERO?') - xzero = float(self.my_resource.read_raw()) - print("xzero = " + repr(xzero) + '\n') - return ymult,yzero,yoff,xincr,xzero - - def readWave(self): - ymult,yzero,yoff,xincr,xzero=self.readOffset() - self.my_resource.write('*CLS') - self.my_resource.write("CURVE?") - file = open('test.txt','w+') - - ########################################## - # receive data format: - # #510000<data>\n receive 10000 data - # #41000<data>\n receive 1000 data - ######################################### - data = np.frombuffer(self.my_resource.read_raw(),dtype=np.int8,count=int(POINT_NUMBER),offset=len(POINT_NUMBER) + 2) - np.savetxt('test.txt',data,fmt='%d',delimiter=',') - - print(data.size) - Volts = (data - 0) * ymult + yzero - Time = np.arange(0, data.size, 1) - Time = Time * xincr + xzero - - return Time, Volts - - def save_wave_data(self,time,voltage): - datadic = {'Time[ms]':time,'Voltage[mv]':voltage} - dataform = pd.DataFrame(datadic,columns=['Time[ms]','Voltage[mv]']) - dataform.to_csv('dataform.csv') - - - def plotWave(self, Time, Volts): - pylab.plot(Time, Volts) - pylab.show() - - -if __name__=="__main__": - POINT_NUMBER = '10000' - CHANNEL = 'CH1' - rm = visa.ResourceManager() - print(rm.list_resources()) - list_sources = rm.list_resources() - for resource_name in list_sources: - match_result = re.match(r'TCPIP',resource_name) - if match_result: - tcpip_resource = resource_name - print("the TCPIP resource is:" + repr(tcpip_resource)) - break - else: - print("no TCPIP resource,please check it!") - exit() - scope=MDO3034C(tcpip_resource) - scope.testIO() - scope.readSet(CHANNEL,POINT_NUMBER) - - Time,Volts = scope.readWave() - scope.plotWave(Time, Volts) - print(max(Volts)-min(Volts)) diff --git a/control/scan_amp_2026.py b/control/scan_amp_2026.py deleted file mode 100644 index 87b998f5965072259fd0ed8bafe2880c9bdb777d..0000000000000000000000000000000000000000 --- a/control/scan_amp_2026.py +++ /dev/null @@ -1,52 +0,0 @@ -import raser.control.kei_2026_bias_control as kei2026 -import raser.control.tek_tds5054b_scope_control as tds5054b -import visa -import time -import pylab -import csv -import numpy as np - -def csv_writer(data,path): - with open(path,"w") as csv_file: - writer=csv.writer(csv_file,lineterminator='\n') - writer.writerow(['Bias Voltage[V]','Measure Voltage [V]','Meaure Current [A]','Max Amp [mV]']) - for val in data: - writer.writerows([val]) - - -biasSupply=kei2026.keithley2026() -scope=tds5054b.TDS5054B() - -scope.testIO() -scope.readSet(3) - -vols=[] -mvols=[] -maxAmp=[] -current=[] - -iStart=int(0*1e3) -iEnd=int(1*1e3) -iStep=int(0.1*1e3) -for iBias in range(iStart,iEnd,iStep): - biasSupply.output_on() - biasvol=iBias/1000 - if biasvol>5: - break - vols.append(biasvol) - mvols.append(biasSupply.set_voltage(biasvol)) - current.append(biasSupply.display_current()) - - Time,Volts = scope.readWave() - maxAmp.append(max(Volts)-min(Volts)) - -print("Bias Vols: "+str(vols)) -print("Measure vols: "+str(mvols)) -print("Current: "+str(current)) -print("MaxAmp: "+str(maxAmp)) - -data=[vols,mvols,current,maxAmp] -dataarray=np.array(data) - -filename="test.csv" -csv_writer(dataarray.T,filename) diff --git a/control/scan_cv_2470.py b/control/scan_cv_2470.py deleted file mode 100644 index 48e441425d646d65150d266e735b9f25d77718e4..0000000000000000000000000000000000000000 --- a/control/scan_cv_2470.py +++ /dev/null @@ -1,107 +0,0 @@ -import raser.control.key_e4980a_bias_control as keye4980a -import raser.control.kei_2470c_bias_control as kei2470 -import csv -import numpy as np -import platform -import sys -import warnings -import time - - -def csv_writer(data,path): - with open(path,"w") as csv_file: - writer=csv.writer(csv_file,lineterminator='\n') - writer.writerow(['Bias Voltage[V]','Measured Voltage[V]','Measured Capacitance[pF]','Capacitance^{-2}[pF]^{-2}','Monitoring Current[A]']) - for val in data: - writer.writerows([val]) - -# prevent from running with python2 -if platform.python_version().startswith('2'): - print('You are running with',platform.python_version(),'.') - print('Please run with python3.') - print('Exit.') - sys.exit() - - -lcr=keye4980a.keysight_e4980a("USB0::0x2A8D::0x2F01::MY46516486::INSTR") - -lcr.set_frequency("1kHz") -lcr.set_voltage_level(0.1) -timedelay=3.0 - - - -biasSupply=kei2470.Keithley2470("USB0::0x05E6::0x2470::04554700::INSTR") -biasSupply.set_current_protection(100E-6) -biasSupply.set_voltage_protection(400) -positiveHV=True -HVrange=150.0*1e3 - - -time_start=time.time() -vols=[] -mvols=[] -pcap=[] - -invpcap2=[] -current=[] - -if positiveHV: - sign=1 -else: - sign=-1 - -iStart=int(0*1e3) -iEnd=int(sign*HVrange+sign*1) -iStep=int(sign*1.0*1e3) -lcr.set_trigger_remote() -biasSupply.output_on() -for iBias in range(iStart,iEnd,iStep): - biasvol=iBias/1000 - if biasvol>400: - warnings.warn("Warning! Exceed the maximum voltage of the bias adapter!") - break - vols.append(biasvol) - mvols.append(biasSupply.set_voltage(biasvol)) - time.sleep(timedelay) - current.append(biasSupply.display_current()) - - tmp_ipcap = 0. - for i in range(5): - print("display_capacitance",i,":",lcr.get_capacitance()/1e-12) - tmp_ipcap += lcr.get_capacitance()/1e-12 - time.sleep(0.2) - ipcap = tmp_ipcap/5.0 - - pcap.append(ipcap) - - invpcap2.append(1.0/(ipcap*ipcap)) - if biasSupply.hit_compliance(): - break - -print("Bias Vols: "+str(vols)) -print("Measured vols: "+str(mvols)) -print("Capacitance: "+str(pcap)) - -print("Current: "+str(current)) - -data=[vols,mvols,pcap,invpcap2,current] - -dataarray=np.array(data) - -filename="test_CV.csv" -csv_writer(dataarray.T,filename) -time_top=time.time() -print("Ramping up takes %3.0f s." % (time_top-time_start)) - -print("Now ramping down...") -lcr.set_trigger_internal() - -biasSupply.sweep(HVrange*sign*1e-3,0,1,5) -biasSupply.output_off() -biasSupply.beep() -time_end=time.time() - -print("Ramping up time:\t%3.0f s" % (time_top-time_start)) -print("Ramping down time:\t%3.0f s" % (time_end-time_top)) -print("Total time:\t\t%3.0f m %2.0f s" % ((time_end-time_start)//60, (time_end-time_start)%60)) diff --git a/control/scan_iv_2400.py b/control/scan_iv_2400.py deleted file mode 100644 index 9fc524c7af07e2a1e260dbb310f85d376513341e..0000000000000000000000000000000000000000 --- a/control/scan_iv_2400.py +++ /dev/null @@ -1,44 +0,0 @@ -import raser.control.kei_2400c_bias_control as kei2400 -import visa -import time -import pylab -import csv -import numpy as np - -def csv_writer(data,path): - with open(path,"w") as csv_file: - writer=csv.writer(csv_file,lineterminator='\n') - writer.writerow(['Bias Voltage[V]','Measure Voltage [V]','Meaure Current [A]']) - for val in data: - writer.writerows([val]) - - -biasSupply=kei2400.keithley2400c() - -vols=[] -mvols=[] -current=[] - -iStart=int(0*1e3) -iEnd=int(5.0*1e3) -iStep=int(0.5*1e3) -for iBias in range(iStart,iEnd,iStep): - biasSupply.output_on() - biasvol=iBias/1000 - if biasvol>2: - break - vols.append(biasvol) - mvols.append(biasSupply.set_voltage(biasvol)) - current.append(biasSupply.display_current()) - -biasSupply.set_voltage(0*1e3) - -print("Bias Vols: "+str(vols)) -print("Measure vols: "+str(mvols)) -print("Current: "+str(current)) - -data=[vols,mvols,current] -dataarray=np.array(data) - -filename="test.csv" -csv_writer(dataarray.T,filename) diff --git a/control/scan_iv_2400_strip.py b/control/scan_iv_2400_strip.py deleted file mode 100644 index 9f7d1b6694983c88b38add774d17f760a9e349ad..0000000000000000000000000000000000000000 --- a/control/scan_iv_2400_strip.py +++ /dev/null @@ -1,45 +0,0 @@ -import raser.control.kei_2400b_bias_control as kei2400 -import visa -import time -import pylab -import csv -import numpy as np - -def csv_writer(data,path): - with open(path,"w") as csv_file: - writer=csv.writer(csv_file,lineterminator='\n') - writer.writerow(['Bias Voltage[V]','Measure Voltage [V]','Meaure Current [A]']) - for val in data: - writer.writerows([val]) - - -biasSupply=kei2400.keithley2400B() - -vols=[] -mvols=[] -current=[] - -iStart=int(0*1e3) -iEnd=int(105.0*1e3) -iStep=int(2.5*1e3) -for iBias in range(iStart,iEnd,iStep): - biasSupply.output_on() - biasvol=iBias/1000 - if biasvol>105: - print("Much high") - break - vols.append(biasvol) - mvols.append(biasSupply.set_voltage(biasvol)) - current.append(biasSupply.display_current()) - -biasSupply.set_voltage(0*1e3) - -print("Bias Vols: "+str(vols)) -print("Measure vols: "+str(mvols)) -print("Current: "+str(current)) - -data=[vols,mvols,current] -dataarray=np.array(data) - -filename="striptest.csv" -csv_writer(dataarray.T,filename) diff --git a/control/scan_iv_2470.py b/control/scan_iv_2470.py deleted file mode 100644 index a60d3e87d2cae17acea7c95aee838cb2d51dc40f..0000000000000000000000000000000000000000 --- a/control/scan_iv_2470.py +++ /dev/null @@ -1,85 +0,0 @@ -#import Kei2400CControl as kei2400 -import raser.control.kei_2470c_bias_control as kei2470 -# import visa -import pyvisa as visa -import time -import pylab -import csv -import numpy as np -import platform -import sys - -def csv_writer(data,path): - with open(path,"w") as csv_file: - writer=csv.writer(csv_file,lineterminator='\n') - writer.writerow(['Bias Voltage[V]','Measured Voltage[V]','Measured Current[A]']) - for val in data: - writer.writerows([val]) - - -if platform.python_version().startswith('2'): - print('You are running with',platform.python_version(),'.') - print('Please run with python3.') - print('Exit.') - sys.exit() -biasSupply=kei2470.Keithley2470("USB0::0x05E6::0x2470::04554700::INSTR") - - -biasSupply.set_current_protection(105E-6) -biasSupply.set_voltage_protection(800) -positiveHV=True -HVrange=700*1e3 -biasSupply.filter_on() - -time_start=time.time() -vols=[] -mvols=[] -current=[] - -if positiveHV: - sign=1 -else: - sign=-1 -iStart=int(0*1e3) -iEnd=int(sign*HVrange+sign*1) -iStep=int(sign*10.0*1e3) -for iBias in range(iStart,iEnd,iStep): - biasSupply.output_on() - biasvol=iBias/1000 - vols.append(biasvol) - mvols.append(biasSupply.set_voltage(biasvol)) - time.sleep(5.0) - - tmp_current = 0. - for i in range(2): - print("display_current",i,":",biasSupply.display_current()) - tmp_current += biasSupply.display_current() - time.sleep(0.2) - - my_current = tmp_current/3.0 - current.append(my_current) - if biasSupply.hit_compliance(): - break - -print("Bias Vols: "+str(vols)) -print("Measured vols: "+str(mvols)) -print("Current: "+str(current)) - -data=[vols,mvols,current] -dataarray=np.array(data) - -filename="test_IV.csv" -csv_writer(dataarray.T,filename) -time_top=time.time() -print("Ramping up takes %3.0f s." % (time_top-time_start)) - -print("Now ramping down...") - -biasSupply.sweep(HVrange*sign*1e-3,0,1 ,5) -biasSupply.output_off() -biasSupply.beep() -time_end=time.time() - -print("Ramping up time:\t%3.0f s" % (time_top-time_start)) -print("Ramping down time:\t%3.0f s" % (time_end-time_top)) -print("Total time:\t\t%3.0f m %2.0f s" % ((time_end-time_start)//60, (time_end-time_start)%60)) diff --git a/control/tek_tds5054b_scope_control.py b/control/tek_tds5054b_scope_control.py deleted file mode 100644 index a5eba0f718439c2974e325a8cf4eb6a73a0dd6f4..0000000000000000000000000000000000000000 --- a/control/tek_tds5054b_scope_control.py +++ /dev/null @@ -1,56 +0,0 @@ -import visa -import numpy as np -from struct import unpack -import pylab - -class TDS5054B: - def __init__(self): - instlist=visa.ResourceManager() - print(instlist.list_resources()) - self.scope=instlist.open_resource("GPIB0::1::INSTR") - - def testIO(self): - message=self.scope.ask('*IDN?') - print(message) - - def readSet(self,ch): - self.scope.write("DATA:SOU "+str(ch)) - self.scope.write('DATA:WIDTH 1') - self.scope.write('DATA:ENC RPB') - - def readOffset(self): - ymult = float(self.scope.ask('WFMPRE:YMULT?')) - yzero = float(self.scope.ask('WFMPRE:YZERO?')) - yoff = float(self.scope.ask('WFMPRE:YOFF?')) - xincr = float(self.scope.ask('WFMPRE:XINCR?')) - return ymult,yzero,yoff,xincr - - def readWave(self): - ymult,yzero,yoff,xincr=self.readOffset() - - self.scope.write("CURVE?") - data=self.scope.read_raw() - headerlen=2+int(data[1]) - header=data[:headerlen] - ADC_wave=data[headerlen:-1] - ADC_wave = np.array(unpack('%sB' % len(ADC_wave),ADC_wave)) - Volts = (ADC_wave - yoff) * ymult + yzero - Time = np.arange(0, xincr * len(Volts), xincr) - Time=Time*1e9 #ns - Volts=Volts*1e3 #mV - - return Time, Volts - - def plotWave(self, Time, Volts): - pylab.plot(Time, Volts) - pylab.show() - - -if __name__=="__main__": - scope=TDS5054B() - scope.testIO() - scope.readSet(3) - - Time,Volts = scope.readWave() - scope.plotWave(Time, Volts) - print(max(Volts)-min(Volts)) diff --git a/draw/__init__.py b/draw/__init__.py deleted file mode 100644 index 59dc25f741ef22e6c47f5c9451ce8176a6edb393..0000000000000000000000000000000000000000 --- a/draw/__init__.py +++ /dev/null @@ -1,102 +0,0 @@ -import os -import ROOT -from . import iv -from . import cv -from . import compare_iv -from . import compare_cv -from . import draw_iv_cv_paper9 -from . import alpha_ana_sicar -from . import data_convolution -from . import draw_figure_sicar as dfc - -def main(kwargs): - label = kwargs['label'] - - if label == 'sicar1.1.8': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8' - output_dir = '/afs/ihep.ac.cn/users/w/wangkeqi/raser/output/fig' - dfc.draw(input_dir, output_dir, label) - elif label == 'compare_sicar1.1.8_iv': - iv.main(label) - elif label == 'compare_sicar1.1.8_cv': - cv.main(label) - elif label == 'sicar1.1.8-1': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8' - output_dir = '/afs/ihep.ac.cn/users/w/wangkeqi/raser/output/fig' - dfc.draw(input_dir, output_dir, label) - elif label == 'sicar1.1.8-2': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8' - output_dir = '/afs/ihep.ac.cn/users/w/wangkeqi/raser/output/fig' - dfc.draw(input_dir, output_dir, label) - elif label == 'itk_md8_data_v1': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/itkmd8/itkmd8data' - output_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/raser/output/fig' - dfc.draw(input_dir, output_dir, label,xtitle_iv="Reverse Bias Voltage [V]",ytitle_iv="Current [nA]", - xtitle_cv="Reverse Bias Voltage [V]",ytitle_cv="Capacitance [pF]", - xlowerlimit_iv=0,xupperlimit_iv=700,ylowerlimit_iv=1e-11,yupperlimit_iv=1e-5,ylogscale_iv=0, - xlowerlimit_cv=0,xupperlimit_cv=400,ylowerlimit_cv=0,yupperlimit_cv=1e2,ylogscale_cv=0) - elif label == 'itk_md8_sim_v1': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/itkmd8/itkmd8sim' - output_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/raser/output/fig' - dfc.draw(input_dir, output_dir, label,xtitle_iv="Reverse Bias Voltage [V]",ytitle_iv="Current [nA]", - xtitle_cv="Reverse Bias Voltage [V]",ytitle_cv="Capacitance [pF]", - xlowerlimit_iv=0,xupperlimit_iv=700,ylowerlimit_iv=1e-11,yupperlimit_iv=1e-5,ylogscale_iv=0, - xlowerlimit_cv=0,xupperlimit_cv=400,ylowerlimit_cv=0,yupperlimit_cv=1e2,ylogscale_cv=0) - elif label == 'itk_md8_compare_dataandsim_v1': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/itkmd8/comparison' - output_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/raser/output/fig' - cv.main(label) - iv.main(label) - elif label == 'itk_atlas18_sim_v1': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/atlas18/sim' - output_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/raser/output/fig' - dfc.draw(input_dir, output_dir, label,xtitle_iv="Reverse Bias Voltage [V]",ytitle_iv="Current [A]", - xtitle_cv="Reverse Bias Voltage [V]",ytitle_cv="Capacitance [pF]", - xlowerlimit_iv=0,xupperlimit_iv=700,ylowerlimit_iv=1e-11,yupperlimit_iv=1e-5,ylogscale_iv=0, - xlowerlimit_cv=0,xupperlimit_cv=400,ylowerlimit_cv=0,yupperlimit_cv=1e2,ylogscale_cv=0) - elif label == 'itk_atlas18_data_v1': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/atlas18/data' - output_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/raser/output/fig' - dfc.draw(input_dir, output_dir, label,xtitle_iv="Reverse Bias Voltage [V]",ytitle_iv="Current [nA]", - xtitle_cv="Reverse Bias Voltage [V]",ytitle_cv="Capacitance [pF]", - xlowerlimit_iv=0,xupperlimit_iv=700,ylowerlimit_iv=1e-11,yupperlimit_iv=1e-5,ylogscale_iv=0, - xlowerlimit_cv=0,xupperlimit_cv=400,ylowerlimit_cv=0,yupperlimit_cv=1e2,ylogscale_cv=0) - elif label == 'sicar1.1.8-1,sicar1.1.8-2_iv': - iv.main(label) - elif label == 'sicar1.1.8-1,sicar1.1.8-2_cv': - cv.main(label) - elif label == "compare_nju_iv": - path1="/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/njupin_iv/nju_pin_iv.root" - path2="./output/2Dresult/simNJUPIN/simIV800.0to800.0.root" - compare_iv.main(label,path1,path2) - elif label == "compare_nju_cv": - path1="/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/njupin_cv/4H-SiC-PIN-cv.root" - path2="./output/2Dresult/simNJUPIN/simCV500.0to500.0.root" - compare_cv.main(label,path1,path2) - elif label == "compare_sim_sicar1.1.8_cv": - path1="/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8/sicar1.1.8-11_cv.root" - path2="./output/2Dresult/simsicar1.1.6/simCV500.0to500.0.root" - compare_cv.main(label,path1,path2) - elif label == "compare_sicar_cv_1d": - path1="/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8/iv_cv/sicar1.1.8-8_cv.root" - path2="./output/field/SICAR-1.1.8/simCV-500.0to0.0.root" - compare_cv.main(label,path1,path2) - elif label == "compare_sim_sicar1.1.8_iv": - path1="/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8/sicar1.1.8-11_iv.root" - path2="./output/2Dresult/simsicar1.1.6/simIV650.0to650.0.root" - compare_iv.main(label,path1,path2) - elif label =="p9": - csv_folder="/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/samples" - for file in os.listdir(csv_folder): - if file.endswith(".csv"): - csv_filename = os.path.join(csv_folder, file) - root_filename = file.replace(".csv", ".root") - root_fullpath = os.path.join(csv_folder, root_filename) - draw_iv_cv_paper9.create_root_file(csv_filename, root_fullpath) - draw_iv_cv_paper9.main() - alpha_ana_sicar.main() - data_convolution.landau_mirror() - data_convolution.energy_sim() - else: - raise NameError(label) - \ No newline at end of file diff --git a/draw/alpha_ana_sicar.py b/draw/alpha_ana_sicar.py deleted file mode 100644 index a37f5d0a31584219ccef8aa7b967d4793496c836..0000000000000000000000000000000000000000 --- a/draw/alpha_ana_sicar.py +++ /dev/null @@ -1,167 +0,0 @@ -import ROOT -import os -import numpy -import sys -import math - -def read_file(file_path,wave_name): - - with open(file_path + '/' + wave_name, 'r') as f: - - lines = f.readlines() - points = lines[1:] - time, volt = [],[] - - for point in points: - try: - time.append(float(point.strip('\n').strip().split(',')[3])*1e9) - volt.append(float(point.strip('\n').strip().split(',')[4])*1e3) - except Exception as e: - pass - - return time,volt - -def get_max(time_list,volt_list): - - volt_max = 0. - time_max = 0. - index_max = 0 - for i in range(len(volt_list)): - if(volt_list[i]>volt_max): - time_max = time_list[i] - volt_max = volt_list[i] - index_max = i - return time_max,volt_max,index_max - -def get_baseline(time_list,volt_list,time_win): - - time_start = time_list[0] - time_end = time_start + time_win - count = 0. - total = 0. - for i in range(len(time_list)): - if(time_list[i] < time_end): - total += volt_list[i] - count += 1. - baseline = total/count - return baseline - -def get_charge(time_list,volt_list,baseline): - - volt_cut_baseline_list = [] - for i in range(len(volt_list)): - volt_cut_baseline_list.append(volt_list[i]-baseline) - - time_max,volt_max,index_max = get_max(time_list,volt_cut_baseline_list) - - time_bin = time_list[1]-time_list[0] - tmp_integrate = 0. - - tmp_index = index_max - while True: - if(volt_cut_baseline_list[tmp_index]<0.): break - tmp_integrate += volt_cut_baseline_list[tmp_index]*time_bin - tmp_index -= 1 - - tmp_index = index_max+1 - while True: - if(volt_cut_baseline_list[tmp_index]<0.): break - tmp_integrate += volt_cut_baseline_list[tmp_index]*time_bin - tmp_index += 1 - - charge = tmp_integrate*(1e-12)/50/100*(1e15) - - return charge - -def main(): - path = '/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/CCE_1.1.8-8-2/' - for file in ["100V","150V","200V","250V","300V","350V"]: - input_name = file - path = '/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/CCE_1.1.8-8-2/' + input_name #文件路径 - waves = os.listdir(path) - time,volt = [],[] - window = 1 - - c = ROOT.TCanvas('c','c',600,500) - c.SetLeftMargin(0.16) - c.SetBottomMargin(0.14) - # c = ROOT.TCanvas('c','c',1500,600) - # c.Divide(2,1) - charge_graph = ROOT.TH1F('charge','charge',50,150,350) #bin,最å°å€¼ï¼Œæœ€å¤§å€¼ - # volt_graph = ROOT.TH1F('volt',"volt",50,800,1800) - charge_graph.SetStats(0) # å…³é—统计框架 - # volt_graph.SetStats(0) # å…³é—统计框架 - - - for wave in waves: - - print(wave) - time,volt = read_file(path,wave) - time_max,volt_max,index_max = get_max(time,volt) - baseline = get_baseline(time,volt,window) - try: - charge = get_charge(time,volt,baseline) - except: - print('error') - if charge > 30 and charge < 330: - charge_graph.Fill(charge) - # volt_graph.Fill(volt_max) - - charge_graph.SetTitle(' ') - charge_graph.GetXaxis().SetTitle("Charge (fC)") - charge_graph.GetXaxis().CenterTitle() - charge_graph.GetXaxis().SetTitleOffset(1.2) - charge_graph.GetXaxis().SetTitleSize(0.05) - charge_graph.GetXaxis().SetLabelSize(0.05) - # charge_graph.GetXaxis().SetNdivisions(505) - charge_graph.GetYaxis().CenterTitle() - charge_graph.GetYaxis().SetTitleOffset(1.6) - charge_graph.GetYaxis().SetTitleSize(0.05) - charge_graph.GetYaxis().SetLabelSize(0.05) - # ROOT.TGaxis.SetMaxDigits(3) - # charge_graph.GetYaxis().SetMaxDigits(3) - # charge_graph.GetYaxis().SetRangeUser(79, 104.99) - - # volt_graph.GetXaxis().SetTitle('Voltage [mV]') - - # c.cd(1) - c.cd() - charge_graph.Draw() - - gaussian = ROOT.TF1("gaussian", "gaus", 150, 350) - - - charge_graph.Fit(gaussian, "R") - #gaussian.Draw("same") - - mean = gaussian.GetParameter(1) - sigma = gaussian.GetParameter(2) - # æ·»åŠ æœ—é“分布 - - landau = ROOT.TF1("landau", "landau", 150, 350) # 创建朗é“分布函数 - charge_graph.Fit(landau,"R") - #landau.Draw("same") - - - landau_mean = landau.GetParameter(0) - landau_sigma = landau.GetParameter(1) - - convolution = ROOT.TF1("convolution", "landau*gaus", 150, 350) # 创建å·ç§¯å‡½æ•° - convolution.SetParameters(landau_mean, landau_sigma, mean, sigma) # 设置åˆå§‹å‚æ•° - charge_graph.Fit(convolution, "R") # 进行å·ç§¯æ‹Ÿåˆ - x_max = convolution.GetMaximumX() - #convolution.GetParameter() - convolution.Draw("same") - latex = ROOT.TLatex() - latex.SetTextSize(0.04) - latex.SetTextAlign(13) - latex.DrawLatexNDC(0.2, 0.8, "x_max = %.2f" % x_max ) - # latex.DrawLatexNDC(0.2, 0.75, "Sigma = %.2f" % sigma) - - # c.cd(2) - # volt_graph.Draw() - - c.SaveAs('/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/CCE_1.1.8-8-2/fig_sen/'+ input_name + '_distribution_cut.png') - c.SaveAs('/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/CCE_1.1.8-8-2/fig_sen/'+ input_name + '_distribution_cut.pdf') -if __name__ == '__main__': - main() \ No newline at end of file diff --git a/draw/compare_cv.py b/draw/compare_cv.py deleted file mode 100755 index 70ad438b678792165ff2cc237adaa1f2d2aa8e0b..0000000000000000000000000000000000000000 --- a/draw/compare_cv.py +++ /dev/null @@ -1,66 +0,0 @@ - -import ROOT -import os -def compare_cv(label,path1,path2): - folder_path="./output/draw" - if not os.path.exists(folder_path): - os.makedirs(folder_path) - - file1 = ROOT.TFile(path1) - tree1 = file1.Get("myTree") - - # 创建第一个图形 - canvas = ROOT.TCanvas("canvas", "Canvas", 1600, 1200) - - # 创建一个TGraph对象æ¥å˜å‚¨ç¬¬ä¸€ä¸ªROOT文件ä¸çš„æ•°æ® - graph1 = ROOT.TGraph(tree1.GetEntries()) - - # ä»Žæ ‘ä¸èŽ·å–å˜é‡æ•°æ®å¹¶æ·»åŠ 到TGraphå¯¹è±¡ä¸ - for i, event in enumerate(tree1): - graph1.SetPoint(i, event.Voltage, event.Capacitance) - - # 设置第一个数æ®ç‚¹çš„æ ‡è®°æ ·å¼å’Œé¢œè‰² - graph1.SetMarkerStyle(20) - graph1.SetMarkerColor(ROOT.kBlue) - graph1.SetMarkerSize(0.5) - graph1.GetXaxis().SetTitle("Voltage/v") - graph1.GetYaxis().SetTitle("CAP/pF") - # 打开第二个ROOT文件 - file2 = ROOT.TFile(path2) - tree2 = file2.Get("SicarTestCV") - - # 创建一个TGraph对象æ¥å˜å‚¨ç¬¬äºŒä¸ªROOT文件ä¸çš„æ•°æ® - graph2 = ROOT.TGraph(tree2.GetEntries()) - - # ä»Žæ ‘ä¸èŽ·å–å˜é‡æ•°æ®å¹¶æ·»åŠ 到TGraphå¯¹è±¡ä¸ - for i, event in enumerate(tree2): - graph2.SetPoint(i, event.voltage, event.CAP) - - # 设置第二个数æ®ç‚¹çš„æ ‡è®°æ ·å¼å’Œé¢œè‰² - graph2.SetMarkerStyle(21) - graph2.SetMarkerColor(ROOT.kRed) - graph2.SetMarkerSize(0.5) - - graph2.GetXaxis().SetTitle("Voltage/v") - graph2.GetYaxis().SetTitle("CAP/pF") - - canvas = ROOT.TCanvas("canvas", "Canvas", 1600, 1200) - graph1.SetTitle("{}_SimulateVSexperiment".format(label)) - graph1.Draw("AP") - graph2.Draw("P") - - # 创建图例 - legend = ROOT.TLegend(0.7, 0.7, 0.9, 0.9) - legend.AddEntry(graph1, "experiment", "p") - legend.AddEntry(graph2, "simulate", "p") - legend.Draw() - - # 显示图形 - - canvas.Update() - canvas.SaveAs("./output/draw/compare_{}_ex.root".format(label)) -def main(label,path1,path2): - compare_cv(label,path1,path2) - -if __name__ == "__main__": - main(label,path1,path2) \ No newline at end of file diff --git a/draw/compare_iv.py b/draw/compare_iv.py deleted file mode 100755 index 8b75d2c52121c5434398514a24c2aa5321a689f7..0000000000000000000000000000000000000000 --- a/draw/compare_iv.py +++ /dev/null @@ -1,62 +0,0 @@ -import ROOT -import os -def compare_iv(label,path1,path2): - folder_path="./output/draw" - if not os.path.exists(folder_path): - os.makedirs(folder_path) - - file1 = ROOT.TFile(path1) - tree1 = file1.Get("myTree") - - # 创建一个TGraph对象æ¥å˜å‚¨ç¬¬ä¸€ä¸ªROOT文件ä¸çš„æ•°æ® - graph1 = ROOT.TGraph(tree1.GetEntries()) - - # ä»Žæ ‘ä¸èŽ·å–å˜é‡æ•°æ®å¹¶æ·»åŠ 到TGraphå¯¹è±¡ä¸ - for i, event in enumerate(tree1): - graph1.SetPoint(i, abs(event.Value), abs(event.Reading)) - - # 设置第一个数æ®ç‚¹çš„æ ‡è®°æ ·å¼å’Œé¢œè‰² - graph1.SetMarkerStyle(20) - graph1.SetMarkerColor(ROOT.kBlue) - graph1.SetMarkerSize(0.5) - graph1.GetXaxis().SetTitle("Voltage/v") - graph1.GetYaxis().SetTitle("Current/A") - # 打开第二个ROOT文件 - file2 = ROOT.TFile(path2) - tree2 = file2.Get("SicarTestIV") - - # 创建一个TGraph对象æ¥å˜å‚¨ç¬¬äºŒä¸ªROOT文件ä¸çš„æ•°æ® - graph2 = ROOT.TGraph(tree2.GetEntries()) - - # ä»Žæ ‘ä¸èŽ·å–å˜é‡æ•°æ®å¹¶æ·»åŠ 到TGraphå¯¹è±¡ä¸ - for i, event in enumerate(tree2): - graph2.SetPoint(i, event.voltage, event.Current) - - # 设置第二个数æ®ç‚¹çš„æ ‡è®°æ ·å¼å’Œé¢œè‰² - graph2.SetMarkerStyle(21) - graph2.SetMarkerColor(ROOT.kRed) - graph2.SetMarkerSize(0.5) - - graph2.GetXaxis().SetTitle("Voltage/v") - graph2.GetYaxis().SetTitle("Current/A") - - canvas = ROOT.TCanvas("canvas", "Canvas", 800, 600) - graph1.SetTitle("{}_SimulateVSexperiment".format(label)) - graph1.Draw("AP") - graph2.Draw("P") - - # 创建图例 - legend = ROOT.TLegend(0.7, 0.7, 0.9, 0.9) - legend.AddEntry(graph1, "experiment", "p") - legend.AddEntry(graph2, "simulate", "p") - legend.Draw() - - # 显示图形 - - canvas.Update() - canvas.SaveAs("./output/draw/compare_{}_ex.root".format(label)) -def main(label,path1,path2): - compare_iv(label,path1,path2) - -if __name__ == "__main__": - main(label,path1,path2) \ No newline at end of file diff --git a/draw/cv.py b/draw/cv.py deleted file mode 100644 index 39e891aaae89d928a3832fde76d0c6604382d37c..0000000000000000000000000000000000000000 --- a/draw/cv.py +++ /dev/null @@ -1,94 +0,0 @@ -import os -import ROOT - -def draw_cv(input_dir, output_dir, label): - com_name = [] - legend_name = [] - - for file in os.listdir(input_dir): - if file.endswith('.root'): - com_name.append(file) - - c_c = ROOT.TCanvas("c_c", "c_c", 800, 800) - c_c.SetLeftMargin(0.22) - c_c.SetBottomMargin(0.16) - c_c.SetGrid() - c_c.SetFrameLineWidth(5) - c_c.SetLogy() - multigraphs_c = ROOT.TMultiGraph() - - for i in range(len(com_name)): - name = com_name[i] - if label == 'sicar1.1.8_cv' and not name.startswith('sicar1.1.8'): - continue - elif label == 'sicar1.1.8-1,sicar1.1.8-2_cv' and not (name.startswith('sicar1.1.8-1_')) and not (name.startswith('sicar1.1.8-2_')): - continue - - name = name.split('.root')[0] - - input_file = os.path.join(input_dir, name + '.root') - - if name.endswith('cv'): - file = ROOT.TFile(input_file, "READ") - tree = file.Get("myTree") - graph = ROOT.TGraph() - legend_name.append(name.split('_')[0]) - - for i, event in enumerate(tree): - x = event.Voltage - x = abs(x) - y = event.Capacitance - y = abs(y) - graph.SetPoint(i, x, y) - - graph.SetNameTitle("") - graph.SetMarkerColor(0+i) - graph.SetMarkerStyle(24) - graph.SetMarkerSize(1) - multigraphs_c.Add(graph) - - multigraphs_c.GetXaxis().SetLimits(0,399.99) - multigraphs_c.GetXaxis().SetTitle("Reverse Bias Voltage [V]") - multigraphs_c.GetXaxis().CenterTitle() - multigraphs_c.GetXaxis().SetTitleOffset(1.4) - multigraphs_c.GetXaxis().SetTitleSize(0.05) - multigraphs_c.GetXaxis().SetLabelSize(0.05) - multigraphs_c.GetXaxis().SetNdivisions(505) - multigraphs_c.GetYaxis().SetLimits(4,5e2) - multigraphs_c.GetYaxis().SetRangeUser(4, 5e2) - multigraphs_c.GetYaxis().SetTitle("Capacitance [pF]") - multigraphs_c.GetYaxis().CenterTitle() - multigraphs_c.GetYaxis().SetTitleOffset(1.8) - multigraphs_c.GetYaxis().SetTitleSize(0.05) - multigraphs_c.GetYaxis().SetLabelSize(0.05) - multigraphs_c.Draw("AP") - - max_i = len(legend_name) - 1 - legend_c = ROOT.TLegend(0.52,0.82-0.05*float(max_i),0.87,0.85) - legend_c.SetTextSize(0.04) - - for i, graph in enumerate(multigraphs_c): - legend_c.AddEntry(graph, legend_name[i]) - - legend_c.Draw() - - file_name_c = label + ".root" - c_c.SaveAs(os.path.join(output_dir, file_name_c)) - file_name_c = label + ".pdf" - c_c.SaveAs(os.path.join(output_dir, file_name_c)) - file_name_c = label + ".png" - c_c.SaveAs(os.path.join(output_dir, file_name_c)) - - -def main(label): - if label=='itk_md8_compare_dataandsim': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/itkmd8/comparison' - output_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/raser/output/fig' - else: - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8' - output_dir = '/afs/ihep.ac.cn/users/w/wangkeqi/raser/output/fig' - - draw_cv(input_dir, output_dir, label) - -if __name__ == "__main__": - main() diff --git a/draw/data_convolution.py b/draw/data_convolution.py deleted file mode 100644 index be207ece6f4a4f05bcfcc315d624368c8bd91d16..0000000000000000000000000000000000000000 --- a/draw/data_convolution.py +++ /dev/null @@ -1,324 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- - -import ROOT -import os -import math -import array -import time as tm -import pandas -def read_file(file_path,wave_name): - - with open(file_path + '/' + wave_name, 'r') as f: - - lines = f.readlines() - points = lines[1:] - time, volt = [],[] - - for point in points: - try: - time.append(float(point.strip('\n').strip().split(',')[3])*1e9) - volt.append(float(point.strip('\n').strip().split(',')[4])*1e3) - except Exception as e: - pass - - return time,volt - -def get_max(time_list,volt_list): - - volt_max = 0. - time_max = 0. - index_max = 0 - for i in range(len(volt_list)): - if(volt_list[i]>volt_max): - time_max = time_list[i] - volt_max = volt_list[i] - index_max = i - return time_max,volt_max,index_max - -def get_baseline(time_list,volt_list,time_win): - - time_start = time_list[0] - time_end = time_start + time_win - count = 0. - total = 0. - for i in range(len(time_list)): - if(time_list[i] < time_end): - total += volt_list[i] - count += 1. - baseline = total/count - return baseline - -def get_charge(time_list,volt_list,baseline): - - volt_cut_baseline_list = [] - for i in range(len(volt_list)): - volt_cut_baseline_list.append(volt_list[i]-baseline) - - time_max,volt_max,index_max = get_max(time_list,volt_cut_baseline_list) - - time_bin = time_list[1]-time_list[0] - tmp_integrate = 0. - - tmp_index = index_max - while True: - if(volt_cut_baseline_list[tmp_index]<0.): break - tmp_integrate += volt_cut_baseline_list[tmp_index]*time_bin - tmp_index -= 1 - - tmp_index = index_max+1 - while True: - if(volt_cut_baseline_list[tmp_index]<0.): break - tmp_integrate += volt_cut_baseline_list[tmp_index]*time_bin - tmp_index += 1 - - charge = tmp_integrate*(1e-12)/50/100*(1e15) - - return charge - - - -def energy_sim(): - c=ROOT.TCanvas("c","c",700,500) - charge_graph_file=ROOT.TFile.Open("./output/SiC_LGAD/energy_deposition_final.root") - charge_graph=charge_graph_file.Get("Edetector") - - # 定义新的直方图 - new_hist = ROOT.TH1F("new_histogram", "New Histogram", 200, 4.1, 4.6) - new_hist.SetStats(0) - # é‡æ–°å¡«å……æ•°æ®åˆ°æ–°çš„直方图 - for i in range(charge_graph.GetNbinsX()): - bin_content = charge_graph.GetBinContent(i) - bin_center = charge_graph.GetBinCenter(i) - new_hist.Fill(bin_center, bin_content) - - # 将新的直方图ä¿å˜åˆ°æ–‡ä»¶ - new_file = ROOT.TFile("new_output.root", "RECREATE") - new_hist.Write() - new_file.Close() - npars=3 - f2 = ROOT.TF1("f2", "[2]*TMath::Landau(2*[0]-x, [0], [1])", 4.1, 4.6,npars) - #f2 = ROOT.TF1("f2", "[2]*TMath::Gaus(x, [0], [1])", 0, 2.5,npars) - f2.SetParLimits(0,4.,5) - f2.SetParLimits(1,0,1) - f2.SetParLimits(2,70.,1000) - f2.SetParameters(4.4,0.1,70) - #h=ROOT.TH1F("h","data",75,150,350) - weight_factor = 1 # å‡è®¾å¢žåŠ 2å€çš„æƒé‡ - data_file = open("data_points.txt", "w") - for i in range(new_hist.GetNbinsX()): - bin_content = new_hist.GetBinContent(i) - bin_error = new_hist.GetBinError(i) - #if bin_content < 80: # 举例:å‡è®¾é«˜äºŽæŸä¸ªé˜ˆå€¼çš„æ•°æ®ç‚¹å¢žåŠ æƒé‡ - new_hist.SetBinContent(i, bin_content) - data_file.write(f"{new_hist.GetXaxis().GetBinCenter(i)} {bin_content}\n") - new_hist.SetBinError(i,0) - data_file.close() - # è¿›è¡Œæ‹Ÿåˆ - new_hist.Fit(f2,"W") - - f2.SetLineColor(ROOT.kBlue) - num_points = 1000 # 设置需è¦è®¡ç®—çš„ç‚¹çš„æ•°é‡ - fit_points = [] - for i in range(num_points): - x = 4 + i * (5 - 4) / num_points # 在x范围内å‡åŒ€é€‰å–点 - y = f2.Eval(x) # 计算拟åˆæ›²çº¿ä¸Šçš„点 - fit_points.append((x, y)) - - # 将拟åˆæ›²çº¿ä¸Šçš„点写入txt文件 - output_file = open("fit_curve.txt", "w") - for point in fit_points: - output_file.write(f"{point[0]} {point[1]}\n") - - output_file.close() - - new_hist.SetLineColor(ROOT.kBlack) - new_hist.SetMarkerStyle(20) # è®¾ç½®ç‚¹çš„æ ·å¼ä¸ºå®žå¿ƒåœ† - new_hist.SetMarkerColor(ROOT.kBlack) # 设置点的颜色为黑色 - new_hist.SetMinimum(0) # 设置y轴最å°å€¼ - new_hist.SetMaximum(90) - new_hist.SetLabelFont(43, "XYZ") - new_hist.SetTitleFont(43, "XYZ") - new_hist.SetLabelSize(20, "XYZ") - new_hist.SetTitleSize(20, "XYZ") - new_hist.SetLabelSize(0.04, "X") # 设置Xè½´æ ‡ç¾çš„长度为2.6 - new_hist.SetLabelSize(0.04, "Y") # 设置Yè½´æ ‡ç¾çš„长度为2.6 - - new_hist.Draw("P") - #f2.Draw("same") - latex = ROOT.TLatex() - latex.SetTextSize(0.04) - latex.SetTextAlign(13) - latex.DrawLatexNDC(0.2, 0.8, "MPV= %.2f" % (f2.GetParameter(0))) - #latex.DrawLatexNDC(0.2, 0.6, "sigma= %.2f" % (f2.GetParameter(1))) - c.SaveAs("./output/SiC_LGAD/fit_alpha.svg") - c.SaveAs("./output/SiC_LGAD/fit_alpha.root") - - -def landau_mirror(): - - charge_con=[] - charge_err=[] - path = '/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/CCE_1.1.8-8-2/' - c = ROOT.TCanvas('c','c',1500,1200) - c.SetLeftMargin(0.16) - c.SetBottomMargin(0.14) - - #c.Divide(3, 2) - for i, file in enumerate(["100v","150v","200v","250v","300v","350v"]): - - input_name = file - path = '/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/alpha/' + input_name #文件路径 - waves = os.listdir(path) - time,volt = [],[] - window = 1 - - c.cd(i+1) - charge = ROOT.RooRealVar("charge", "charge", 30, 200) - - charge_graph = ROOT.TH1F('charge','charge',120,30.,200) #bin,最å°å€¼ï¼Œæœ€å¤§å€¼ - # volt_graph = ROOT.TH1F('volt',"volt",50,800,1800) - xaxis = charge_graph.GetXaxis() - yaxis = charge_graph.GetYaxis() - - # è®¾ç½®æ¨ªè½´å’Œçºµè½´æ ‡ç¾ - xaxis.SetTitle("Charge (fC)") - xaxis.CenterTitle() # å°†æ ‡ç¾å±…ä¸ - xaxis.SetTitleSize(0.04) # è®¾ç½®æ ‡ç¾çš„å¤§å° - - - yaxis.SetTitle("Counts (a.u.)") - yaxis.CenterTitle() # å°†æ ‡ç¾å±…ä¸ - yaxis.SetTitleSize(0.04) # è®¾ç½®æ ‡ç¾çš„å¤§å° - charge_graph.SetStats(0) # å…³é—统计框架S - - - output_file_2 = open("charge_histogram.{}txt".format(input_name), "w") - for wave in waves: - #print(wave) - time,volt = read_file(path,wave) - time_max,volt_max,index_max = get_max(time,volt) - baseline = get_baseline(time,volt,window) - try: - charge = get_charge(time,volt,baseline) - except: - print('error') - if charge > 30 and charge < 330: - charge_graph.Fill(charge) - - output_file_2.write(f"{charge}\n") - - - charge_var = ROOT.RooRealVar("charge_var", "charge_var", charge) - data = ROOT.RooDataHist("charge_graph", "charge_graph", ROOT.RooArgList( charge_var), ROOT.RooFit.Import(charge_graph)) - output_file_2.close() - output_file_2 = open("charge_histogram.{}txt".format(input_name), "w") - - npars=6 - #f2=ROOT.TF1("f2","0.5*[0]*[1]/TMath::Pi() /TMath::Max( 1.e-10,(x-[2])*(x-[2])+ .25*[1]*[1]") - f2 = ROOT.TF1("f2", "[2]*TMath::Landau(2*[0]-x, [0], [1])+[5]*TMath::Gaus(x,[3],[4])", 30, 200,npars) - f2.SetParLimits(0,150.,155) - f2.SetParLimits(1,0.,10) - f2.SetParLimits(2,0.,1000) - f2.SetParLimits(3,150.,155) - f2.SetParLimits(4,0.,10) - f2.SetParLimits(5,0.,1000) - f2.SetParameters(150,2,0,150,2,0) - - charge_graph.Fit(f2,"w") - # 计算拟åˆæ›²çº¿ä¸Šçš„点 - num_points = 1000 # 设置需è¦è®¡ç®—çš„ç‚¹çš„æ•°é‡ - fit_points = [] - for i in range(num_points): - x = 30 + i * (200 - 30) / num_points # 在x范围内å‡åŒ€é€‰å–点 - y = f2.Eval(x) # 计算拟åˆæ›²çº¿ä¸Šçš„点 - fit_points.append((x, y)) - - # 将拟åˆæ›²çº¿ä¸Šçš„点写入txt文件 - output_file = open("fit_curve_points{}.txt".format(input_name), "w") - for point in fit_points: - output_file.write(f"{point[0]} {point[1]}\n") - - output_file.close() - f2.SetLineColor(ROOT.kBlue) - - - charge_graph.SetLineColor(ROOT.kBlack) - charge_graph.SetMarkerStyle(20) # è®¾ç½®ç‚¹çš„æ ·å¼ä¸ºå®žå¿ƒåœ† - charge_graph.SetMarkerColor(ROOT.kBlack) # 设置点的颜色为黑色 - charge_graph.SetMinimum(0) # 设置y轴最å°å€¼ - charge_graph.SetMaximum(70) - graph = ROOT.TGraph() - graph.GetXaxis().SetLabelFont(42) # 设置xè½´æ ‡é¢˜çš„å—体 - graph.GetXaxis().SetLabelSize(0.04) # 设置xè½´æ ‡é¢˜çš„å—å· - graph.GetYaxis().SetLabelFont(42) # 设置yè½´æ ‡é¢˜çš„å—体 - graph.GetYaxis().SetLabelSize(0.04) - graph.GetXaxis().SetNdivisions(1010) # 设置x轴主刻度和次刻度的分割数 - graph.GetYaxis().SetNdivisions(1001) # 设置y轴主刻度和次刻度的分割数 # 设置yè½´æ ‡é¢˜çš„å—å· - graph.GetXaxis().SetTitle( 'Charge (fC)' ) - graph.GetYaxis().SetTitle( 'Counts (a.u.)' ) - graph.GetXaxis().SetTickLength(0.04) # 设置x轴刻度长度 - graph.GetYaxis().SetTickLength(0.04) # 设置y轴刻度长度 - graph.GetXaxis().CenterTitle() # å°†xè½´æ ‡é¢˜å±…ä¸ - graph.GetYaxis().CenterTitle() # å°†yè½´æ ‡é¢˜å±…ä¸ - charge_graph.Draw("E") - #f2.Draw("same") - latex = ROOT.TLatex() - latex.SetTextSize(0.04) - latex.SetTextAlign(13) - latex.DrawLatexNDC(0.2, 0.8, "MPV= %.2f" % (f2.GetParameter(0))) - latex.DrawLatexNDC(0.2, 0.7, "SL= %.2f" % (f2.GetParameter(1))) - #latex.DrawLatexNDC(0.2,0.4,"Charge=%.4f"%(integral_value)) - - - charge_con.append(f2.GetParameter(0)) - charge_err.append(f2.GetParameter(1)) - - c.Update() - - c.SaveAs("fit_alpha" + input_name + ".png") - canvas=ROOT.TCanvas("canvas","canvas",1500,1200) - print(charge_con) - - graph=ROOT.TGraphErrors() - for i,n in enumerate([100,150,200,250,300,350]): - graph.SetPointError(i,0,charge_err[i]) - graph.SetPoint(i,n,charge_con[i]) - mg=ROOT.TMultiGraph("mg","") - graph.SetMarkerStyle(20) # è®¾ç½®ç‚¹çš„æ ·å¼ä¸ºå®žå¿ƒåœ† - graph.SetMarkerColor(ROOT.kBlack) # 设置点的颜色为黑色 - graph.GetXaxis().SetLabelFont(42) # 设置xè½´æ ‡é¢˜çš„å—体 - graph.GetXaxis().SetLabelSize(0.04) # 设置xè½´æ ‡é¢˜çš„å—å· - graph.GetYaxis().SetLabelFont(42) # 设置yè½´æ ‡é¢˜çš„å—体 - graph.GetYaxis().SetLabelSize(0.04) # 设置yè½´æ ‡é¢˜çš„å—å· - graph.GetYaxis().SetTitle( 'Charge (fC)' ) - graph.GetXaxis().SetTitle( 'Reverse Bias Voltage (V)' ) - graph.GetXaxis().CenterTitle() # å°†xè½´æ ‡é¢˜å±…ä¸ - graph.GetYaxis().CenterTitle() # å°†yè½´æ ‡é¢˜å±…ä¸ - - graph.Draw("AP") - data=pandas.read_csv("./raser/draw/fit.csv") - x = abs(data['X'].values) - y = abs(data['Y'].values) - fit_graph=ROOT.TGraph() - for i ,n in enumerate(x): - fit_graph.SetPoint(i,n,y[i]) - #fit_graph.SetLineStyle(2) - fit_graph.SetMarkerStyle(20) # è®¾ç½®ç‚¹çš„æ ·å¼ä¸ºå®žå¿ƒåœ† - fit_graph.SetMarkerColor(ROOT.kRed) # 设置点的颜色为黑色 - fit_graph.GetXaxis().SetLabelFont(42) # 设置xè½´æ ‡é¢˜çš„å—体 - fit_graph.GetXaxis().SetLabelSize(0.04) # 设置xè½´æ ‡é¢˜çš„å—å· - fit_graph.GetYaxis().SetLabelFont(42) # 设置yè½´æ ‡é¢˜çš„å—体 - fit_graph.GetYaxis().SetLabelSize(0.04) # 设置yè½´æ ‡é¢˜çš„å—å· - fit_graph.GetYaxis().SetTitle( 'Charge (fC)' ) - fit_graph.GetXaxis().SetTitle( 'Reverse Bias Voltage (V)' ) - fit_graph.GetXaxis().CenterTitle() # å°†xè½´æ ‡é¢˜å±…ä¸ - fit_graph.GetYaxis().CenterTitle() - fit_graph.Draw("AP") - - mg.Add(graph) - mg.Add(fit_graph) - mg.Draw("AP") - canvas.SaveAs("charge_alpha.root") - canvas.SaveAs("charge_alpha.png") - diff --git a/draw/draw_figure_sicar.py b/draw/draw_figure_sicar.py deleted file mode 100644 index ab74bcf6748272e4945e9152a00ee8702b10f8c5..0000000000000000000000000000000000000000 --- a/draw/draw_figure_sicar.py +++ /dev/null @@ -1,110 +0,0 @@ -import os -import ROOT -def draw(input_dir, output_dir, label,xtitle_iv="Reverse Bias Voltage [V]",ytitle_iv="Current [A]", - xtitle_cv="Reverse Bias Voltage [V]",ytitle_cv="Capacitance [pF]", - xlowerlimit_iv=0,xupperlimit_iv=510,ylowerlimit_iv=1e-11,yupperlimit_iv=1e-5,ylogscale_iv=0, - xlowerlimit_cv=0,xupperlimit_cv=399.99,ylowerlimit_cv=0,yupperlimit_cv=1e2,ylogscale_cv=0): - - com_name = [] - for file in os.listdir(input_dir): - if file.endswith('.root'): - com_name.append(file) - for name in com_name: - if label == 'sicar1.1.8' and not name.startswith('sicar1.1.8'): - continue - elif label == 'sicar1.1.8-1' and not name.startswith('sicar1.1.8-1_'): - continue - elif label == 'sicar1.1.8-2' and not name.startswith('sicar1.1.8-2_'): - continue - name = name.split('.root')[0] - - input_file = os.path.join(input_dir, name + '.root') - output_file = os.path.join(output_dir, name + '.root') - pdf_file = os.path.join(output_dir, name + '.pdf') - png_file = os.path.join(output_dir, name + '.png') - - if name.endswith('iv'): - file = ROOT.TFile(input_file, "READ") - tree = file.Get("myTree") - graph = ROOT.TGraph() - - for i, event in enumerate(tree): - if label in ['itk_md8_data','itk_atlas18_data']: - x = event.Voltage_V - x = abs(x) - y = event.Current_nA - y = abs(y)*1e-9 - elif label == 'itk_atlas18_sim': - x = event.Voltage - x = abs(x) - y = event.Current - y = abs(y)*1e-9 - else: - x = event.Value - x = abs(x) - y = event.Reading - y = abs(y) - graph.SetPoint(i, x, y) - - draw_with_options(graph,name,output_file,pdf_file,png_file,xtitle_iv,ytitle_iv, - xlowerlimit_iv,xupperlimit_iv,ylowerlimit_iv,yupperlimit_iv,ylogscale_iv) - #problem: unable to change y limits - - if name.endswith('cv'): - file = ROOT.TFile(input_file, "READ") - tree = file.Get("myTree") - graph = ROOT.TGraph() - for i, event in enumerate(tree): - x = event.Voltage - x = abs(x) - y = event.Capacitance - y = abs(y) - graph.SetPoint(i, x, y) - - draw_with_options(graph,name,output_file,pdf_file,png_file,xtitle_cv,ytitle_cv, - xlowerlimit_cv,xupperlimit_cv,ylowerlimit_cv,yupperlimit_cv,ylogscale_cv) - - -def draw_with_options(graph,name,output_file,pdf_file,png_file,xtitle,ytitle, - xlowerlimit,xupperlimit,ylowerlimit,yupperlimit,ylogscale): - graph.SetNameTitle("") - graph.SetLineWidth(1) - graph.SetMarkerColor(ROOT.kBlack) - graph.SetMarkerStyle(24) - graph.SetMarkerSize(1) - - graph.GetXaxis().SetTitle(xtitle) - graph.GetXaxis().SetLimits(xlowerlimit,xupperlimit) - graph.GetXaxis().CenterTitle() - graph.GetXaxis().SetTitleOffset(1.4) - graph.GetXaxis().SetTitleSize(0.05) - graph.GetXaxis().SetLabelSize(0.05) - graph.GetXaxis().SetNdivisions(505) - - graph.GetYaxis().SetLimits(ylowerlimit,yupperlimit) - graph.GetYaxis().SetTitle(ytitle) - graph.GetYaxis().CenterTitle() - graph.GetYaxis().SetTitleOffset(1.8) - graph.GetYaxis().SetTitleSize(0.05) - graph.GetYaxis().SetLabelSize(0.05) - graph.Draw("AP") - - c = ROOT.TCanvas("c","c",500,500) - c.SetLeftMargin(0.22) - c.SetBottomMargin(0.16) - legend = ROOT.TLegend(0.27,0.67,0.62,0.80) - c.SetGrid() - c.SetFrameLineWidth(5) - - legend.SetTextSize(0.04) - legend.AddEntry(graph,name.split('_')[0]) - - c.cd() - c.SetLogy(ylogscale) - graph.Draw() - legend.Draw() - - c.SaveAs(output_file) - c.SaveAs(pdf_file) - c.SaveAs(png_file) - del c \ No newline at end of file diff --git a/draw/draw_iv_cv_paper4.py b/draw/draw_iv_cv_paper4.py deleted file mode 100644 index d1754d4a9250d1fb3e7ab27dc09c5d6b724121aa..0000000000000000000000000000000000000000 --- a/draw/draw_iv_cv_paper4.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python -import numpy as np -import ROOT - -def draw_double_iv(path1, path2, start): - data1=np.loadtxt(path1, skiprows=start-1, comments="END") - v1=-data1.T[0] - i1=-data1.T[1] - data2=np.loadtxt(path2, skiprows=start-1, comments="END") - v2=-data2.T[0] - i2=-data2.T[1] - - c = ROOT.TCanvas('c', '', 800, 600) - c.SetFillColor(0) - c.SetFrameFillColor(0) - ROOT.gStyle.SetPadColor(0) - ROOT.gStyle.SetCanvasColor(0) - ROOT.gStyle.SetOptStat(0) - c.SetLeftMargin(0.15) - c.SetBottomMargin(0.15) - - c.SetLogy() - - mg=ROOT.TMultiGraph("mg","") - n1=len(v1) - graph1 = ROOT.TGraph(n1,v1,i1) - n2=len(v2) - graph2 = ROOT.TGraph(n2,v2,i2) - - graph1.SetLineColor(4) - graph2.SetLineColor(6) - graph1.SetMarkerColor(4) - graph2.SetMarkerColor(6) - graph1.SetMarkerStyle(20) - graph2.SetMarkerStyle(22) - - mg.Add(graph1) - mg.Add(graph2) - mg.Draw('apl') - mg.SetMinimum(7e-10) - mg.SetMaximum(1.5e-4) - - mg.GetYaxis().SetTitle('Current [A]') - mg.GetXaxis().SetTitle('Reverse Bias Voltage [V]') - mg.GetYaxis().SetLabelSize(0.05) - mg.GetYaxis().SetTitleSize(0.05) - mg.GetXaxis().SetLabelSize(0.05) - mg.GetXaxis().SetTitleSize(0.05) - - legend = ROOT.TLegend(0.2, 0.6, 0.4, 0.75) - legend.AddEntry(graph1, "p-i-n", "pl") - legend.AddEntry(graph2, "LGAD", "pl") - legend.SetTextSize(27) - legend.SetTextFont(43) - - legend.SetBorderSize(0) - legend.SetFillColor(0) - legend.Draw() - - c.SaveAs("output/iv_comparison.pdf") - - -def draw_double_cv(path1, path2, start): - data1=np.loadtxt(path1, skiprows=start-1, comments="END") - v1=-data1.T[0] - c1=data1.T[1] - data2=np.loadtxt(path2, skiprows=start-1, comments="END") - v2=-data2.T[0] - c2=data2.T[1] - - c = ROOT.TCanvas('c', '', 800, 600) - c.SetFillColor(0) - c.SetFrameFillColor(0) - ROOT.gStyle.SetPadColor(0) - ROOT.gStyle.SetCanvasColor(0) - ROOT.gStyle.SetOptStat(0) - c.SetLeftMargin(0.15) - c.SetBottomMargin(0.15) - - - mg=ROOT.TMultiGraph("mg","") - n1=len(v1) - graph1 = ROOT.TGraph(n1,v1,c1**(-2)) - n2=len(v2) - graph2 = ROOT.TGraph(n2,v2,c2**(-2)) - - graph1.SetLineColor(4) - graph2.SetLineColor(6) - graph1.SetMarkerColor(4) - graph2.SetMarkerColor(6) - graph1.SetMarkerStyle(20) - graph2.SetMarkerStyle(22) - - mg.Add(graph1) - mg.Add(graph2) - mg.Draw('apl') - - mg.GetYaxis().SetTitle('Capacitance^{-2} [F^{-2}]') - mg.GetXaxis().SetTitle('Reverse Bias Voltage [V]') - mg.GetYaxis().SetLabelSize(0.05) - mg.GetYaxis().SetTitleSize(0.05) - mg.GetXaxis().SetLabelSize(0.05) - mg.GetXaxis().SetTitleSize(0.05) - - legend = ROOT.TLegend(0.6, 0.2, 0.8, 0.35) - legend.AddEntry(graph1, "p-i-n", "pl") - legend.AddEntry(graph2, "LGAD", "pl") - legend.SetTextSize(27) - legend.SetTextFont(43) - - legend.SetBorderSize(0) - legend.SetFillColor(0) - legend.Draw() - - c.SaveAs("output/cv_comparison.pdf") - -pin_iv = '/afs/ihep.ac.cn/users/f/fuchenxi/disk/1/hpk_ivcv/HPK-EPI-W2-200-DS-SE5PINNM-01/HPK-EPI-W2-200-DS-SE5PINNM-01_2019-09-03_1.iv' -pin_cv = '/afs/ihep.ac.cn/users/f/fuchenxi/disk/1/hpk_ivcv/HPK-EPI-W2-200-DS-SE5PINNM-01/HPK-EPI-W2-200-DS-SE5PINNM-01_2019-09-03_1.cv' -lgad_iv = '/afs/ihep.ac.cn/users/f/fuchenxi/disk/1/hpk_ivcv/HPK-EPI-W2-200-DS-SE5-01/HPK-EPI-W2-200-DS-SE5-01_2019-08-26_1.iv' -lgad_cv = '/afs/ihep.ac.cn/users/f/fuchenxi/disk/1/hpk_ivcv/HPK-EPI-W2-200-DS-SE5-01/HPK-EPI-W2-200-DS-SE5-01_2019-08-28_1.cv' -iv_start = 66 -cv_start = 71 -draw_double_iv(pin_iv, lgad_iv, iv_start) -draw_double_cv(pin_cv, lgad_cv, cv_start) \ No newline at end of file diff --git a/draw/draw_iv_cv_paper9.py b/draw/draw_iv_cv_paper9.py deleted file mode 100644 index 29b3865f302e0959b60fcdb6777b254df93fab53..0000000000000000000000000000000000000000 --- a/draw/draw_iv_cv_paper9.py +++ /dev/null @@ -1,234 +0,0 @@ -#!/usr/bin/env python -import ROOT -import csv -import os -from array import array -import numpy as np -from scipy.optimize import curve_fit -# 读å–CSV文件 -def read_csv(csv_filename): - data = [] - with open(csv_filename, 'r') as csvfile: - csvreader = csv.reader(csvfile) - next(csvreader) # 跳过表头 - for row in csvreader: - if csv_filename.endswith("cv.csv"): - if row: # 检查是å¦å˜åœ¨æ•°æ® - x_value = float(row[0]) if row[0] else 0.0 - y_value = float(row[2]) if row[2] else 0.0 - data.append((x_value, y_value)) - elif csv_filename.endswith("iv.csv"): - if row: # 检查是å¦å˜åœ¨æ•°æ® - x_value = float(row[0]) if row[0] else 0.0 - y_value = float(row[1]) if row[1] else 0.0 - data.append((x_value, y_value)) - elif csv_filename.endswith("other.csv"): - if row: # 检查是å¦å˜åœ¨æ•°æ® - x_value = float(row[0]) if row[0] else 0.0 - y_value = float(row[1]) if row[1] else 0.0 - data.append((x_value, y_value)) - - return data - -# 创建ROOT文件并å˜å‚¨æ•°æ® -def create_root_file(csv_filename, root_filename): - data = read_csv(csv_filename) - - # 创建ROOT文件 - root_file = ROOT.TFile(root_filename, "RECREATE") - - # 创建TTree对象 - tree = ROOT.TTree("data_tree", "Data from CSV") - x = ROOT.std.vector('double')() - y = ROOT.std.vector('double')() - tree.Branch("x", x) - tree.Branch("y", y) - - for i, (x_val, y_val) in enumerate(data): - x.push_back(x_val) - y.push_back(y_val) - tree.Fill() - - # å°†TTree对象写入ROOT文件 - tree.Write() - root_file.Close() - - -def draw_iv_p9(): - # 创建一个Canvas - c = ROOT.TCanvas('c', '', 800, 600) - c.SetFillColor(0) - c.SetFrameFillColor(0) - ROOT.gStyle.SetPadColor(0) - ROOT.gStyle.SetCanvasColor(0) - ROOT.gStyle.SetOptStat(0) - c.SetLeftMargin(0.15) - c.SetBottomMargin(0.15) - c.SetLogy() - # é历文件夹 - folder_path = "/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/samples/" # 文件夹路径 - colors = [ROOT.kGreen, ROOT.kRed, ROOT.kTeal, ROOT.kYellow, ROOT.kMagenta] # 定义ä¸åŒçš„颜色 - mg=ROOT.TMultiGraph("mg","") - legend = ROOT.TLegend(0.6, 0.2, 0.8, 0.4) - legend.SetBorderSize(0) # 设置图例的边框大å°ä¸º0,å³æ²¡æœ‰è¾¹æ¡† - for i,file_name in enumerate(os.listdir(folder_path)): - if file_name.endswith("iv.root"): # 如果文件å以"iv.root"结尾 - file_number = int(''.join(filter(str.isdigit, file_name))) - color_index = file_number - 1 - root_file = ROOT.TFile(os.path.join(folder_path, file_name)) - tree = root_file.Get("data_tree") # 获å–Treeå称 - n_entries = tree.GetEntries() - x_data = array('d', [0]*n_entries) # 创建一个数组æ¥å˜å‚¨x值 - y_data = array('d', [0]*n_entries) - - ex_data = array('d',[0]*n_entries) # 创建一个数组æ¥å˜å‚¨x误差 - ey_data = array('d',[0]*n_entries) # 创建一个数组æ¥å˜å‚¨y误差 # 创建一个数组æ¥å˜å‚¨y值 - for n in range(n_entries): - tree.GetEntry(n) - for i, x in enumerate(tree.x): - if 0 <= abs(x) <= 400: # ä»…æ·»åŠ 0 到 400 之间的 x 值åŠå¯¹åº”çš„ y 值 - x_data.append(abs(x)) - ex_data.append(0) - y_data.append(abs(tree.y[i]/(3.14*0.05*0.05))) - ey_data.append(0) - #print(x_data,y_data) - #graph = ROOT.TGraphErrors(len(x_data), array('d', x_data), array('d', y_data),ex_data,ey_data) # 创建TGraph对象 - graph = ROOT.TGraph(len(x_data), array('d', x_data), array('d', y_data)) # 创建TGraph对象 - graph.SetMarkerStyle(20) # è®¾ç½®æ ‡è®°å½¢çŠ¶ - graph.SetMarkerSize(0.5) - - graph.SetMarkerColor(colors[color_index]) - mg.Add(graph) # æ·»åŠ åˆ°TMultiGraphä¸ - legend.AddEntry(graph, file_name.split("_iv")[0], "p") - - - mg.GetYaxis().SetTitle('Current Density [A/cm^2]') - mg.GetXaxis().SetTitle('Reverse Bias Voltage [V]') - mg.GetYaxis().SetLabelSize(0.05) - mg.GetYaxis().SetTitleSize(0.05) - mg.GetYaxis().CenterTitle(True) - mg.GetXaxis().SetLabelSize(0.05) - mg.GetXaxis().SetTitleSize(0.05) - mg.GetXaxis().CenterTitle(True) - mg.SetMinimum(1e-11) - mg.SetMaximum(1e-2) - mg.Draw('AP') - legend.Draw() - #c.Update() - - c.SaveAs("/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/samples/output/iv_comparison.root") - c.SaveAs("/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/samples/output/iv_comparison.pdf") - #c.SaveAs("./iv_comparison.root") - #c.SaveAs("./iv_comparison.pdf") - - -def draw_cv_p9(): - # 创建一个Canvas - c = ROOT.TCanvas('c', '', 1200, 600) # 调整画布大å°ä»¥å®¹çº³ä¸¤ä¸ªå图 - #c.Divide(2, 1) # 将画布分割æˆä¸¤åˆ— - c.SetFillColor(0) - c.SetFrameFillColor(0) - ROOT.gStyle.SetPadColor(0) - ROOT.gStyle.SetCanvasColor(0) - ROOT.gStyle.SetOptStat(0) - c.SetLeftMargin(0.15) - c.SetBottomMargin(0.15) - c.SetLogy() - #c.cd(1) - # é历文件夹 - folder_path = "/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/samples" # 文件夹路径 - mg = ROOT.TMultiGraph("mg", "") - legend = ROOT.TLegend(0.6, 0.6, 0.8, 0.8) - legend.SetBorderSize(0) # 设置图例的边框大å°ä¸º0,å³æ²¡æœ‰è¾¹æ¡† - colors = [ROOT.kGreen, ROOT.kRed, ROOT.kPink, ROOT.kCyan, ROOT.kOrange] # 定义ä¸åŒçš„颜色 - for i, file_name in enumerate(os.listdir(folder_path)): - if file_name.endswith("cv.root"): # 如果文件å以"cv.root"结尾 - file_number = int(''.join(filter(str.isdigit, file_name))) - color_index = file_number - 1 - root_file = ROOT.TFile(os.path.join(folder_path, file_name)) - tree = root_file.Get("data_tree") # 获å–Treeå称 - n_entries = tree.GetEntries() - x_data = array('d', [0] * n_entries) # 创建一个数组æ¥å˜å‚¨x值 - y_data = array('d', [0] * n_entries) - ex_data = array('d', [0] * n_entries) # 创建一个数组æ¥å˜å‚¨x误差 - ey_data = array('d', [0] * n_entries) # 创建一个数组æ¥å˜å‚¨y误差 # 创建一个数组æ¥å˜å‚¨y值 - for n in range(n_entries): - tree.GetEntry(n) - for i, x in enumerate(tree.x): - if 0 <= abs(x) <= 400: # ä»…æ·»åŠ 0 到 400 之间的 x 值åŠå¯¹åº”çš„ y 值 - x_data.append(abs(x)) - ex_data.append(0) - y_data.append(abs(tree.y[i])) - ey_data.append(0) - graph = ROOT.TGraph(len(x_data), array('d', x_data), array('d', y_data)) # 创建TGraphErrors对象 - graph.SetMarkerStyle(20) - graph.SetMarkerColor(colors[color_index]) # è®¾ç½®æ ‡è®°é¢œè‰²ï¼Œä½¿ç”¨å–ä½™è¿ç®—é‡å¤ä½¿ç”¨é¢œè‰² - #graph.SetLineColor(colors[i % len(colors)]) - graph.SetMarkerSize(0.5) - mg.Add(graph) # æ·»åŠ åˆ°TMultiGraphä¸ - - legend.AddEntry(graph, file_name.split("_cv")[0], "p") - - - mg.GetYaxis().SetTitle('Capacitance [pF]') - mg.GetXaxis().SetTitle('Reverse Bias Voltage [V]') - mg.GetYaxis().SetLabelSize(0.05) - mg.GetYaxis().SetTitleSize(0.05) - mg.GetYaxis().CenterTitle(True) - mg.GetXaxis().SetLabelSize(0.05) - mg.GetXaxis().SetTitleSize(0.05) - mg.GetXaxis().CenterTitle(True) - mg.SetMinimum(1e0) - mg.SetMaximum(1e3) - mg.Draw('P') - legend.Draw("same") - - """ - c.cd(2) - fig2_files="/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/simulation_cv" - mg=ROOT.TMultiGraph("mg","") - legend=ROOT.TLegend(0.6,0.6,0.8,0.8) - legend.SetBorderSize(0) - for file_name in os.listdir(fig2_files): - if file_name.endswith("cv_other.root"): - root_file = ROOT.TFile(os.path.join(folder_path, file_name)) - tree=root_file.Get("data_tree") - n_entries=tree.GetEntries() - x_data = array('d', [0] * n_entries) # 创建一个数组æ¥å˜å‚¨x值 - y_data = array('d', [0] * n_entries) - for n in range(n_entries): - tree.GetEntry(n) - for i,x in enumerate(tree.x): - if 0<x<=400: - x_data.append(abs(x)) - y_data.append(abs(tree.y[i])) - print(x_data) - graph=ROOT.TGraph(len(x_data),array("d",x_data),array("d",y_data)) - graph.SetMarkerStyle(20) - graph.SetMarkerSize(0.5) - mg.Add(graph) # æ·»åŠ åˆ°TMultiGraphä¸ - legend.AddEntry(graph, file_name.split("_cv_other")[0], "p") - - mg.GetYaxis().SetTitle('Capacitance [pF]') - mg.GetXaxis().SetTitle('Reverse Bias Voltage [V]') - mg.GetYaxis().SetLabelSize(0.05) - mg.GetYaxis().SetTitleSize(0.05) - mg.GetYaxis().CenterTitle(True) - mg.GetXaxis().SetLabelSize(0.05) - mg.GetXaxis().SetTitleSize(0.05) - mg.GetXaxis().CenterTitle(True) - mg.SetMinimum(1e0) - mg.SetMaximum(1e3) - mg.Draw('P') - legend.Draw("same") - c.Update()""" - - c.SaveAs("/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/samples/output/cv_comparison.root") - c.SaveAs("/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/samples/output/cv_comparison.pdf") - - -def main(): - draw_cv_p9() - draw_iv_p9() - #test() - #print("fix cv") \ No newline at end of file diff --git a/draw/field_comparison.py b/draw/field_comparison.py deleted file mode 100644 index f3793e20c26073d2b1d2e46f99aeb92d2c009e27..0000000000000000000000000000000000000000 --- a/draw/field_comparison.py +++ /dev/null @@ -1,152 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -''' -@Description: compare the difference of the electric field of p-i-n and LGAD -@Date : 2023/02/14 17:00:00 -@Author : Chenxi Fu -@version : 1.0 - -Usage : -source ./run raser -raser 'python/paper4/field_comparison.py' -''' - -# TODO: Need to be rewritten or deleted! - -import sys -import os -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -import raser -import time -import ROOT -import math - -def draw_fields(my_pin_field,my_lgad_field,path): - - c1 = ROOT.TCanvas("c", "canvas",1200, 1000) - ROOT.gStyle.SetOptStat(ROOT.kFALSE) - ROOT.gStyle.SetOptFit() - c1.SetLeftMargin(0.18) - c1.SetBottomMargin(0.14) - - n = 2000 - lgad_field_histo = ROOT.TH1F("","",n,0,50) - lgad_field_histo.GetXaxis().SetTitle("z[\mu m]") - lgad_field_histo.GetYaxis().SetTitle("E[V/\mu m]") - pin_field_histo = ROOT.TH1F("","",n,0,50) - pin_field_histo.GetXaxis().SetTitle("z[\mu m]") - pin_field_histo.GetYaxis().SetTitle("E[V/\mu m]") - - for i in range(n): - z = (i+1)*50/n - le = my_lgad_field.get_e_field(650,650,z-0.01)[2] - lgad_field_histo.SetBinContent(i+1,le) - pe = my_pin_field.get_e_field(650,650,z-0.01)[2] - pin_field_histo.SetBinContent(i+1,pe) - - lgad_field_histo.SetTitle("") - lgad_field_histo.SetLineColor(6) - lgad_field_histo.SetMarkerColor(6) - lgad_field_histo.SetMarkerStyle(20) - lgad_field_histo.Draw("HIST") - lgad_field_histo.Draw("SAME P") - pin_field_histo.SetLineColor(4) - pin_field_histo.SetMarkerColor(4) - pin_field_histo.SetMarkerStyle(22) - pin_field_histo.Draw("SAME HIST") - pin_field_histo.Draw("SAME P") - - lgad_field_histo.GetXaxis().SetTitleSize(0.05) - lgad_field_histo.GetXaxis().SetLabelSize(0.05) - lgad_field_histo.GetYaxis().SetTitleSize(0.05) - lgad_field_histo.GetYaxis().SetLabelSize(0.05) - - legend = ROOT.TLegend(0.5, 0.6, 0.8, 0.8) - legend.AddEntry(pin_field_histo, "p-i-n", "pl") - legend.AddEntry(lgad_field_histo, "LGAD", "pl") - legend.SetTextSize(0.05) - legend.SetBorderSize(0) - legend.Draw("same") - - c1.SaveAs(path+"field_comparison"+".pdf") - c1.SaveAs(path+"field_comparison"+".root") - -def draw_sigma(field,path): - n = 100 - E = ROOT.TH1F("","",n,0,50) - E.GetXaxis().SetTitle("z[\mu m]") - E.GetYaxis().SetTitle("E[V/\mu m]") - - S = ROOT.TH1F("","",n,0,50) - S.GetXaxis().SetTitle("z[\mu m]") - S.GetYaxis().SetTitle("\sigma^{-2}[\mu m^{-2}]") - - e_2 = field.get_e_field(650,650,2)[2] - for i in range(n): - z = (i+1)*50/n - e = field.get_e_field(650,650,z-0.01)[2] - if z<2: - s=0 - else: - s = 1/(450 + 49 + 2.8*(1+2*math.log(e_2/e))**2) # temporal_FWHM^2 v^2 + sigma_0^2 + (k_{B}Tε/q^2N_{eff})(1+2ln(E_2/E)^2) - E.SetBinContent(i+1,e) - S.SetBinContent(i+1,s) - - c1 = ROOT.TCanvas("c", "canvas",1000, 1000) - ROOT.gStyle.SetOptStat(ROOT.kFALSE) - ROOT.gStyle.SetOptFit() - c1.SetLeftMargin(0.18) - c1.SetRightMargin(0.2) - c1.SetBottomMargin(0.14) - c1.SetRightMargin(0.12) - - E.Draw("COLZ") - E.GetXaxis().SetTitleSize(0.05) - E.GetXaxis().SetLabelSize(0.05) - E.GetYaxis().SetTitleSize(0.05) - E.GetYaxis().SetLabelSize(0.05) - E.SetLineWidth(2) - E.SetTitle("") - c1.SaveAs(path+"Field.pdf") - c1.SaveAs(path+"Field.root") - del c1 - - c2 = ROOT.TCanvas("c", "canvas",1000, 1000) - ROOT.gStyle.SetOptStat(ROOT.kFALSE) - ROOT.gStyle.SetOptFit() - c2.SetLeftMargin(0.18) - c2.SetRightMargin(0.2) - c2.SetBottomMargin(0.14) - c2.SetRightMargin(0.12) - - S.Draw("COLZ") - S.GetXaxis().SetTitleSize(0.05) - S.GetXaxis().SetLabelSize(0.05) - S.GetYaxis().SetTitleSize(0.05) - S.GetYaxis().SetLabelSize(0.05) - S.SetLineWidth(2) - S.SetTitle("") - c2.SaveAs(path+"Sigma.pdf") - c2.SaveAs(path+"Sigma.root") - del c2 - -def main(): - path = "output/lgadtct/HPK-Si-LGAD/" - if not os.access(path, os.F_OK): - os.makedirs(path, exist_ok=True) - - pin_paras = ["det_name=HPK-Si-PIN","parfile=param_file/setting.json"] - pin_set = raser.Setting(pin_paras) - my_pin = raser.R3dDetector(pin_set) - my_pin_field = raser.FenicsCal(my_pin,pin_set.fenics) - - lgad_paras = ["det_name=HPK-Si-LGAD","parfile=param_file/setting.json"] - lgad_set = raser.Setting(lgad_paras) - my_lgad = raser.R3dDetector(lgad_set) - my_lgad_field = raser.FenicsCal(my_lgad,lgad_set.fenics) - - draw_fields(my_pin_field,my_lgad_field,path) - draw_sigma(my_lgad_field,path) - -if __name__ == "__main__": - main() \ No newline at end of file diff --git a/draw/iv.py b/draw/iv.py deleted file mode 100644 index fb5783884afd319be7f41498d05bf806f15b9d68..0000000000000000000000000000000000000000 --- a/draw/iv.py +++ /dev/null @@ -1,90 +0,0 @@ -import os -import ROOT - -def draw_iv(input_dir, output_dir, label): - com_name = [] - legend_name = [] - - for file in os.listdir(input_dir): - if file.endswith('.root'): - com_name.append(file) - - c_i = ROOT.TCanvas("c_i", "c_i", 800, 800) - c_i.SetLeftMargin(0.22) - c_i.SetBottomMargin(0.16) - c_i.SetGrid() - c_i.SetFrameLineWidth(5) - multigraphs_i = ROOT.TMultiGraph() - - for i in range(len(com_name)): - name = com_name[i] - if label == 'sicar1.1.8' and not name.startswith('sicar1.1.8'): - continue - elif label == 'sicar1.1.8-1,sicar1.1.8-2_iv' and not (name.startswith('sicar1.1.8-1_')) and not (name.startswith('sicar1.1.8-2_')): - continue - - name = name.split('.root')[0] - - input_file = os.path.join(input_dir, name + '.root') - - if name.endswith('iv'): - file = ROOT.TFile(input_file, "READ") - tree = file.Get("myTree") - graph1 = ROOT.TGraph() - legend_name.append(name.split('_')[0]) - for i, event in enumerate(tree): - x = event.Value - x = abs(x) - y = event.Reading - y = abs(y) - graph1.SetPoint(i, x, y) - - graph1.SetNameTitle("") - graph1.SetMarkerColor(0+i) - graph1.SetMarkerStyle(24) - graph1.SetMarkerSize(1) - multigraphs_i.Add(graph1) - - multigraphs_i.GetXaxis().SetTitle("Reverse Bias Voltage [V]") - multigraphs_i.GetXaxis().SetLimits(0,510) - multigraphs_i.GetXaxis().CenterTitle() - multigraphs_i.GetXaxis().SetTitleOffset(1.4) - multigraphs_i.GetXaxis().SetTitleSize(0.05) - multigraphs_i.GetXaxis().SetLabelSize(0.05) - multigraphs_i.GetXaxis().SetNdivisions(505) - multigraphs_i.GetYaxis().SetLimits(1e-11,1e-5) - multigraphs_i.GetYaxis().SetTitle("Current [A]") - multigraphs_i.GetYaxis().CenterTitle() - multigraphs_i.GetYaxis().SetTitleOffset(1.8) - multigraphs_i.GetYaxis().SetTitleSize(0.05) - multigraphs_i.GetYaxis().SetLabelSize(0.05) - multigraphs_i.Draw("AP") - - max_i = len(legend_name) - 1 - legend_i = ROOT.TLegend(0.52,0.82-0.05*float(max_i),0.87,0.85) - legend_i.SetTextSize(0.04) - - for i, graph1 in enumerate(multigraphs_i): - legend_i.AddEntry(graph1, legend_name[i]) - - legend_i.Draw() - - file_name_i = label + "_iv.root" - c_i.SaveAs(os.path.join(output_dir, file_name_i)) - file_name_i = label + "_iv.pdf" - c_i.SaveAs(os.path.join(output_dir, file_name_i)) - file_name_i = label + "_iv.png" - c_i.SaveAs(os.path.join(output_dir, file_name_i)) - -def main(label): - if label=='itk_md8_compare_dataandsim': - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/itkmd8/comparison' - output_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/raser/output/fig' - else: - input_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8' - output_dir = '/afs/ihep.ac.cn/users/w/wangkeqi/raser/output/fig' - - draw_iv(input_dir, output_dir, label) - -if __name__ == "__main__": - main() diff --git a/elec/noise_histogram.py b/elec/noise_histogram.py deleted file mode 100644 index abee1d106ffc25ed3b63ae0702f1421e68c11c87..0000000000000000000000000000000000000000 --- a/elec/noise_histogram.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- - -import os -import matplotlib.pyplot as plt -import numpy as np - -csv_files = [] - -def read_csv_file(folder_path): - for csv_file in os.listdir(folder_path): - if csv_file.endswith('.csv'): - csv_files.append(os.path.join(folder_path, csv_file)) - return csv_files - -folder_path = 'C:\\Users\\86188\\Desktop\\20230808\\noise_diya_ucsc' -csv_files = read_csv_file(folder_path) - -def read_csv(csv_file): - time, voltage = [], [] - with open(csv_file, 'r') as file: - lines = file.readlines() - for line in lines[6:]: - time.append(float(line.split(',')[3]) * 1e9) - voltage.append(float(line.split(',')[4]) * 1e3) - return time, voltage - -voltage_list = [] - -for csv_file in csv_files: - time, voltage = read_csv(csv_file) - voltage_list.extend(voltage) # å°†æ¯ä¸ªcsvæ–‡ä»¶çš„ç”µåŽ‹å€¼æ·»åŠ åˆ°åˆ—è¡¨ä¸ - -# 计算直方图 -hist, bins = np.histogram(voltage_list, bins=70) - -# 计算å‡å€¼å’Œæ ‡å‡†å·® -mean = np.mean(voltage_list) -stddev = np.std(voltage_list) - -# 绘制直方图 -plt.figure(figsize=(10, 6)) -plt.hist(voltage_list, bins=50, alpha=1, density=True, label='Voltage Distribution') - -# 显示å‡å€¼å’Œæ ‡å‡†å·® -plt.text(0.7, 0.9, f'Mean: {mean:.2f} mV', transform=plt.gca().transAxes) -plt.text(0.7, 0.85, f'Standard Deviation: {stddev:.2f} mV', transform=plt.gca().transAxes) - -plt.xlabel('Voltage/mV') -plt.ylabel('Frequency') -plt.title(' noise voltage distribution') - -save_dir = 'C:\\Users\\86188\\Desktop\\20230808\\noise_diya_ucsc' -file_name = 'noise.pdf' -save_file = os.path.join(save_dir,file_name) -plt.savefig(save_file) -plt.show() -# TODO: Need to be TOTALLY rewritten \ No newline at end of file diff --git a/motor/GUI/Limits.ui b/motor/GUI/Limits.ui deleted file mode 100644 index dad80ce20d1f92e99d2727acf77d49666eb8b384..0000000000000000000000000000000000000000 --- a/motor/GUI/Limits.ui +++ /dev/null @@ -1,95 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Limits</class> - <widget class="QDialog" name="Limits"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>229</width> - <height>112</height> - </rect> - </property> - <property name="windowTitle"> - <string>Limits</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="1"> - <widget class="QLabel" name="LabelUpper"> - <property name="text"> - <string>Upper Limit</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QDoubleSpinBox" name="LowerLimit"> - <property name="decimals"> - <number>0</number> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QDoubleSpinBox" name="UpperLimit"> - <property name="decimals"> - <number>0</number> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="LabelLower"> - <property name="text"> - <string>Lower Limit</string> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QDialogButtonBox" name="ButtonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> - </property> - <property name="centerButtons"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections> - <connection> - <sender>ButtonBox</sender> - <signal>accepted()</signal> - <receiver>Limits</receiver> - <slot>accept()</slot> - <hints> - <hint type="sourcelabel"> - <x>248</x> - <y>254</y> - </hint> - <hint type="destinationlabel"> - <x>157</x> - <y>274</y> - </hint> - </hints> - </connection> - <connection> - <sender>ButtonBox</sender> - <signal>rejected()</signal> - <receiver>Limits</receiver> - <slot>reject()</slot> - <hints> - <hint type="sourcelabel"> - <x>316</x> - <y>260</y> - </hint> - <hint type="destinationlabel"> - <x>286</x> - <y>274</y> - </hint> - </hints> - </connection> - </connections> -</ui> diff --git a/motor/GUI/XWidget.ui b/motor/GUI/XWidget.ui deleted file mode 100644 index d6d3214dc69e9d41528fcc8032a8252c1b97c180..0000000000000000000000000000000000000000 --- a/motor/GUI/XWidget.ui +++ /dev/null @@ -1,218 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Form</class> - <widget class="QWidget" name="Form"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>298</width> - <height>296</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="3"> - <widget class="QLabel" name="CurPos"> - <property name="text"> - <string>Current Position:</string> - </property> - </widget> - </item> - <item row="4" column="2"> - <widget class="QGroupBox" name="RelativeMove"> - <property name="title"> - <string>Relative Move</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="1" column="0"> - <widget class="QDoubleSpinBox" name="RelativePos"> - <property name="minimumSize"> - <size> - <width>50</width> - <height>0</height> - </size> - </property> - <property name="decimals"> - <number>0</number> - </property> - <property name="minimum"> - <double>-1015.000000000000000</double> - </property> - <property name="maximum"> - <double>1015.000000000000000</double> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="mm"> - <property name="text"> - <string>um</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QPushButton" name="MoveRE"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Move</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="6" column="3"> - <widget class="QPushButton" name="Limits"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Limits</string> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QPushButton" name="Home"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Home</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QLabel" name="StatusLabel"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="4" column="3"> - <widget class="QGroupBox" name="AbsoluteMove"> - <property name="title"> - <string>Absolut Move</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="3" column="0"> - <widget class="QDoubleSpinBox" name="DesirePos"> - <property name="minimumSize"> - <size> - <width>50</width> - <height>0</height> - </size> - </property> - <property name="sizeIncrement"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="decimals"> - <number>0</number> - </property> - <property name="maximum"> - <double>1015.000000000000000</double> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="mm_2"> - <property name="text"> - <string>um</string> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QPushButton" name="MoveAB"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Move</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="3" column="3"> - <widget class="QLCDNumber" name="CurrentPos"/> - </item> - <item row="2" column="1" rowspan="7"> - <widget class="QScrollBar" name="Scroll"> - <property name="maximum"> - <number>1015</number> - </property> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="invertedAppearance"> - <bool>false</bool> - </property> - <property name="invertedControls"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="7" column="2"> - <widget class="QPushButton" name="JogPlus"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>X+ Jog</string> - </property> - </widget> - </item> - <item row="6" column="2"> - <widget class="QPushButton" name="JogMinus"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>X- Jog</string> - </property> - </widget> - </item> - <item row="7" column="3"> - <widget class="QPushButton" name="Stop"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/motor/GUI/XYZWidget.ui b/motor/GUI/XYZWidget.ui deleted file mode 100644 index d0790ede4506f0dcefdc36245fb3397fcf998aac..0000000000000000000000000000000000000000 --- a/motor/GUI/XYZWidget.ui +++ /dev/null @@ -1,1850 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MainWindow</class> - <widget class="QMainWindow" name="MainWindow"> - <property name="enabled"> - <bool>true</bool> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>655</width> - <height>450</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>655</width> - <height>450</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>655</width> - <height>450</height> - </size> - </property> - <property name="windowTitle"> - <string>MainWindow</string> - </property> - <widget class="QWidget" name="centralwidget"> - <widget class="QTabWidget" name="tabWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>631</width> - <height>411</height> - </rect> - </property> - <property name="currentIndex"> - <number>0</number> - </property> - <widget class="QWidget" name="tab"> - <attribute name="title"> - <string>Stage Control</string> - </attribute> - <widget class="QLabel" name="label_4"> - <property name="geometry"> - <rect> - <x>510</x> - <y>0</y> - <width>60</width> - <height>24</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:16pt; font-weight:600;">Reset</span></p></body></html></string> - </property> - </widget> - <widget class="QGroupBox" name="groupBox_2"> - <property name="geometry"> - <rect> - <x>480</x> - <y>30</y> - <width>131</width> - <height>331</height> - </rect> - </property> - <property name="title"> - <string/> - </property> - <widget class="QPushButton" name="ResetPosX"> - <property name="geometry"> - <rect> - <x>10</x> - <y>40</y> - <width>51</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Home X</string> - </property> - </widget> - <widget class="QPushButton" name="ResetPosY"> - <property name="geometry"> - <rect> - <x>10</x> - <y>130</y> - <width>51</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Home Y</string> - </property> - </widget> - <widget class="QPushButton" name="ResetPosZ"> - <property name="geometry"> - <rect> - <x>10</x> - <y>200</y> - <width>51</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Home Z</string> - </property> - </widget> - <widget class="QPushButton" name="SetMotor"> - <property name="geometry"> - <rect> - <x>10</x> - <y>280</y> - <width>101</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Set Motor</string> - </property> - </widget> - <widget class="QPushButton" name="zeroX"> - <property name="geometry"> - <rect> - <x>70</x> - <y>40</y> - <width>51</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Zero X</string> - </property> - </widget> - <widget class="QPushButton" name="zeroY"> - <property name="geometry"> - <rect> - <x>70</x> - <y>130</y> - <width>51</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Zero Y</string> - </property> - </widget> - <widget class="QPushButton" name="zeroZ"> - <property name="geometry"> - <rect> - <x>70</x> - <y>200</y> - <width>51</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Zero Z</string> - </property> - </widget> - </widget> - <widget class="QLabel" name="label_8"> - <property name="geometry"> - <rect> - <x>320</x> - <y>0</y> - <width>144</width> - <height>18</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">Current Position</span></p></body></html></string> - </property> - </widget> - <widget class="QGroupBox" name="groupBox_3"> - <property name="geometry"> - <rect> - <x>320</x> - <y>30</y> - <width>151</width> - <height>271</height> - </rect> - </property> - <property name="title"> - <string/> - </property> - <widget class="QLCDNumber" name="CurrentPosX"> - <property name="geometry"> - <rect> - <x>30</x> - <y>40</y> - <width>91</width> - <height>41</height> - </rect> - </property> - </widget> - <widget class="QLCDNumber" name="CurrentPosY"> - <property name="geometry"> - <rect> - <x>30</x> - <y>130</y> - <width>91</width> - <height>41</height> - </rect> - </property> - </widget> - <widget class="QLCDNumber" name="CurrentPosZ"> - <property name="geometry"> - <rect> - <x>30</x> - <y>220</y> - <width>91</width> - <height>41</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="label_9"> - <property name="geometry"> - <rect> - <x>20</x> - <y>20</y> - <width>81</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>Current Pos.X</string> - </property> - </widget> - <widget class="QLabel" name="label_10"> - <property name="geometry"> - <rect> - <x>20</x> - <y>100</y> - <width>91</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>Current Pos.Y</string> - </property> - </widget> - <widget class="QLabel" name="label_11"> - <property name="geometry"> - <rect> - <x>20</x> - <y>190</y> - <width>91</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>Current Pos.Z</string> - </property> - </widget> - </widget> - <widget class="QLabel" name="PosContr"> - <property name="geometry"> - <rect> - <x>70</x> - <y>0</y> - <width>192</width> - <height>24</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:16pt; font-weight:600;">Position Control</span></p></body></html></string> - </property> - </widget> - <widget class="QGroupBox" name="groupBox"> - <property name="geometry"> - <rect> - <x>0</x> - <y>30</y> - <width>311</width> - <height>331</height> - </rect> - </property> - <property name="title"> - <string/> - </property> - <property name="flat"> - <bool>false</bool> - </property> - <property name="checkable"> - <bool>false</bool> - </property> - <widget class="QLabel" name="label_5"> - <property name="geometry"> - <rect> - <x>210</x> - <y>50</y> - <width>72</width> - <height>18</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt;">Set pos.X</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_6"> - <property name="geometry"> - <rect> - <x>210</x> - <y>130</y> - <width>72</width> - <height>18</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt;">Set pos.Y</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_7"> - <property name="geometry"> - <rect> - <x>210</x> - <y>220</y> - <width>72</width> - <height>18</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt;">Set pos.Z</span></p></body></html></string> - </property> - </widget> - <widget class="QSpinBox" name="StepMoveX"> - <property name="geometry"> - <rect> - <x>110</x> - <y>130</y> - <width>71</width> - <height>31</height> - </rect> - </property> - <property name="buttonSymbols"> - <enum>QAbstractSpinBox::UpDownArrows</enum> - </property> - <property name="maximum"> - <number>500</number> - </property> - </widget> - <widget class="QSpinBox" name="StepMoveY"> - <property name="geometry"> - <rect> - <x>110</x> - <y>210</y> - <width>71</width> - <height>31</height> - </rect> - </property> - <property name="maximum"> - <number>500</number> - </property> - </widget> - <widget class="QSpinBox" name="StepMoveZ"> - <property name="geometry"> - <rect> - <x>110</x> - <y>300</y> - <width>71</width> - <height>31</height> - </rect> - </property> - <property name="maximum"> - <number>500</number> - </property> - </widget> - <widget class="QLabel" name="label"> - <property name="geometry"> - <rect> - <x>20</x> - <y>130</y> - <width>71</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>Step move X</string> - </property> - </widget> - <widget class="QLabel" name="label_2"> - <property name="geometry"> - <rect> - <x>20</x> - <y>210</y> - <width>71</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>Step move Y</string> - </property> - </widget> - <widget class="QLabel" name="label_3"> - <property name="geometry"> - <rect> - <x>20</x> - <y>300</y> - <width>71</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>Step move Z</string> - </property> - </widget> - <widget class="QPushButton" name="XMinus"> - <property name="geometry"> - <rect> - <x>60</x> - <y>70</y> - <width>61</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string><</string> - </property> - </widget> - <widget class="QPushButton" name="XPlus"> - <property name="geometry"> - <rect> - <x>120</x> - <y>70</y> - <width>61</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>></string> - </property> - </widget> - <widget class="QPushButton" name="YMinus"> - <property name="geometry"> - <rect> - <x>60</x> - <y>170</y> - <width>61</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string><</string> - </property> - </widget> - <widget class="QPushButton" name="YPlus"> - <property name="geometry"> - <rect> - <x>120</x> - <y>170</y> - <width>61</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>></string> - </property> - </widget> - <widget class="QPushButton" name="ZMinus"> - <property name="geometry"> - <rect> - <x>60</x> - <y>250</y> - <width>61</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string><</string> - </property> - </widget> - <widget class="QPushButton" name="ZPlus"> - <property name="geometry"> - <rect> - <x>120</x> - <y>250</y> - <width>61</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>></string> - </property> - </widget> - <widget class="QPushButton" name="MoveButton"> - <property name="geometry"> - <rect> - <x>200</x> - <y>290</y> - <width>91</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>move</string> - </property> - </widget> - <widget class="QLineEdit" name="SetPosX"> - <property name="geometry"> - <rect> - <x>200</x> - <y>80</y> - <width>91</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>0</string> - </property> - </widget> - <widget class="QLineEdit" name="SetPosY"> - <property name="geometry"> - <rect> - <x>200</x> - <y>170</y> - <width>91</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>0</string> - </property> - </widget> - <widget class="QLineEdit" name="SetPosZ"> - <property name="geometry"> - <rect> - <x>202</x> - <y>260</y> - <width>91</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>0</string> - </property> - </widget> - <widget class="QLabel" name="label_29"> - <property name="geometry"> - <rect> - <x>40</x> - <y>2</y> - <width>54</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">motor</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_30"> - <property name="geometry"> - <rect> - <x>140</x> - <y>2</y> - <width>54</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">motor</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_31"> - <property name="geometry"> - <rect> - <x>250</x> - <y>2</y> - <width>54</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">motor</span></p></body></html></string> - </property> - </widget> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>20</y> - <width>311</width> - <height>32</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <item> - <widget class="QLabel" name="label_26"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>37</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">X:</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="X_Motor_Num"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>28</height> - </size> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>3</number> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_27"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>37</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">Y:</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="Y_Motor_Num"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>28</height> - </size> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>3</number> - </property> - <property name="value"> - <number>2</number> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_28"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>37</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">Z:</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="Z_Motor_Num"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>28</height> - </size> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>3</number> - </property> - <property name="value"> - <number>3</number> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - <widget class="QPushButton" name="StopBut"> - <property name="geometry"> - <rect> - <x>350</x> - <y>320</y> - <width>91</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </widget> - <widget class="QWidget" name="tab_2"> - <attribute name="title"> - <string>Movement Parameters</string> - </attribute> - <widget class="QLabel" name="label_12"> - <property name="geometry"> - <rect> - <x>10</x> - <y>20</y> - <width>111</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Step definitions</span></p></body></html></string> - </property> - </widget> - <widget class="QGroupBox" name="groupBox_4"> - <property name="geometry"> - <rect> - <x>0</x> - <y>50</y> - <width>311</width> - <height>301</height> - </rect> - </property> - <property name="title"> - <string/> - </property> - <widget class="QSpinBox" name="x0"> - <property name="geometry"> - <rect> - <x>20</x> - <y>40</y> - <width>91</width> - <height>31</height> - </rect> - </property> - <property name="minimum"> - <number>-100000</number> - </property> - <property name="maximum"> - <number>100000</number> - </property> - </widget> - <widget class="QSpinBox" name="dx"> - <property name="geometry"> - <rect> - <x>115</x> - <y>40</y> - <width>91</width> - <height>31</height> - </rect> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>1000</number> - </property> - </widget> - <widget class="QSpinBox" name="Nx"> - <property name="geometry"> - <rect> - <x>210</x> - <y>40</y> - <width>101</width> - <height>31</height> - </rect> - </property> - <property name="maximum"> - <number>1000</number> - </property> - </widget> - <widget class="QSpinBox" name="y0"> - <property name="geometry"> - <rect> - <x>20</x> - <y>110</y> - <width>91</width> - <height>31</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="sizeIncrement"> - <size> - <width>0</width> - <height>20</height> - </size> - </property> - <property name="minimum"> - <number>-100000</number> - </property> - <property name="maximum"> - <number>100000</number> - </property> - </widget> - <widget class="QSpinBox" name="Ny"> - <property name="geometry"> - <rect> - <x>210</x> - <y>110</y> - <width>101</width> - <height>31</height> - </rect> - </property> - <property name="maximum"> - <number>1000</number> - </property> - </widget> - <widget class="QSpinBox" name="dy"> - <property name="geometry"> - <rect> - <x>115</x> - <y>110</y> - <width>91</width> - <height>31</height> - </rect> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>1000</number> - </property> - </widget> - <widget class="QSpinBox" name="z0"> - <property name="geometry"> - <rect> - <x>20</x> - <y>180</y> - <width>91</width> - <height>31</height> - </rect> - </property> - <property name="minimum"> - <number>-100000</number> - </property> - <property name="maximum"> - <number>100000</number> - </property> - </widget> - <widget class="QSpinBox" name="Nz"> - <property name="geometry"> - <rect> - <x>210</x> - <y>180</y> - <width>101</width> - <height>31</height> - </rect> - </property> - <property name="maximum"> - <number>1000</number> - </property> - </widget> - <widget class="QSpinBox" name="dz"> - <property name="geometry"> - <rect> - <x>115</x> - <y>180</y> - <width>91</width> - <height>31</height> - </rect> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>1000</number> - </property> - </widget> - <widget class="QLabel" name="label_19"> - <property name="geometry"> - <rect> - <x>20</x> - <y>150</y> - <width>86</width> - <height>29</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">z0</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_20"> - <property name="geometry"> - <rect> - <x>112</x> - <y>150</y> - <width>85</width> - <height>29</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">dz</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_21"> - <property name="geometry"> - <rect> - <x>203</x> - <y>150</y> - <width>86</width> - <height>29</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">Nz</span></p></body></html></string> - </property> - </widget> - <widget class="QPushButton" name="ScanBut"> - <property name="geometry"> - <rect> - <x>20</x> - <y>230</y> - <width>91</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Scan</string> - </property> - </widget> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>20</x> - <y>10</y> - <width>271</width> - <height>31</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="label_13"> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">x0</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_14"> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">dx</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_15"> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">Nx</span></p></body></html></string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>20</x> - <y>80</y> - <width>271</width> - <height>31</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> - <widget class="QLabel" name="label_16"> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">y0</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_17"> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">dy</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_18"> - <property name="text"> - <string><html><head/><body><p><span style=" font-size:12pt; font-weight:600;">Ny</span></p></body></html></string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>20</x> - <y>150</y> - <width>271</width> - <height>31</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_3"/> - </widget> - <widget class="QPushButton" name="ScanStop"> - <property name="geometry"> - <rect> - <x>200</x> - <y>230</y> - <width>91</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Scanning Stop</string> - </property> - </widget> - <widget class="QPushButton" name="Set_Speed"> - <property name="geometry"> - <rect> - <x>110</x> - <y>230</y> - <width>91</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Set Speed</string> - </property> - </widget> - </widget> - <widget class="QGroupBox" name="groupBox_5"> - <property name="geometry"> - <rect> - <x>470</x> - <y>50</y> - <width>151</width> - <height>301</height> - </rect> - </property> - <property name="title"> - <string/> - </property> - <widget class="QLCDNumber" name="CurrentPosX_2"> - <property name="geometry"> - <rect> - <x>30</x> - <y>40</y> - <width>91</width> - <height>41</height> - </rect> - </property> - </widget> - <widget class="QLCDNumber" name="CurrentPosY_2"> - <property name="geometry"> - <rect> - <x>30</x> - <y>130</y> - <width>91</width> - <height>41</height> - </rect> - </property> - </widget> - <widget class="QLCDNumber" name="CurrentPosZ_2"> - <property name="geometry"> - <rect> - <x>30</x> - <y>220</y> - <width>91</width> - <height>41</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="label_22"> - <property name="geometry"> - <rect> - <x>20</x> - <y>20</y> - <width>81</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>Current Pos.X</string> - </property> - </widget> - <widget class="QLabel" name="label_23"> - <property name="geometry"> - <rect> - <x>20</x> - <y>100</y> - <width>91</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>Current Pos.Y</string> - </property> - </widget> - <widget class="QLabel" name="label_24"> - <property name="geometry"> - <rect> - <x>20</x> - <y>190</y> - <width>91</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>Current Pos.Z</string> - </property> - </widget> - </widget> - <widget class="QLabel" name="label_25"> - <property name="geometry"> - <rect> - <x>470</x> - <y>20</y> - <width>144</width> - <height>18</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">Current Position</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_32"> - <property name="geometry"> - <rect> - <x>300</x> - <y>20</y> - <width>171</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Speed Paremeters</span></p></body></html></string> - </property> - </widget> - <widget class="QGroupBox" name="groupBox_6"> - <property name="geometry"> - <rect> - <x>310</x> - <y>50</y> - <width>161</width> - <height>301</height> - </rect> - </property> - <property name="title"> - <string/> - </property> - <widget class="QLabel" name="label_33"> - <property name="geometry"> - <rect> - <x>10</x> - <y>20</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Step X</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_34"> - <property name="geometry"> - <rect> - <x>90</x> - <y>20</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Speed X</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_35"> - <property name="geometry"> - <rect> - <x>90</x> - <y>90</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Speed Y</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_36"> - <property name="geometry"> - <rect> - <x>10</x> - <y>90</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Step Y</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_37"> - <property name="geometry"> - <rect> - <x>90</x> - <y>160</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Speed Z</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="label_38"> - <property name="geometry"> - <rect> - <x>10</x> - <y>160</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Step Z</span></p></body></html></string> - </property> - </widget> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>40</y> - <width>158</width> - <height>27</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <item> - <widget class="QSpinBox" name="Step_X"> - <property name="minimumSize"> - <size> - <width>75</width> - <height>25</height> - </size> - </property> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>256</number> - </property> - <property name="value"> - <number>0</number> - </property> - <property name="displayIntegerBase"> - <number>10</number> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="Speed_X"> - <property name="minimumSize"> - <size> - <width>75</width> - <height>25</height> - </size> - </property> - <property name="maximum"> - <number>100000</number> - </property> - <property name="value"> - <number>1000</number> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>110</y> - <width>158</width> - <height>27</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <item> - <widget class="QSpinBox" name="Step_Y"> - <property name="minimumSize"> - <size> - <width>75</width> - <height>25</height> - </size> - </property> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>256</number> - </property> - <property name="value"> - <number>0</number> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="Speed_Y"> - <property name="minimumSize"> - <size> - <width>75</width> - <height>25</height> - </size> - </property> - <property name="maximum"> - <number>100000</number> - </property> - <property name="value"> - <number>1000</number> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>180</y> - <width>158</width> - <height>27</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_7"> - <item> - <widget class="QSpinBox" name="Step_Z"> - <property name="minimumSize"> - <size> - <width>75</width> - <height>25</height> - </size> - </property> - <property name="minimum"> - <number>0</number> - </property> - <property name="maximum"> - <number>256</number> - </property> - <property name="value"> - <number>0</number> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="Speed_Z"> - <property name="minimumSize"> - <size> - <width>75</width> - <height>25</height> - </size> - </property> - <property name="maximum"> - <number>100000</number> - </property> - <property name="value"> - <number>1000</number> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QRadioButton" name="default_speed"> - <property name="geometry"> - <rect> - <x>20</x> - <y>220</y> - <width>111</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string>Default Speed</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - <widget class="QRadioButton" name="setting_speed"> - <property name="geometry"> - <rect> - <x>20</x> - <y>260</y> - <width>101</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string>Setting Speed</string> - </property> - </widget> - </widget> - </widget> - <widget class="QWidget" name="tab_3"> - <attribute name="title"> - <string>Data Capture</string> - </attribute> - <widget class="QCommandLinkButton" name="FolderSet"> - <property name="geometry"> - <rect> - <x>580</x> - <y>170</y> - <width>41</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string/> - </property> - </widget> - <widget class="QPushButton" name="CaptureBut"> - <property name="geometry"> - <rect> - <x>490</x> - <y>230</y> - <width>101</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Capture</string> - </property> - </widget> - <widget class="QLabel" name="label_39"> - <property name="geometry"> - <rect> - <x>320</x> - <y>180</y> - <width>51</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>Folder:</string> - </property> - </widget> - <widget class="QLineEdit" name="FolderText"> - <property name="geometry"> - <rect> - <x>370</x> - <y>180</y> - <width>201</width> - <height>31</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="label_40"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>141</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Devices and Interface:</span></p></body></html></string> - </property> - </widget> - <widget class="QComboBox" name="Interface"> - <property name="geometry"> - <rect> - <x>0</x> - <y>20</y> - <width>301</width> - <height>31</height> - </rect> - </property> - <property name="currentText"> - <string/> - </property> - </widget> - <widget class="QPushButton" name="ReadyBut"> - <property name="geometry"> - <rect> - <x>370</x> - <y>230</y> - <width>91</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Ready</string> - </property> - </widget> - <widget class="QTextEdit" name="InfoText"> - <property name="geometry"> - <rect> - <x>0</x> - <y>100</y> - <width>301</width> - <height>271</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="label_43"> - <property name="geometry"> - <rect> - <x>330</x> - <y>60</y> - <width>161</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-weight:600;">Capture Frequency(HZ):</span></p></body></html></string> - </property> - </widget> - <widget class="QSpinBox" name="Frequency"> - <property name="geometry"> - <rect> - <x>500</x> - <y>60</y> - <width>71</width> - <height>21</height> - </rect> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>1000</number> - </property> - </widget> - <widget class="QPushButton" name="CapturePause"> - <property name="geometry"> - <rect> - <x>490</x> - <y>290</y> - <width>101</width> - <height>41</height> - </rect> - </property> - <property name="text"> - <string>Pause</string> - </property> - </widget> - <widget class="QWidget" name="layoutWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>70</y> - <width>301</width> - <height>32</height> - </rect> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_8"> - <item> - <widget class="QLabel" name="label_41"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>25</height> - </size> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Channel:</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="Channel"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>25</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>4</number> - </property> - <property name="value"> - <number>1</number> - </property> - </widget> - </item> - <item> - <widget class="QLabel" name="label_42"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>25</height> - </size> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">Data Point:</span></p></body></html></string> - </property> - </widget> - </item> - <item> - <widget class="QSpinBox" name="Points"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>25</height> - </size> - </property> - <property name="minimum"> - <number>1</number> - </property> - <property name="maximum"> - <number>99999</number> - </property> - <property name="value"> - <number>1000</number> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QLabel" name="label_44"> - <property name="geometry"> - <rect> - <x>330</x> - <y>90</y> - <width>41</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">ymult:</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="ymult"> - <property name="geometry"> - <rect> - <x>380</x> - <y>90</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string/> - </property> - </widget> - <widget class="QLabel" name="label_46"> - <property name="geometry"> - <rect> - <x>460</x> - <y>90</y> - <width>51</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">yoff:</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="yoff"> - <property name="geometry"> - <rect> - <x>510</x> - <y>90</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string/> - </property> - </widget> - <widget class="QLabel" name="label_47"> - <property name="geometry"> - <rect> - <x>330</x> - <y>120</y> - <width>41</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">yzero:</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="yzero"> - <property name="geometry"> - <rect> - <x>380</x> - <y>120</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string/> - </property> - </widget> - <widget class="QLabel" name="label_45"> - <property name="geometry"> - <rect> - <x>460</x> - <y>120</y> - <width>51</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">xincr:</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="xincr"> - <property name="geometry"> - <rect> - <x>510</x> - <y>120</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string/> - </property> - </widget> - <widget class="QLabel" name="label_48"> - <property name="geometry"> - <rect> - <x>330</x> - <y>150</y> - <width>41</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p><span style=" font-weight:600;">xzero:</span></p></body></html></string> - </property> - </widget> - <widget class="QLabel" name="xzero"> - <property name="geometry"> - <rect> - <x>380</x> - <y>150</y> - <width>54</width> - <height>12</height> - </rect> - </property> - <property name="text"> - <string/> - </property> - </widget> - <widget class="QRadioButton" name="Frequency_mode"> - <property name="geometry"> - <rect> - <x>330</x> - <y>30</y> - <width>91</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>Frequency</string> - </property> - </widget> - <widget class="QRadioButton" name="step_mode"> - <property name="geometry"> - <rect> - <x>480</x> - <y>30</y> - <width>89</width> - <height>21</height> - </rect> - </property> - <property name="text"> - <string>step</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - </widget> - <widget class="QLabel" name="label_49"> - <property name="geometry"> - <rect> - <x>330</x> - <y>10</y> - <width>91</width> - <height>16</height> - </rect> - </property> - <property name="text"> - <string><html><head/><body><p align="center"><span style=" font-weight:600;">Capture Mode:</span></p></body></html></string> - </property> - </widget> - </widget> - </widget> - </widget> - <widget class="QMenuBar" name="menubar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>655</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QStatusBar" name="statusbar"/> - </widget> - <resources/> - <connections/> -</ui> diff --git a/motor/GUI/YWidget.ui b/motor/GUI/YWidget.ui deleted file mode 100644 index 44111526a92e9ab17218f4c99ab89952de41f547..0000000000000000000000000000000000000000 --- a/motor/GUI/YWidget.ui +++ /dev/null @@ -1,215 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Form</class> - <widget class="QWidget" name="Form"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>266</width> - <height>296</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="7" column="2"> - <widget class="QPushButton" name="Stop"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - <item row="10" column="1" colspan="2"> - <widget class="QScrollBar" name="Scroll"> - <property name="maximum"> - <number>299</number> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="invertedAppearance"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLabel" name="StatusLabel"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QPushButton" name="Home"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Home</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QLabel" name="CurPos"> - <property name="text"> - <string>Current Position:</string> - </property> - </widget> - </item> - <item row="3" column="2"> - <widget class="QLCDNumber" name="CurrentPos"/> - </item> - <item row="7" column="1"> - <widget class="QPushButton" name="Limits"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Limits</string> - </property> - </widget> - </item> - <item row="4" column="1"> - <widget class="QGroupBox" name="RelativeMove"> - <property name="title"> - <string>Relative Move</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="1" column="0"> - <widget class="QDoubleSpinBox" name="RelativePos"> - <property name="minimumSize"> - <size> - <width>50</width> - <height>0</height> - </size> - </property> - <property name="decimals"> - <number>0</number> - </property> - <property name="minimum"> - <double>-299.000000000000000</double> - </property> - <property name="maximum"> - <double>299.000000000000000</double> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="mm"> - <property name="text"> - <string>um</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QPushButton" name="MoveRE"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Move</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="4" column="2"> - <widget class="QGroupBox" name="AbsoluteMove"> - <property name="title"> - <string>Absolut Move</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="3" column="0"> - <widget class="QDoubleSpinBox" name="DesirePos"> - <property name="minimumSize"> - <size> - <width>50</width> - <height>0</height> - </size> - </property> - <property name="sizeIncrement"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="decimals"> - <number>0</number> - </property> - <property name="maximum"> - <double>299.000000000000000</double> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="mm_2"> - <property name="text"> - <string>um</string> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QPushButton" name="MoveAB"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Move</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="8" column="2"> - <widget class="QPushButton" name="JogMinus"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Y- Jog</string> - </property> - </widget> - </item> - <item row="8" column="1"> - <widget class="QPushButton" name="JogPlus"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Y+ Jog</string> - </property> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/motor/GUI/ZWidget.ui b/motor/GUI/ZWidget.ui deleted file mode 100644 index 6fd59da4691502f9c4246904e65e1c3cafe3cf70..0000000000000000000000000000000000000000 --- a/motor/GUI/ZWidget.ui +++ /dev/null @@ -1,218 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>Form</class> - <widget class="QWidget" name="Form"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>298</width> - <height>266</height> - </rect> - </property> - <property name="windowTitle"> - <string>Form</string> - </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="3" column="2"> - <widget class="QPushButton" name="Home"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Home</string> - </property> - </widget> - </item> - <item row="2" column="1" rowspan="5"> - <widget class="QScrollBar" name="Scroll"> - <property name="maximum"> - <number>300</number> - </property> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="invertedAppearance"> - <bool>true</bool> - </property> - <property name="invertedControls"> - <bool>true</bool> - </property> - </widget> - </item> - <item row="5" column="3"> - <widget class="QPushButton" name="Limits"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Limits</string> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QLabel" name="CurPos"> - <property name="text"> - <string>Current Position:</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QLabel" name="StatusLabel"> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item row="6" column="2"> - <widget class="QPushButton" name="JogMinus"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Z- Jog</string> - </property> - </widget> - </item> - <item row="6" column="3"> - <widget class="QPushButton" name="Stop"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - <item row="5" column="2"> - <widget class="QPushButton" name="JogPlus"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>40</height> - </size> - </property> - <property name="text"> - <string>Z+ Jog</string> - </property> - </widget> - </item> - <item row="3" column="3"> - <widget class="QLCDNumber" name="CurrentPos"/> - </item> - <item row="4" column="2"> - <widget class="QGroupBox" name="RelativeMove"> - <property name="title"> - <string>Relative Move</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="1" column="0"> - <widget class="QDoubleSpinBox" name="RelativePos"> - <property name="minimumSize"> - <size> - <width>50</width> - <height>0</height> - </size> - </property> - <property name="decimals"> - <number>0</number> - </property> - <property name="minimum"> - <double>-300.000000000000000</double> - </property> - <property name="maximum"> - <double>300.000000000000000</double> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLabel" name="mm"> - <property name="text"> - <string>um</string> - </property> - </widget> - </item> - <item row="3" column="0" colspan="2"> - <widget class="QPushButton" name="MoveRE"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Move</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - <item row="4" column="3"> - <widget class="QGroupBox" name="AbsoluteMove"> - <property name="title"> - <string>Absolut Move</string> - </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="3" column="0"> - <widget class="QDoubleSpinBox" name="DesirePos"> - <property name="minimumSize"> - <size> - <width>50</width> - <height>0</height> - </size> - </property> - <property name="sizeIncrement"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="decimals"> - <number>0</number> - </property> - <property name="maximum"> - <double>300.000000000000000</double> - </property> - </widget> - </item> - <item row="3" column="1"> - <widget class="QLabel" name="mm_2"> - <property name="text"> - <string>um</string> - </property> - </widget> - </item> - <item row="4" column="0" colspan="2"> - <widget class="QPushButton" name="MoveAB"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>30</height> - </size> - </property> - <property name="text"> - <string>Move</string> - </property> - </widget> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - <resources/> - <connections/> -</ui> diff --git a/motor/det_lab_stage.py b/motor/det_lab_stage.py deleted file mode 100644 index 46f05772be7320c2dad886d2d2fac9d79567af37..0000000000000000000000000000000000000000 --- a/motor/det_lab_stage.py +++ /dev/null @@ -1,236 +0,0 @@ -#! /usr/bin/env python - -# Reference: -# Luis Ardila leardilap@unal.edu.co 22/03/15 -import sys -from PyQt5 import QtGui, QtCore, uic, QtWidgets - -tctEnable = True -if tctEnable: - import pymotor - -testPass = False - -class Axis(QtWidgets.QWidget): - def __init__(self, parent, Title, Device, uiFile): - super(Axis, self).__init__(parent) - - self.ui = uic.loadUi(uiFile) - - #Declaring Device - if tctEnable: - self.axis = pymotor.Motor(Device) - - #Jogging Plus - self.ui.JogPlus.pressed.connect(self.JogPlus) - self.ui.JogPlus.released.connect(self.Stop) - - #Jogging Minus - self.ui.JogMinus.pressed.connect(self.JogMinus) - self.ui.JogMinus.released.connect(self.Stop) - - #Home - self.ui.Home.clicked.connect(self.Home) - - #Move - self.ui.MoveAB.clicked.connect(self.MoveAB) - self.ui.MoveRE.clicked.connect(self.MoveRE) - - ##Stop - self.ui.Stop.clicked.connect(self.Stop) - - ##Limits - self.ui.Limits.clicked.connect(self.Limits) - - #Scroll - self.ui.Scroll.valueChanged[int].connect(self.UpdateDesiredPosScroll) - - #Updating State - Position - self.timer = QtCore.QTimer() - self.timer.start(100) - self.timer.timeout.connect(self.UpdateState) - self.timer.timeout.connect(self.CurrentPosition) - - ##################### - # Initializing Widget - self.UpdateDesiredPos() - self.ui.setWindowTitle(Title) - - # Var - self.currentPos = 0 - self.Title = Title - self.lenght = self.ui.DesirePos.maximum() - - def JogPlus(self): - if tctEnable: - self.axis.moveforward() - else: - self.ui.StatusLabel.setText("JogPlus") - - def JogMinus(self): - if tctEnable: - self.axis.movebackward() - else: - self.ui.StatusLabel.setText("JogMinus") - - def Home(self): - ret = QtWidgets.QMessageBox.warning(self, "Homming", - "Please Check the setup!\n\nAre you sure you really want\nto Home the motor?", - QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Escape) - if ret == QtWidgets.QMessageBox.Yes: - if tctEnable: - self.axis.home() - else: - self.ui.StatusLabel.setText("Home") - - def Stop(self): - if tctEnable: - self.axis.stop() - else: - self.ui.StatusLabel.setText("") - - self.UpdateDesiredPos() - - def Limits(self): - self.Limits = Limits(self) - - def MoveAB(self): - pos = self.ui.DesirePos.value() - if tctEnable: - self.axis.move(pos) - self.ui.CurrentPos.display(self.currentPos) - else: - self.ui.StatusLabel.setText(str(pos)) - self.currentPos = self.ui.DesirePos.value() - self.ui.CurrentPos.display(self.currentPos) - - self.ui.Scroll.setValue(pos) - - def MoveRE(self): - movement = self.ui.RelativePos.value() - UpperLimit = self.ui.DesirePos.maximum() - LowerLimit = self.ui.DesirePos.minimum() - - if self.currentPos + movement > UpperLimit: - movement = UpperLimit - self.currentPos - elif self.currentPos + movement < LowerLimit: - movement = LowerLimit - self.currentPos - - if tctEnable: - self.axis.forward(movement) - else: - self.ui.StatusLabel.setText(str(movement)) - self.currentPos = self.currentPos + movement - self.ui.CurrentPos.display(self.currentPos) - - self.UpdateDesiredPos() - - def UpdateDesiredPosScroll(self): - pos = self.ui.Scroll.value() - self.ui.DesirePos.setValue(pos) - - def UpdateDesiredPos(self): - if tctEnable: - pos = self.axis.get_status_position() - self.ui.DesirePos.setValue(pos) - self.ui.Scroll.setValue(pos) - - def CurrentPosition(self): - if tctEnable: - self.currentPos = self.axis.get_status_position() - self.ui.CurrentPos.display(self.currentPos) - - def UpdateState(self): - if tctEnable and testPass: - state = self.axis.state() - self.ui.StatusLabel.setText(str(state)) - - def run(self): - self.ui.show() - -class Limits(QtWidgets.QDialog): - def __init__(self, parent): - QtWidgets.QDialog.__init__(self, parent) - - # Declaring GUI - self.ui = uic.loadUi('GUI/Limits.ui') - self.ui.show() - self.ui.ButtonBox.accepted.connect(lambda: self.Accepted) - self.ui.UpperLimit.valueChanged.connect(lambda: self.UpdateUpperLimit) - self.ui.LowerLimit.valueChanged.connect(lambda: self.UpdateLowerLimit) - self.ui.setWindowTitle(str(parent.Title + " Limits")) - self.ui.UpperLimit.setMaximum(parent.lenght*2) - self.ui.LowerLimit.setMaximum(parent.lenght*2) - self.ui.UpperLimit.setMinimum(-parent.lenght*2) - self.ui.LowerLimit.setMinimum(-parent.lenght*2) - self.ui.UpperLimit.setValue(parent.ui.DesirePos.maximum()) - self.ui.LowerLimit.setValue(parent.ui.DesirePos.minimum()) - - def UpdateUpperLimit(self, parent): - self.UpperLimit = self.ui.UpperLimit.value() - self.LowerLimit = self.ui.LowerLimit.value() - if self.UpperLimit - self.LowerLimit > parent.lenght: - self.ui.LowerLimit.setValue(self.UpperLimit - parent.lenght) - elif self.UpperLimit <= self.LowerLimit: - self.ui.LowerLimit.setValue(self.UpperLimit - 1) - - def UpdateLowerLimit(self, parent): - self.UpperLimit = self.ui.UpperLimit.value() - self.LowerLimit = self.ui.LowerLimit.value() - if self.LowerLimit + parent.lenght < self.UpperLimit: - self.ui.UpperLimit.setValue(self.LowerLimit + parent.lenght) - elif self.LowerLimit >= self.UpperLimit: - self.ui.UpperLimit.setValue(self.LowerLimit + 1) - - def Accepted(self, parent): - parent.ui.DesirePos.setMaximum(self.ui.UpperLimit.value()) - parent.ui.DesirePos.setMinimum(self.ui.LowerLimit.value()) - parent.ui.Scroll.setMaximum(self.ui.UpperLimit.value()) - parent.ui.Scroll.setMinimum(self.ui.LowerLimit.value()) - -class MainWidget(QtWidgets.QWidget): - def __init__(self, parent=None): - super(MainWidget, self).__init__(parent) - - self.stack = QtWidgets.QStackedWidget() - layout = QtWidgets.QVBoxLayout(self) - layout.addWidget(self.stack) - - ############################################################## - # DETECTOR - # X Detector - XD_Title = "X Detector" - XD_Device = "testxdet" - #XD_Device = "xi-com:///dev/tty.usbmodem00000D81" - XD_uiFile = "GUI/XWidget.ui" - self.XDetector = Axis(self, XD_Title, XD_Device, XD_uiFile) - - ## Y Detector - #YD_Title = "Y Detector" - #YD_Device = "testydet" - #YD_uiFile = "GUI/YWidget.ui" - #self.YDetector = Axis(self, YD_Title, YD_Device, YD_uiFile) - - ## Z Detector - #ZD_Title = "Z Detector" - #ZD_Device = "testzdet" - #ZD_uiFile = "GUI/ZWidget.ui" - #self.ZDetector = Axis(self, ZD_Title, ZD_Device, ZD_uiFile) - - ################################################################ - # MAIN WINDOW - self.stack.addWidget(self.XDetector) - #self.stack.addWidget(self.YDetector) - #self.stack.addWidget(self.ZDetector) - - self.XDetector.run() - #self.YDetector.run() - #self.ZDetector.run() - - -if __name__ == "__main__": - app = QtWidgets.QApplication(sys.argv) - - win = MainWidget() - - sys.exit(app.exec_()) diff --git a/motor/pymotor.py b/motor/pymotor.py deleted file mode 100644 index bb4fc5c4a9771341a74bc5d091bc0b01a96234b3..0000000000000000000000000000000000000000 --- a/motor/pymotor.py +++ /dev/null @@ -1,211 +0,0 @@ -import ctypes -from ctypes import * -import time -import os -import sys -import re -import platform -#from VitualDevice import * -import tempfile - -cur_dir = os.path.abspath(os.path.dirname(__file__)) -ximc_dir = os.path.join(cur_dir, "..", "ximc") -ximc_package_dir = os.path.join(ximc_dir, "crossplatform", "wrappers", "python") -sys.path.append(ximc_package_dir) # add ximc.py wrapper to python path - -print(ximc_package_dir) - -if platform.system() == "Windows": - print("windows#################") - if platform.architecture() == ('64bit', 'WindowsPE') : - libdir = os.path.join(ximc_dir, "win64") - #print(platform.architecture()) - else: - libdir = os.path.join(ximc_dir,"win32") - #print(platform.architecture()) - - - #print(libdir) -os.environ["Path"] = libdir + ";" + os.environ["Path"] # add dll - -if sys.version_info >= (3,0): - - try: - from pyximc import * - except ImportError as err: - print ("Can't import pyximc module.\ - The most probable reason is that \ - you haven't copied pyximc.py to the working directory.\ - See developers' documentation for details.") - exit() - except OSError as err: - print ("Can't load libximc library.\ - Please add all shared libraries to the appropriate places \ - (next to pyximc.py on Windows). \ - It is decribed in detailes in developers' documentation.") - exit() - -# variable 'lib' points to a loaded library -# note that ximc uses stdcall on win -print("Library loaded") -sbuf = create_string_buffer(64) -lib.ximc_version(sbuf) -print("Library version: " + sbuf.raw.decode()) - -DEBUG = False -def log(s): - if DEBUG: - print(s) - -def enum_device(): - devenum = lib.enumerate_devices(EnumerateFlags.ENUMERATE_PROBE, None) - print("Device enum handle: " + repr(devenum)) - print("Device enum handle type: " + repr(type(devenum))) - - dev_count = lib.get_device_count(devenum) - print("Device count: " + repr(dev_count)) - - controller_name = controller_name_t() - enum_name = ['','',''] - friend_name = ['', '', ''] - for dev_ind in range(0, dev_count): - enum_name[dev_ind] = lib.get_device_name(devenum, dev_ind) - result = lib.get_enumerate_device_controller_name(devenum, dev_ind, - byref(controller_name)) - if result == Result.Ok: - friend_name[dev_ind] = controller_name.ControllerName - print("Enumerated device #{} name (port name): ".format(dev_ind) \ - + repr(enum_name[dev_ind]) \ - + ". Friendly name: " \ - + repr(controller_name.ControllerName) \ - + ".") - - return enum_name, dev_count, friend_name - -class Motor(): - def __init__(self, device_name = None): - self.lib = lib - self.device_id = self.open_device(device_name) - - - def set_speed(self,step,speed): - log("\nset speed\n") - speed_settings = move_settings_t() - speed_settings.Speed = speed - speed_settings.uSpeed = step - speed_settings.Accel = 1000 - speed_settings.Decel = 2000 - speed_settings.AntiplaySpeed = 50 - speed_settings.uAntiplaySpeed = 0 - result = self.lib.set_move_settings(self.device_id,byref(speed_settings)) - print("move settings Result:" + repr(result)) - move_settings = move_settings_t() - result = self.lib.get_move_settings(self.device_id,byref(move_settings)) - if result == 0: - print("move settings:",move_settings.Speed,move_settings.uSpeed,move_settings.Accel,move_settings.Decel) - - - def home(self): - log("\nMoving home") - result = self.lib.command_homezero(self.device_id) - log("Result: " + repr(result)) - - def zero(self): - log("\nzero the position") - result = self.lib.command_zero(self.device_id) - log("Result: " + repr(result)) - - def forward(self, distance): # move forward Deltaposition - log("\nShifting") - log(distance) - dis = ctypes.c_int() - dis.value = int(distance) - move_settings = move_settings_t() - result = self.lib.get_move_settings(self.device_id,byref(move_settings)) - if result == 0: - print("move settings:",move_settings.Speed,move_settings.uSpeed,move_settings.Accel,move_settings.Decel,move_settings.AntiplaySpeed,move_settings.uAntiplaySpeed) - result = self.lib.command_movr(self.device_id, dis, 0) - log("Result: " + repr(result)) - - def backward(self, distance): # move backward Deltaposition - log("\nShifting") - shift = ctypes.c_int() - shift.value = 0 - int(distance) # in oppsite direction - result = self.lib.command_movr(self.device_id, shift, 0) - log("Result: " + repr(result)) - - def moveforward(self): - log("\nMoving forward") - result = self.lib.command_right(self.device_id) - log("Result: " + repr(result)) - - def movebackward(self): - log("\nMoving backward") - result = self.lib.command_left(self.device_id) - log("Result: " + repr(result)) - - def move(self, position): # move to the Setposition - log("\nMoving position") - pos = ctypes.c_int() - pos.value = int(position) - result = self.lib.command_move(self.device_id, pos, 0) - print("Result: " + repr(result)) - - def stop(self): - log("\nStopping") - result = self.lib.command_stop(self.device_id) - log("Result: " + repr(result)) - - def get_position(self): - print("\nRead position") - pos = get_position_t() - result = self.lib.get_position(self.device_id, byref(pos)) - print("Result: " + repr(result)) - if result == Result.Ok: - print("Position: " + repr(pos.Position)) - return pos.Position - - def set_position(self, position): - print("\nSet position") - pos = set_position_t() - pos.Position = position - result = self.lib.set_position(self.device_id, byref(pos)) - print("Result: " + repr(result)) - if result == Result.Ok: - print("Setting Position Done") - - def get_status_position(self): - log("\nGet status") - status = status_t() - result = self.lib.get_status(self.device_id, byref(status)) - log("Result: " + repr(result)) - if result == Result.Ok: - log("Status.CurPosition: " + repr(status.CurPosition)) - return status.CurPosition - - def get_status(self): - log("\nGet status") - status = status_t() - result = self.lib.get_status(self.device_id, byref(status)) - log("Result: " + repr(result)) - if result == Result.Ok: - log("Status.CurPosition: " + repr(status.CurPosition)) - - def get_name(self,devenum,dev_index): - return self.lib.get_device_name(devenum,dev_index) - - - def open_device(self, open_name): - device_id = ctypes.c_int() - print("\nOpen device " + repr(open_name)) - device_id = self.lib.open_device(open_name) - - print("\ndevice id:" + repr(device_id)) - return device_id - - def close_device(self): - result = self.lib.close_device(byref(cast(self.device_id, POINTER(c_int)))) - if result == Result.Ok: - print("Close device " + repr(self.device_id)) - - diff --git a/motor/stage.py b/motor/stage.py deleted file mode 100644 index 0b6c59b9119f14d611f45db6176f71d1f8432eaf..0000000000000000000000000000000000000000 --- a/motor/stage.py +++ /dev/null @@ -1,123 +0,0 @@ -import time -import pymotor - -tctEnable = True - -class Stage(): - def __init__(self,device): - self.Xaxis = device[0] - self.Yaxis = device[1] - self.Zaxis = device[2] - self.flag = 1 - - def SetSpeed(self,step,speed): - self.Xaxis.set_speed(step[0],speed[0]) - self.Yaxis.set_speed(step[1],speed[1]) - self.Zaxis.set_speed(step[2],speed[2]) - - - def Home(self,motor): - if tctEnable: - motor.home() - - def Zero(self,motor): - if tctEnable: - motor.zero() - - def Stop(self): - if tctEnable: - self.Xaxis.stop() - self.Yaxis.stop() - self.Zaxis.stop() - - ''' - def Limits(self): - self.Limits = Limits(self) - ''' - def MoveAB(self,pos_X,pos_Y,pos_Z): - if tctEnable: - self.Xaxis.move(pos_X) - self.Yaxis.move(pos_Y) - self.Zaxis.move(pos_Z) - #waiting for motor moving to (pos_X,pos_Y,pos_Z) - while True: - position_flag = (self.Xaxis.get_status_position() == pos_X) and (self.Yaxis.get_status_position() == pos_Y) and (self.Zaxis.get_status_position() == pos_Z) - if position_flag: - break - - def MoveRE(self,motor,movement): - UpperLimit = 100000 - LowerLimit = -100000 - currentPos = motor.get_status_position() - movePos = currentPos + movement - if currentPos + movement > UpperLimit: - movement = UpperLimit - currentPos - elif currentPos + movement < LowerLimit: - movement = LowerLimit - currentPos - - if tctEnable: - motor.forward(movement) - #wait for accomplishing move - while True: - move_flag = movePos == motor.get_status_position() - if move_flag: - break - - - - def Scan(self,pos_o,dp,Np): - self.x0 = pos_o[0] - self.y0 = pos_o[1] - self.z0 = pos_o[2] - self.dx = dp[0] - self.dy = dp[1] - self.dz = dp[2] - self.Nx = Np[0] - self.Ny = Np[1] - self.Nz = Np[2] - self.scan_signal = False - - #preprocess the situation when Nx = 0 or Ny = 0 or Nz = 0 - if self.Nx == 0: - self.dx = 0 - self.Nx = 1 - if self.Ny == 0: - self.dy = 0 - self.Ny = 1 - if self.Nz == 0: - self.dz = 0 - self.Nz = 1 - - if self.flag == 1: - self.MoveAB(self.x0,self.y0,self.z0) - - # scan step by step - self.flag1 = self.flag2 = -1 - for self.i in range(0, self.Nz): - if self.flag == 0: - break - self.MoveRE(self.Zaxis, self.dz) - if self.dz != 0: - self.scan_signal = True - self.flag1 = self.flag1 * (-1) - for self.j in range(0, self.Nx): - if self.flag == 0: - break - self.MoveRE(self.Xaxis, self.flag1 * self.dx) - if self.dx != 0: - self.scan_signal = True - print(self.Xaxis.get_status_position(),self.Yaxis.get_status_position(),self.Zaxis.get_status_position()) - - self.flag2 = self.flag2 * (-1) - for self.k in range(0, self.Ny): - if self.flag == 0: - break - self.MoveRE(self.Yaxis, self.flag2 * self.dy) - if self.dy != 0: - self.scan_signal = True - #time.sleep(1) - print(self.Xaxis.get_status_position(),self.Yaxis.get_status_position(),self.Zaxis.get_status_position()) - #print(self.ui.CurrentPosX_2.value(),self.ui.CurrentPosY_2.value(),self.ui.CurrentPosZ_2.value()) - #self.timer.timeout.connect(self.UpdateDesiredPos) - #self.timer.start(100) - #self.UpdateDesiredPos() \ No newline at end of file diff --git a/motor/tct_control.py b/motor/tct_control.py deleted file mode 100644 index a1593240bc4781dba519e6eee16e57572d926038..0000000000000000000000000000000000000000 --- a/motor/tct_control.py +++ /dev/null @@ -1,348 +0,0 @@ -#! /usr/bin/env python - -#reference: -#Luis Ardila leardilap@unal.edu.co 22/03/15 - -#Liejian Chen - -import sys,time -import numpy -from PyQt5 import QtGui, QtCore, uic, QtWidgets - -tctEnable = True -if tctEnable: - import pymotor - import thread - import raser.motor.mdo_3034_control as mdo_3034_control - import raser.motor.vitual_device as vitual_dev - -testpass = False -""" -扫æ时默认æ¯ä¸€ä¸ªæ‰«æç‚¹é‡‡é›†ä¸€æ¬¡æ•°æ® -如需在æ¯ä¸ªç‚¹é‡‡é›†å¤šæ¬¡æ•°æ®ï¼Œè¯·åœ¨è¿è¡Œç¨‹åºæ—¶åŠ ä¸ŠåŠ ä¸Šæ¯ä¸ªé‡‡é›†ç‚¹éœ€è¦é‡‡é›†æ•°æ®çš„次数 -例: -æ¯ä¸ªé‡‡é›†ç‚¹åªéœ€è¦é‡‡é›†1次数æ®ï¼špython TCTControl.py -æ¯ä¸ªé‡‡é›†ç‚¹éœ€è¦é‡‡é›†50次数æ®ï¼špython TCTControl.py 50 -""" -if len(sys.argv)==2: - count_2=int(sys.argv[1]) -else: - count_2=1 - - -class MainWidget(QtWidgets.QWidget): - SignalCapture = QtCore.pyqtSignal() - SignalScanContinue = QtCore.pyqtSignal() - def __init__(self, parent=None): - super(MainWidget, self).__init__(parent) - - - ################################################ - #initialize the device information,search usable device - self.EmumDevice() - - self.uiFile = "GUI/XYZWidget.ui" - self.ui = uic.loadUi(self.uiFile) - self.Title = "TCT Control" - ############################################################## - self.timer = QtCore.QTimer() - self.timer.start(500) - self.SetMotor() - self.SpeedMode() - self.ui.Interface.addItems(mdo_3034_control.ReadInterface()) - - - #Move - self.ui.MoveButton.clicked.connect(lambda:self.ClickMove(int(self.ui.SetPosX.text()), int(self.ui.SetPosY.text()), int(self.ui.SetPosZ.text()))) - - #Step move X - self.ui.XPlus.clicked.connect(lambda:self.MoveStep("X",1,self.ui.StepMoveX.value())) - self.ui.XMinus.clicked.connect(lambda:self.MoveStep("X",-1,self.ui.StepMoveX.value())) - - #Step move Y - self.ui.YPlus.clicked.connect(lambda:self.MoveStep("Y",1,self.ui.StepMoveY.value())) - self.ui.YMinus.clicked.connect(lambda:self.MoveStep("Y",-1,self.ui.StepMoveY.value())) - - #Step move Z - self.ui.ZPlus.clicked.connect(lambda:self.MoveStep("Z",1,self.ui.StepMoveZ.value())) - self.ui.ZMinus.clicked.connect(lambda:self.MoveStep("Z",-1,self.ui.StepMoveZ.value())) - - #Home - self.ui.ResetPosX.clicked.connect(lambda:self.Home("X")) - self.ui.ResetPosY.clicked.connect(lambda:self.Home("Y")) - self.ui.ResetPosZ.clicked.connect(lambda:self.Home("Z")) - - #Zero - self.ui.zeroX.clicked.connect(lambda:self.Zero("X")) - self.ui.zeroY.clicked.connect(lambda:self.Zero("Y")) - self.ui.zeroZ.clicked.connect(lambda:self.Zero("Z")) - - #scan - self.ui.ScanBut.clicked.connect(self.Scan) - self.SignalScanContinue.connect(self.ScanContinue) - - #Stop - self.ui.StopBut.clicked.connect(self.Stop) - self.ui.ScanStop.clicked.connect(self.ScanStop) - - #set motor - self.ui.SetMotor.clicked.connect(self.SetMotor) - - #set speed - self.ui.default_speed.toggled.connect(self.SpeedMode) - self.ui.setting_speed.toggled.connect(self.SpeedMode) - self.ui.Set_Speed.clicked.connect(lambda:self.SetSpeed(False)) - - #set folder - self.ui.FolderSet.clicked.connect(self.SetFolder) - - #capture data - self.ui.CaptureBut.clicked.connect(self.SaveData) - self.SignalCapture.connect(lambda:self.CaptureMode(True)) - - #capture pause - self.ui.CapturePause.clicked.connect(self.CapturePause) - - #Capture ready - self.ui.ReadyBut.clicked.connect(self.Ready) - - # Var - self.currentPosX = 0 - self.currentPosY = 0 - self.currentPosZ = 0 - - ##################### - # Initializing Widget - self.UpdateDesiredPos() - self.ui.setWindowTitle(self.Title) - self.timer.timeout.connect(self.UpdateDesiredPos) - - - self.ui.show() - - def ClickMove(self,px,py,pz): - self.new_thread = thread.ControlThread(self.setdevice) - self.new_thread.operation_num = 3 - self.new_thread.px = px - self.new_thread.py = py - self.new_thread.pz = pz - self.new_thread.start() - - def MoveStep(self,motor,direction,steps): - self.new_thread = thread.ControlThread(self.setdevice) - self.new_thread.operation_num = 4 - self.new_thread.mv = direction*steps - if motor == "X": - self.new_thread.motor = self.new_thread.laser_stage.Xaxis - elif motor == "Y": - self.new_thread.motor = self.new_thread.laser_stage.Yaxis - elif motor == "Z": - self.new_thread.motor = self.new_thread.laser_stage.Zaxis - else: - print("\n\n\nError!!!!!!!\n\n\n") - self.new_thread.start() - - def Home(self,motor): - self.new_thread = thread.ControlThread(self.setdevice) - self.new_thread.operation_num = 1 - if motor == "X": - self.new_thread.motor = self.new_thread.laser_stage.Xaxis - elif motor == "Y": - self.new_thread.motor = self.new_thread.laser_stage.Yaxis - elif motor == "Z": - self.new_thread.motor = self.new_thread.laser_stage.Zaxis - else: - print("\n\n\nError!!!!!!!\n\n\n") - self.new_thread.start() - - def Zero(self,motor): - self.new_thread = thread.ControlThread(self.setdevice) - self.new_thread.operation_num = 5 - if motor == "X": - self.new_thread.motor = self.new_thread.laser_stage.Xaxis - elif motor == "Y": - self.new_thread.motor = self.new_thread.laser_stage.Yaxis - elif motor == "Z": - self.new_thread.motor = self.new_thread.laser_stage.Zaxis - else: - print("\n\n\nError!!!!!!!\n\n\n") - self.new_thread.start() - - - def Scan(self): - self.scan_thread = thread.ScanThread(self.setdevice) - self.scan_thread.flag = True - self.scan_thread.pos_o = [self.ui.x0.value(),self.ui.y0.value(),self.ui.z0.value()] - self.scan_thread.dp = [self.ui.dx.value(),self.ui.dy.value(),self.ui.dz.value()] - self.scan_thread.Np = [self.ui.Nx.value(),self.ui.Ny.value(),self.ui.Nz.value()] - self.scan_thread.start() - print(111) - - def ScanContinue(self): - self.scan_thread.continue_flag = True - - def SetMotor(self): - self.setdevice = numpy.empty(3,dtype=object) - self.setdevice[0] = self.device[self.ui.X_Motor_Num.value()-1] - self.setdevice[1] = self.device[self.ui.Y_Motor_Num.value()-1] - self.setdevice[2] = self.device[self.ui.Z_Motor_Num.value()-1] - print(self.setdevice) - - def SetSpeed(self,default): - self.steps = numpy.empty(3,dtype=int) - self.speed = numpy.empty(3,dtype=int) - if default: - self.steps = [0,0,0] - self.speed = [1000,1000,1000] - else: - self.steps[0] = self.ui.Step_X.value() - self.steps[1] = self.ui.Step_Y.value() - self.steps[2] = self.ui.Step_Z.value() - self.speed[0] = self.ui.Speed_X.value() - self.speed[1] = self.ui.Speed_Y.value() - self.speed[2] = self.ui.Speed_Z.value() - self.new_thread = thread.ControlThread(self.setdevice) - self.new_thread.operation_num = 6 - self.new_thread.step = self.steps - self.new_thread.speed = self.speed - self.new_thread.start() - self.new_thread.wait() - - def SpeedMode(self): - if self.ui.setting_speed.isChecked(): - self.ui.Set_Speed.setEnabled(True) - if self.ui.default_speed.isChecked(): - self.ui.Set_Speed.setEnabled(False) - self.SetSpeed(True) - - - def Stop(self): - self.new_thread = thread.ControlThread(self.setdevice) - self.new_thread.operation_num = 2 - self.new_thread.start() - - def ScanStop(self): - self.scan_thread.flag = False - - - - def EmumDevice(self): - pymotor.enum_device() - print('\nemum complete!\n') - self.device_name ,self.dev_count, self.friend_name = pymotor.enum_device() - self.device = numpy.empty(5,dtype=object) - if self.dev_count == 0: - print("\nNo finding of device.") - print("\nUse the vitual device:\n") - self.device_name = ["testxmotor","testymotor","testzmotor"] - self.i = 0 - for self.str_device in self.device_name: - print('str_device:'+self.str_device) - self.device[self.i] = vitual_dev.VitualDevice(self.device_name[self.i]) - print('device[]' + str(self.device[self.i])) - #self.testmotor = pymotor.Motor(vitual_dev.VitualDevice(self.str_device).open_name) - #self.testmotor.move(10) - self.i = self.i + 1 - else: - for self.dev_ind in range(0,self.dev_count): - if 'Axis 1' in repr(self.friend_name[self.dev_ind]): self.device[0] =pymotor.Motor(self.device_name[self.dev_ind]) - if 'Axis 2' in repr(self.friend_name[self.dev_ind]): self.device[1] =pymotor.Motor(self.device_name[self.dev_ind]) - if 'Axis 3' in repr(self.friend_name[self.dev_ind]): self.device[2] =pymotor.Motor(self.device_name[self.dev_ind]) - print(self.device) - - - - def CurrentPosition(self): - if tctEnable: - self.currentPosX = self.setdevice[0].get_status_position() - self.currentPosY = self.setdevice[1].get_status_position() - self.currentPosZ = self.setdevice[2].get_status_position() - - def UpdateDesiredPos(self): - if tctEnable: - self.CurrentPosition() - self.ui.CurrentPosX.display(self.currentPosX) - self.ui.CurrentPosX_2.display(self.currentPosX) - self.ui.CurrentPosY.display(self.currentPosY) - self.ui.CurrentPosY_2.display(self.currentPosY) - self.ui.CurrentPosZ.display(self.currentPosZ) - self.ui.CurrentPosZ_2.display(self.currentPosZ) - #self.timer.start(500) - def SetFolder(self): - dlg = QtWidgets.QFileDialog() - dlg.setFileMode(QtWidgets.QFileDialog.Directory) - dlg.setFilter(QtCore.QDir.Files) - if dlg.exec_(): - filenames = dlg.selectedFiles() - print(repr(filenames)) - self.ui.FolderText.setText(filenames[0]) - - def SaveData(self): - if self.ui.Frequency_mode.isChecked() == True: - self.CaptureMode(False) - if self.ui.step_mode.isChecked() == True: - self.Scan() - self.scan_thread.CaptureSignal.connect(self.StepCapture) - - def StepCapture(self): - print("capture\n") - self.scan_thread.continue_flag = False #let scan thread wait - self.SignalCapture.emit() - - def CaptureMode(self,mode): - for i in range(0,count_2): - self.capture_thread = thread.DataCapture() - self.capture_thread.flag = True - self.capture_thread.stepmode_flag = mode - self.capture_thread.resource = self.ui.Interface.currentText() - self.capture_thread.folder = self.ui.FolderText.text() - self.capture_thread.device = self.setdevice - self.capture_thread.frequency = self.ui.Frequency.value() - self.capture_thread.point_num = self.ui.Points.value() - self.capture_thread.ymult = float(self.ui.ymult.text()) - self.capture_thread.yzero = float(self.ui.yzero.text()) - self.capture_thread.yoff = float(self.ui.yoff.text()) - self.capture_thread.xincr = float(self.ui.xincr.text()) - self.capture_thread.xzero = float(self.ui.xzero.text()) - self.capture_thread.scope = self.scope - self.capture_thread.info = self.oscilloscope_info - self.capture_thread.start() - self.capture_thread.scan_signal.connect(self.SignalScanContinue.emit) - print(i) - time.sleep(0.2) - #self.capture_thread.wait() - - def CapturePause(self): - self.capture_thread.flag = False - self.ScanStop() - #self.scope.close_resource() - - - - def Ready(self): - self.readythread = thread.ReadyThread() - self.readythread.resource_name = self.ui.Interface.currentText() - self.readythread.channel = self.ui.Channel.value() - self.readythread.point_number = self.ui.Points.value() - self.readythread.start() - self.readythread.sinOut.connect(self.DisplayReadyInfo) - - def DisplayReadyInfo(self,dis_message): - if dis_message == "offset": - self.ui.InfoText.append(self.readythread.message) - self.ui.ymult.setText(str(self.readythread.ymult)) - self.ui.yzero.setText(str(self.readythread.yzero)) - self.ui.yoff.setText(str(self.readythread.yoff)) - self.ui.xincr.setText(str(self.readythread.xincr)) - self.ui.xzero.setText(str(self.readythread.xzero)) - elif dis_message == "open": - self.scope = self.readythread.scope - self.oscilloscope_info = self.readythread.message - self.ui.InfoText.append(self.readythread.message) - else: - self.ui.InfoText.append(self.readythread.message) - -if __name__ == "__main__": - app = QtWidgets.QApplication(sys.argv) - win = MainWidget() - sys.exit(app.exec_()) diff --git a/motor/test_combine.py b/motor/test_combine.py deleted file mode 100644 index 03745a28c73b43327365d6aca0942fcf28377864..0000000000000000000000000000000000000000 --- a/motor/test_combine.py +++ /dev/null @@ -1,184 +0,0 @@ -#! /usr/bin/env python - -#reference: -#Luis Ardila leardilap@unal.edu.co 22/03/15 - -#Liejian Chen - -import sys,time -import numpy -from PyQt5 import QtGui, QtCore, uic, QtWidgets - -tctEnable = True -if tctEnable: - import pymotor - import raser.motor.vitual_device as vitual_dev - -testpass = False - - -class MainWidget(QtWidgets.QWidget): - def __init__(self, parent=None): - super(MainWidget, self).__init__(parent) - - ################################################ - #initialize the device information,search usable device - self.InitEmum() - - self.uiFile = "GUI/XYZWidget.ui" - self.ui = uic.loadUi(self.uiFile) - self.Title = "XYZ Motor" - ############################################################## - self.timer = QtCore.QTimer() - - #Declaring Device - self.SetMotor() - - #Move - self.ui.MoveButton.clicked.connect(lambda:self.MoveAB(int(self.ui.SetPosX.text()), int(self.ui.SetPosY.text()), int(self.ui.SetPosZ.text()))) - - #Step move X - self.ui.XPlus.clicked.connect(lambda:self.MoveRE(self.Xaxis,self.ui.StepMoveX.value())) - self.ui.XMinus.clicked.connect(lambda:self.MoveRE(self.Xaxis,-self.ui.StepMoveX.value())) - - #Step move Y - self.ui.YPlus.clicked.connect(lambda:self.MoveRE(self.Yaxis,self.ui.StepMoveY.value())) - self.ui.YMinus.clicked.connect(lambda:self.MoveRE(self.Yaxis,-self.ui.StepMoveY.value())) - - #Step move Z - self.ui.ZPlus.clicked.connect(lambda:self.MoveRE(self.Zaxis,self.ui.StepMoveZ.value())) - self.ui.ZMinus.clicked.connect(lambda:self.MoveRE(self.Zaxis,-self.ui.StepMoveZ.value())) - - #Home - self.ui.ResetPosX.clicked.connect(lambda:self.Home(self.Xaxis)) - self.ui.ResetPosY.clicked.connect(lambda:self.Home(self.Yaxis)) - self.ui.ResetPosZ.clicked.connect(lambda:self.Home(self.Zaxis)) - - #scan - self.ui.ScanBut.clicked.connect(lambda:self.Scan(self.Xaxis,self.Yaxis,self.Zaxis)) - - #set motor - self.ui.SetMotor.clicked.connect(self.SetMotor) - - # Var - self.currentPosX = 0 - self.currentPosY = 0 - self.currentPosZ = 0 - - ##################### - # Initializing Widget - self.UpdateDesiredPos() - self.ui.setWindowTitle(self.Title) - self.ui.show() - - def InitEmum(self): - pymotor.enum_device() - print('\nemum complete!\n') - self.devenum ,self.dev_count = pymotor.enum_device() - self.device = numpy.empty(5,dtype=object) - if self.dev_count == 0: - print("\nNo finding of device.") - print("\nUse the vitual device:\n") - self.device_name = ["testxmotor","testymotor","testzmotor"] - self.i = 0 - for self.str_device in self.device_name: - print('str_device:'+self.str_device) - self.device[self.i] = vitual_dev.VitualDevice(self.device_name[self.i]) - print('device[]' + str(self.device[self.i])) - self.i = self.i + 1 - else: - for self.dev_ind in range(0,self.dev_count): - self.device[self.dev_count] =pymotor.Motor(pymotor.Motor.get_name(self,self.devenum,self.dev_ind)) - - def Home(self,motor): - ret = QtWidgets.QMessageBox.warning(self, "Homming", - "Please Check the setup!\n\nAre you sure you really want\nto Home the motor?", - QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.Cancel | QtWidgets.QMessageBox.Escape) - if ret == QtWidgets.QMessageBox.Yes: - if tctEnable: - motor.home() - else: - self.ui.StatusLabel.setText("Home") - self.UpdateDesiredPos() - - def Stop(self): - if tctEnable: - self.Xaxis.stop() - else: - self.ui.StatusLabel.setText("") - - self.UpdateDesiredPos() - ''' - def Limits(self): - self.Limits = Limits(self) - ''' - def MoveAB(self,pos_X,pos_Y,pos_Z): - if tctEnable: - self.Xaxis.move(pos_X) - self.Yaxis.move(pos_Y) - self.Zaxis.move(pos_Z) - self.UpdateDesiredPos() - - def MoveRE(self,motor,movement): - UpperLimit = 100 - LowerLimit = -100 - currentPos = motor.get_status_position() - if currentPos + movement > UpperLimit: - movement = UpperLimit - currentPos - elif currentPos + movement < LowerLimit: - movement = LowerLimit - currentPos - - if tctEnable: - motor.forward(movement) - time.sleep(0.1) - self.UpdateDesiredPos() - - def Scan(self,motor1,motor2,motor3): - self.x0 = self.ui.x0.value() - self.y0 = self.ui.y0.value() - self.z0 = self.ui.z0.value() - self.dx = self.ui.dx.value() - self.dy = self.ui.dy.value() - self.dz = self.ui.dz.value() - self.Nx = self.ui.Nx.value() - self.Ny = self.ui.Ny.value() - self.Nz = self.ui.Nz.value() - - self.MoveAB(self.x0,self.y0,self.z0) - #delay 1 second for motor moving to (x0,y0.z0) - time.sleep(2) - - for self.PZ in range(self.z0, self.z0 + ((self.Nz + 1) * self.dz) , self.dz): - for self.PX in range(self.x0, self.x0 + ((self.Nx + 1) * self.dx) , self.dx): - for self.PY in range(self.y0, self.y0 + ((self.Ny + 1) * self.dy) , self.dy): - self.MoveAB(self.PX, self.PY, self.PZ) - print(self.Xaxis.get_status_position(),self.Yaxis.get_status_position(),self.Zaxis.get_status_position()) - self.timer.timeout.connect(self.UpdateDesiredPos) - self.timer.start(100) - #time.sleep(0.1) - - def SetMotor(self): - self.Xaxis = self.device[self.ui.X_Motor_Num.value()-1] - self.Yaxis = self.device[self.ui.Y_Motor_Num.value()-1] - self.Zaxis = self.device[self.ui.Z_Motor_Num.value()-1] - - def CurrentPosition(self): - if tctEnable: - self.currentPosX = self.Xaxis.get_status_position() - self.currentPosY = self.Yaxis.get_status_position() - self.currentPosZ = self.Zaxis.get_status_position() - def UpdateDesiredPos(self): - if tctEnable: - self.CurrentPosition() - self.ui.CurrentPosX.display(self.currentPosX) - self.ui.CurrentPosX_2.display(self.currentPosX) - self.ui.CurrentPosY.display(self.currentPosY) - self.ui.CurrentPosY_2.display(self.currentPosY) - self.ui.CurrentPosZ.display(self.currentPosZ) - self.ui.CurrentPosZ_2.display(self.currentPosZ) - self.timer.start(100) - -if __name__ == "__main__": - app = QtWidgets.QApplication(sys.argv) - win = MainWidget() - sys.exit(app.exec_()) diff --git a/motor/thread.py b/motor/thread.py deleted file mode 100644 index 2b7a6b6a738dc8c137ac315fcd4c5a8257243292..0000000000000000000000000000000000000000 --- a/motor/thread.py +++ /dev/null @@ -1,205 +0,0 @@ -import pymotor,stage,raser.motor.vitual_device as vitual_device -import raser.control.mdo_3034_scope_control as MD -import time -from datetime import datetime -import numpy as np -from PyQt5 import QtCore - -class ControlThread(QtCore.QThread): - def __init__(self,device): - super(ControlThread,self).__init__() - self.laser_stage = stage.Stage(device) - #control message initial - self.operation_num = 0 - self.motor = self.laser_stage.Xaxis - self.px = 0 - self.py = 0 - self.pz = 0 - self.mv = 0 - self.po = [0,0,0] - self.dp = [1,1,1] - self.Np = [0,0,0] - self.step = [8,8,8] - self.speed = [0,0,0] - - ############################# - # 1.home - # 2.stop - # 3.move set position - # 4.move step - # 5.zero - # 6.set speed - ############################ - def run(self): - if self.operation_num == 1: - self.laser_stage.Home(self.motor) - elif self.operation_num == 2: - self.laser_stage.Stop() - elif self.operation_num == 3: - self.laser_stage.MoveAB(self.px,self.py,self.pz) - elif self.operation_num == 4: - self.laser_stage.MoveRE(self.motor,self.mv) - elif self.operation_num == 5: - self.laser_stage.Zero(self.motor) - elif self.operation_num == 6: - self.laser_stage.SetSpeed(self.step,self.speed) - else: - time.sleep(1) - -class DataCapture(QtCore.QThread): - stop_signal = QtCore.pyqtSignal(str) - scan_signal = QtCore.pyqtSignal() - def __init__(self): - super(DataCapture,self).__init__() - self.resource = 'ASRL1::INSTR' - self.folder = './' - self.device = [] - self.frequency = 10 - self.point_num = 10000 - self.ymult = 0 - self.yoff = 0 - self.yzero = 0 - self.xincr = 0 - self.xzero = 0 - self.stepmode_flag = True - self.flag = True - self.scope = None - self.info = '' - - def capture(self): - filename = self.folder + '/TCT' + datetime.now().isoformat().replace(':','') + '.csv' - self.pos = [self.device[0].get_status_position(),self.device[1].get_status_position(),self.device[2].get_status_position()] - time,voltage = self.scope.readWave(self.ymult,self.yzero,self.yoff,self.xincr,self.xzero,self.point_num) - myfile = open(filename,'w+') - myfile.write('oscilloscope,' + self.info + '\n') - myfile.write(',' + 'x' + ',' + str(self.pos[0]) + '\n') - myfile.write(',' + 'y' + ',' + str(self.pos[1]) + '\n') - myfile.write(',' + 'z' + ',' + str(self.pos[2]) + '\n') - self.scope.save_wave_data(time,voltage,myfile) - print("capture done!") - myfile.close() - - if self.flag == False: - self.stop_signal.emit('stop') - #print("pause##########") - #self.timer.stop() - #self.finished() - self.scan_signal.emit() #emit scan continue signal - - def run(self): - self.timer = QtCore.QTimer() - if self.stepmode_flag: - time.sleep(0.1) - self.capture() - else: - self.timer.start(int(1000/self.frequency)) - self.info = self.scope.testIO() - self.timer.timeout.connect(self.capture) - self.stop_signal.connect(self.timer.stop) - self.exec() - - -class ReadyThread(QtCore.QThread): - sinOut = QtCore.pyqtSignal(str) - def __init__(self): - super(ReadyThread,self).__init__() - self.resource_name = '' - self.channel = 1 - self.point_number = 10000 - self.message = 'Nothing has done!' - - def run(self): - self.scope = MD.MDO3034C(self.resource_name) - msg = self.scope.testIO() - self.message = "ocsilloscope information:" + msg - self.sinOut.emit('open') - self.scope.readSet('ch' + str(self.channel),str(self.point_number)) - self.message = "read set complete!" - self.sinOut.emit('readset') - self.ymult,self.yzero,self.yoff,self.xincr,self.xzero = self.scope.readOffset() - self.message = "read offset complete!" - self.sinOut.emit('offset') - -class ScanThread(QtCore.QThread): - CaptureSignal = QtCore.pyqtSignal(str) - def __init__(self,device): - super(ScanThread,self).__init__() - self.laser_stage = stage.Stage(device) - self.pos_o = [0,0,0] - self.dp = [1,1,1] - self.Np = [0,0,0] - self.flag = False #stop flag - self.continue_flag = True - - def scan(self): - self.x0 = self.pos_o[0] - self.y0 = self.pos_o[1] - self.z0 = self.pos_o[2] - self.dx = self.dp[0] - self.dy = self.dp[1] - self.dz = self.dp[2] - self.Nx = self.Np[0] - self.Ny = self.Np[1] - self.Nz = self.Np[2] - #preprocess the situation when Nx = 0 or Ny = 0 or Nz = 0 - if self.Nx == 0: - self.dx = 0 - self.Nx = 1 - if self.Ny == 0: - self.dy = 0 - self.Ny = 1 - if self.Nz == 0: - self.dz = 0 - self.Nz = 1 - - if self.flag: - self.laser_stage.MoveAB(self.x0,self.y0,self.z0) - print("move ab\n") - - # scan step by step - self.flag1 = self.flag2 = -1 - for self.i in range(0, self.Nz): - if self.flag == False: - print("break\n") - break - if self.dy == 0: self.laser_stage.MoveAB(self.x0, self.laser_stage.Yaxis.get_status_position(), self.laser_stage.Zaxis.get_status_position()) - if self.dx == 0: self.laser_stage.MoveAB(self.laser_stage.Xaxis.get_status_position(), self.y0, self.laser_stage.Zaxis.get_status_position()) - self.laser_stage.MoveRE(self.laser_stage.Zaxis, self.dz) - if self.dz != 0: - self.CaptureSignal.emit('capture') #one step move complete,emit capture signal - time.sleep(0.1) - while True: - if self.continue_flag: - break - - self.flag1 = self.flag1 * (-1) - for self.j in range(0, self.Nx): - if self.flag == False: - print("break\n") - break - if self.dz == 0: self.laser_stage.MoveAB(self.laser_stage.Xaxis.get_status_position(), self.y0, self.laser_stage.Zaxis.get_status_position()) # x-y scan - self.laser_stage.MoveRE(self.laser_stage.Xaxis, self.dx) - if self.dx != 0: - self.CaptureSignal.emit('capture') - time.sleep(0.1) - while True: - if self.continue_flag: - break - print(self.laser_stage.Xaxis.get_status_position(),self.laser_stage.Yaxis.get_status_position(),self.laser_stage.Zaxis.get_status_position()) - - self.flag2 = self.flag2 * (-1) - for self.k in range(0, self.Ny): - if self.flag == False: - print("break\n") - break - self.laser_stage.MoveRE(self.laser_stage.Yaxis, self.dy) - if self.dy != 0: - self.CaptureSignal.emit('capture') - time.sleep(0.1) - while True: - if self.continue_flag: - break - print(self.laser_stage.Xaxis.get_status_position(),self.laser_stage.Yaxis.get_status_position(),self.laser_stage.Zaxis.get_status_position()) - - def run(self): - self.scan() diff --git a/motor/vitual_device.py b/motor/vitual_device.py deleted file mode 100644 index d72422fd97b2378c9eacc6de1639ff11f56d3bc0..0000000000000000000000000000000000000000 --- a/motor/vitual_device.py +++ /dev/null @@ -1,29 +0,0 @@ -#this file is used to make a vitual device - -import pymotor -import sys -import os -import re -import tempfile -import urllib.parse - -class VitualDevice(pymotor.Motor): - def __init__(self,device_name): - if sys.version_info < (3,0): - print("Using virtual device needs python3!") - exit(1) - - # use URI for virtual device when there is new urllib python3 API - tempdir = tempfile.gettempdir() + "/" + str(device_name)+ ".bin" - print("\ntempdir: " + tempdir) - # "\" <-> "/" - if os.altsep: - tempdir = tempdir.replace(os.sep, os.altsep) - - uri = urllib.parse.urlunparse(urllib.parse.ParseResult \ - (scheme="file",netloc=None, path=tempdir,\ - params=None, query=None, fragment=None)) - # converter address to b - self.open_name = re.sub(r'^file', 'xi-emu', uri).encode() - super(VitualDevice,self).__init__(self.open_name) - diff --git a/root/__init__.py b/root/__init__.py deleted file mode 100644 index fc45015038cf102ace020c9b54eb36863b56d110..0000000000000000000000000000000000000000 --- a/root/__init__.py +++ /dev/null @@ -1,42 +0,0 @@ -def main(kwargs): - from .convert import convert_csv_to_root - label = kwargs['label'] - - if label == 'sicar1.1.8': - input_dir = '/scratchfs/bes/wangkeqi/wangkeqi/data/SICAR1.1.8' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8/iv_cv' - elif label == 'sicar1.1.8-1': - input_dir = '/scratchfs/bes/wangkeqi/wangkeqi/data/SICAR1.1.8' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8/iv_cv' - elif label == 'sicar1.1.8-2': - input_dir = '/scratchfs/bes/wangkeqi/wangkeqi/data/SICAR1.1.8' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8/iv_cv' - elif label == 'itk_md8_data_v1': - input_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/sensorsimanddata/itkmd8/itkmd8data' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/itkmd8/itkmd8data' - elif label == 'itk_md8_sim_v1': - input_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/sensorsimanddata/itkmd8/itkmd8sim' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/itkmd8/itkmd8sim' - elif label == 'itk_atlas18_sim_v1': - input_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/sensorsimanddata/itkatlas18/sim' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/atlas18/sim' - elif label == 'itk_atlas18_data_v1': - input_dir = '/afs/ihep.ac.cn/users/l/lizhan/disk/scrathfs/sensorsimanddata/itkatlas18/data' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/lizhan/atlas18/data' - elif label == 'njupin_iv_v1': - input_dir = "/afs/ihep.ac.cn/users/s/senzhao/njupin" - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/njupin_iv' - elif label == 'njupin_cv_v1': - input_dir = "/afs/ihep.ac.cn/users/s/senzhao/njupin/cv" - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/zhaosen/njupin_cv' - elif label == 'sicar1.1.8_alpha_v1': - input_dir = '/scratchfs/bes/wangkeqi/wangkeqi/data/SICAR1.1.8/CCE_1.1.8-8-1/400v' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8/alpha/1/400V' - elif label == 'sicar1.1.8_beta': - input_dir = '/scratchfs/bes/wangkeqi/wangkeqi/data/SICAR1.1.8/time_1.1.8-8/20231116/si/beta_' - output_dir = '/publicfs/atlas/atlasnew/silicondet/itk/raser/wangkeqi/sicar1.1.8/beta' - else: - raise NameError(label) - - convert_csv_to_root(input_dir, output_dir, label) - diff --git a/root/convert.py b/root/convert.py deleted file mode 100644 index 09d92ada4b73d92f7c361b53cb70915fa7b8218c..0000000000000000000000000000000000000000 --- a/root/convert.py +++ /dev/null @@ -1,54 +0,0 @@ -import sys -import os -import ROOT -import csv - -def convert_csv_to_root(input_dir, output_dir, label): - com_name = [] - for file in os.listdir(input_dir): - if file.endswith('.csv'): - com_name.append(file) - for name in com_name: - if label == 'sicar1.1.8' and not name.startswith('sicar1.1.8'): - continue - elif label == 'sicar1.1.8-1' and not name.startswith('sicar1.1.8-1_'): - continue - elif label == 'sicar1.1.8-2' and not name.startswith('sicar1.1.8-2_'): - continue - - name = name.split('.csv')[0] - input_file = os.path.join(input_dir, name + '.csv') - output_file = os.path.join(output_dir, name + '.root') - - if name.endswith('iv'): - if label=="itk_atlas18_data_v1": - df = ROOT.RDF.MakeCsvDataFrame(input_file, True, '\t') - elif label =="njupin_iv_v1": - df = ROOT.RDF.MakeCsvDataFrame(input_file, True, ',') - else: - df = ROOT.RDF.MakeCsvDataFrame(input_file, True, ',') - if label in ["itk_md8_data_v1","itk_atlas18_data_v1"]: - df.Snapshot("myTree", output_file, {"Voltage_V", "Current_nA"}) - elif label in ['itk_atlas18_sim_v1','itk_md8_sim_v1']: - df.Snapshot("myTree", output_file, {"Voltage", "Current"}) - elif label =="njupin_iv_v1": - df.Snapshot("myTree", output_file, {"Current","Voltage"}) - - else: - df.Snapshot("myTree", output_file, {"Value","Reading"}) - - if name.endswith('cv'): - df = ROOT.RDF.MakeCsvDataFrame(input_file, True, ',') - if label=="itk_md8_sim_v1": - df.Snapshot("myTree", output_file, {"Voltage", "Capacitance"}) - elif label =="njupin_cv_v1": - df.Snapshot("myTree", output_file, {"Voltage", "Capacitance"}) - else: - df.Snapshot("myTree", output_file, {"Voltage", "Capacitance", "Capacitance^-2"}) - - if name.endswith('Wfm'): - df = ROOT.RDF.MakeCsvDataFrame(input_file, True, ',') - df.Snapshot("myTree", output_file, {"Time", "Volt"}) - - - sys.stdout.write('Saved as {}\n'.format(output_file)) diff --git a/tct/__init__.py b/tct/__init__.py index d74d4bfd1d3f85d2fd59fc6858229175625a8459..acadfc43471714874894ba86a63098b4a78985b7 100644 --- a/tct/__init__.py +++ b/tct/__init__.py @@ -1,10 +1,7 @@ def main(kwargs): label = kwargs['label'] - if label == 'extract_waveform': - from . import extract_waveform - extract_waveform.main() - elif label == 'signal': + if label == 'signal': from . import tct_signal tct_signal.main(kwargs) else: diff --git a/tct/extract_waveform.py b/tct/extract_waveform.py deleted file mode 100644 index 8806dceffc113a0cc476033e405b96f45e60c1db..0000000000000000000000000000000000000000 --- a/tct/extract_waveform.py +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env python3 -import sys -import os -import math -import ROOT -from array import array - -def save_experiment_data(Vbias, z_init, z_0, t_init, myt, out): - - n = myt.Draw("-(volt-aBlineMean):(time-{})".format(t_init), - "Vbias=={}\ - &&(z-{}-{}>-0.0001)\ - &&(z-{}-{}<0.0001)\ - &&((time-{})>0)\ - &&((time-{})<10)".format(Vbias,z_init,z_0,z_init,z_0,t_init,t_init), - "goff") - graph1 = ROOT.TGraph(n,myt.GetV2(),myt.GetV1()) - v1 = array('d') - t1 = array('d') - for i in range(n): - v1.append(graph1.GetPointY(i)) - t1.append(graph1.GetPointX(i)) - - volt = array('d',[999.]) - time = array('d',[999.]) - fout = ROOT.TFile(out+".root", "RECREATE") - t_out = ROOT.TTree("tree", "signal") - t_out.Reset() - t_out.Branch("volt", volt, "volt/D") - t_out.Branch("time", time, "time/D") - for i in range(len(t1)): - time[0]=t1[i] - volt[0]=v1[i] - t_out.Fill() - t_out.Write() - fout.Close() - del t_out - print(out+".root Saved") - -def main(): - if not os.access('output/pintct/HPK-Si-PIN/data/', os.F_OK): - os.makedirs('output/pintct/HPK-Si-PIN/data/', exist_ok=True) - if not os.access('output/lgadtct/HPK-Si-LGAD/data/', os.F_OK): - os.makedirs('output/lgadtct/HPK-Si-LGAD/data/', exist_ok=True) - - myPinFile = ROOT.TFile("/afs/ihep.ac.cn/users/f/fuchenxi/disk/1/edge_voltage_2019_10_24_15_12_57_HPK-EPI-W2-200-DS-SE5PINNM-01.txt.root") - myPinTree = myPinFile.Get("edge") - myLgadFile = ROOT.TFile("/afs/ihep.ac.cn/users/f/fuchenxi/disk/1/edge_voltage_2019_10_09_12_26_57_HPK-EPI-W2-200-DS-SE5-04.txt.root") - myLgadTree = myLgadFile.Get("edge") - # myPinTree.Show(17) # checkout the members - - z_init_pin = "11.986" - z_init_lgad = "11.954" - t_init_pin = "10.853" - t_init_lgad = "10.803" - - for j in range(-10, 60+1): - rel_z = 0.02*j - z_0 = str(1e-3*j) # in milimeter - save_experiment_data(-200, z_init_pin, z_0, t_init_pin, myPinTree,"output/pintct/HPK-Si-PIN/data/exp-TCT"+str(round(rel_z,2))+"fz_rel") - save_experiment_data(-200, z_init_lgad, z_0, t_init_lgad, myLgadTree,"output/lgadtct/HPK-Si-LGAD/data/exp-TCT"+str(round(rel_z,2))+"fz_rel") - - for V in range(-200, -40, 20): - z_0 = str(1e-3*25) - save_experiment_data(V, z_init_pin, z_0, t_init_pin, myPinTree,"output/pintct/HPK-Si-PIN/data/exp-TCT"+str(round(V,0))+"voltage") - save_experiment_data(V, z_init_lgad, z_0, t_init_lgad, myLgadTree,"output/lgadtct/HPK-Si-LGAD/data/exp-TCT"+str(round(V,0))+"voltage") - -if __name__ == "__main__": - main() - \ No newline at end of file diff --git a/tct/tct_analysis.py b/tct/tct_analysis.py deleted file mode 100644 index 6ad905637bf539f4380850b05a24cf580d2dc0e5..0000000000000000000000000000000000000000 --- a/tct/tct_analysis.py +++ /dev/null @@ -1,538 +0,0 @@ -#!/usr/bin/env python3 -# -*- encoding: utf-8 -*- -""" -author: wanghaobo -time: 2022.12.25 -Use: 1.Read the data of Raser eTCT induced current - 2.Add experimental noise on induced current - 3.Get the risertime,charge collection and velocity profile -""" - -from array import array -import contextlib -import os -import sys -import ROOT -import math -import numpy as np - -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -import raser - -def collect_data(path, model, volt_scale, time_scale, keys, key_name): - amplitude = array("d") - risetime = array("d") - charge = array("d") - velprof = array("d") - difprof = array("d") - volts = [] - times = [] - - for key in keys: - volt=array("d",[0.]) - time=array("d",[0.]) - rootfile=path+model+str(key)+key_name+".root" - volt,time=read_rootfile(rootfile, volt_scale, time_scale) - volts.append(volt) - times.append(time) - J=len(volt) - - amplitude.append(get_amplitude(volt,J)) - charge.append(get_charge(volt,J)) - velprof.append(get_velprof(volt,time,J)) - risetime.append(get_risetime(volt,time,J)) - difprof.append(get_difprof(volt,time,J)) - - return amplitude, charge, risetime, velprof, difprof, volts, times - -def read_rootfile(rootfile,volt_scale,time_scale): - J=0 - v1=array("d") - t1=array("d") - myFile = ROOT.TFile(str(rootfile)) - myt = myFile.tree - for entry in myt: - v1.append(volt_scale*entry.volt) - t1.append(time_scale*entry.time) - J=J+1 - return v1,t1 - -def add_noise(rootfile,J,v1,t1): - v2=array("d",[0.]) - t2=array("d",[0.]) - noise=np.array([0]) - fout = ROOT.TFile("noise_"+str(rootfile), "RECREATE") - t_out = ROOT.TTree("tree", "signal") - t_out.Branch("volt", v2, "volt/D") - t_out.Branch("time", t2, "time/D") - for i in range(J): - t2[0]=t1[i] - v2[0]=v1[i]+noise[i] - t_out.Fill() - t_out.Write() - fout.Close() - -def get_amplitude(volt,J): - Vmax = max(volt) - for Max in range(J): - if volt[Max] - Vmax > -1e-5*Vmax: - break - for min in range(Max,0,-1): - if volt[min-1] > volt[min]: - #Vmin = volt[min] - Vmin = 0 - break - else: - #Vmin = volt[0] - Vmin = 0 - return(Vmax-Vmin) - -def get_charge(volt,J): - sum_volt=0 - for j in range(J): - sum_volt+=volt[j] - return sum_volt*50e-12/(100*0.65e-9/2.2/(3.7e-12))*1e15 - # t_bin = 50e-12 A = 100 Ï„_RC_D = 0.65e-9/2.2 C_D = 3.7e-12 result in fC - -def get_velprof(volt,time,J): - t = 1.1 #ns - for j in range(J): - if time[j] >= t: - break - return volt[j] - -def get_difprof(volt,time,J): - max_diff = 0 - for i in range(J-1): - if volt[i+1]-volt[i] > max_diff: - max_diff = volt[i+1]-volt[i] - return max_diff/(100*0.65e-9/2.2/(3.7e-12))/50e-12/2.24e-4/16992*1e-6 - # A = 100 Ï„_RC_D = 0.65e-9/2.2 C_D = 3.7e-12 t_bin = 50e-12 k_2hν = 2.24e-4 E_p/hν = 19992 result in μm - -def get_risetime(volt,time,J): - x=array("d") - y=array("d") - Vmax=max(volt) - for Max in range(J): - if volt[Max] - Vmax > -1e-5*Vmax: - break - for min in range(Max,0,-1): - if volt[min-1] > volt[min]and volt[min]<0.1*Vmax: - Vmin = volt[min] - break - else: - Vmin = volt[0] - for k in range(J): - if (volt[k] - Vmin)<0.1*(Vmax - Vmin)<(volt[k+1] - Vmin): - break - for l in range(J): - if (volt[l-1] - Vmin)<0.9*(Vmax - Vmin)<(volt[l] - Vmin): - break - n=l-k - for j in range(k,l+1): - x.append(time[j]) - y.append(volt[j]) - - graph1 = ROOT.TGraph(n,x,y) - f=ROOT.TF1("f","[0]+[1]*x",0,10) - graph1.Fit(f,"Q") - b=f.GetParameter(1) - c=f.GetParameter(0) - e1=np.true_divide((0.2*(Vmax-Vmin)-c),b) - e2=np.true_divide((0.8*(Vmax-Vmin)-c),b) - risetime=np.true_divide((e2-e1),0.6) - return risetime - -def draw_graphs(array1,keys,key_name,name,path): - n=len(array1) - g = ROOT.TCanvas('g', '', 800, 600) - g.SetFillColor(0) - g.SetFrameFillColor(0) - ROOT.gStyle.SetPadColor(0) - ROOT.gStyle.SetCanvasColor(0) - ROOT.gStyle.SetOptStat(0) - g.SetLeftMargin(0.15) - g.SetRightMargin(0.15) - g.SetTopMargin(0.1) - g.SetBottomMargin(0.15) - - graph=ROOT.TGraph(n,keys,array1) - graph.SetMarkerStyle(3) - graph.Draw('ap') - - legend = ROOT.TLegend(0.6,0.7, 0.83, 0.89) - legend.AddEntry(graph,"RASER Simulation", "p") - legend.SetTextSize(18) - legend.SetTextFont(43) - legend.SetBorderSize(0) - legend.SetFillColor(0) - legend.Draw() - - g.SaveAs(path+name+".pdf") - - return - -def draw_double_graphs(array1,array2,keys1,keys2,key_name,name,path): - c = ROOT.TCanvas('c', '', 800, 600) - c.SetFillColor(0) - c.SetFrameFillColor(0) - ROOT.gStyle.SetPadColor(0) - ROOT.gStyle.SetCanvasColor(0) - ROOT.gStyle.SetOptStat(0) - c.SetLeftMargin(0.15) - c.SetBottomMargin(0.15) - - mg=ROOT.TMultiGraph("mg","") - n1=len(array1) - graph1 = ROOT.TGraph(n1,keys1,array1) - n2=len(array2) - graph2 = ROOT.TGraph(n2,keys2,array2) - - graph1.SetLineColor(2) - graph2.SetLineColor(1) - graph1.SetMarkerColor(2) - graph2.SetMarkerColor(1) - graph1.SetMarkerStyle(26) - graph2.SetMarkerStyle(4) - - mg.Add(graph1) - mg.Add(graph2) - mg.Draw('ap') - - if name == 'Amplitude': - Y_title = 'Amplitude [V]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,1.13) - else: - mg.GetYaxis().SetRangeUser(0,0.04) - - if name == 'Charge': - Y_title = 'Charge [fC]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,200) - else: - mg.GetYaxis().SetRangeUser(0,6) - - if name == 'VelProf': - Y_title = 'Ve+Vh [a.u.]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,0.1) - else: - mg.GetYaxis().SetRangeUser(0,0.015) - - if name == 'RiseTime': - Y_title = 'RiseTime [ns]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,1.5) - else: - mg.GetYaxis().SetRangeUser(0,1.5) - - if name == 'DifProf': - Y_title = '1/\sigma [\mu m^{-1}]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,0.1) - else: - mg.GetYaxis().SetRangeUser(0,0.003) - - mg.GetYaxis().SetTitle(Y_title) - if key_name == "z": - mg.GetXaxis().SetTitle('z [\mu m]') - elif key_name == "voltage": - mg.GetXaxis().SetTitle('Reverse bias voltage [V]') - mg.GetYaxis().SetLabelSize(0.05) - mg.GetYaxis().SetTitleSize(0.05) - mg.GetXaxis().SetLabelSize(0.05) - mg.GetXaxis().SetTitleSize(0.05) - - legend = ROOT.TLegend(0.45,0.65, 0.81, 0.86) - legend.AddEntry(graph1, "RASER simulation", "p") - legend.AddEntry(graph2, "TCT measurement", "p") - legend.SetTextSize(27) - legend.SetTextFont(43) - - legend.SetBorderSize(0) - legend.SetFillColor(0) - legend.Draw() - - c.SaveAs(path+name+"_"+key_name+"_comparison.pdf") - -def draw_triple_graphs(array1,array2,array3,keys1,keys2,keys3,key_name,name,path): - c = ROOT.TCanvas('c', '', 800, 600) - c.SetFillColor(0) - c.SetFrameFillColor(0) - ROOT.gStyle.SetPadColor(0) - ROOT.gStyle.SetCanvasColor(0) - ROOT.gStyle.SetOptStat(0) - c.SetLeftMargin(0.15) - c.SetBottomMargin(0.15) - - mg=ROOT.TMultiGraph("mg","") - n1=len(array1) - graph1 = ROOT.TGraph(n1,keys1,array1) - n2=len(array2) - graph2 = ROOT.TGraph(n2,keys2,array2) - n3=len(array3) - graph3 = ROOT.TGraph(n3,keys3,array3) - - graph1.SetLineColor(2) - graph2.SetLineColor(1) - graph3.SetLineColor(35) - graph1.SetMarkerColor(2) - graph2.SetMarkerColor(1) - graph3.SetMarkerColor(35) - graph1.SetMarkerStyle(26) - graph2.SetMarkerStyle(4) - graph3.SetMarkerStyle(32) - - graph3.SetLineWidth(4) - - # fill the background - # gain layer - x1 = array("d",[0,2,2,0,0]) - y1 = array("d",[0,0,0.1,0.1,0]) - excl1 = ROOT.TGraph(5,x1,y1) - excl1.SetLineColor(ROOT.kPink+1) - excl1.SetFillColor(ROOT.kPink+1) - # bulk - x2 = array("d",[2,50,50,2,2]) - y2 = array("d",[0,0,0.1,0.1,0]) - excl2 = ROOT.TGraph(5,x2,y2) - excl2.SetLineColor(ROOT.kCyan-10) - excl2.SetFillColor(ROOT.kCyan-10) - - mg.Add(excl1,"f") - mg.Add(excl2,"f") - - mg.Add(graph1,"p") - mg.Add(graph2,"p") - mg.Add(graph3,"l") - mg.Draw("a*") - - ROOT.gPad.RedrawAxis() - ROOT.gPad.RedrawAxis("G") - - if name == 'Amplitude': - Y_title = 'Amplitude [V]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,1.13) - else: - mg.GetYaxis().SetRangeUser(0,0.04) - - if name == 'Charge': - Y_title = 'Charge [fC]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,200) - else: - mg.GetYaxis().SetRangeUser(0,6) - - if name == 'VelProf': - Y_title = 'Ve+Vh [a.u.]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,0.1) - else: - mg.GetYaxis().SetRangeUser(0,0.015) - - if name == 'RiseTime': - Y_title = 'RiseTime [ns]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,1.5) - else: - mg.GetYaxis().SetRangeUser(0,1.5) - - if name == 'DifProf': - Y_title = '1/\sigma [\mu m^{-1}]' - if 'LGAD' in path: - mg.GetYaxis().SetRangeUser(0,0.1) - else: - mg.GetYaxis().SetRangeUser(0,0.003) - - Box=ROOT.TBox(8,0.03,42,0.05) - Box.SetLineColor(ROOT.kRed) - Box.SetFillStyle(0) - Box.SetLineStyle(2) - Box.Draw() - - l=ROOT.TLatex() - l.SetTextSize(20) - l.SetTextFont(43) - l.DrawLatex(11,0.022,"Full Gaussian shape region") - - mg.GetYaxis().SetTitle(Y_title) - if key_name == "z": - mg.GetXaxis().SetTitle('z [\mu m]') - elif key_name == "voltage": - mg.GetXaxis().SetTitle('Reverse bias voltage [V]') - mg.GetYaxis().SetLabelSize(0.05) - mg.GetYaxis().SetTitleSize(0.05) - mg.GetXaxis().SetLabelSize(0.05) - mg.GetXaxis().SetTitleSize(0.05) - - legend = ROOT.TLegend(0.4,0.65, 0.76, 0.85) - legend.AddEntry(graph1, "RASER simulation", "p") - legend.AddEntry(graph2, "TCT measurement", "p") - legend.AddEntry(graph3, "Expected value", "l") - legend.SetTextSize(27) - legend.SetTextFont(43) - - legend.SetBorderSize(0) - legend.SetFillColor(0) - legend.Draw() - - c.SaveAs(path+name+"_"+key_name+"_theory_comparison.pdf") - -def draw_double_signals(time_1,time_2,signal_1,signal_2,key,key_name,path): - c = ROOT.TCanvas('c', '', 800, 600) - c.SetFillColor(0) - c.SetFrameFillColor(0) - ROOT.gStyle.SetPadColor(0) - ROOT.gStyle.SetCanvasColor(0) - ROOT.gStyle.SetOptStat(0) - c.SetLeftMargin(0.15) - c.SetBottomMargin(0.15) - - mg=ROOT.TMultiGraph("mg","") - n1=len(time_1) - graph1 = ROOT.TGraph(n1,time_1,signal_1) - n2=len(time_2) - graph2 = ROOT.TGraph(n2,time_2,signal_2) - - graph1.SetLineColor(2) - graph2.SetLineColor(1) - graph1.SetMarkerColor(2) - graph2.SetMarkerColor(1) - graph1.SetMarkerStyle(26) - graph2.SetMarkerStyle(4) - - mg.Add(graph1) - mg.Add(graph2) - mg.Draw('apl') - - mg.GetYaxis().SetTitle('Signal [V]') - mg.GetXaxis().SetTitle('Time [ns]') - mg.GetYaxis().SetLabelSize(0.05) - mg.GetYaxis().SetTitleSize(0.05) - mg.GetXaxis().SetLabelSize(0.05) - mg.GetXaxis().SetTitleSize(0.05) - - mg.GetXaxis().SetLimits(0,10) - - legend = ROOT.TLegend(0.45,0.65, 0.81, 0.86) - legend.AddEntry(graph1, "RASER simulation", "pl") - legend.AddEntry(graph2, "TCT measurement", "pl") - legend.SetTextSize(27) - legend.SetTextFont(43) - - legend.SetBorderSize(0) - legend.SetFillColor(0) - legend.Draw() - - c.SaveAs(path+str(key)+key_name+"_comparison.pdf") - -def analysis_depth(path,output_path,pulse_energy_scale): - Z = array("d") - rel_z = array("d") - for L in range(-8,59): - Z.append(L) - rel_z.append(round(0.02*L,2)) - - if "experiment" in sys.argv: - amplitude, charge, risetime, velprof, difprof, volts, times = collect_data(path, "sim-TCT", pulse_energy_scale, 1e9, rel_z, 'fz_rel') - amplitude_exp, charge_exp, risetime_exp, velprof_exp, difprof_exp, volts_exp, times_exp = collect_data(path, "exp-TCT", 1, 1, rel_z, 'fz_rel') - draw_double_graphs(amplitude,amplitude_exp,Z,Z,"z","Amplitude",output_path) - draw_double_graphs(charge,charge_exp,Z,Z,"z","Charge",output_path) - draw_double_graphs(risetime,risetime_exp,Z,Z,"z","RiseTime",output_path) - draw_double_graphs(velprof,velprof_exp,Z,Z,"z","VelProf",output_path) - draw_double_graphs(difprof,difprof_exp,Z,Z,"z","DifProf",output_path) - - velprof_theory, difprof_theory = dif_cal() - Z_vel = array("d") - Z_dif = array("d") - for L in range(0,51): - Z_vel.append(L) - for L in range(2,51): - Z_dif.append(L) - draw_triple_graphs(velprof,velprof_exp,velprof_theory,Z,Z,Z_vel,"z","VelProf",output_path) - draw_triple_graphs(difprof,difprof_exp,difprof_theory,Z,Z,Z_dif,"z","DifProf",output_path) - - for volt,time,volt_exp,time_exp,z in zip(volts, times, volts_exp, times_exp, list(Z)): - draw_double_signals(time,time_exp,volt,volt_exp,z,"z",output_path) - - else: - amplitude, charge, risetime, velprof, difprof, volts, times= collect_data(path, "sim-TCT", pulse_energy_scale, 1e9, rel_z, 'fz_rel') - draw_graphs(amplitude,Z,"z","Amplitude",output_path) - draw_graphs(charge,Z,"z","Charge",output_path) - draw_graphs(risetime,Z,"z","RiseTime",output_path) - draw_graphs(velprof,Z,"z","VelProf",output_path) - draw_graphs(difprof,Z,"z","DifProf",output_path) - -def analysis_voltage(path,output_path,pulse_energy_scale): - V = array("d") - VN = array("i") - for L in range(60,220,20): - V.append(L) - VN.append(-L) - - if "experiment" in sys.argv: - amplitude, charge, risetime, velprof, difprof, volts, times = collect_data(path, "sim-TCT", pulse_energy_scale, 1e9, V, 'voltage') - amplitude_exp, charge_exp, risetime_exp, velprof_exp, difprof_exp, volts_exp, times_exp = collect_data(path, "exp-TCT", 1, 1, VN, 'voltage') - draw_double_graphs(charge,charge_exp,V,V,"voltage","Charge",output_path) - - for volt,time,volt_exp,time_exp,v in zip(volts, times, volts_exp, times_exp, list(V)): - draw_double_signals(time,time_exp,volt,volt_exp,v,"voltage",output_path) - - else: - amplitude, charge, risetime, velprof, difprof, volts, times= collect_data(path, "sim-TCT", pulse_energy_scale, 1e9, V, 'voltage') - draw_graphs(charge,V,"voltage","Charge",output_path) - -def dif_cal(): - lgad_paras = ["det_name=HPK-Si-LGAD","parfile=param_file/setting.json"] - lgad_set = raser.Setting(lgad_paras) - my_lgad = raser.R3dDetector(lgad_set) - my_lgad_field = raser.FenicsCal(my_lgad,lgad_set.fenics) - - field = array("d") # in [0,50] - dif = array("d") # in [2,50] - E_2 = my_lgad_field.get_e_field(650,650,2)[2] - for i in range(0,51): - E = my_lgad_field.get_e_field(650,650,i)[2] - field.append(0.002*E) - if i not in range(2,51): - continue - fE = (E_2/E)**2 - C = (350e-12*1e5*1e6/2)**2/2/np.log(2) # Ï„^2v^2 - z1C0 = (6.8/2)**2 # w_0^2/4 - z1C2 = 1.064**2/4/np.pi**2/(6.8/2)**2/11.9**2 - z2 = 2.8 - alpha = 9.87e-4 - def f(x): - return np.exp(-alpha*x)*alpha/(C + (z1C2 * x**2 + z1C0) * fE + z2/2 * (fE-1))**0.5 - - n = 1301 - x_list = np.linspace(0, 1300, n) # in cm - f_list = np.zeros(n) - for j in range(n): - f_list[j] = f(x_list[j]) - - int_f = 0 - for j in range(n-1): - int_f += (f_list[j] + f_list[j+1]) * (x_list[j+1] - x_list[j]) /2 - - dif.append(int_f) - - return field,dif - -def main(): - path=sys.argv[1] - output_path=sys.argv[2] - if not os.access(output_path, os.F_OK): - os.makedirs(output_path, exist_ok=True) - if 'LGAD' in path: - pulse_energy_scale = 1.58 - else: - pulse_energy_scale = 1 - # the pulse energy difference in experiment - analysis_depth(path,output_path,pulse_energy_scale) - analysis_voltage(path,output_path,pulse_energy_scale) - -if __name__ == "__main__": - main()