[ROOT] TClonesArray gathering

From: Ben Kilminster (bjk@fnal.gov)
Date: Thu Mar 11 2004 - 21:45:05 MET

I am trying to figure out how to fill a Tree in one object with a  
TClonesArray from another object.
My code is crashing when I try to do the copying.

In my main class, I define a tree with a branch, with a TClonesArray of  
objects in it:
class MainSim
   TTree* SimTree;
   TClonesArray* CloneXftpixel;
   xft2Lpixel* xftpixelB;

     CloneXftpixel = new TClonesArray("xft2Lpixel");
     SimTree = new TTree("T","SimTree");

I then fill the TClonesArray in another class, like :

class FinderChip
{    TClonesArray* CloneXftpixel;
      xft2Lpixel*  xft2pixelF;
      int iPixel;

	xft2pixelF = new ((*CloneXftpixel)[iPixel]) xft2Lpixel;
	xft2pixelF->Chip =  this->COT_chip;

Now, I want to fill the SimTree with the array of xft2Lpixels from the  
FinderChip object.
But I have many FinderChip objects, with any number of xft2pixelF  
objects,  so I have to gather them by checking the iPixel counter for  
each FinderChip :


     for(int nbrd=0; nbrd<8; nbrd++) {
       for (int nchp=0;nchp<8;nchp++) {
         int nPix =  
	if (nPix > 0)
         CloneXftpixel =  


This compiles and runs, but crashes filling the CloneXftpixel in the  
FillTree() method.

Instead of the if (nPix>0), I also tried to do this with a loop as in  
the At() statement :
         for (int i=0; i < nPix; nPix++) {
           xftpixelB =   

but this crashed in the same place.

What is the correct way to do this ?


This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET