SLIC  6.1.1
Simulation for the Linear Collider (SLIC) - Geant4 simulation application
PhysicsMessenger.cc
Go to the documentation of this file.
1 // SLIC
2 #include "PhysicsMessenger.hh"
3 #include "PhysicsListManager.hh"
4 #include "HepPDTManager.hh"
5 
6 // LCDD
7 #include "lcdd/util/StringUtil.hh"
8 
9 // Geant4
10 #include "G4UIcmdWithABool.hh"
11 #include "G4UIcmdWithoutParameter.hh"
12 #include "G4UIdirectory.hh"
13 
14 namespace slic {
15 
17  m_physicsListDir(0), m_selectCmd(0) {
19 }
20 
22 }
23 
24 void PhysicsMessenger::SetNewValue(G4UIcommand* cmd, G4String newVals) {
25  std::istringstream is((const char*) newVals);
26 
27  std::string s;
28  is >> s;
29 
31 
32  // set physics list
33  if (cmd == m_selectCmd) {
34  mgr->setCurrentListName(s);
35  }
36  // print available lists
37  else if (cmd == m_printListsCmd) {
38  PhysicsListManager::instance()->printAvailablePhysicsLists();
39  }
40  // Print current list and whether initialized.
41  else if (cmd == m_printCurrentCmd) {
42  mgr->log() << LOG::okay << "Current physics list <" << mgr->getCurrentListName() << ">." << LOG::done;
43  mgr->log() << LOG::okay << "Physics has been initialized <" << mgr->isInitialized() << ">." << LOG::done;
44  }
45  // Enable optical physics processes.
46  else if (cmd == m_enableOpticalCmd) {
47  bool enableOptical = true;
48  if (newVals != G4String(""))
49  enableOptical = G4UIcmdWithABool::GetNewBoolValue(newVals);
50  PhysicsListManager::instance()->enableOptical(enableOptical);
51  }
52  // Set location of particle.tbl for HepPDT.
53  else if (cmd == m_pdgCmd) {
54  HepPDTManager::instance()->setParticleDataFile(s);
55  } else {
56  mgr->log() << LOG::error << "Unknown command for PhysicsMessenger." << LOG::done;
57  }
58 }
59 
61  G4UIparameter* p;
62 
63  m_physicsListDir = new G4UIdirectory("/physics/");
64  m_physicsListDir->SetGuidance("Physics list commands. [SLIC]");
65 
66  // select physics list
67  m_selectCmd = new G4UIcommand("/physics/select", this);
68  m_selectCmd->SetGuidance("Select the Geant4 physics list. This command is only available in the PreInit state.");
69  p = new G4UIparameter("list", 's', false);
70  m_selectCmd->SetParameter(p);
71  m_selectCmd->AvailableForStates(G4State_PreInit);
72 
73  // print available lists
74  m_printListsCmd = new G4UIcmdWithoutParameter("/physics/printLists", this);
75  m_printListsCmd->SetGuidance("Print available physics lists.");
76 
77  // print current list
78  m_printCurrentCmd = new G4UIcmdWithoutParameter("/physics/printCurrent", this);
79  m_printCurrentCmd->SetGuidance("Print name of currently selected physics list.");
80 
81  // Enable optical physics processes for the current list when it is initialized.
82  m_enableOpticalCmd = new G4UIcmdWithABool("/physics/enableOptical", this);
83  m_enableOpticalCmd->SetGuidance("Enable optical physics processes.");
84  m_enableOpticalCmd->SetParameterName("enable", 'b', true);
85  m_enableOpticalCmd->SetDefaultValue(true);
86 
87  // Set location of particle.tbl for supplementary particle data.
88  m_pdgCmd = new G4UIcommand("/physics/setPDGFile", this);
89  m_pdgCmd->SetGuidance("Set location of particle data for HepPDT, probably called particle.tbl.");
90  p = new G4UIparameter("file", 's', false);
91  m_pdgCmd->SetParameter(p);
92  m_pdgCmd->AvailableForStates(G4State_PreInit);
93 }
94 }
static PhysicsListManager * instance()
LogStream & log()
Definition: Module.hh:99
Provides management of user physics lists.
void setCurrentListName(const std::string &name)
const std::string & getCurrentListName()
virtual void SetNewValue(G4UIcommand *cmd, G4String newVals)
G4UIcmdWithoutParameter * m_printCurrentCmd
G4UIcmdWithoutParameter * m_printListsCmd
G4UIcmdWithABool * m_enableOpticalCmd
G4UIdirectory * m_physicsListDir
@ okay
Definition: LogStream.hh:33
@ error
Definition: LogStream.hh:33
@ done
Definition: LogStream.hh:26