Hi,
I am trying to use TTreeFormula::EvalInstance() but found that I only get at most two
instances. I always get 0.0 if I ask for the third instance or higher. The following code
demonstrates this problem. Did I miss something? Thanks. I am using 4.04/02.
[code]{
TTree* _tree= new TTree(“reduced”,“Reduced Tree”);
Int_t _nc;
Float_t *_xx= new Float_t[10];
_tree->Branch(“nc”, &_nc, “nc/I”);
_tree->Branch(“xx”, _xx, “xx[nc]/F”);
TRandom rand;
for ( Int_t j=0; j<5; j++) {
_nc= 5;
for ( Int_t k=0; k<_nc; k++) {
_xx[k] = rand.Rndm();
}
_tree->Fill();
}
_tree->SetScanField(0);
_tree->Scan(“xx”);
TTreeFormula *tf= new TTreeFormula(“tf”,“xx”,_tree);
cout << “Get entry 3” << endl;
_tree->GetEntry(3);
cout << "instance value " << endl;
for ( Int_t k=0; k<5 ; k++ ) {
cout << k << " " << tf->EvalInstance(k) << endl;
}
}[/code]
[code]
root [12] .x ttftest.C
- Row * Instance * xx *
-
0 * 0 * 0.1079150 * -
0 * 1 * 0.5874750 * -
0 * 2 * 0.3189729 * -
0 * 3 * 0.1464375 * -
0 * 4 * 0.2992230 * -
1 * 0 * 0.0407005 * -
1 * 1 * 0.1521224 * -
1 * 2 * 0.9564707 * -
1 * 3 * 0.4798908 * -
1 * 4 * 0.5815624 * -
2 * 0 * 0.9404398 * -
2 * 1 * 0.2410030 * -
2 * 2 * 0.8393390 * -
2 * 3 * 0.3083940 * -
2 * 4 * 0.4706811 * -
3 * 0 * 0.4858036 * -
3 * 1 * 0.9754050 * -
3 * 2 * 0.2558995 * -
3 * 3 * 0.7278150 * -
3 * 4 * 0.4584717 * -
4 * 0 * 0.1907299 * -
4 * 1 * 0.5294313 * -
4 * 2 * 0.2968764 * -
4 * 3 * 0.9638074 * -
4 * 4 * 0.2188322 *
Get entry 3
instance value
0 0.485804
1 0.975405
2 0
3 0
4 0[/code]