Skip to content

Schema & Dictionary

Type Enum

Data type identifiers used throughout the library.

enum Type {
    kByte   = 1,  // int8_t,  1 byte,  schema char: B
    kShort  = 2,  // int16_t, 2 bytes, schema char: S
    kInt    = 3,  // int32_t, 4 bytes, schema char: I
    kFloat  = 4,  // float,   4 bytes, schema char: F
    kDouble = 5,  // double,  8 bytes, schema char: D
    kLong   = 8,  // int64_t, 8 bytes, schema char: L
};

schemaEntry_t

Metadata for a single column in a bank.

Field Type Description
name std::string Column name (e.g., "px")
type std::string Type character (e.g., "F")
typeId int Numeric type ID (from Type enum)
typeSize int Size in bytes
offset int Byte offset within a row

hipo::schema

Defines the column layout of a bank.

Construction

schema();
schema(const char *name, int group, int item);

Parsing

void parse(const std::string& format);

Format string: "col1/T,col2/T,..." where T is the type character (B, S, I, F, D, L).

hipo::schema s("event::particle", 100, 1);
s.parse("pid/S,px/F,py/F,pz/F");

Metadata

std::string getName();              // schema name
int         getGroup();             // group ID
int         getItem();              // item ID
int         getEntries();           // number of columns
int         getRowLength();         // bytes per row
std::string getEntryName(int idx);  // column name by index
int         getEntryType(int idx);  // column type by index
int         getEntryType(const char *name);  // column type by name

Column Lookup

int getEntryOrder(const char *name);

Returns the column index for a given name, or -1 if not found.

bool exists(const char *name);

Returns true if the column name exists.

Offset Computation

int getOffset(int item, int order, int rows);
int getSizeForRows(int rows);

Display

void show();

hipo::dictionary

Collection of schemas, typically loaded from a file header.

Adding Schemas

void addSchema(schema sc);

Querying

bool    hasSchema(const char *name);
schema& getSchema(const char *name);

Warning

getSchema() throws hipo::schema_error if the schema does not exist. Check with hasSchema() first if unsure.

Listing

std::vector<std::string> getSchemaList();

Parsing

bool parse(const char *schemaString);

Parses the dictionary text format used in HIPO file headers:

{BankName/group/item}{col1/T,col2/T,...}

Display

void show();

Example

// Create and configure a schema
hipo::schema s("REC::Particle", 300, 1);
s.parse("pid/I,px/F,py/F,pz/F,vx/D,vy/D,vz/D,charge/B,status/L");

// Query schema properties
printf("Name: %s\n", s.getName().c_str());
printf("Columns: %d\n", s.getEntries());
printf("Row length: %d bytes\n", s.getRowLength());

// Column lookup
int pidCol = s.getEntryOrder("pid");  // 0
int pxCol  = s.getEntryOrder("px");   // 1

// Check existence
if (s.exists("missing_column")) { /* ... */ }

// Add to dictionary
hipo::dictionary dict;
dict.addSchema(s);

// Retrieve from dictionary
auto& schema = dict.getSchema("REC::Particle");