Initially the data are collected in the HADES format (.hld files). Then in order to convert them to the root trees and perform the channel-to-time calibration the modified version of Mainz unpacker (mz-umpacker) is used. The initial version is available here, while the modified one here. Some information about channel-to-time calibration and mz-unpacker running available in the TRB3 manual.
The first modification was made in order to make the program comparable with root6. It includes the following changes:
The second modification was performed in order to achieve correct reading of the events with one EpochCounter for more than one channel. These events occour when the TRB3 operates at the approximately same frequency as a reading signal (one event per gate). Here are two screenshots of the output of "hldprint" command for *.hld files with one EpochCounter for two channels 24 and 26 and with separate EpochCounter for each channel.
One more difference between the initial and our version of the mz-unpacker is in the file " TDC_Addresses_test.txt". We put there "0x910" that corresponds to the FPGA1 on our TRB3.
How to use mz-unpacker? (Most of the information here are come from the README file of the original version of mz-unpacker).
Firstly we need to go to the mz-unpacker folder and open there "root". Then we need to execute two following commands: ".x BuildTrbUnpacker.cpp" and ".x <nop>BuildTrbCalibration.cpp". These two commands create shared libraries which we need to load before each conversion and calibration process. We simply put them to the rootlogon.C file.
*.hld to *.root convertsion.
To perform that you need to create a variable <var> with type <nop>TTrbUnpacker. Command: "TTrbUnpacker <var>(<file>.hld, 0x8000, 0x8000, " ","TDC_Addresses_test.txt",0,kFALSE);", where "<file>.hld" converting file, the first 0x8000 stands for subevent id (see hldprint outputs above), the second 0x8000 is the CTS (Central Trigger System) address (see TRB3 manual for details), the blank space " " serve for file with Hub addresses which is not needed when only one TRB3 is in use, "TDC_Addresses_test.txt" is the file in the mz-unpacker folder which contains the addresses of used FPGA, Boolean zero "0" serves to suppress verbose mode, and "kFALSE" means do not skip subevents.
When the variable <var> is created, simply run "<var>.Decode(0);" (zero in parentheses means all the events) command and you are done. As a result you will have a file with the same name but with .root extension (<file>.hld.root).
Here we need to define variable <var> type of <nop>TTrbCalibration. Command: "TTrbCalibration <var>(<file>.hld.root, 0, 0, kFALSE);", where <file>.hld.root is the root file obtained on the previous step, the first zero "0" stands for simple calibration using only the total width of the fine time distribution (option "1" for sophisticated calibration is also available), the second "0" means all the statistics, and kFALSE for suppressing screen output (verbose mode).
After that, the calibration itself can be done using "<var>.DoTdcCalibration();" command. As a result you will have two root files. The first one named as an input file plus "_calibrated.root" contains the calibrated data (subject for further analysis), while the second one named as an input file plus "_CalibrationData.root" contains the calibration histograms.