Re: The second branch

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Mar 03 1999 - 10:48:41 MET


Hi Valeri,
Numbering in ROOT and C++ starts at 0, not 1. If you replace the 2
lines:
           track1 = (Track*)event->GetTracks()->UncheckedAt(1);
           track2 = (Track*)event->GetTracks()->UncheckedAt(2);
by
           track1 = (Track*)event->GetTracks()->UncheckedAt(0);
           track2 = (Track*)event->GetTracks()->UncheckedAt(1);

Your program will probably work.
Note that you could also replace the 2 lines:
     Track *track1 = new Track();  
     Track *track2 = new Track();  
by
     Track *track1 = 0;  
     Track *track2 = 0;  


Rene Brun


Tioukov Valeri wrote:
> 
> Dear rooters,
> 
> I have 2 TObjArrays and after some selections I need to store objects
> from them into the different branches of the tree.
> 
> When I have just one branch it works fine. If I add the second all tree
> leaves are filled by zeros.
> 
> To illustrate a problem I added the following lines into
> test/MainEvent.cxx:
> 
>      // Create one event
> ....
>      Track *track1 = new Track();
>      Track *track2 = new Track();
> ....
>      TTree *tree2 = new TTree("T2","My example of a ROOT tree");
>      tree2->Branch("track1", "Track", &track1, bufsize,split);  //1-st branch
>      tree2->Branch("track2", "Track", &track2, bufsize,split);  //2-d branch
> ....
> 
> // inside the event cycle:
> 
>          if( event->GetNtrack()>1) {
>            track1 = (Track*)event->GetTracks()->UncheckedAt(1);
>            track2 = (Track*)event->GetTracks()->UncheckedAt(2);
>            if (write) tree2->Fill();
>          }
> 
> ....
> 
> If I just comment the line belongs to one branch  the tree filling
> correctly.
> 
> What is wrong here?
> 
> Best regards
> Valeri Tioukov



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:29 MET