Histogram Plotting Array Data in Txt file with ROOT


I have variety Array data in my txt file. Each event has special array data in txt file. I want to create root file and want to plot histogram. How can I get array data in txt file ?

Txt file format:
Event Data
0 [x,y,z,c]
1 [a,x,y,s]

300 [e,s,y,z]

My txt file is same this.
While I am define txt file (fstream file;) , I write x for first column and jet_pt for second column. But second column type is array and thats why ı can not take it. How can I get array data?

Please help
Thank you

Hi @rabiatuylek ,

and welcome to the ROOT forum! This is not really a ROOT-related question: the complicated part is to read the text file and retrieve the values you want to fill the histogram with, but that can/should be solved with standard C++ or Python code – you can search google or stackoverflow for related how-tos. I guess you want to open the file, read it line by line, and for each line you want to extract the information you want.

When that’s done, filling a ROOT histogram is simple :slight_smile: See for example Histograms - ROOT or the histogram tutorials at ROOT: Histograms tutorials .

I hope this helps!


Thank you for your feedback. I will examine this file that you send. Moreover, I solve my problem yesterday.

Again thanks…

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