Home | News | Documentation | Download

TGraph is Zombie error message


#1

Hi, I’m a beginner at using ROOT and I’m trying to plot a graph using data from a txt file, but for a reason my txt file can’t be opened. This is the error message I get in the root terminal:
root [1] g = new TGraph(“data.txt”)
Error in TGraph::TGraph: Cannot open file: data.txt, TGraph is Zombie
(TGraph *) 0x7faff5900500

data.txt is in the same directory where all my macros are which have worked so far, so the location should be no problem. When I write a macro and include the above line and try to execute it, I get the same message “Cannot open file … TGraph is Zombie” and when I do g->Draw(), I get an empty canvas (which is no surprise if data.txt can’t be opened) and I also get an error message “illegal number of points(0)” (which also makes sense) So I think the problem is with not being able to open data.txt

Any suggestions?

Thanks


#2

Either give the full path of the file, or put the file in the current directory.


#3

It is in the current directory


#4

You mean both the macro and the data files are in the same (current) directory?


#5

Yes, they are. (Also, I’m not sure how to give the full path in the root terminal)
EDIT I deleted data.txt from that directory, and I got the very same error message when data.txt was still there.


#6

Well, simply like this:

g = new TGraph("/path/where/your/file/is/data.txt")

#7

Thanks a lot, finally I didn’t get the error message using the full path, but now only 1 data point is plotted, (and there are 14 data points.) The range of the x and y axis is too small for the other data points to be seen, and I can’t seem to find a reference for how to change that with TGraph. Have you ever had that issue?


#8

Nope. What is the format of your data (i.e. could you paste a few lines here)?


#9

I attached my data file I’m using. (It’s just made up data for practice)

data.txt (71 Bytes)


#10

Your data has Mac line endings (CR only). Try with this one:data_copy.txt (71 Bytes)
which has correct (Linux/LF) line endings


#11
sed -i -e '{s/\r/\n/g}' data.txt

Root wont read graph data completely
#12

omg, it works perfectly, thank you! How can I do this conversion?


#13

See the previous @Wile_E_Coyote answer


#14

Do you know what the equivalent is for mac terminal? When I try to use this, I receive the following error:

sed: 1: "{s/\r/\n/g}": bad flag in substitute command: '}'


#17

tr ‘\r’ ‘\n’ < macfile.txt > unixfile.txt

this one works for me


#18

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