Hi Kate,
Are you sure that instead of:
int* evptr = 0;
amstree->SetBranchAddress("Eventno",&evptr)
you should may be have :
EventNtuple02* event = 0;
amstree->SetBranchAddress("event02",&event);
For sure int* must be wrong.
Rene Brun
Kate Scholberg wrote:
>
> Hi,
>
> I have a root file containing trees generated with
> split branches,
>
> For instance:
>
> EventNtuple02 _event02;
> static void *pev2=(void*)&_event02;
> TBranch *b2=_tree->Branch("event02", "EventNtuple02", &pev2, 64000,1);
>
> The EventNtuple02 class is a simple one, containing basic data types
>
> class EventNtuple02: public TObject {
> public:
> int Eventno;
> int Run;
> ...
> };
>
> When I try to read the file in a standard way, as follows:
>
> {
>
> // Load shared lib etc..
>
> TFile file("prv3.root","UPDATE");
> TTree *amstree = (TTree*)file->Get("AMSRoot");
> EventNtuple02* event02 = new EventNtuple02;
> amstree->SetBranchAddress("event02",&event02);
>
> int nevent = amstree.GetEntries();
>
> for(int i=0;i<nevent;i++)
> {
>
> amstree->GetEvent(i);
> printf("Run, event %d %d\n",event02->Run, event02->Event);
>
> }
>
> }
>
> No problem... all fine.
>
> But what I would like to do is access directly one of the sub-branches
> of the event02 branch.
>
> int* evptr = 0;
> amstree->SetBranchAddress("Eventno",&evptr)
>
> This seems to find the sub-branch correctly.
> Also if I get the sub-branch with
> TBranch *evbranch = amstree->GetBranch("Eventno");
> it Prints OK.
>
> However, then
>
> amstree.GetEvent(i)
>
> doesn't seem to read anything into evptr.
>
> (and doing explicitly evbranch->GetEntry(i,1) returns nbytes=1).
>
> Is this the expected behavior for sub-branches?
>
> I haven't looked into the source, but from my not-extremely-thorough
> reading of the docs I would expect SetAddress to create an int, have
> evptr point to it, and GetEvent would put stuff into it from the
> branch.
>
> Same behavior if the int evptr points to is already instantiated,
> i.e. int* evptr= new int;
>
> Same behavior on Linux and OSF1, with Root versions 2.22, 2.25 and 3.00
>
> Kate Scholberg
> schol@mit.edu
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:51 MET