Hello Rene,
nice to hear from you that soon!
Well, in the meantime I solved a part of the problem on my own.
To answer your question: I did set the branch address, but made
a mess out of some pointers and addresses of pointers. :o)
However, a few question marks have been left. Maybe you can help me to
clear the picture.
Unlike I wrote in my previous message, I initialised the branch
before serialising with split-level zero, means:
dT->Branch( "myArrayBranch", "TClonesArray", &aBuf, 32000, 0);
If I do so, TClonesArray::GetEntries() returns the correct amount
of objects stored in TClonesArray, when reading it back from
the ROOT file. I can also get objects from TClonesArray and I can
correctly read data stored inside of the objects.
That's the functionality I wish to have.
So far, so good.
If I initialise the branch with split-level > 0, for example 99,
TClonesArray::GetEntries() returns always 0 in case of
reading it back from the file. It seems to loose it's objects?!?
Does this happen on purpose? What is the reason?
Thanks in advance for your answer.
H.-Gerd Rosarius
On Thu, 2003-09-18 at 12:11, Rene Brun wrote:
> H-Gerd,
>
> You descrive very well the points 1,2 and 3. But in your point 4,
> you do not say if you set the branch address. This is mandatory if your class
> in the TClonesArray contains complex structures
>
> Rene Brun
>
> "H.-Gerd Rosarius" wrote:
> >
> > Hello Rooters,
> >
> > I have problems with writing a TClonesArray to a root-file
> > and my work doesn't look to different from the Event/Track
> > examples coming with ROOT.
> >
> > However, let me describe the situation in detail first.
> >
> > 1. I wrote an own class, called WARequest, which serves as a
> > kind of data container for different variables of type
> > string, map<string,string>, Double_t, etc.
> > It is derived from TObject.
> > That class includes the ClassDef-/ClassImp-Makros and a
> > dictionary-file is generated with rootcint successfully.
> >
> > 2. In my main application I have a TClonesArray which is
> > filled with n objects of type WARequest. The objects
> > in TClonesArray are still fine after filling the array, because
> >
> > WARequest* r = (WARequest*) myClonesArray->At(0);
> > cout << r->getValue() << endl;
> >
> > returns a senseful string like "Hello world!" to the console.
> >
> > 3. I want to use a TTree that holds a TClonesArray with my
> > WARequest-Objects as branch. Therefore I coded (shortened):
> >
> > TClonesArray* aBuf = new TClonesArray( "WARequest", 100 );
> >
> > dT = new TTree( "myTree", "No description" );
> > dT->Branch( "myArrayBranch", "TClonesArray", &aBuf, 32000, 99 );
> >
> > and I fill the tree with
> >
> > aBuf = myClonesArray;
> > dT->Fill();
> >
> > At this point all objects in TClonesArray are still in
> > a fine condition.
> >
> > 4. I write the tree and close the file.
> >
> > When I read the file, get the tree, open the branch, get an entry
> > and access the TClonesArray, TClonesArray::GetEntries() returns
> > the right number of objects inside.
> > If I take an object from TClonesArray and want to get data from
> > the object, say again for example
> >
> > WARequest* r = (WARequest*) myClonesArray->At(0);
> > cout << r->getValue() << endl;
> >
> > the output consists of strange characters.
> >
> > It seems the objects in TClonesArray "forget" the values
> > in their fields.
> >
> > What is happening here? Am I doing something wrong? If so, what?
> >
> > Thanks for any help.
> >
> > H.-Gerd Rosarius
> >
> > Tech: Using ROOT 3.05/03 made from source with g++ 3.0.4, running
> > on a Debian Linux box.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
--
Dipl.-Betriebsw. (FH) H.-Gerd Rosarius
Softwareentwickler und Berater mailto:rosarius@getit.de
-----
GETIT - Gesellschaft für Technologie- und Informationstransfer mbH
Fon: +49.231.9742.298
Fax: +49.231.9742.356
Emil-Figge-Straße 76-80 http://www.getit.de
44227 Dortmund mailto:info@getit.de
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET