Loss of TOF precision after converting ROOT to TXT

Dear CASToR developers and users

I am post-processing the root list-mode data generated from the GATE simulation and reconstructing it using the CASToR. First I convert the ROOT to TXT, after the post-processing, I convert the TXT back to ROOT for the reconstruction. Most of the things went well, and the image can be successfully reconstructed by CASToR.

However, recently I am trying to add TOF in the recon, but soon realize that the txt file converted from ROOT has a lower TOF data precision. I have output the .dat file from GATE directly for a comparison: For example, In the txt file converted from ROOT, I got TOF = 4.83994e-06 for eventID 30. In .dat, I got TOF = 4.83994034373751110439431e-06 for the same event.

The loss of precision basically ruined the image since every event got the same time difference. Although I can bypass the loss of precision during the root to txt by using the .dat files, I am worrying that the same thing will happen again when I convert txt back to ROOT.

Apologize that I am very new to c programming and ROOT. I attached the converting code I am currently using. May someone point out where is the problem, please. Thank you very much for your attention, appreciate it!


txttoroot.C (5.58 KB)

TreeTotxt.cxx (7.35 KB)

DTOF_debug.root (3.1 MB)

Hi Zipai,

I didn’t look into details, but it appears to be a float/double issue, or a precision problem when you write your txt file.

Maybe you could set the precision of the value in the output txt file in your c++ script with std::setprecision(x).

Hope this helps,