Problems in converting ntuples to text files

Hello.,

I am still having problems doing this . I have already tried:

TFile file(“file.dat”,“CREATE”);
mytuple.SetScanField(0)
mytuple.Scan();>file

But it comes with this error:

Error: G__getvariable: expression FILE:(tmpfile) LINE:1
(class TFile)149670192
*** Interpreter error recovered ***
I do not know how to solve it…
And how can i convert to a text file only some variables, those that start with “AA…”, for example, and saving all to the same text file.

thanks a lot

[
Hi,
here is the screen dump, when i try to save in a .dat file the entire ntuple.

root [0] TFile f(“root/trigger.root”)
root [1] TDirectory *dir = f.Get(“ELECTRON”)
root [2] TNtuple *tuple = dir.Get(“h101”)
root [3] TFile file(“test.dat”)
root [4] tuple->SetScanField(0);
root [5] tuple->Scan();>file


  • Row * Instance * Idrun * Idevent * Idroi * T2canclus * T2caeme * T2caemes0 * T2caemes1 * T2caemes2 *

  •    0 *        0 *      2105 *      1001 *         0 *         1 * 95791.171 * 614.45568 * 20241.296 * 70146.148 *
    
  •    1 *        0 *      2105 *      1002 *         0 *         1 * 96867.093 * 1485.1832 * 23951.406 * 70377.570 *
    
  •    2 *        0 *      2105 *      1003 *         0 *         1 * 95700.734 * 583.96710 * 13732.195 * 79912.578 *
    
  •    3 *        0 *      2105 *      1004 *         0 *         1 * 97796.898 * 503.38360 * 3594.9863 * 82071.671 *
    
  •    4 *        0 *      2105 *      1005 *         0 *         1 * 96796.585 * 1554.5087 * 24619.765 * 70154.195 *
    

Error: G__getvariable: expression FILE:(tmpfile) LINE:1
(class TFile)149597408

*** Break *** segmentation violation

Root >

Thanks very much.

Follows the error message

Hi,

In the expression

the part of > should not be a C++ variable. You should have

Cheers,
Philippe.

Hi

no it still don’t work, now root says :

Error: G__getvariable: expression FILE:(tmpfile) LINE:1
Error: Symbol test is not defined in current scope FILE:(tmpfile) LINE:1
Error: Failed to evaluate teste.dat(const int)0
*** Interpreter error recovered ***

I have tried : mytuple.Scan();>“test.dat” . And comes:

Error: G__getvariable: expression FILE:(tmpfile) LINE:1
Error: > Illegal operator for pointer 3 FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***

I really need to solve it. Is it so hard to convert ntuples to text files?

Thanks for your help.

Is it so hard to convert ntuples to text files?

No it is not :slight_smile:
Just add a space between ; and >. And do not put quote around the file name

root [5] tuple->Scan(); >file 

Cheers,
Philippe.

hi

Man, finally. what a space can do…

One last question and I will stop. :wink:

The ntuple.Scan() does not fit all the ntuple in the screen and only what is in the screen that is saved to the file.

How can i put the entire ntuple in the file all at once ?

Thanks very much !!!

Hi,

You must have forgotten the line

If not I do not understand what you mean by “does not fit all the ntuple on the screen”.

Cheers,
Philippe.

Hi again.

No I did not forget, what i mean is:
my ntuple has about 20 colum and when i go mytuple.Scan(); >file, after mytuple.SetScanField(0), all the rows are shown at once , but the colums not.
So the file is written without those colums that could not be shown because of the limitation on the screen size.

Hope you understood.

Cheers.

Hi,

Actually when doing

This shows 8 columns. To show more columns either specify the columns you want to see or do

Cheers,
Philippe.

hello,

Thanks very much, now it is working perfectly.

I shall stop bothering you now… for some weeks.

Ciodaro

Hello,

once more, i shall need your help.

I have a function that converts a tree to text files, but when i run:

tree->SetScanField(0);
tree->Scan("*"); >file

it does not work.
when i type the same thing inside root it works, but in a function it does not.

He says that file is not defined in the current scope.

i have tried :
char cmd[100];
sprintf( cmd, “%s”, “tree->Scan(”*"); >file");
gROOT->ProcessLine( cmd );

But then he says that tree is not defined in the current scope,
i have tried to put { } but no.

I do not know what else to do…

Thanks for your help.

Do

Special CINT commands like the one starting with ‘.’ or the easy redirection of the standard output are not diretly available inside a macro or inside compile code. You have to go through gROOT->ProcessLine.

Cheers,
Philippe.