Skip to content

Commit a2a292d

Browse files
plexoosCopilot
andauthored
feat(config): route SEvt output directory through app config (#322)
This PR makes `gphox::Config` the authoritative source for runtime configuration parameters that are applied to supported binaries execution. The main focus is refactoring event runtime controls, especially `event.mode` and `event.output_dir`, so they are read from the app config JSON and then synchronized into `SEventConfig` from one place. - Added `--config` support to the affected binaries so runtime behavior can be selected via config file. - Updated tests/scripts to use the config-controlled output location instead of relying on fake `USER`/`GEOM` environment setup. - Eliminated the need to set `USER` and `GEOM` environment variables for the supported binaries/tests that now route output through `Config`. --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 5f20ed4 commit a2a292d

12 files changed

Lines changed: 289 additions & 107 deletions

config/dev.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
"event": {
2727
"mode": "DebugLite",
28-
"maxslot": 1000000
28+
"maxslot": 1000000,
29+
"output_dir": "./"
2930
}
3031
}

src/GPUCerenkov.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "sysrap/OPTICKS_LOG.hh"
1414

1515
#include "GPUCerenkov.h"
16+
#include "config.h"
1617

1718
#include "G4RunManager.hh"
1819
#include "G4RunManagerFactory.hh"
@@ -56,7 +57,7 @@ int main(int argc, char **argv)
5657

5758
argparse::ArgumentParser program("GPUCerenkov", "0.0.0");
5859

59-
string gdml_file, macro_name;
60+
string gdml_file, config_name, macro_name;
6061
bool interactive;
6162

6263
program.add_argument("-g", "--gdml")
@@ -65,6 +66,12 @@ int main(int argc, char **argv)
6566
.nargs(1)
6667
.store_into(gdml_file);
6768

69+
program.add_argument("-c", "--config")
70+
.help("the name of a config file")
71+
.default_value(string("dev"))
72+
.nargs(1)
73+
.store_into(config_name);
74+
6875
program.add_argument("-m", "--macro")
6976
.help("path to G4 macro")
7077
.default_value(string("run.mac"))
@@ -87,6 +94,8 @@ int main(int argc, char **argv)
8794
exit(EXIT_FAILURE);
8895
}
8996

97+
gphox::Config{config_name};
98+
9099
// Configure Geant4
91100
// The physics list must be instantiated before other user actions
92101
G4VModularPhysicsList *physics = new FTFP_BERT;

src/GPUPhotonFileSource.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "sysrap/OPTICKS_LOG.hh"
1515

1616
#include "GPUPhotonFileSource.h"
17+
#include "config.h"
1718

1819
using namespace std;
1920

@@ -23,7 +24,7 @@ int main(int argc, char **argv)
2324

2425
argparse::ArgumentParser program("GPUPhotonFileSource", "0.0.0");
2526

26-
string gdml_file, macro_name, photon_file;
27+
string gdml_file, config_name, macro_name, photon_file;
2728
bool interactive;
2829

2930
program.add_argument("-g", "--gdml")
@@ -32,6 +33,12 @@ int main(int argc, char **argv)
3233
.nargs(1)
3334
.store_into(gdml_file);
3435

36+
program.add_argument("-c", "--config")
37+
.help("the name of a config file")
38+
.default_value(string("dev"))
39+
.nargs(1)
40+
.store_into(config_name);
41+
3542
program.add_argument("-p", "--photons")
3643
.help("path to input photon text file (one photon per line: pos_x pos_y pos_z time mom_x mom_y mom_z pol_x "
3744
"pol_y pol_z wavelength)")
@@ -75,6 +82,8 @@ int main(int argc, char **argv)
7582
CLHEP::HepRandom::setTheSeed(seed);
7683
G4cout << "Random seed set to: " << seed << G4endl;
7784

85+
gphox::Config{config_name};
86+
7887
// Configure Geant4
7988
// The physics list must be instantiated before other user actions
8089
G4VModularPhysicsList *physics = new FTFP_BERT;

src/GPURaytrace.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "sysrap/OPTICKS_LOG.hh"
1414

1515
#include "GPURaytrace.h"
16+
#include "config.h"
1617

1718
#include "G4RunManager.hh"
1819
#include "G4RunManagerFactory.hh"
@@ -53,7 +54,7 @@ int main(int argc, char **argv)
5354

5455
argparse::ArgumentParser program("GPURaytrace", "0.0.0");
5556

56-
string gdml_file, macro_name;
57+
string gdml_file, config_name, macro_name;
5758
bool interactive;
5859

5960
program.add_argument("-g", "--gdml")
@@ -62,6 +63,12 @@ int main(int argc, char **argv)
6263
.nargs(1)
6364
.store_into(gdml_file);
6465

66+
program.add_argument("-c", "--config")
67+
.help("the name of a config file")
68+
.default_value(string("dev"))
69+
.nargs(1)
70+
.store_into(config_name);
71+
6572
program.add_argument("-m", "--macro")
6673
.help("path to G4 macro")
6774
.default_value(string("run.mac"))
@@ -98,6 +105,8 @@ int main(int argc, char **argv)
98105
CLHEP::HepRandom::setTheSeed(seed);
99106
G4cout << "Random seed set to: " << seed << G4endl;
100107

108+
gphox::Config{config_name};
109+
101110
// Configure Geant4
102111
// The physics list must be instantiated before other user actions
103112
G4VModularPhysicsList *physics = new FTFP_BERT;

0 commit comments

Comments
 (0)