[ROOT] TClonesArray constructor

From: Sebastien Greder (greder@in2p3.fr)
Date: Wed Apr 09 2003 - 15:56:34 MEST


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