Re: [ROOT] Problem using new Branch() with TString?

From: Victor Perevoztchikov (perev@bnl.gov)
Date: Mon Jun 18 2001 - 23:44:20 MEST


> My question now is:
> Is it necessary to reserve memory for TString?

NO.
Victor


cstrato@EUnet.at wrote:
> 
> Dear Rene
> 
> Thank you for this suggestion, I will try it as soon as possible.
> Meanwhile I realized that sometimes it works, but most of the time
> it crashes, so this may be a memory problem.
> 
> Could it be a problem with the storage of TString, since I am not sure
> if I handle strings correctly:
> In my class I have "TString fName" as member variable.
> In the constructor I initialize  it to the empty string"fName = "";".
> Only in a later function I set fName to a real name. Nowhere did I
> reserve memory for TString.
> 
> My question now is:
> Is it necessary to reserve memory for TString?
> How do I have to reserve memory? (fName = TString(32); ?)
> 
> Thank you once more for your help
> 
> Best regards
> Christian
> 
> Rene Brun wrote:
> 
> > Hi Christian,
> >
> > You can have your libraries where you want. They don't need to be
> > in $ROOTSYS/lib !
> > Concerning your problem, you do not provide enough information.
> > Did you set the branch address ?
> > You can get an idea of what happens (with version 3.01/05) by activating
> > the debug flag. Just before the loop on entries, add the statement
> >   gDebug = 2;  (in TSystem.h)
> >
> > Rene Brun
> >
> > On Sat, 16 Jun 2001 cstrato@EUnet.at wrote:
> >
> > > Dear Rene
> > >
> > > Thank you for your suggestion. Sorrowly, the problem persists
> > > with version 3.01/05.
> > >
> > > Regarding your second suggestion, until now I have not been
> > > able to extract a subset where the problem can be reproduced.
> > > I have tried to create test classes, but the problem never
> > > appeared.
> > >
> > > However, I know exactly where the program crashes:
> > > // The following command is still ok:
> > >    Int_t  vNEntries = (Int_t)(vTree->GetEntries());
> > > cout << "vNEntries <" << vNEntries << ">" << endl;
> > >    for (Int_t i=0;i<vNEntries;i++) {
> > > // The following line crashes!!
> > >       vTree->GetEntry(i);
> > >       some code;
> > >    }//for_i
> > >
> > > Although there are entries in the tree, it cannot get the
> > > entries.
> > > Maybe, you can give me some hints where to look further?
> > >
> > > I have seen that the option Bronch() requires access to the
> > > library where the corresponding class is defined.
> > > Since my libs are stored in /opt/rootcode maybe Bronch()
> > > cannot access the corresponding library, although it is
> > > loaded first with gSystem->Load(lib).
> > > Could it be that I need to store my own libraries also
> > > in /opt/root/lib in order for Bronch() to find the
> > > corresponding class?
> > >
> > > Thank you for your help.
> > > Best regards
> > > Christian
> > >

-- 
Victor M. Perevoztchikov   perev@bnl.gov  perev@vxcern.cern.ch       
Brookhaven National Laboratory MS 510A PO Box 5000 Upton NY 11973-5000
tel office : 631-344-7894; fax 631-344-4206; home 631-345-2690



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:49 MET