Re: [ROOT] TClonesArray constructor

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Apr 11 2003 - 11:36:29 MEST


Hi Sebastien,

As I said, I cannot reproduce your problem. see below:

root [0] TClonesArray* array = new TClonesArray("class",10) ;
Error in <TClonesArray::TClonesArray>: class is not a valid class name
root [1] if(array->IsZombie()) cout << "is zombie" << endl ;
is zombie
root [2]

Rene Brun


Sebastien Greder wrote:
> 
> Hi Rene,
> 
> thanks for the reply, but indeed this small script doesn't work for me :
> 
> {
> TClonesArray* array = new TClonesArray("class",10) ;
> if(array->IsZombie()) cout << "is zombie" << endl ;
> }
> 
> which obvroot [0] TClonesArray* array = new TClonesArray("class",10) ;
Error in <TClonesArray::TClonesArray>: class is not a valid class name
root [1] if(array->IsZombie()) cout << "is zombie" << endl ;
is zombie
root [2]iously gives an error message since class is not known but
> doesn't return the expected "is zombie" statement.
> 
> seb.
> 
> ps : I'm running on redhat 7.2, gcc 2.96, version 3.05/02.
> 
> On Thu, 10 Apr 2003, Rene Brun wrote:
> 
> > Hi Sebastien,
> >
> > I cannot reproduce your problem with the test on Zombie.
> > Note that in your example, you had a typo, testing on aclone
> > instead of aclonesarray.
> >
> > I have added the call to MakeZombie in the second TClonesArray
> > constructor. Thanks for this remark.
> >
> > Rene Brun
> >
> > On Wed, 9 Apr
> > 2003, Sebastien Greder wrote:
> >
> > > Hello,
> > >
> > > I'm facing a small problem concerning the TClonesArray constructor :
> > >
> > >  I create a TClonesArray with the usual constructor :
> > >
> > >  TClonesArray* aclone = new TClonesArray("aclassname",100) ;
> > >
> > >  If the classname is not known by ROOT (i.e gROOT->GetClass("classname")
> > > fails) one gets the message : "classname is not a valid clas name"
> > > and MakeZombie() is called .
> > >
> > > Since I want to test if the TClonesArray has been successfuly built , that
> > > means not only have a message but be able to stop my prog somehow I
> > > decided to test the TClonesArray by : aclone->IsZombie() but this doesn't
> > > work, so to sum up the code :
> > >
> > > TClonesArray* trackarray = 0 ;
> > > TClonesArray* muonarray = 0;
> > > ....
> > >
> > > trackarray = InitArrays(track_branch,trackarray,"Track") ;
> > > muonarray = Init...
> > >
> > > TClonesArray* InitArrays(TBranchElement* abranch,
> > >                          TClonesArray* aclonesarray,
> > >                          TString aclassname)
> > > {
> > > if(abranch) {
> > >  aclonesarray = new TClonesArray(aclassname.Data(),100) ;
> > >   if(aclone->IsZombie()) return 0 ;
> > >   else {
> > >   tree->SetBranchAddress(abranch->GetName(),&aclonesarray);
> > >   return aclonesarray ;
> > >    }
> > >  }
> > >  else {
> > >  cout << "couldn't find branch" << endl ;
> > >  return 0 ;
> > >  }
> > > }
> > >
> > > Am I doing  something wrong ?
> > >
> > > Thanks for help,
> > >
> > > seb.
> > >
> > > ps : by the way the second constructor of TClonesArray :
> > > TClonesArray(const TClass *cl,....)
> > >
> > > does not have the call MakeZombie() if cl is NULL, just a message error
> > >
> >
> >



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET