persistent C structures?

Paolo Calafiura (Paolo.Calafiura@cern.ch)
Wed, 11 Mar 1998 21:10:55 +0100 (MET)


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?

Thanks for your help
Paolo Calafiura

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!!!