00001
00002 #include "PhysicsMessenger.hh"
00003
00004
00005 #include "PhysicsListManager.hh"
00006
00007
00008 #include "StringUtil.hh"
00009
00010
00011 #include "G4UIcmdWithABool.hh"
00012 #include "G4UIcmdWithoutParameter.hh"
00013 #include "G4UIdirectory.hh"
00014
00015 namespace slic
00016 {
00017
00018 PhysicsMessenger::PhysicsMessenger()
00019 : m_physicsListDir(0),
00020 m_selectCmd(0)
00021 {
00022 defineCommands();
00023 }
00024
00025 PhysicsMessenger::~PhysicsMessenger()
00026 {}
00027
00028 void PhysicsMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals)
00029 {
00030 std::istringstream is ( ( const char* ) newVals );
00031
00032 std::string s;
00033 is >> s;
00034
00035 PhysicsListManager* mgr = PhysicsListManager::instance();
00036
00037
00038 if ( cmd == m_selectCmd ) {
00039 mgr->setCurrentListName( s );
00040 }
00041
00042 else if ( cmd == m_printListsCmd ) {
00043 PhysicsListFactory::instance()->printAvailableLists();
00044 }
00045
00046 else if ( cmd == m_printCurrentCmd ) {
00047 mgr->log() << LOG::okay << "Current physics list <" << mgr->getCurrentListName() << ">." << LOG::done;
00048 mgr->log() << LOG::okay << "Physics has been initialized <" << mgr->isInitialized() << ">." << LOG::done;
00049 }
00050
00051 else if ( cmd == m_enableOpticalCmd ) {
00052 bool enableOptical=true;
00053 if (newVals != G4String("") )
00054 enableOptical = G4UIcmdWithABool::GetNewBoolValue(newVals);
00055 PhysicsListManager::instance()->enableOptical(enableOptical);
00056 }
00057 else {
00058 mgr->log() << LOG::error << "Unknown command for PhysicsMessenger." << LOG::done;
00059 }
00060 }
00061
00062 void PhysicsMessenger::defineCommands()
00063 {
00064 G4UIparameter* p;
00065
00066 m_physicsListDir = new G4UIdirectory( "/physics/" );
00067 m_physicsListDir->SetGuidance( "Physics list commands. [SLIC]" );
00068
00069
00070 m_selectCmd = new G4UIcommand("/physics/select", this );
00071 m_selectCmd->SetGuidance( "Select the Geant4 physics list. This command is only available in the PreInit state." );
00072 p = new G4UIparameter( "list", 's', false );
00073 m_selectCmd->SetParameter( p );
00074 m_selectCmd->AvailableForStates( G4State_PreInit );
00075
00076
00077 m_printListsCmd = new G4UIcmdWithoutParameter("/physics/printLists", this );
00078 m_printListsCmd->SetGuidance( "Print available physics lists." );
00079
00080
00081 m_printCurrentCmd = new G4UIcmdWithoutParameter( "/physics/printCurrent", this );
00082 m_printCurrentCmd->SetGuidance( "Print name of currently selected physics list." );
00083
00084
00085 m_enableOpticalCmd = new G4UIcmdWithABool("/physics/enableOptical", this);
00086 m_enableOpticalCmd->SetGuidance("Enable optical physics processes.");
00087 m_enableOpticalCmd->SetParameterName ("enable", 'b', true);
00088 m_enableOpticalCmd->SetDefaultValue(true);
00089 }
00090 }