I’m surprised that there is no standard feature in root of converting at least 1d histograms into plain ascii file. I would expect that such a feature would be very much appreciated by many physicists especially of old generation who are not familiar with C++ and with root itself, but may still use it for simple analysis by dumping histograms into an ascii file and then processing it as they are used to with gnuplot or Origin or whatever other data plotting programs.
Why not to add, for example, an option “ASCII” to “SaveAs” context menu entry for a histogram which would save plain two columns: x and y without any additional text like “fsumw” etc?
Of course it’s easy for any programmer to write a simple macro which does it, but why not to make it a part of root?
Another question to all: does anybody have a macro which reads all 1D histograms from a .root file and writes each of them to a separate ascii file as described above: just two columns x and y?
Will dump out all the bin contents. As far as a script that does this automatically, that’s a little more tricky as I don’t know how to redirect output to a file named in a variable.
Naïvely, if someone asked me to write a function that printed a histogram “in ascii”, I would write one that prints an ascii-art histogram, with little stacks of symbols for the height of each bin. If printing to a csv (or other tabular text) format, I would like it not to have a more specific name than “ascii”.
While I’m talking about it, an ascii-art mode for printing would actually be useful sometimes. I’ve used the gnuplot “dumb” terminal to make quick plots through non-X-forwarded ssh connections. Something similar for ROOT was talked about enthusiastically 4 years ago: [url]lsRoot to dump root contents to terminal