From a03b3d780a44e20a33db92b10c7fcc8148eed875 Mon Sep 17 00:00:00 2001 From: Jan Kieseler Date: Fri, 8 Sep 2023 22:53:07 +0200 Subject: [PATCH] fixes --- CMakeLists.txt | 6 +++--- bind/bindings.cpp | 4 ++-- bind/example.py | 4 ++-- exampleB4a.cc | 3 ++- include/SystemBuilder.hh | 2 +- src/DetectorConstruction.cc | 2 ++ src/SystemBuilder.cc | 6 +++--- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77a398a..b974414 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,9 +43,9 @@ target_link_libraries(exampleB4a ${Geant4_LIBRARIES}) file(GLOB_RECURSE SOURCES "${PROJECT_SOURCE_DIR}/src/*.cc" ) add_subdirectory(lib/pybind11) -pybind11_add_module(bindings ${SOURCES} "${PROJECT_SOURCE_DIR}/bind/bindings.cpp") -target_include_directories(bindings PUBLIC lib/pybind11/include) -target_link_libraries(bindings PUBLIC ${Geant4_LIBRARIES}) +pybind11_add_module(minicalo ${SOURCES} "${PROJECT_SOURCE_DIR}/bind/bindings.cpp") +target_include_directories(minicalo PUBLIC lib/pybind11/include) +target_link_libraries(minicalo PUBLIC ${Geant4_LIBRARIES}) #---------------------------------------------------------------------------- # Copy all scripts to the build directory, i.e. the directory in which we diff --git a/bind/bindings.cpp b/bind/bindings.cpp index 722a6fb..0658f5e 100644 --- a/bind/bindings.cpp +++ b/bind/bindings.cpp @@ -25,8 +25,8 @@ void makeSystemBuilder(M& m, std::string name){ .def("visualize", &SystemBuilder::visualize); } -PYBIND11_MODULE(bindings, m) { - m.doc() = "pybind11 example plugin"; // optional module docstring +PYBIND11_MODULE(minicalo, m) { + m.doc() = "pybind11 plugin"; // optional module docstring makeConstructionWrapper(m, "ConstructionWrapper"); makeSystemBuilder(m, "SystemBuilder"); } \ No newline at end of file diff --git a/bind/example.py b/bind/example.py index 2865bed..5d76507 100644 --- a/bind/example.py +++ b/bind/example.py @@ -1,5 +1,5 @@ -from bindings import ConstructionWrapper, SystemBuilder +from minicalo import ConstructionWrapper, SystemBuilder cw = ConstructionWrapper() cw.addLayer(10,"G4_Si",True) @@ -8,4 +8,4 @@ cw.addLayer(10,"G4_Si",False) sb = SystemBuilder() sb.init(cw) -sb.run_batch(100, "e-", 1000, 5000) \ No newline at end of file +sb.run_batch(100, "e-", 1000, 5000) diff --git a/exampleB4a.cc b/exampleB4a.cc index 6eda7f0..2b49781 100644 --- a/exampleB4a.cc +++ b/exampleB4a.cc @@ -273,7 +273,7 @@ int main(){ SystemBuilder builder; builder.init(cw, true); //builder.run_gui(); - builder.run_batch(10000, "e-", 1, 100); + builder.run_batch(10000, ((std::string)"e-").data(), 1, 100); //run(cw, 1000, "e-", 1, 100, true); @@ -281,3 +281,4 @@ int main(){ } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... + diff --git a/include/SystemBuilder.hh b/include/SystemBuilder.hh index cd9d0cf..c57a076 100644 --- a/include/SystemBuilder.hh +++ b/include/SystemBuilder.hh @@ -31,7 +31,7 @@ SystemBuilder(){}; void init(ConstructionWrapper &cw, bool gui=false); void visualize()const{} //TBI void run_gui(); -void run_batch(int nEvents, std::string partSpecies, double minEnergy, double maxEnergy); +void run_batch(int nEvents, char* partSpecies, double minEnergy, double maxEnergy); private: diff --git a/src/DetectorConstruction.cc b/src/DetectorConstruction.cc index 56e8a3b..7c0ccd8 100644 --- a/src/DetectorConstruction.cc +++ b/src/DetectorConstruction.cc @@ -251,6 +251,7 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes() layer.assignPhysicalVolume(ppv); //maybe this needs to be ppv - check // assign sensors to layer by copyNumber; access the copyNumber of the volumes + if(layer.isActive){ for(int i = 0; i < layer.nx*layer.ny; i++){ Sensor sensor; @@ -263,6 +264,7 @@ G4VPhysicalVolume* DetectorConstruction::DefineVolumes() } position += layer.thickness / 2 *cm; //assign the physical volume to the layer + } // // Visualization attributes diff --git a/src/SystemBuilder.cc b/src/SystemBuilder.cc index a062ce4..0267780 100644 --- a/src/SystemBuilder.cc +++ b/src/SystemBuilder.cc @@ -59,10 +59,10 @@ void SystemBuilder::run_gui(){ } } -void SystemBuilder::run_batch(int nEvents, std::string partSpecies, double minEnergy, double maxEnergy){ - G4String partSpec = (G4String)partSpecies; +void SystemBuilder::run_batch(int nEvents, char* partSpecies, double minEnergy, double maxEnergy){ + G4String partSpec = partSpecies; G4cout << "running with particle species " << partSpec << G4endl; actionInitialization->setGeneratorProperties(minEnergy, maxEnergy, partSpec); UImanager->ApplyCommand("/run/initialize"); runManager->BeamOn(nEvents); -} \ No newline at end of file +}