Skip to content

6. Large ROOT files

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

Running the TOF manually

If you need to get the TOF data from large .root files, it is very likely that the GUI will crash. In order to avoid such problems, it is possible to run the TOF manually.

Note that even if you run the code manually, it is possible for the code to still crash. In this case, the most probable error would be that numpy is unable to allocate enough memory for the arrays containing your data. It will be preferable in this case to take multiple runs in order to avoid such a problem.

>>> import pint
>>> from ReadROOT import read_root as r
>>> from ReadROOT import merge as m
>>> file0 = "Full path to the start channel root file"
>>> file1 = "Full path to the stop channel root file"
>>> csv_file = r.generate_csv_name(file0, 0, 1, pint.Quantity(1,"us")) #Note that 0 and 1 are the channel numbers and can be changed. 
>>> #The pint.Quantity is also something that can be changed.
>>>
>>> merger = m.Merger(file_ch0=file0, file_ch1=file1, window=int(1e6), tree="Data_R") #The window has to be an integer.
>>> data = merger.merge()
>>>
>>> convert = m.Converter(data)
>>> convert.save(csv_file)

Reading the data from the .csv file and plotting into 2D histogram

>>> import ReadROOT as r
>>> from ReadROOT import read_root as re
>>> data = re.get_cpp_evse_hist("CSV file path", 16384, 16384) #16384 is the number of bins.
>>> graph = r.plotter((10,10)) #(10,10) is the window size.
>>> graph.plot(data[3][0], data[3][1], 16384)
>>> graph.show()

Clone this wiki locally