Files
minicalosim/run_pbwo4.cc
T
2026-06-10 09:19:55 +02:00

37 lines
958 B
C++

#include "GeometryDescriptor.hh"
#include "G4System.hh"
#include <iostream>
#include <string>
#include <vector>
int main(int argc, char** argv) {
int nEvents = 10;
if (argc > 2) {
std::cerr << "Usage: run_pbwo4 [nEvents]" << std::endl;
return 1;
}
if (argc == 2) {
try {
nEvents = std::stoi(argv[1]);
if (nEvents <= 0) throw std::invalid_argument("must be positive");
} catch (const std::exception& e) {
std::cerr << "Invalid nEvents '" << argv[1] << "': " << e.what() << std::endl;
return 1;
}
}
std::string outfile = "pbwo4_" + std::to_string(nEvents) + "events_hits.root";
GeometryDescriptor gd;
gd.addLayer(20.0, "G4_PbWO4", true, 10, 10);
G4System g4;
g4.init(gd, -1);
g4.run_batch(nEvents, {"e-"}, 1.0, 1.0, outfile);
std::cout << "Saved " << nEvents << " events to " << outfile << std::endl;
return 0;
}