Hello dear Rooters!
Sorry if i fell in to the wrong place…
I am in a very tight spot concerning this problem. It has annoyed me hellofalot. So here it goes:
I have to export histograms from ROOT files to ASCII. Currently i am using this.
[code]TFile f = TFile(“xxx.root”);
// file xxx.root is in the same local directory
// where i opened ANY root file
TH1D* histY = (TH1D*)f.Get(“Z”);
histY->Print(“all”); > ZZZZ.dat[/code]
As long as i throw this code row by row, while ANY root file is open, in to the “Command (local):” box everything works fine. But earlier, i had to export only few of histograms from one file, so it was allright. Now it gets to around 10-20, and it gets very annoying and time consuming.
I decided to script it in a xyz.C file. So the main problem is that, when i run it, which should extract those graphs in theory, the intepreter just throws up at the third line. Sometimes i get ZZZZ.dat is out of scope, or something like that the ; is missing somewhere.
For example, this is the script code:
{
TFile f = TFile("D:/Geant4_10.0.0/share/Geant4-10.0.0/examples/extended/electromagnetic/TestEm18antras-build3/Release/pixeErdvinisKampas.root");
TH1D* hist5 = (TH1D*)f.Get("5");
hist5->Print("all"); > histfilename.dat
}
And this is what i get in the interpreter:
fSumw[1000]=0, x=19.99, error=0
fSumw[1001]=0, x=20.01, error=0
Syntax Error: > histfilename.dat Maybe missing ‘;’ D:\root\macros\dataout2.c(5)
*** Interpreter error recovered ***
The script file is in the macros directory.
I just cannot understand, why it works if you feed it line by line, but otherwise not…
Can anyone help?