detector change might work - might
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ void makeConstructionWrapper(M & m, std::string name){
|
||||
template<class M>
|
||||
void makeG4System(M& m, std::string name){
|
||||
py::class_<G4System>(m, name.data()).def(py::init())
|
||||
.def("init", &G4System::init, py::arg("cw"), py::arg("gui")=false)
|
||||
.def("init", &G4System::init, py::arg("cw"))
|
||||
.def("run_gui", &G4System::run_gui)
|
||||
.def("run_batch", &G4System::run_batch, py::arg("nEvents"), py::arg("partSpecies"), py::arg("minEnergy_GeV"), py::arg("maxEnergy_GeV"))
|
||||
.def("run_visualize", &G4System::run_visualize, py::arg("partSpecies"), py::arg("minEnergy_GeV"), py::arg("maxEnergy_GeV"))
|
||||
|
||||
+2
-2
@@ -270,8 +270,8 @@ int main(){
|
||||
cw.addLayer(4, "G4_Pb", false);
|
||||
cw.addLayer(3, "G4_Si", true, 23);
|
||||
|
||||
G4System builder;
|
||||
builder.init(cw, true);
|
||||
G4System builder(true);
|
||||
builder.init(cw);
|
||||
//builder.run_gui();
|
||||
builder.run_batch(10000, ((std::string)"e-").data(), 1, 100);
|
||||
|
||||
|
||||
@@ -90,6 +90,15 @@ public:
|
||||
|
||||
void printSensorEnergies()const;
|
||||
|
||||
bool isAssigned()const{
|
||||
if(layers.size() == 0){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
return layers[0].physicalVolume != nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
double xywidth;
|
||||
|
||||
+3
-2
@@ -21,7 +21,7 @@
|
||||
class G4System{
|
||||
public:
|
||||
|
||||
G4System(){};
|
||||
G4System(bool Gui=false):gui(Gui){};
|
||||
~G4System(){
|
||||
if(visManager != nullptr){
|
||||
delete visManager;
|
||||
@@ -31,7 +31,7 @@ G4System(){};
|
||||
};
|
||||
|
||||
|
||||
void init(ConstructionWrapper &cw, bool gui=false);
|
||||
void init(ConstructionWrapper &cw);
|
||||
//will use dawn for visualization, also wrap more in python
|
||||
void run_visualize(const std::string& partSpecies, double minEnergy_GeV, double maxEnergy_GeV);
|
||||
//runs the whole gui if available
|
||||
@@ -50,6 +50,7 @@ private:
|
||||
|
||||
void check()const;
|
||||
|
||||
bool gui;
|
||||
|
||||
G4RunManager * runManager=nullptr;
|
||||
B4::DetectorConstruction * detConstruction=nullptr;
|
||||
|
||||
+20
-14
@@ -1,7 +1,11 @@
|
||||
|
||||
#include "G4System.hh"
|
||||
|
||||
void G4System::init(ConstructionWrapper &CW, bool gui){
|
||||
void G4System::init(ConstructionWrapper &CW){
|
||||
|
||||
if(CW.isAssigned()){
|
||||
throw std::runtime_error("ConstructionWrapper already assigned");
|
||||
}
|
||||
|
||||
char* argv[]={(char*)"dummy"};
|
||||
|
||||
@@ -16,12 +20,11 @@ void G4System::init(ConstructionWrapper &CW, bool gui){
|
||||
}
|
||||
else{
|
||||
// Abort the current run
|
||||
runManager->AbortRun(true);
|
||||
|
||||
// Clear any pending events
|
||||
runManager->Clear();
|
||||
G4RunManager::GetRunManager()->AbortRun(true);
|
||||
first_init = false;
|
||||
|
||||
//delete actionInitialization;
|
||||
//delete detConstruction;
|
||||
//delete actionInitialization;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,24 +40,27 @@ void G4System::init(ConstructionWrapper &CW, bool gui){
|
||||
|
||||
runManager->SetUserInitialization(detConstruction);
|
||||
|
||||
auto physicsList = new FTFP_BERT;
|
||||
runManager->SetUserInitialization(physicsList);
|
||||
if(first_init){
|
||||
auto physicsList = new FTFP_BERT;
|
||||
runManager->SetUserInitialization(physicsList);
|
||||
|
||||
|
||||
actionInitialization = new B4a::ActionInitialization(detConstruction);
|
||||
runManager->SetUserInitialization(actionInitialization);
|
||||
|
||||
}
|
||||
if(! first_init){
|
||||
runManager->GeometryHasBeenModified();
|
||||
runManager->ReinitializeGeometry();
|
||||
runManager->PhysicsHasBeenModified();
|
||||
runManager->ReinitializePhysics();
|
||||
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||
}
|
||||
|
||||
// Initialize visualization
|
||||
if(visManager == nullptr){
|
||||
// Initialize visualization
|
||||
//
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user