Hi,
I have a problem. Here is the code (below). If I call the test::fill() function twice the TNtuple will be filled with crazy numbers the second time.
[code]//////////////////////////////////////////////////////
//testntuple.C
#include <TNtuple.h>
#include
using namespace std;
class test{
public:
test();
~test();
void fill();
public:
TNtuple * n;
};
test::test(){
n = new TNtuple(“n”,“n”, “x:y”);
}
test::~test(){
delete n;
}
void test::fill(){
for(int i = 0; i < 1000; i++){
n->Fill(i, i);
}
cout << n->GetEntries() << endl;
float x,y;
n->SetBranchAddress(“x”, &x);
n->SetBranchAddress(“y”, &y);
for(int j = 0; j < n->GetEntries(); j++){
n->GetEntry(j);
cout << x << ", " << y << endl;
}
}
void testntuple(){
test * t = new test();
t->fill();
t->fill();
}
//////////////////////////////////////////////////////[/code]
The problem is - I guess - that I call the SetBranchAddress and after that I have to set it “back” somehow…
Can someone help me?
Balint