Skip to content

Utilities

hipo::hipoeventfile

Simplified event file reader with range-based iteration.

hipoeventfile(const char *filename);

dictionary& dictionary();
bool next();
void read(event& evt);

// Range-based iteration
iterator begin();
iterator end();
hipo::hipoeventfile file("data.hipo");
hipo::bank particles(file.dictionary().getSchema("REC::Particle"));

for (auto& event : file) {
    event.read(particles);
    // process...
}

hipo::fusion

Multi-file reader with event merging:

void addFile(const char *filename);
bool next();
void read(event& evt);
dictionary& dictionary();

hipo::reaction

Physics analysis helper with particle identification:

reaction(reader& r, const char *definition);
bool next();
bool hasParticle(int pid);
double px(int index);
double py(int index);
double pz(int index);
double mass();
double missingMass();
hipo::reader reader("data.hipo");
hipo::reaction rxn(reader, "11:2212:211:-211:Kp");

while (rxn.next()) {
    if (rxn.hasParticle(321)) {
        double mm = rxn.missingMass();
    }
}

hipo::tuple

Write flat n-tuple files (text format):

tuple(const char *filename, const char *format);
void fill(double *values);
void close();

hipo::Parser

Expression parser for row filtering:

Parser(const char *expression);
bool evaluate(bank& b, int row);

Used internally by bank::rowlist::filter(const char*). For performance, construct once and reuse:

hipo::Parser parser("pid==11&&charge<0");
while (reader.next(list)) {
    list[0].getMutableRowList().filter(parser);
}

hipo::benchmark

Simple timing utility:

benchmark();
void resume();
void pause();
double getTimeSec();
int    getCounter();
void   show();

hipo::utils

Static utility functions:

static std::string substring(const std::string& str, const char* start, const char* end, int offset);
static int findEndOfStructure(const char* buffer, int size, int group, int item);

hipo::datastream

Abstract I/O abstraction:

class datastream {
    virtual void open(const char *filename) = 0;
    virtual void read(char *buffer, int size) = 0;
    virtual long size() = 0;
    virtual long position() = 0;
    virtual void position(long pos) = 0;
};

Implementations:

  • datastreamLocalFile -- wraps std::ifstream
  • datastreamXrootd -- wraps XrdClient (compile with -D__XROOTD__)

hipo::ThreadPool

Thread pool for parallel processing:

ThreadPool(int numThreads, const std::string& name = "Worker");

template<typename F>
std::future<void> submit(F&& func);

void shutdown();

hipo::ProgressTracker

Visual progress bar for long operations:

ProgressTracker(std::size_t total, Config config = {});
void start();
void increment();
void finish();

Configuration:

struct Config {
    std::size_t bar_width = 40;
    bool show_eta = true;
    bool show_rate = true;
    bool use_colors = true;
    std::string label = "Progress";
};