Redirection of TTree::Scan

Hi,

What would be the trick to make this basic macro work? (ie have the file 3023_Fisher-ccbar.dat: currently I have a segmentation violation)

(Note: I do not want it to use it interactively. I really need a macro.)

{
TFile *f=new   TFile("/nfs/farm/babar/AWG21/Breco/GLWADS/test/ntp/signal/Dstar0K/TMVA/var6/Chained1005-BchToD0KAll-R18b-dk-Rec3023_Fisher.root");
 TTree *mytree=f->Get("T");
 mytree->SetScanField(0);
int numb=mytree->GetEntries();

gROOT->ProcessLine("mytree->Scan(\"*\",\"cosThetaT<0.9\",\"colsize=30 precision=12\",numb,0); >3023_Fisher-ccbar.dat");
}

Thanks for your precious help.
Emmanuel

Write your file myscript.C as shown below

//myscript.C

[code]{
TFile *f=new TFile("/nfs/farm/babar/AWG21/Breco/GLWADS/test/ntp/signal/Dstar0K/TMVA/var6/Chained1005-BchToD0KAll-R18b-dk-Rec3023_Fisher.root");
TTree mytree=(TTree)f->Get(“T”);
mytree->SetScanField(0);
int numb=mytree->GetEntries();

mytree->Scan("*",“cosThetaT<0.9”,“colsize=30 precision=12”,numb,0);
}
[/code]
and execute it with:

root >.x myscript.C >3023_Fisher-ccbar.dat

Hi Rene,

With this solution, I am back with the issue I have posted the day before: if I use your solution and submit my job at a unix prompt:

(myFisher/test2-myFisher-3023-ccbar.csh written at the end of the posting)

This works and I get the test.dat file. But if I submit the job in to a LSF queue:

bsub -q short -C 0 -o log/test.log myFisher/test2-myFisher-3023-ccbar.csh
it crashes with a segmentation fault.

I am not sure it is a problem from ROOT. Do you have an idea?
Thanks a lot.

Emmanuel

PS: The script myFisher/test2-myFisher-3023-ccbar.csh is as follows (replace the “[…]” in the following lines by “.x testmacro.C >test.dat”: I did not include this line in the code because the text displayed was not the one I typed because of the “>”):

#!/bin/tcsh -f bbrroot -b <<DONE [...] DONE exit