Sorry for such a newbie question but how do I use this piece of code? I cannot run it as a macro, so how is it used to convert the root histogram into an ascii file?
Thanks for the reply but my question was how to execute Arne’s code described above.
I have used the myhist->Print(“all”) > output.txt before but it formats the text in an undesirable way. I would like plain columns with no descriptive text.
I don’t know while the given code should not work as a macro. However, use it as a member of a class handling the export of histograms.
If you remove “TRemiHistExport::” from the example and save it as SingleExportAscii.C it should also work as a macro.
actually the use of the “filename” argument for this function is not as input, but as output. I.e. the filename of the ascii file is generated from the histogram’s name and written to the “filename” string as a reference. Therefore you have to name a valid TString variable in the function call:
The other arguments of the SingleExportAscii function are optional. If you leave them blank, the file will be written into the current folder and the data values will be separated by tabulators. The filename where hist1 was exported to will be contained in histfilename.
[quote=“apetts”]Thanks for the reply but my question was how to execute Arne’s code described above.
I have used the myhist->Print(“all”) > output.txt before but it formats the text in an undesirable way. I would like plain columns with no descriptive text.
I would like to be without the “fsumw” etc[/quote]
I did
root> h->Print(“all”); > h.dat
bash> perl -ne ‘($a,$b)=($_=~/fSumw[(\d+)]=(\d+)/);print “$a $b\n”;’ h.dat > h.2col
In case you are looking for a c++ executable callable from the command line (outside of ROOT) that does the same job, try this! How to compile and use it is included in the file.
I am getting error while trying to write the output in a file. Output on terminal is working fine but not in a file. I am using ROOT 6.14 and a novice. Thanks