Problem in reading data from a text file


I am generating a root file after reading data from a text file. The data in the text file (“gs_out.txt”) in each row is organized in the order as given below:


The root file (“gs_data.root”) that I am generating has branches of the same names as above. However the problem is that the following branches are showing same data although the data file contains different values for those variables!

  • dE_a2 and dE_p

  • E_a2 and E_p

  • Th_a2 and Th_p

I am attaching the data file, the root file and the macro (“gs_data.C”) that I am using to generate the root file. Any help will be much appreciated.

Thank you in advance.

gs_data.C (1.3 KB)
gs_data.root (20.0 KB)
gs_out.txt (32.4 KB)

dE_a2 and dE_p refer to the same adress &dE_a2


very likely copy/paste mistake :slight_smile:


if you have a recent-enough ROOT version (v6.12 should work already) you could also try with:

auto df = ROOT::Experimental::TDF::MakeCsvDataFrame("gs_out.txt"); // create a DataFrame that reads a CSV file
df.Snapshot("treename", "gs_data.root"); // write contents of DataFrame to root file


1 Like

Thank you so much for pointing out the silly mistake! My bad! :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.