Thank you. My problem turned out to be an issue with
std::vector<TNtuple*>. I got it working with TList. Object ownership and
removal from memory had nothing to do with it. Cint being willing to pun
between object* and object made this more difficult to debug.
Still one question: what is the difference between directories and folders, and why are there both?
Tom Roberts
Fine, Valeri wrote:
> May I advice you to read first the
> "Object Ownership"
> ftp://root.cern.ch/root/doc/chapter8.pdf <ftp://root.cern.ch/root/doc/chapter8.pdf>
> from User's Guide v5.14 http://root.cern.ch/root/doc/RootDoc.html <http://root.cern.ch/root/doc/RootDoc.html> ?
> It is to answer the very basic things your code is facing.
>
> Hope this helps, Valeri
> ________________________________
>
> From: owner-roottalk_at_pcroot.cern.ch on behalf of Tom Roberts
> Sent: Sun 1/7/2007 4:44 PM
> To: 'ROOT Talk'
> Subject: [ROOT] How to reference an object in a TFile?
>
>
>
> I am an experienced C++ developer new to root.
>
> I am implementing a graphical user interface for my users, and I want
> them to be able to select any single TNtuple out of any open Root file.
>
> So I loop over gROOT->GetListOfFiles() and descend each file's directory
> tree, putting the TNtuple pointers into a std::vector<TNtuple*> (and
> also their names into a TGListBox from which the user will select).
> Inside that loop I can call p->GetName() and p->GetEntries(), for p the
> current pointer to a TNtuple. But later, after all NTuples have been
> found and the loop over files is complete, I cannot call any TNtuple
> function using those pointers -- an interpreter segfault happens. I
> guess those objects no longer remain in memory (??).
>
> Is there a better way to do this? I do not expect my users to understand
> TBrowser and then know enough to open the TreeViewer -- I am basically
> re-implementing HistoScope for Root files....
>
> I tried keeping a std::vector<TString> with each entry the full name of
> the TNtuple (i.e. /path/file.root:/path/name ). How can I turn that name
> into a TNtuple pointer I can use? -- do I need to laboriously descend
> into the file as before? (a pain, as TDirectory::GetPath() does not
> return the actual root path when inside a TFile)
>
> What is the difference between folders and directories? -- there seem to
> be parallel but different functions and objects...(??)
>
> How does it decide which objects to remove from memory? -- after all, I
> had recently referenced each and every NTuple....
>
> [If it matters, my loop just uses pointers to TDirectory-s,
> never opening any TFile nor calling any cd() function.]
>
>
> Tom Roberts
>
>
>
Received on Mon Jan 08 2007 - 02:47:05 CET
This archive was generated by hypermail 2.2.0 : Mon Jan 08 2007 - 11:50:00 CET