python bindings to be tested (arm vs intep python issues)
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
#define B4aActionInitialization_h 1
|
||||
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
|
||||
#include "PrimaryGeneratorAction.hh"
|
||||
|
||||
namespace B4
|
||||
{
|
||||
@@ -52,8 +52,17 @@ class ActionInitialization : public G4VUserActionInitialization
|
||||
void BuildForMaster() const override;
|
||||
void Build() const override;
|
||||
|
||||
void setGeneratorProperties(G4double minEnergy, G4double maxEnergy, G4String partSpecies){
|
||||
this->minEnergy = minEnergy;
|
||||
this->maxEnergy = maxEnergy;
|
||||
this->partSpecies = partSpecies;
|
||||
}
|
||||
|
||||
private:
|
||||
B4::DetectorConstruction* fDetConstruction = nullptr;
|
||||
G4double minEnergy;
|
||||
G4double maxEnergy;
|
||||
G4String partSpecies;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
|
||||
#include "ConstructionWrapper.hh"
|
||||
#include <stdexcept>
|
||||
#include "G4RunManagerFactory.hh"
|
||||
#include "DetectorConstruction.hh"
|
||||
#include "ActionInitialization.hh"
|
||||
|
||||
#include "G4RunManagerFactory.hh"
|
||||
#include "G4SteppingVerbose.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UIExecutive.hh"
|
||||
#include "G4VisExecutive.hh"
|
||||
|
||||
#include "FTFP_BERT.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
class SystemBuilder{
|
||||
public:
|
||||
|
||||
SystemBuilder(){};
|
||||
~SystemBuilder(){
|
||||
if(visManager != nullptr){
|
||||
delete visManager;
|
||||
delete runManager;
|
||||
delete ui;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
|
||||
inline void check(){
|
||||
if(runManager == nullptr){
|
||||
throw std::runtime_error("runManager not found");
|
||||
}
|
||||
if(detConstruction == nullptr){
|
||||
throw std::runtime_error("DetectorConstruction not found");
|
||||
}
|
||||
if(actionInitialization == nullptr){
|
||||
throw std::runtime_error("ActionInitialization not found");
|
||||
}
|
||||
if(visManager == nullptr){
|
||||
throw std::runtime_error("VisManager not found");
|
||||
}
|
||||
if(UImanager == nullptr){
|
||||
throw std::runtime_error("UImanager not found");
|
||||
}
|
||||
if(ui == nullptr){
|
||||
throw std::runtime_error("UI not found");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4RunManager * runManager=nullptr;
|
||||
B4::DetectorConstruction * detConstruction=nullptr;
|
||||
B4a::ActionInitialization * actionInitialization=nullptr;
|
||||
G4VisExecutive * visManager=nullptr;
|
||||
G4UImanager * UImanager=nullptr;
|
||||
G4UIExecutive * ui=nullptr;
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user