This function is responsible for reading an event from a file and
returning an Event object. The order is assumed to be correct as well as
the file type. Otherwise this function will load garbage without
warning. Since it's assuming a simple well-defined bytestream there's no
way of verifying it's well-formed and uncorrupted. What would be better
is a dedicated serialization library that stores type and class
information along with the data. This should be the next thing to do.
The byte stream is assumed as follows in this order:
-
4 bytes - runID(unsigned int)
-
4 bytes - year(unsigned int)
-
8 bytes - startTime (long) - Number of tenths of nanoseconds since
the beginning of the year.
-
8 bytes - eventLength(float) - Units of microseconds.
-
4 bytes - (long) - Number of triggers. This is not a member of the
Event class, since it's simply the size of the trigger list. For each
trigger the byte structure is given as :
-
8 bytes - trigger time (float) - Time of the trigger with respect
to the start of the event.
-
4 bytes - nchar (int) - Number of characters in the trigger name.
-
nchar * 1 byte - The characters that make up the trigger name.
-
8 bytes - nhits (long) - Number of hits in the event. The next set
consists of nhits*5*8 bytes (one chunk of 8 bytes for each float of
q,t,x,y,z).
To Do:
Make a robust serialization library that stores the type information so
that it is more generic and robust. Something closer to boost's
serialization library. We won't regret it.
|