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>
|
template<class M>
|
||||||
void makeG4System(M& m, std::string name){
|
void makeG4System(M& m, std::string name){
|
||||||
py::class_<G4System>(m, name.data()).def(py::init())
|
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_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_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"))
|
.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(4, "G4_Pb", false);
|
||||||
cw.addLayer(3, "G4_Si", true, 23);
|
cw.addLayer(3, "G4_Si", true, 23);
|
||||||
|
|
||||||
G4System builder;
|
G4System builder(true);
|
||||||
builder.init(cw, true);
|
builder.init(cw);
|
||||||
//builder.run_gui();
|
//builder.run_gui();
|
||||||
builder.run_batch(10000, ((std::string)"e-").data(), 1, 100);
|
builder.run_batch(10000, ((std::string)"e-").data(), 1, 100);
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,15 @@ public:
|
|||||||
|
|
||||||
void printSensorEnergies()const;
|
void printSensorEnergies()const;
|
||||||
|
|
||||||
|
bool isAssigned()const{
|
||||||
|
if(layers.size() == 0){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return layers[0].physicalVolume != nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double xywidth;
|
double xywidth;
|
||||||
|
|||||||
+3
-2
@@ -21,7 +21,7 @@
|
|||||||
class G4System{
|
class G4System{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
G4System(){};
|
G4System(bool Gui=false):gui(Gui){};
|
||||||
~G4System(){
|
~G4System(){
|
||||||
if(visManager != nullptr){
|
if(visManager != nullptr){
|
||||||
delete visManager;
|
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
|
//will use dawn for visualization, also wrap more in python
|
||||||
void run_visualize(const std::string& partSpecies, double minEnergy_GeV, double maxEnergy_GeV);
|
void run_visualize(const std::string& partSpecies, double minEnergy_GeV, double maxEnergy_GeV);
|
||||||
//runs the whole gui if available
|
//runs the whole gui if available
|
||||||
@@ -50,6 +50,7 @@ private:
|
|||||||
|
|
||||||
void check()const;
|
void check()const;
|
||||||
|
|
||||||
|
bool gui;
|
||||||
|
|
||||||
G4RunManager * runManager=nullptr;
|
G4RunManager * runManager=nullptr;
|
||||||
B4::DetectorConstruction * detConstruction=nullptr;
|
B4::DetectorConstruction * detConstruction=nullptr;
|
||||||
|
|||||||
+20
-14
@@ -1,7 +1,11 @@
|
|||||||
|
|
||||||
#include "G4System.hh"
|
#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"};
|
char* argv[]={(char*)"dummy"};
|
||||||
|
|
||||||
@@ -16,12 +20,11 @@ void G4System::init(ConstructionWrapper &CW, bool gui){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// Abort the current run
|
// Abort the current run
|
||||||
runManager->AbortRun(true);
|
G4RunManager::GetRunManager()->AbortRun(true);
|
||||||
|
|
||||||
// Clear any pending events
|
|
||||||
runManager->Clear();
|
|
||||||
first_init = false;
|
first_init = false;
|
||||||
|
//delete actionInitialization;
|
||||||
|
//delete detConstruction;
|
||||||
|
//delete actionInitialization;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -37,24 +40,27 @@ void G4System::init(ConstructionWrapper &CW, bool gui){
|
|||||||
|
|
||||||
runManager->SetUserInitialization(detConstruction);
|
runManager->SetUserInitialization(detConstruction);
|
||||||
|
|
||||||
auto physicsList = new FTFP_BERT;
|
if(first_init){
|
||||||
runManager->SetUserInitialization(physicsList);
|
auto physicsList = new FTFP_BERT;
|
||||||
|
runManager->SetUserInitialization(physicsList);
|
||||||
|
|
||||||
|
|
||||||
actionInitialization = new B4a::ActionInitialization(detConstruction);
|
actionInitialization = new B4a::ActionInitialization(detConstruction);
|
||||||
runManager->SetUserInitialization(actionInitialization);
|
runManager->SetUserInitialization(actionInitialization);
|
||||||
|
}
|
||||||
if(! first_init){
|
if(! first_init){
|
||||||
runManager->GeometryHasBeenModified();
|
G4RunManager::GetRunManager()->GeometryHasBeenModified();
|
||||||
runManager->ReinitializeGeometry();
|
G4RunManager::GetRunManager()->ReinitializeGeometry();
|
||||||
runManager->PhysicsHasBeenModified();
|
|
||||||
runManager->ReinitializePhysics();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize visualization
|
if(visManager == nullptr){
|
||||||
|
// Initialize visualization
|
||||||
//
|
//
|
||||||
visManager = new G4VisExecutive;
|
visManager = new G4VisExecutive;
|
||||||
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
|
// G4VisExecutive can take a verbosity argument - see /vis/verbose guidance.
|
||||||
// G4VisManager* visManager = new G4VisExecutive("Quiet");
|
// G4VisManager* visManager = new G4VisExecutive("Quiet");
|
||||||
|
|
||||||
|
}
|
||||||
visManager->Initialize();
|
visManager->Initialize();
|
||||||
|
|
||||||
// Get the pointer to the User Interface manager
|
// Get the pointer to the User Interface manager
|
||||||
|
|||||||
Reference in New Issue
Block a user