Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions configs/config_ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## XRootD edm4hep source configuration used in continuous integration testing

max_events: 10
random_seed: 1
timeframe_duration: 2000.0 # in ns
bunch_crossing_period: 40.0 # in ns
introduce_offsets: true
Expand Down
1 change: 1 addition & 0 deletions include/MergerConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ struct MergerConfig {
bool introduce_offsets{true};
float timeframe_duration{2000.0f};
float bunch_crossing_period{10.0f};
unsigned int random_seed{0}; // 0 means use random_device

// Config per source
std::vector<struct SourceConfig> sources;
Expand Down
7 changes: 7 additions & 0 deletions src/CommandLineParser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ void CommandLineParser::printUsage(const char* program_name) {
<< " -n, --nevents N Maximum number of timeframes to generate (default: 100)\n"
<< " -d, --duration TIME Timeframe duration in ns (default: 20.0)\n"
<< " -p, --bunch-period PERIOD Bunch crossing period in ns (default: 10.0)\n"
<< " --random-seed SEED Random number generator seed (default: 0, use random_device)\n"
<< " -h, --help Show this help message\n"
<< "\nDefault Source Options (backward compatibility):\n"
<< " -f, --frequency FREQ Mean event frequency (events/ns) (default: 1.0)\n"
Expand Down Expand Up @@ -152,6 +153,7 @@ void CommandLineParser::loadYAMLConfig(const std::string& config_file, MergerCon
if (yaml["max_events"]) config.max_events = yaml["max_events"].as<size_t>();
if (yaml["timeframe_duration"]) config.timeframe_duration = yaml["timeframe_duration"].as<float>();
if (yaml["bunch_crossing_period"]) config.bunch_crossing_period = yaml["bunch_crossing_period"].as<float>();
if (yaml["random_seed"]) config.random_seed = yaml["random_seed"].as<unsigned int>();
if (yaml["introduce_offsets"]) config.introduce_offsets = yaml["introduce_offsets"].as<bool>();

if (yaml["sources"]) {
Expand Down Expand Up @@ -280,6 +282,7 @@ void CommandLineParser::printConfiguration(const MergerConfig& config) {
std::cout << "Max events: " << config.max_events << std::endl;
std::cout << "Timeframe duration: " << config.timeframe_duration << " ns" << std::endl;
std::cout << "Bunch crossing period: " << config.bunch_crossing_period << " ns" << std::endl;
std::cout << "Random seed: " << config.random_seed << (config.random_seed == 0 ? " (using random_device)" : "") << std::endl;
std::cout << "Introduce offsets: " << (config.introduce_offsets ? "true" : "false") << std::endl;
std::cout << "================================================" << std::endl;
}
Expand Down Expand Up @@ -328,6 +331,7 @@ MergerConfig CommandLineParser::parse(int argc, char* argv[]) {
{"duration", required_argument, 0, 'd'},
{"frequency", required_argument, 0, 'f'},
{"bunch-period", required_argument, 0, 'p'},
{"random-seed", required_argument, 0, 1005},
{"use-bunch-crossing", no_argument, 0, 'b'},
{"static-events", no_argument, 0, 's'},
{"events-per-frame", required_argument, 0, 'e'},
Expand Down Expand Up @@ -383,6 +387,9 @@ MergerConfig CommandLineParser::parse(int argc, char* argv[]) {
case 1003:
default_source.generator_status_offset = std::stoi(optarg);
break;
case 1005:
config.random_seed = std::stoul(optarg);
break;
case 'h':
printUsage(new_argv[0]);
std::exit(0);
Expand Down
2 changes: 1 addition & 1 deletion src/TimeframeBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <chrono>

TimeframeBuilder::TimeframeBuilder(const MergerConfig& config)
: m_config(config), gen(rd()) {}
: m_config(config), gen(config.random_seed == 0 ? rd() : config.random_seed) {}

void TimeframeBuilder::setDataHandler(std::unique_ptr<DataHandler> handler) {
data_handler_ = std::move(handler);
Expand Down