Hi Ole,
Instead of:
> EventCounter *counter = new EventCounter();
> t->GetBranch("Counter")->SetAddress(&counter);
do
> EventCounter *counter = 0;
> t->GetBranch("Counter")->SetAddress(&counter);
Rene Brun
On Mon, 2 Sep 2002, Ole Streicher wrote:
> Hello, sorry for that much mails,
>
> what is the correct usage of the SetAddress() function of the
> TBranch class?
>
> I thought that it always needs a pointer to a pointer with an
> initialized events, but in the example of the User's manual (pg. 247),
> they use
>
> static Float_d destep;
> t2->GetBranch("destep")->SetAddress(&destep);
>
> For me, neither of the two works. My script looks like:
>
> gSystem->Load("run/.libs/libpamelarun");
> TFile *f = new TFile("Physics.root");
> TTree *t = (TTree *)f.Get("Physics");
>
> EventCounter *counter = new EventCounter();
> t->GetBranch("Counter")->SetAddress(&counter);
>
> t->GetEntry(0);
> cout << counter->GetEventNumber() << endl;
> t->GetEntry(10);
> cout << counter->GetEventNumber() << endl;
>
> which doesn't print anything else than "0". Changing the "counter"
> from a pointer to a local variable doesn't help. No error message is
> printed, using "t->GetBranch("Counter")->Print()" I can see that it
> contains the correct structure. Also with
> "t->GetBranch()->Draw("Counter.EventNumber")" I find that the Number
> is not zero.
>
> How can I proceed to debug?
>
> Ole
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:08 MET