Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions form/form_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
#include "form/form.hpp"
#include "form/technology.hpp"

#include <cassert>
#include <iostream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <unordered_map>

namespace {

Expand Down Expand Up @@ -52,10 +57,10 @@ namespace {
// STEP 1: Extract metadata from Phlex's product_store

// Extract creator (algorithm name)
std::string creator = store.source();
auto creator = store.source();

// Extract segment ID (partition) - extract once for entire store
std::string segment_id = store.index()->to_string();
auto segment_id = store.index()->to_string();

std::cout << "\n=== FormOutputModule::save_data_products ===\n";
std::cout << "Creator: " << creator << "\n";
Expand All @@ -74,6 +79,7 @@ namespace {
for (auto const& [product_name, product_ptr] : store) {
// product_name: "tracks" (from the map key)
// product_ptr: pointer to the actual product data
assert(product_ptr && "store should not contain null product_ptr");

std::cout << " Product: " << product_name << "\n";

Expand All @@ -94,8 +100,8 @@ namespace {
}

private:
std::string m_output_file;
int m_technology;
std::string const m_output_file;
int const m_technology;
std::unique_ptr<form::experimental::form_interface> m_form_interface;
};

Expand All @@ -106,26 +112,26 @@ PHLEX_REGISTER_ALGORITHMS(m, config)
std::cout << "Registering FORM output module...\n";

// Extract configuration from Phlex config
std::string output_file = config.get<std::string>("output_file", "output.root");
std::string tech_string = config.get<std::string>("technology", "ROOT_TTREE");
std::string const output_file = config.get<std::string>("output_file", "output.root");
std::string const tech_string = config.get<std::string>("technology", "ROOT_TTREE");

std::cout << "Configuration:\n";
std::cout << " output_file: " << output_file << "\n";
std::cout << " technology: " << tech_string << "\n";

// Map Phlex config string to FORM technology constant
int technology = form::technology::ROOT_TTREE; // default
std::unordered_map<std::string_view, int> const tech_lookup = {
{"ROOT_TTREE", form::technology::ROOT_TTREE},
{"ROOT_RNTUPLE", form::technology::ROOT_RNTUPLE},
{"HDF5", form::technology::HDF5}};

if (tech_string == "ROOT_TTREE") {
technology = form::technology::ROOT_TTREE;
} else if (tech_string == "ROOT_RNTUPLE") {
technology = form::technology::ROOT_RNTUPLE;
} else if (tech_string == "HDF5") {
technology = form::technology::HDF5;
} else {
auto it = tech_lookup.find(tech_string);

if (it == tech_lookup.end()) {
throw std::runtime_error("Unknown technology: " + tech_string);
}

int const technology = it->second;

auto products_to_save = config.get<std::vector<std::string>>("products");

// Phlex needs an OBJECT
Expand Down
Loading