I’m running a macro script that plots a scatter plot using TGraph, reading data from a root file. The TGraph contains about 5-6 million points (which I would hope root can handle), retrieving it from a root file.
It takes about a minute for the graph to appear, but once I try to interact with the canvas (e.g. open an editor), root hangs — that is it takes forever for the editor to appear (2-3 min). The root.exe’s cpu usage sky rocket as I wait for the editor to appear:
The problem is actually the high amount of points.
Everytime you change anything in the editor Root redraws all drawn objects in the canvas. Which means everytime the 5-6 million points are redrawn which takes 2-3min.
Although Root can handle these large numeber of points your system seems to be overloaded by it. I would suggest to code the style directly in the Macro instead of using the editors.
BTW. Is there actually anything visible with 5-6 million points? Might it be possible to use a TH2 instead which would be much faster.
There are patterns that I need to view (hence the scatter plot) even if it has 5-6 million points. I avoid the TH2 because of binning will sometimes obscure the view if not binned correctly (which would not be obvious), which the TGraph avoids.
Is there some other options that would be less taxing on the system when viewing scatter plots for a large number of points?
The odd thing though if I view the data via TreeViewer from the tree in the root file (which my script retrieves data from), it doesn’t seem to have any problems plotting the scatter plot and have no problems interacting with it. Though applying specific cuts hasn’t always been successful via the TreeViewer. Which is why I resorted to writing a script that would give similar views but the convenience of filtering the data appropriately (as well as add the necessary legend, title, etc, easily).
What exactly is the TreeViewer using to plot scatter plots? It seems to plot quicker than TGraphs, for the same number of points …
Unfortunatly I have never worked with the TreeViewer but as far as I know there is no other possibility to draw 2D plots besides TGraph and TH2 so I think it can only be a TH2. Maybe to be sure right click on the drawn object. Then the class is displayed in the top of the menu.