Skip to content

Commit

Permalink
Merge pull request #127 from rest-for-physics/lobis-download
Browse files Browse the repository at this point in the history
Option to set run number from cli
  • Loading branch information
lobis authored Mar 10, 2024
2 parents 8d720c7 + 3a0fdd0 commit 061aaf2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ struct Options {
int nRequestedEntries = 0;
int timeLimitSeconds = 0;

int runNumber = -1;

// reference to original argc and argv necessary to pass to G4UIExecutive
int argc;
char** argv;
Expand Down
17 changes: 16 additions & 1 deletion src/Application.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,18 @@ Options ProcessCommandLineOptions(int argc, char* const argv[]) {
cerr << "--time option requires one argument." << endl;
exit(1);
}
} else if (arg == "--runNumber") {
if (i + 1 < argc) { // Make sure we aren't at the end of argv!
options.runNumber =
stoi(argv[++i]); // Increment 'i' so we don't get the argument as the next argv[i].
if (options.runNumber < 0) {
cout << "--runNumber option error: runNumber cannot be negative" << endl;
exit(1);
}
} else {
cerr << "--runNumber option requires one argument." << endl;
exit(1);
}
} else {
const string argument = argv[i];
if (argument[0] == '-') {
Expand Down Expand Up @@ -347,6 +359,10 @@ void Application::Run(const CommandLineOptions::Options& options) {

run->LoadConfigFromFile(inputRmlClean);

if (options.runNumber >= 0) {
run->SetRunNumber(options.runNumber);
}

if (!options.outputFile.empty()) {
run->SetOutputFileName(options.outputFile);
}
Expand All @@ -362,7 +378,6 @@ void Application::Run(const CommandLineOptions::Options& options) {

run->AddMetadata(fSimulationManager.GetRestMetadata());
run->AddMetadata(fSimulationManager.GetRestPhysicsLists());

run->PrintMetadata();

run->FormOutputFile();
Expand Down

0 comments on commit 061aaf2

Please sign in to comment.