Skip to content

4. ReadROOT's Merger

Chloé Legué edited this page Jul 13, 2023 · 4 revisions

The Merger

In order to use the Merger, we need to import it from ReadROOT.

>>> from ReadROOT import merge

The merge subpackage of ReadROOT contains two important classes that are used to find the TOF events, the Merger and the Converter.

Merger Class

The Merger can be accessed from the merge subpackage. It is usually used with the GUI in a QThread. When creating a Merger instance, two files need to be passed as well as a time window and a TTree key.

Using energy cuts on the data

If cuts are enabled, the user can select the minimum and maximum energies used for the cuts for each file. The following commands can be executed:

>>> new_merge = merge.Merger(file0, file1, window, "Data_R")
>>> new_merge.select_cuts(min, max, 0)

The last option of the function select_cuts allows to choose which file is affected by the cut.

Note that file0 here represents the stop file and file1 the start file. If you are in an IDE where you can see documentation, you should be able to see Merger(stop_file : Path, start_file : Path, window : U64, tree : str). This also means that 0 for the file selected in select_cuts will be the stop file and 1 the start file.

Calculating the TOF data

Using the merge function, the data will be parsed quickly and return a list of ConsolidatedData. This ConsolidatedData is a simple data class made for the Merger class. When the parsing is done, the resulting list will be emitted through a pyqtSignal and will also be returned. This can then be used by the Converter class.

Converter Class

The Converter can be accessed just like the Merger class from the merge subpackage. The only use of this class is to convert a list of ConsolidatedData returned by the Merger.merge function into a .csv format, compressed or not. This means that this class should always be used after the Merger is no longer used.

Save a list of ConsolidatedData to a csv file

When creating a Converter instance, a list of ConsolidatedData is passed. Using the Converter.save function, one can save to a specified file path the data. By default all the .csv files saved with the Converter class will be compressed with bz2. This can be turned off using Converter.compress = False. This will then save the .csv files as normal, without any compression.

Clone this wiki locally