Package: hgcroc-toa-simulator
To have a reference with witch to compare the measured Data with, as well as being able to generate data
for software system tests and help people in understanding the behaviour of the Time to Digital converters
(TDC) of the HGCROCv3, this simulation provides data generation and visualisation techniques.Installation from pypiThe easiest and recommended way to install the package is by simply installing it from PyPi. to do this
you can run:pip install hgcroc-toa-simulatorThis will automatically install the latest public version of the software.Installation from sourceThe code in this repository constitutes a python package so with the current version of this repository
it can be installed usingpip install .optionally it can be installed ineditable modewithpip install --editable .Editable mode allows changes made in the repository code to affect the installed package immediately.UsageThe software is built to be a command line tool. After eitherpypi_installationorsource_installation, thetoa-simulatorcommand will
be available on the command line.All commands and subcommands provide ahelpfunction that lists all available options and shows how
the command is to be called. The tool is quite sensitive to the exact order in whitch options, arguments
and subcommands are written, please stick to the format outlined in thehelpsection of the tool.Thetoa-simulatorhas a total of 5 subcommands.
* Thegenerate-datasubcommand generates uniformily distributed events from 0 to 25000ps and converts them to ToA codes using the ToA software simulation.
* Theconvert-datasubcommand reads in arrival times from an input file and converts them to ToA codes which are written tostdoutor a file
* Thehistogramgenerates uniformily distributed random arrival times and creates a histogram of the resulting ToA codes. Code distributions for different
slow control configurations of the ToA can be drawn into the same plot.Theplot-timingshows a view of the internal state of the TDC and describes how the TDC-code was generated.Persistent configurationIf the command line utility is run multiple times in a row, it generates a new TDC with slightly different
characteristics (in the same way the fabrication process would generate a slightly different behaviour for
each instance of the TDC. To acheive reliable results the exact internal state can be written to a config
file for use in later invocations.ExampleshistogramThe easiest thing to get going is to run thehistogramcommand as follows:toa-simulator histogram 40000 -shThis will generate 40000 ToA codes, histogram them and then show the result on the screen. Using the-csoption we can se the results for different settings
of theCTRL_IN_SIG_CTDC_P_Dconfiguration parameter. This would then look like:toa-simulator histogram 40000 -sh -cs 0 -cs 10 -cs 20 -cs 30Which will draw 4 histograms in the same plot, one for each value ofCTRL_IN_SIG_CTDC_P_Dand show them together in the same histogram.convert-dataTo convert data generated externally to the toa-simulator theconvert-datasubcommand can be used. The convert data function reads in data from a file
that looks similar to:Here we have some meta information
Arrival Time [ps]
402.3
102.2
803.2
444
579
913
8799Each line has to have a single number on is that represents the arrival time that is to be converted. It can have arbitrarily many header lines.
The number of header-lines need to be passed to theconvert-datacommand in the-soption (see thetoa-simulatorconvert-datahelp).
It will produce a new-line separated sequence of ToA codes onstdout, or optionally write the output to a file. The position of the output Code
corresponds to the position of the arrival time-stamp in the input.To process the above file with the pathexample_input.txtthe following command can be used to output the resulting ToA codes into the console:toa-simulator convert-data example-input.txt