To convert file.txt data and read by root

the .txt file contains 763693 line, and two column (the 1st depth varies between -148.5 and 148.5 , and the 2nd dose values).
I want to plot by root the dose versus on depth. my questions how I can convert the dose values, we must devise each dose value by the maximum value and multiply to 100.


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi @Assalmi

Do you want to read the file with ROOT or you are just interested in how to do the plot?

Here you can find an example of how to read a CSV file with ROOT (you would need to specify a different delimiter than comma):

You would need to define a new column that is based in the dose_value column and applies the division by the maximum value and multiplies by 100.

If you are in Python, you can also use python libraries to read the CSV if you prefer, and do the plot with PyROOT.

1 Like

thank you for your answer, if I understood your answer, I would read this file.txt and the converted by python has a file in ((/ max) * 100). or do you mean to convert the dose values from the source code (geant4) that I used to simulate the dose

You can start from your .txt file and you read it with RDataFrame. You define a new column whose formula is / max * 100 (provided that you found the max beforehand).

If this seems complicated, you can also read the txt file yourself (for example, from Python, which has good libraries for CSV reading) and use ROOT to do the plot.

1 Like

ok thank you very much, i will try with python.

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