Add per-step Spawning ntuple, Geant4 submodule superbuild, and standalone dataset executables #1
+14
-4
@@ -8,6 +8,7 @@
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int nEvents = 10;
|
||||
double energy_GeV = 1.0;
|
||||
|
||||
int seed = -1;
|
||||
if (const char* seedEnv = std::getenv("MINICALOSIM_SEED")) {
|
||||
@@ -21,11 +22,11 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (argc > 2) {
|
||||
std::cerr << "Usage: run_pbwo4 [nEvents]" << std::endl;
|
||||
if (argc > 3) {
|
||||
std::cerr << "Usage: run_pbwo4 [nEvents] [energy_GeV]" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if (argc == 2) {
|
||||
if (argc >= 2) {
|
||||
try {
|
||||
nEvents = std::stoi(argv[1]);
|
||||
if (nEvents <= 0) throw std::invalid_argument("must be positive");
|
||||
@@ -34,6 +35,15 @@ int main(int argc, char** argv) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (argc == 3) {
|
||||
try {
|
||||
energy_GeV = std::stod(argv[2]);
|
||||
if (energy_GeV <= 0) throw std::invalid_argument("must be positive");
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Invalid energy_GeV '" << argv[2] << "': " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
std::string outfile = "pbwo4_" + std::to_string(nEvents) + "events_hits.root";
|
||||
|
||||
@@ -42,7 +52,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
G4System g4;
|
||||
g4.init(gd, seed);
|
||||
g4.run_batch(nEvents, {"e-"}, 1.0, 1.0, outfile);
|
||||
g4.run_batch(nEvents, {"e-"}, energy_GeV, energy_GeV, outfile);
|
||||
|
||||
std::cout << "Saved " << nEvents << " events to " << outfile << std::endl;
|
||||
return 0;
|
||||
|
||||
+14
-4
@@ -57,7 +57,7 @@ const std::vector<std::pair<std::string, GeometryDescriptor (*)()>> kConfigs = {
|
||||
};
|
||||
|
||||
void printUsage() {
|
||||
std::cerr << "Usage: run_sampling [configName|configIndex] [nEvents]" << std::endl;
|
||||
std::cerr << "Usage: run_sampling [configName|configIndex] [nEvents] [energy_GeV]" << std::endl;
|
||||
std::cerr << "Available configs:" << std::endl;
|
||||
for (std::size_t i = 0; i < kConfigs.size(); ++i) {
|
||||
std::cerr << " " << (i + 1) << ": " << kConfigs[i].first << std::endl;
|
||||
@@ -69,15 +69,16 @@ void printUsage() {
|
||||
int main(int argc, char** argv) {
|
||||
std::string configName = kConfigs.front().first;
|
||||
int nEvents = 10;
|
||||
double energy_GeV = 1.0;
|
||||
|
||||
if (argc > 3) {
|
||||
if (argc > 4) {
|
||||
printUsage();
|
||||
return 1;
|
||||
}
|
||||
if (argc >= 2) {
|
||||
configName = argv[1];
|
||||
}
|
||||
if (argc == 3) {
|
||||
if (argc >= 3) {
|
||||
try {
|
||||
nEvents = std::stoi(argv[2]);
|
||||
if (nEvents <= 0) throw std::invalid_argument("must be positive");
|
||||
@@ -86,6 +87,15 @@ int main(int argc, char** argv) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (argc == 4) {
|
||||
try {
|
||||
energy_GeV = std::stod(argv[3]);
|
||||
if (energy_GeV <= 0) throw std::invalid_argument("must be positive");
|
||||
} catch (const std::exception& e) {
|
||||
std::cerr << "Invalid energy_GeV '" << argv[3] << "': " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
GeometryDescriptor (*builder)() = nullptr;
|
||||
try {
|
||||
@@ -130,7 +140,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
G4System g4;
|
||||
g4.init(gd, seed);
|
||||
g4.run_batch(nEvents, {"e-"}, 1.0, 1.0, outfile);
|
||||
g4.run_batch(nEvents, {"e-"}, energy_GeV, energy_GeV, outfile);
|
||||
|
||||
std::cout << "Saved " << nEvents << " events to " << outfile << std::endl;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user