Skip to content

1. ReadROOT's GUI

Chloé Legué edited this page Aug 25, 2023 · 10 revisions

The GUI

To use the GUI coded in the ReadROOT package, the first step is to import ReadROOT like any other package:

>>> import ReadROOT as r
>>> r.guiv2()

The last line r.guiv2() will create a GUIv2 instance, a class defined in read_root_guiv2.py. Once the GUI is created, it will be shown immediately to the user.

image The GUI here is in light mode, but the GUI is capable of changing to dark mode if your computer uses it. If the auto-detection doesn't work, or you want to force it into a specific theme, adding dark_theme=True will force the GUI's theme to be dark.

Another thing that the GUI can do is scale according to your computer's scale factor. Getting the computer's screen scale factor will only work on Windows, but it is possible to specify the ratio with ratio=2 for example. This ratio can only be an integer.

Other parameters that can be passed to the GUI and how to pass them

  • full_screen (bool): Forces the GUI to show in full screen
  • show (bool): Shows the GUI (by default on True)
  • compress (bool): This will turn on (if True) the bz2 compression of the .csv files made by the GUI. By default this setting is on.
>>> r.guiv2(full_screen = True, show = True, ratio=2)

Using the GUI to get CoMPASS run information

The GUI comes with a CoMPASS tab. This tab contains a version of the CoMPASS original GUI. Information such as the run time, board information, or settings used during the run can be found in the CoMPASS tab. For the CoMPASS settings, a channel can be selected to show what settings are being used.

image Changing the channel will update the settings if they are different. Otherwise, the settings will not change and will show the settings set on the board.

Selecting a folder

Pressing the folder button on the top left of the GUI will open a file explorer, allowing you to navigate to the saved CoMPASS acquisition. image

Once the folder is loaded correctly, the GUI will update and show the information from the selected run. Loading a folder will also update the graph title.

This is not a one time use function. You can always change the folder.

Using the GUI to plot the CoMPASS graphs

Aside from the CoMPASS tab, there is also a graph tab inside the GUI. Here, a lot of different settings can be changed to modify the plot you want to make. image On the left side, next to the plot window, are placed all the CoMPASS graph buttons. Hovering on them will show you what histogram it will create. Pressing on any of the graph buttons will make the GUI look for the .root files saved inside the folder selected: image Here, the GUI is looking inside the RAW folder which contains the raw root files and disabled channels 2 and 3. This is a security measure to avoid errors when plotting. The disabled buttons correspond to root files that are completely empty. On the first load, this disabling feature might take a while to update. Afterward, if the type of root file isn't changed, it will use the information previously saved.

To confirm your histogram selection, the Plot button can be clicked (the Plot button is above the Clear button). Once a histogram is added to the graph section, the histogram selection will update to the histograms added on the graph section.

Changing plot settings

On the right side of the plot window, all the settings used for the plots are shown:

  • Title: Changes the title of the graph. This setting is automatically updated to the run's folder name.
  • Legend: Shows the legend.
  • Line settings
    • Name: Changes the line of the name. This will most of the time be automatically set when plotting, though it can be changed.
    • Pen Color: Changes the outline color of the histogram. This setting will open a color picker.
    • Brush Color: Changes the fill color of the histogram. This setting will open a color picker.
  • Grid settings
    • X Axis: Toggles the grid for the x-axis.
    • Y-Axis: Toggles the grid for the y-axis.
  • Axis settings
    • X Label: Changes the text of the x-axis label.
    • Y Label: Changes the text of the y-axis label.
    • X Log Scale: Toggle the log scale for the x-axis.
    • Y Log Scale: Toggle the log scale for the y-axis.
    • Min X: Minimum value shown for the x-axis.
    • Max X: Maximum value shown for the x-axis.
    • Min Y: Minimum value shown for the y-axis.
    • Max Y: Maximum value shown for the y-axis
  • Histogram settings:
    • X Axis bins: Number of bins used for 1D histograms.
    • Y Axis bins: Number of bins used for the 2D histograms' y-axis.
    • Fill Level: Y value level after which we fill the histograms with the Brush Color.
    • Minimum bin: For ranged histograms (Time and TOF), minimum value for the bins.
    • Maximum bin: For ranged histograms (Time and TOF), maximum value for the bins.

Saving changes made to a selected histogram and deleting lines

If the plot settings are modified, they can be saved. For example, if you need to see the histogram with fewer bins, or you want to change the fill color of your histogram to make it look better, the Save button allows you to save those changes. All settings will work on 1D histograms. For 2D histograms, only the number of bins will update the histogram.

If you no longer need a histogram, it can be deleted without clearing everything in the graph section and restarting. The selection box left to the Save button allows you to select a line and then delete it if needed.

Changing the selected line will also change the opacity of all the other lines. This makes it so that more than one histogram can be seen on your graph without it being a nightmare.

Saving a screenshot of the graph section

The camera icon button on the left side of the graph tab allows you to save a screenshot in the SCREENSHOTS folder of the selected acquisition folder. It will only save what's inside the graph section and the screenshot will be named after the graph title and the time of day.

Using the GUI to run the TOF analysis

Note that for large .root files the GUI might not respond and crash your computer. If this does happen, it is better to directly use the Merger and Converter to get your data in a .csv file format. The procedure to do so is explained in section 6.

Some buttons will trigger the TOF Settings collapsible section to open. The TOF histogram, Energy vs Energy histogram, and TOF vs Energy buttons will force the collapsible to open. image In this collapsible section, two sets of sliders and buttons will work for the start and stop channels. Since the TOF requires at least two working files, using it with less than two files will not work.

One way to plot those histograms is to use the root type FILTERED (which contains the TOF data if the TOF was run on CoMPASS beforehand) and select two viable files. This will simply plot the histogram selected. The only downside of this method is that it requires you to run the TOF on CoMPASS. The time window cannot be changed using this method, meaning this set of data is only good for one window.

Choosing a time window

image

If changing the time window is important for your analysis, it can be changed using the Window time QQuantity object placed in the GUI above the start and stop channel buttons and under the sliders, as seen in the picture above. The time scale can be changed to whatever value needed. This QQuantity object might not show you all the units you want. Since this object is from the superqt library, you can directly modify the superqt files to have the missing units. This file to modify should be in the site-packages of your Python version in the folder superqt/spinbox/_quantity.py. You will want to add to the "[time]" in DEFAULT_OPTIONS the units "us", "ns" and "ps".

Selection of region of interest (energy cuts)

image

If an energy cut needs to be performed, the ROI button symbolized by the swiping finger next to the Calculate TOF button will allow two regions of interest to be added to the graph section. The regions can only be updated with the ranged sliders placed above the buttons. You can see in the picture above the button pressed to show the ROIs.

The range of the slider will be updated every time a new histogram is added, meaning that the energy histogram should first be plotted before plotting a TOF histogram with cuts.

Running the TOF

image

Before running the TOF, you need to select the start channel and stop channel. If some files do not contain data, they will be disabled and cannot be used for the TOF. Toggling the Calculate TOF button will force the analysis to run. After the analysis is done, all the data used to make the histograms will be saved in a .csv file compressed with bz2 for a smaller file size. This csv file will be saved in the acquisition folder selected beforehand in a new folder called TOF Data. The csv file will be named according to the channels, window and cuts used: foldername_tree_start chn_stop chn_window_cuts.csv where tree is the type of root file and cuts is a tuple containing the start and stop cuts.

Note that the bz2 compression of the .csv files can be disabled when running the GUI. Passing compress=False will save the files as normal with no compression.

Reloading the TOF data from a csv file

image

Since the data is saved in a csv file, it is easy to load it back up. The selection box under the Calculate TOF button allows you to reload the data from the selected file. The check mark next to the selection box is to confirm the choice and to force the GUI to reload your selected csv file. You also do not have to rerun the TOF if you want to plot another histogram, the csv file contains all the data needed for all three histograms needing the TOF.