Event¶
hipo::event¶
Container for a single physics event, holding multiple banks/structures.
Internal Buffer Layout¶
Byte: 0 4 8 12 16 eventSize
+-------+--------+--------+--------+-------------------------+
|"EVNT" | size | tag |reserved| structure0 | struct1 ..|
|(4B) |(uint32) |(uint32)| (0) | (8B hdr + data each) |
+-------+--------+--------+--------+-------------------------+
|<- event header (16 bytes) ->|<- concatenated structures -->|
Default buffer size: 128 KB.
Construction¶
event();
Reset¶
void reset(); // set signature="EVNT", size=16 (empty event)
Adding Banks¶
void addStructure(structure& str);
Appends the structure (8-byte header + payload) to the event buffer and updates the size field.
Reading Banks¶
void read(bank& b); // preferred: uses bank's schema (group/item)
void read(bank& b, int item, int index); // read by item index
void getStructure(structure& str); // read using str's group/item
void getStructure(structure& str, int group, int item);
// Zero-copy from raw buffer
static void read(const char* buffer, int bufferSize, bank& b);
event.read(bank) performs a linear scan through the event buffer to find a structure matching the bank's (group, item). If found, it copies the data into the bank's buffer and sets the row count. If not found, the bank's row count is set to 0.
Modifying¶
void replace(structure& str); // overwrite same-size bank in-place
void remove(int group, int item); // remove a structure, shift trailing data
Initialization¶
void init(std::vector<char>& buffer); // init from external buffer
Display¶
void show(); // print all structures with hex dump
Important Behaviors¶
event.read(bank)uses the bank's schema to locate the matching structureaddStructure()appends and updates the size field at offset 4replace()overwrites in-place (must be same size)remove()shifts trailing structures backward to fill the gap- The event buffer is reused across iterations
Example¶
// Writing
hipo::event event;
hipo::bank particles(schema, 3);
particles.putInt("pid", 0, 11);
particles.putFloat("px", 0, 1.5f);
event.reset();
event.addStructure(particles);
writer.addEvent(event);
// Reading
hipo::bank particles(dict.getSchema("REC::Particle"));
while (reader.next()) {
reader.read(event);
event.read(particles); // fills particles from event
if (particles.getRows() > 0) {
// bank was found in this event
}
}