How to draw TNtuple data?

Hi,

could you please advise, how to draw TNtuple data?

I have a couple of problems:

1./ I wanted to read MS Excel .csv data, i.e. in the file the separators are comma and new line. Is there a way to give separator other than space?

2./ It looks like that I can read my data from a file, even I can display them, but not quite in the format I prefer. Although I set the marker size to 0, on some graphs a huge gray dot is visible where my data points are. What is the right way to format them?
(actually, I display the first dataset last. For the first drawn graph, I set the marker size to 0 before the first Draw(), and there are no markers here. After this, I draw one more data set, and there are markers there. Then I set the marker size to 3 and there are markers on the 3rd graph, in unchanged size.)

3./ What I really want, it is to show the first data set with markers and the rest with lines. I see no way to disable lines completely when I want only markers and vice versa. Is there a way to do so?

3./ What is the algorithm to set the vertical scale? It looks like it is set according to the data in the first dataset I draw.
(An interesting feature: if I change the vertical User Range from the one set by ROOT to, say, to [4000,30000], the scale changes correspondingly and the markers are ONLY displayed in the region which was originally visible)

4./ How can i connect a TLegend to the TNtuple graphs?

5./ Is somewhere the TNtuple documented? (selecting options, etc.)

6./ After reading an TNtuple from a file, can I reach the individual data vectors somehow?

Thanks

Janos

PS: attaching a file to my mail does not work reliably for me. It it surely no problem with the first file, but sometimes the second either is not visible that it is attached or not attached. Now I wanted to attach my datafile, too, but ‘Posted attachments’ shown only the macro file. Despite that I added 3 times my data file, only the macro is visible in the preview.
bgdiff.C (1.3 KB)

[quote=“jvegh”]
PS: attaching a file to my mail does not work reliably for me. It it surely no problem with the first file, but sometimes the second either is not visible that it is attached or not attached. Now I wanted to attach my datafile, too, but ‘Posted attachments’ shown only the macro file. Despite that I added 3 times my data file, only the macro is visible in the preview.[/quote]
And, it was not present in the sent message, too. I tried to attach it to this reply, with no success. Then I renamed it to .txt, and OK, it is attached. It looks like .csv files cannot be attached.
LossBG1.txt (6.46 KB)

Hi,

About your questions:

1.) I’m not sure how it could be done in C/C++. For example, fscanf and similar functions in C use empty spaces (space, tab, newline) as string separators, and a comma would be a string on its own. You may want to consider saving the CSV files with a tab as a separator.

If you can’t, I suggest the following.

a) Solution 1:

  • Open the CSV file in Notepad / Wordpad.
  • Replace all occurrences of “,” for " " (space).
  • Save the file.

In principle, this should be enough.

b) Solution 2: if you’re using a Cygwin shell

sed -n 's/,/ /g' inputfile1.csv >outputfile.csv

or something similar.

  1. About the gray dot.

Is the gray dot a diffuse cloud (as in, very close dots)? You may want to use a different rendering. Here’s some options that have been useful for me in the past:

a) histo->Draw(“prof”)
This draws a “profile” histogram.
b) histo->Draw(“colz”)
Color histogram.
c) A combination, like: histo->Draw(“colz prof”)

  1. Legends:

a) Draw the graph. For example,

ntuple->StartViewer()

and select the variables (drag-and-drop) to the corresponding axes. For the legend:

TLegend *leg = new TLegend(0.75,0.75,0.90,0.90)
leg->AddEntry(variable1,"Variable one")
leg->AddEntry(variable2,"Variable two")
leg->AddEntry(var3,"x^{2} + y^{2}")
leg->Draw()

(note the LaTeX coolness… :wink: )

Hope this helps…