towards vis
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
|
||||
#ifndef G4SYSTEM_HH
|
||||
#define G4SYSTEM_HH
|
||||
|
||||
#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 G4System{
|
||||
public:
|
||||
|
||||
G4System(){};
|
||||
~G4System(){
|
||||
if(visManager != nullptr){
|
||||
delete visManager;
|
||||
delete runManager;
|
||||
delete ui;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
void init(ConstructionWrapper &cw, bool gui=false);
|
||||
//will use dawn for visualization, also wrap more in python
|
||||
void run_visualize(const std::string& partSpecies, double minEnergy, double maxEnergy);
|
||||
//runs the whole gui if available
|
||||
void run_gui();
|
||||
void run_batch(int nEvents, const std::string& partSpecies, double minEnergy, double maxEnergy);
|
||||
|
||||
void applyUICommand(const std::string& command){
|
||||
check();
|
||||
UImanager->ApplyCommand(command);
|
||||
}
|
||||
|
||||
void displayEvent()const{}; //just a placeholder, this will be implemented in python
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void check()const;
|
||||
|
||||
|
||||
G4RunManager * runManager=nullptr;
|
||||
B4::DetectorConstruction * detConstruction=nullptr;
|
||||
B4a::ActionInitialization * actionInitialization=nullptr;
|
||||
G4VisExecutive * visManager=nullptr;
|
||||
G4UImanager * UImanager=nullptr;
|
||||
G4UIExecutive * ui=nullptr;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
|
||||
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