Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,12 @@ class Application {
static void ListCommands(const std::string& directory);
static G4UImanager* GetUIManager();

static std::filesystem::path GetTemporaryApplicationDirectory();

const PrimaryGeneratorAction& GetPrimaryGeneratorAction() const;
const StackingAction& GetStackingAction() const;
const DetectorConstruction& GetDetectorConstruction() const;

static std::filesystem::path GetTemporaryApplicationDirectory();
const PhysicsList& GetPhysicsList() const;
};

}// namespace geant4_app
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class DetectorConstruction : public G4VUserDetectorConstruction {
void SetGDML(const std::string& gdml);

static std::set<std::string> GetMaterialNames();
static std::set<std::string> GetNISTMaterialNames();
static std::set<std::string> GetLogicalVolumeNames();
static std::set<std::string> GetPhysicalVolumeNames();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ namespace geant4_app {
class PhysicsList : public G4VModularPhysicsList {
public:
PhysicsList();

static std::set<std::string> GetPhysicsListNames();
static std::set<std::string> GetProcessNames();
};
}// namespace geant4_app
11 changes: 11 additions & 0 deletions src/geant4_application/src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ const DetectorConstruction& Application::GetDetectorConstruction() const {
return *detectorConstruction;
}

const PhysicsList& Application::GetPhysicsList() const {
if (runManager == nullptr) {
throw runtime_error("RunManager needs to be set up first");
}
const auto physicsList = dynamic_cast<const PhysicsList*>(runManager->GetUserPhysicsList());
if (physicsList == nullptr) {
throw runtime_error("Physics list is not available");
}
return *physicsList;
}

filesystem::path Application::GetTemporaryApplicationDirectory() {
const auto dir = filesystem::temp_directory_path() / "geant4_python_application";
if (!filesystem::exists(dir)) {
Expand Down
9 changes: 9 additions & 0 deletions src/geant4_application/src/DetectorConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ set<string> DetectorConstruction::GetMaterialNames() {
return names;
}

set<string> DetectorConstruction::GetNISTMaterialNames() {
set<string> names;
const auto materialTable = G4NistManager::Instance()->GetNistMaterialNames();
for (const auto& material: materialTable) {
names.insert(material);
}
return names;
}

set<string> DetectorConstruction::GetLogicalVolumeNames() {
set<string> names;
const auto logicalVolumeTable = G4LogicalVolumeStore::GetInstance();
Expand Down
24 changes: 24 additions & 0 deletions src/geant4_application/src/PhysicsList.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@

#include "geant4_application/PhysicsList.h"

#include <G4Box.hh>
#include <G4DecayPhysics.hh>
#include <G4EmExtraPhysics.hh>
#include <G4EmStandardPhysics.hh>
#include <G4EmStandardPhysics_option4.hh>
#include <G4HadronElasticPhysics.hh>
#include <G4HadronElasticPhysicsHP.hh>
#include <G4HadronPhysicsFTFP_BERT.hh>
#include <G4HadronPhysicsQGSP_BIC_HP.hh>
#include <G4HadronicProcessStore.hh>
#include <G4IonPhysics.hh>
#include <G4Neutron.hh>
#include <G4NeutronTrackingCut.hh>
#include <G4NistManager.hh>
#include <G4PVPlacement.hh>
#include <G4ProcessTable.hh>
#include <G4ProcessTableMessenger.hh>
#include <G4RadioactiveDecayPhysics.hh>
#include <G4StoppingPhysics.hh>
#include <G4SystemOfUnits.hh>
#include <G4VModularPhysicsList.hh>
#include <G4VUserDetectorConstruction.hh>
#include <QBBC.hh>

using namespace geant4_app;

Expand Down Expand Up @@ -42,3 +54,15 @@ PhysicsList::PhysicsList() : G4VModularPhysicsList() {
// Neutron tracking cut
RegisterPhysics(new G4NeutronTrackingCut());
}

std::set<std::string> PhysicsList::GetPhysicsListNames() {
std::set<std::string> names;
// TODO
return names;
}

std::set<std::string> PhysicsList::GetProcessNames() {
std::set<std::string> names;
// TODO
return names;
}
8 changes: 8 additions & 0 deletions src/geant4_python_application/physics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from __future__ import annotations

from geant4_python_application import Application


class Physics:
def __init__(self, application: Application):
self._application = application
3 changes: 2 additions & 1 deletion src/python/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ PYBIND11_MODULE(_geant4_application, m) {
.def_static("list_commands", &Application::ListCommands, py::arg("directory") = "/")
.def_property_readonly("generator", &Application::GetPrimaryGeneratorAction, py::return_value_policy::reference_internal)
.def_property_readonly("detector", &Application::GetDetectorConstruction, py::return_value_policy::reference_internal)
.def_property_readonly("stacking", &Application::GetStackingAction, py::return_value_policy::reference_internal);
.def_property_readonly("stacking", &Application::GetStackingAction, py::return_value_policy::reference_internal)
.def_property_readonly("physics", &Application::GetPhysicsList, py::return_value_policy::reference_internal);

py::class_<PrimaryGeneratorAction>(m, "PrimaryGeneratorAction")
.def_property_static(
Expand Down