python bindings to be tested (arm vs intep python issues)

This commit is contained in:
Jan Kieseler
2023-09-08 16:40:28 +02:00
parent a9fc5d8a9a
commit a01466f649
7 changed files with 302 additions and 7 deletions
+109 -1
View File
@@ -41,8 +41,15 @@
#include "ConstructionWrapper.hh"
#include "SystemBuilder.hh"
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
namespace {
void PrintUsage() {
G4cerr << " Usage: " << G4endl;
@@ -55,7 +62,7 @@ namespace {
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
int main(int argc,char** argv)
int main2(int argc,char** argv)
{
// Evaluate arguments
//
@@ -135,6 +142,8 @@ int main(int argc,char** argv)
auto actionInitialization = new B4a::ActionInitialization(detConstruction);
runManager->SetUserInitialization(actionInitialization);
actionInitialization->setGeneratorProperties(100, 1000, "e-");
// Initialize visualization
//
auto visManager = new G4VisExecutive;
@@ -170,6 +179,105 @@ int main(int argc,char** argv)
delete visManager;
delete runManager;
delete cw;
return 0;
}
//later
//class Runner {
//public:
// void initialize(ConstructionWrapper CW, bool gui=false);
// void run(int nEvents, std::string partSpecies, double minEnergy, double maxEnergy);
//}
void run(ConstructionWrapper CW, int nEvents, std::string partSpecies, double minEnergy, double maxEnergy, bool gui=false){
char* argv[]={(char*)"dummy"};
// Construct the default run manager
//
auto* runManager =
G4RunManagerFactory::CreateRunManager(G4RunManagerType::Default);
runManager->SetNumberOfThreads(1);
ConstructionWrapper * cw = &CW;
G4String session;
G4UIExecutive* ui = nullptr;
if ( gui ) {
ui = new G4UIExecutive((int)1, argv, session);
}
// Set mandatory initialization classes
//
auto detConstruction = new B4::DetectorConstruction(cw);
runManager->SetUserInitialization(detConstruction);
auto physicsList = new FTFP_BERT;
runManager->SetUserInitialization(physicsList);
auto actionInitialization = new B4a::ActionInitialization(detConstruction);
runManager->SetUserInitialization(actionInitialization);
actionInitialization->setGeneratorProperties(minEnergy, maxEnergy, partSpecies);
// Initialize visualization
//
auto visManager = new G4VisExecutive;
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
// G4VisManager* visManager = new G4VisExecutive("Quiet");
visManager->Initialize();
// Get the pointer to the User Interface manager
auto UImanager = G4UImanager::GetUIpointer();
// Process macro or start UI session
//
if ( gui ) {
// interactive mode : define UI session
UImanager->ApplyCommand("/control/execute init_vis.mac");
if (ui->IsGUI()) {
UImanager->ApplyCommand("/control/execute gui.mac");
}
ui->SessionStart();
delete ui;
}
else {
G4String command = "/control/execute run1.mac";
UImanager->ApplyCommand("/run/initialize");
UImanager->ApplyCommand("/run/beamOn "+ std::to_string(nEvents));
}
// Job termination
// Free the store: user actions, physics_list and detector_description are
// owned and deleted by the run manager, so they should not be deleted
// in the main() program !
delete visManager;
delete runManager;
}
int main(){
ConstructionWrapper cw;
//to be moved
cw.addLayer(1, "G4_Pb", false);
cw.addLayer(10, "G4_Si", true, 9);
cw.addLayer(1, "G4_Pb", false);
cw.addLayer(20, "G4_Si", true, 15);
cw.addLayer(4, "G4_Pb", false);
cw.addLayer(3, "G4_Si", true, 23);
SystemBuilder builder;
builder.init(cw, true);
//builder.run_gui();
builder.run_batch(10000, "e-", 1, 100);
//run(cw, 1000, "e-", 1, 100, true);
return 0;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....