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