Package: dpx-control
Dosepix Control Software for python3Module name: dpx_controlAuthor: Sebastian SchmidtE-Mail:schm.seb@gmail.comInstallationThere are multiple ways to install the module. The easiest one is to use a virtual environment. More experiened users might consider to install the module directly. Please refer to the instructions below and ensure that python 3 is used.Virtual Environment InstallationFirst,  a directory for the virtual environment has to be created. To provide an example, it is calleddpx_venvin the following.  Afterwards, the environment is created viapython3-mvenvdpx_venvActivate the virtual environment by executingsourcedpx_virtenv/bin/activateIf everything worked correctly, the name of your virtual environment should appear in parentheses in front of your command prompt. Finally, proceed like described in the "Direct Installation"-section below.Direct Installationsudomight be needed in order to provide installation privileges. This won't be necessary when installing in an virtual environment.via pipIf no administrator access is possible, add the parameter--userright behindinstall.python3-mpipinstall/path/to/packageIf you want to modify the code later on, usepython3-mpipinstall-e/path/to/packageinstead.viasetup.pyExecute in the module's main directory:python3setup.pyinstallIf you want to modify the code later on, usepython3setup.pydevelopinstead.ExamplesDosepix initializationFirst, import the module.importdpx_controlThe connection to the Dosepix test board is established via:dpx=dpx_control.Dosepix(portName,baudRate=2e6,configFN=None,thl_calib_files=None,params_file=None,bin_edges_file=None)This creates an objectdpxof the classDosepix.Important parameters are:ParameterFunctionportNameName of the used com-port of the PC. For Linux, it usually is/dev/ttyUSB0. For Windows, the port name has the form of 'COMX'.baudRateUsed baud rate of the connection between DPX test board and PC. This is set to 2e6 in the board's current firmware and shouldn't be modified here.configFnConfiguration file containing important parameters of the used Dosepix detectors.thl_calib_filesThe DAC value and corresponding voltage of the threshold (THL) show a dependency of a sloped sawtooth. By measuring this dependency, a corrected threshold value can be used. Only important for certain tasks like threshold equalization or threshold scan measurements.params_fileFile containing the calibration curve parameters (a, b, c, t) for each detector and pixel. Only needed for dose measurements as it is used to specify the bin edges in DosiMode.bin_edges_fileFile containing the bin edges used in DosiMode. Ifparams_fileis set, the file should contain the bin edges in energy. Else, it should contain the bin edges in ToT.eye_lensSet toTrueif hardware for eye lens dosimetry is used, as it only utilizes a single slot. Standard value isFalseA measurement can be started by using thedpxobject. For example a ToT-measurement:dpx.measureToT(slot=[1,2,3],intPlot=True,cnt=10000,storeEmpty=True,logTemp=True)See documentation for more info.EqualizationSee theequalization-script.First, important parameters are defined:PORT='/dev/ttyUSB0'CONFIG_FN='DPXConfig.conf'CONFIG_DIR='config/'CHIP_NUMS=[22,6,109]CALIB_THL=FalseCONFIG_FNspecifies the file in which the configuration of the current setup is stored. This file will be created in the directory specified inCONFIG_DIR.  If the configuration directory does not exist, the program will create the folder by itself.CHIP_NUMSare the identification numbers of the used detectors, usually written on the backside of the COB.This equalization procedure includes THL measurementes which are optional. They are performed if the flagCALIB_THLis set toTrue. Afterwards, a THL-calibration file is created for each detector. This improves the equalization procedure but is not a necessity. At the current revision of the DPX test board, the measurement of the relation between THL DAC and THL voltage is only possible at Slot 1. Therefore, only one detector can be measured at a time.IMPORTANT:the board has to be disconnected from power when switching detectors!Afterwards, the commanddpx.thresholdEqualizationConfig(CONFIG_DIR+'/'+CONFIG_FN,I_pixeldac=None,reps=1,intPlot=False,resPlot=True)performs the threshold equalization and stores the results in the specified configuration file. IfintPlotis set toTrue, equalization results are shown for each detector once the equalization is done.