Paolo Calafiura wrote:
>
> Hi,
> I have an Event class that is a copy element by element of a C data
> structure:
> struct cmpEvent {
> int n;
> int trigword;
> int timestamp;
> int recflag;
> float evtfspare[10];
> int evtispare[10];
> struct RNDMsummary rndm;
> u_int Ntstamp;
> struct EVTtimestamp tstamp[MAX_TS] ;
> struct PMBscaler KLmon;
> ..... more stuff
> };
> becomes
> class Event : public TObject {
> protected:
> int n;
> int trigword;
> int timestamp;
> int recflag;
> float evtfspare[10];
> int evtispare[10];
> struct RNDMsummary rndm;
> u_int Ntstamp;
> struct EVTtimestamp tstamp[MAX_TS] ;
> struct PMBscaler KLmon;
> .... as above
> public:
> void Dump();
> .... some other member functions
> };
> The idea is to keep the same memory layout as in the C structure for the
> data members, so that I can "fill" an Event object in the functions
> that were prepared to fill the C structure just by passing a
> pointer to the object. This works fine as I checked Dumping the C
> structure I read and the Event I want to write.
>
> Even before trying to read back the Event.root out file, if I browse the
> class Event, using the Object Browser, I see that, for example,
> the structure "rndm" is not among the "Real Data Members". Oddly enough,
> the array of structures tstamp[MAX_TS] is there...
>
> Now if I look into the "event" tree of Event.root (I wrote in split mode).
> I see only the data members of type "intrinsic": I don't see rndm and all
> other members of type structure or array of structures: even tstamp[]
> that was among the "Real Data Members" of the class did not make it to the
> file.
>
> When I read back the files using a standalone program I see, using Dump()
> that for all events, all the members of type structure are left 0.
>
> How should I handle that? Is default Write() unable to deal with
> structures inside an object? Do I have to provide my own Write()?
> Or maybe I messed up something trivial?
>
No, you do not have to provide your own Write. I suggest you read
the following two pages related to your problem.
http://root.cern.ch/root/HowtoWrite.html
http://root.cern.ch/root/HowtoWriteTree.html
The first page explains how to implement your own Streamer function
for a class using C structures.
The second page list the restrictions to the use of the split mode.
>
> P.S. I am using the beta of version 2 on Solaris, and it looks fine.
> Thanks Fons for fixing the name clash with gzip routines!!!
This was a "bit" more work than initially expected. I had to change
the definition of several global variables used in this piece of
C code. The previous ZIP package was effectively clashing with
other C-based packages using the XDR system in particular.
Rene Brun