Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
G4ProcessManagerMessenger Class Reference

#include <G4ProcessManagerMessenger.hh>

Inheritance diagram for G4ProcessManagerMessenger:
G4UImessenger

Public Member Functions

G4bool CommandsShouldBeInMaster () const
 
 G4ProcessManagerMessenger (const G4ProcessManagerMessenger &)=delete
 
 G4ProcessManagerMessenger (G4ParticleTable *pTable=nullptr)
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4ProcessManagerMessengeroperator= (const G4ProcessManagerMessenger &)=delete
 
G4bool operator== (const G4UImessenger &messenger) const
 
virtual void SetNewValue (G4UIcommand *command, G4String newValues)
 
virtual ~G4ProcessManagerMessenger ()
 

Protected Member Functions

void AddUIcommand (G4UIcommand *newCommand)
 
G4String BtoS (G4bool b)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
G4String DtoS (G4double a)
 
G4String ItoS (G4int i)
 
G4bool StoB (G4String s)
 
G4double StoD (G4String s)
 
G4int StoI (G4String s)
 
G4long StoL (G4String s)
 

Protected Attributes

G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Private Member Functions

const G4ParticleDefinitionSetCurrentParticle ()
 

Private Attributes

G4UIcmdWithAnIntegeractivateCmd = nullptr
 
const G4ParticleDefinitioncurrentParticle = nullptr
 
G4VProcesscurrentProcess = nullptr
 
G4UIcmdWithAnIntegerdumpCmd = nullptr
 
G4UIcmdWithAnIntegerinactivateCmd = nullptr
 
G4ProcessManagertheManager = nullptr
 
G4ParticleTabletheParticleTable = nullptr
 
G4ProcessVectortheProcessList = nullptr
 
G4UIdirectorythisDirectory = nullptr
 
G4UIcommandverboseCmd = nullptr
 

Detailed Description

Definition at line 59 of file G4ProcessManagerMessenger.hh.

Constructor & Destructor Documentation

◆ G4ProcessManagerMessenger() [1/2]

G4ProcessManagerMessenger::G4ProcessManagerMessenger ( G4ParticleTable pTable = nullptr)

Definition at line 50 of file G4ProcessManagerMessenger.cc.

51 : theParticleTable(pTable)
52{
53 if ( theParticleTable == nullptr)
55
56 // Command /particle/process
57 thisDirectory = new G4UIdirectory("/particle/process/");
58 thisDirectory->SetGuidance("Process Manager control commands.");
59
60 // Command /particle/process/dump
61 dumpCmd = new G4UIcmdWithAnInteger("/particle/process/dump",this);
62 dumpCmd->SetGuidance("dump process manager or process information");
63 dumpCmd->SetGuidance(" dump [process index]");
64 dumpCmd->SetGuidance(" process index: -1 for process manager");
65 dumpCmd->SetParameterName("index", true);
67
68 // Command /particle/process/verbose
69 verboseCmd = new G4UIcommand("/particle/process/verbose",this);
70 verboseCmd->SetGuidance("Set Verbose Level for Process or Process Manager");
71 verboseCmd->SetGuidance(" Verbose [Verbose] [process index]");
72 verboseCmd->SetGuidance(" process index: -1 for process manager");
73 G4UIparameter* param = new G4UIparameter("Verbose",'i',true);
74 param->SetDefaultValue(1);
76 param = new G4UIparameter("index",'i',true);
77 param->SetDefaultValue(-1);
80
81 // Command /particle/process/activate
82 activateCmd = new G4UIcmdWithAnInteger("/particle/process/activate",this);
83 activateCmd->SetGuidance("Activate process ");
84 activateCmd->SetGuidance(" Activate [process index]");
85 activateCmd->SetParameterName("index", false);
87 activateCmd->SetRange("index >=0");
89
90 // Command /particle/process/inactivate
91 inactivateCmd = new G4UIcmdWithAnInteger("/particle/process/inactivate",this);
92 inactivateCmd->SetGuidance("Inactivate process ");
93 inactivateCmd->SetGuidance(" inactivate [process index]");
94 inactivateCmd->SetParameterName("index", false);
96 inactivateCmd->SetRange("index >=0");
98}
@ G4State_EventProc
@ G4State_Init
@ G4State_Idle
@ G4State_GeomClosed
@ G4State_PreInit
static G4ParticleTable * GetParticleTable()
G4UIcmdWithAnInteger * inactivateCmd
G4UIcmdWithAnInteger * activateCmd
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetDefaultValue(G4int defVal)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:146
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:288
void SetDefaultValue(const char *theDefaultValue)

References activateCmd, G4UIcommand::AvailableForStates(), dumpCmd, G4State_EventProc, G4State_GeomClosed, G4State_Idle, G4State_Init, G4State_PreInit, G4ParticleTable::GetParticleTable(), inactivateCmd, G4UIparameter::SetDefaultValue(), G4UIcmdWithAnInteger::SetDefaultValue(), G4UIcommand::SetGuidance(), G4UIcommand::SetParameter(), G4UIcmdWithAnInteger::SetParameterName(), G4UIcommand::SetRange(), theParticleTable, thisDirectory, and verboseCmd.

◆ ~G4ProcessManagerMessenger()

G4ProcessManagerMessenger::~G4ProcessManagerMessenger ( )
virtual

Definition at line 101 of file G4ProcessManagerMessenger.cc.

102{
103 delete activateCmd;
104 delete inactivateCmd;
105 delete verboseCmd;
106 delete dumpCmd;
107 delete thisDirectory;
108}

References activateCmd, dumpCmd, inactivateCmd, thisDirectory, and verboseCmd.

◆ G4ProcessManagerMessenger() [2/2]

G4ProcessManagerMessenger::G4ProcessManagerMessenger ( const G4ProcessManagerMessenger )
delete

Member Function Documentation

◆ AddUIcommand()

void G4UImessenger::AddUIcommand ( G4UIcommand newCommand)
protectedinherited

Definition at line 149 of file G4UImessenger.cc.

150{
151 G4cerr << "Warning : Old style definition of G4UIcommand <"
152 << newCommand->GetCommandPath() << ">." << G4endl;
153}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
const G4String & GetCommandPath() const
Definition: G4UIcommand.hh:136

References G4cerr, G4endl, and G4UIcommand::GetCommandPath().

◆ BtoS()

G4String G4UImessenger::BtoS ( G4bool  b)
protectedinherited

Definition at line 98 of file G4UImessenger.cc.

99{
100 G4String vl = "0";
101 if(b)
102 vl = "true";
103 return vl;
104}

◆ CommandsShouldBeInMaster()

G4bool G4UImessenger::CommandsShouldBeInMaster ( ) const
inlineinherited

Definition at line 77 of file G4UImessenger.hh.

78 {
80 }
G4bool commandsShouldBeInMaster

References G4UImessenger::commandsShouldBeInMaster.

Referenced by G4UIcommand::G4UIcommandCommonConstructorCode().

◆ CreateCommand()

template<typename T >
T * G4UImessenger::CreateCommand ( const G4String cname,
const G4String dsc 
)
protectedinherited

Definition at line 110 of file G4UImessenger.hh.

111{
112 G4String path;
113 if(cname[0] != '/')
114 {
115 path = baseDirName + cname;
116 if(path[0] != '/')
117 path = "/" + path;
118 }
119
120 T* command = new T(path.c_str(), this);
121 command->SetGuidance(dsc.c_str());
122
123 return command;
124}
G4String baseDirName

References G4UImessenger::baseDirName.

◆ CreateDirectory()

void G4UImessenger::CreateDirectory ( const G4String path,
const G4String dsc,
G4bool  commandsToBeBroadcasted = true 
)
protectedinherited

Definition at line 156 of file G4UImessenger.cc.

158{
160
161 G4String fullpath = path;
162 if(fullpath.back() != '/')
163 fullpath.append("/");
164
165 G4UIcommandTree* tree = ui->GetTree()->FindCommandTree(fullpath.c_str());
166 if(tree != nullptr)
167 {
168 baseDirName = tree->GetPathName();
169 }
170 else
171 {
172 baseDir = new G4UIdirectory(fullpath.c_str(), commandsToBeBroadcasted);
173 baseDirName = fullpath;
174 baseDir->SetGuidance(dsc.c_str());
175 }
176}
const G4String & GetPathName() const
G4UIcommandTree * FindCommandTree(const char *commandPath)
G4UIcommandTree * GetTree() const
Definition: G4UImanager.hh:186
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:77
G4UIdirectory * baseDir

References G4UImessenger::baseDir, G4UImessenger::baseDirName, G4UIcommandTree::FindCommandTree(), G4UIcommandTree::GetPathName(), G4UImanager::GetTree(), G4UImanager::GetUIpointer(), and G4UIcommand::SetGuidance().

Referenced by G4MoleculeShootMessenger::G4MoleculeShootMessenger(), and G4UImessenger::G4UImessenger().

◆ DtoS()

G4String G4UImessenger::DtoS ( G4double  a)
protectedinherited

Definition at line 90 of file G4UImessenger.cc.

91{
92 std::ostringstream os;
93 os << a;
94 return G4String(os.str());
95}

Referenced by G4ScoreQuantityMessenger::FilterCommands(), and G4UIcontrolMessenger::SetNewValue().

◆ GetCurrentValue()

G4String G4ProcessManagerMessenger::GetCurrentValue ( G4UIcommand command)
virtual

Reimplemented from G4UImessenger.

Definition at line 219 of file G4ProcessManagerMessenger.cc.

220{
221 if(SetCurrentParticle() == nullptr) return "";
222
223 if( command==verboseCmd )
224 {
225 // Command /particle/process/Verbose
227 }
228 else
229 {
230 return "";
231 }
232}
const G4ParticleDefinition * SetCurrentParticle()
G4int GetVerboseLevel() const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:445

References G4UIcommand::ConvertToString(), G4ProcessManager::GetVerboseLevel(), SetCurrentParticle(), theManager, and verboseCmd.

◆ ItoS()

G4String G4UImessenger::ItoS ( G4int  i)
protectedinherited

Definition at line 82 of file G4UImessenger.cc.

83{
84 std::ostringstream os;
85 os << i;
86 return G4String(os.str());
87}

Referenced by G4GenericMessenger::DeclareMethod(), and G4ParticleGunMessenger::GetCurrentValue().

◆ operator!=()

G4bool G4UImessenger::operator!= ( const G4UImessenger messenger) const
inherited

Definition at line 76 of file G4UImessenger.cc.

77{
78 return this != &messenger;
79}

◆ operator=()

G4ProcessManagerMessenger & G4ProcessManagerMessenger::operator= ( const G4ProcessManagerMessenger )
delete

◆ operator==()

G4bool G4UImessenger::operator== ( const G4UImessenger messenger) const
inherited

Definition at line 70 of file G4UImessenger.cc.

71{
72 return this == &messenger;
73}

◆ SetCurrentParticle()

const G4ParticleDefinition * G4ProcessManagerMessenger::SetCurrentParticle ( )
private

Definition at line 111 of file G4ProcessManagerMessenger.cc.

112{
113 // access to selected particle in the G4ParticleTable
115 if (currentParticle == nullptr)
116 {
117 theManager = nullptr;
118 G4cout << "G4ProcessManagerMessenger::SetCurrentParticle() - not selected";
119 }
120 else
121 {
124 }
125 return currentParticle;
126}
G4GLOB_DLL std::ostream G4cout
G4ProcessManager * GetProcessManager() const
const G4ParticleDefinition * GetSelectedParticle() const
const G4ParticleDefinition * currentParticle
G4ProcessVector * GetProcessList() const

References currentParticle, G4cout, G4ProcessManager::GetProcessList(), G4ParticleDefinition::GetProcessManager(), G4ParticleTable::GetSelectedParticle(), theManager, theParticleTable, and theProcessList.

Referenced by GetCurrentValue(), and SetNewValue().

◆ SetNewValue()

void G4ProcessManagerMessenger::SetNewValue ( G4UIcommand command,
G4String  newValues 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 129 of file G4ProcessManagerMessenger.cc.

130{
132 if (SetCurrentParticle() == nullptr)
133 {
134 ed << "Particle is not selected yet !! Command ignored.";
135 command->CommandFailed(ed);
136 return;
137 }
138 if( command == dumpCmd )
139 {
140 // Command /particle/process/dump
141 G4int index = dumpCmd->GetNewIntValue(newValue);
142 if (index <0)
143 {
145 }
146 else if ( index < theManager->GetProcessListLength())
147 {
148 currentProcess = (*theProcessList)(index);
149 if (currentProcess == nullptr)
150 {
151 ed << " no process at index of " << index
152 << " in the Process Vector";
153 command->CommandFailed(ed);
154 }
155 else
156 {
158 }
159 }
160 else
161 {
162 ed << " illegal index !!! ";
163 command->CommandFailed(ed);
164 currentProcess = nullptr;
165 }
166
167 }
168 else if( command==activateCmd )
169 {
170 // Command /particle/process/activate
172 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
173
174 }
175 else if( command==inactivateCmd )
176 {
177 // Command /particle/process/inactivate
179 G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
180
181 }
182 else if( command==verboseCmd )
183 {
184 // Command /particle/process/Verbose
185 // inputstream for newValues
186 const char* temp = (const char*)(newValue);
187 std::istringstream is((char*)temp);
188 G4int Verbose, index;
189 is >>Verbose >>index;
190 if (index <0)
191 {
192 theManager->SetVerboseLevel(Verbose);
193
194 }
195 else if ( index < theManager->GetProcessListLength())
196 {
197 currentProcess = (*theProcessList)(index);
198 if (currentProcess == nullptr)
199 {
200 ed << " no process at index of " << index
201 << " in the Process Vector";
202 command->CommandFailed(ed);
203 }
204 else
205 {
207 }
208 }
209 else
210 {
211 ed << " illegal index !!! ";
212 command->CommandFailed(ed);
213 currentProcess = nullptr;
214 }
215 }
216}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
int G4int
Definition: G4Types.hh:85
G4VProcess * SetProcessActivation(G4VProcess *aProcess, G4bool fActive)
void SetVerboseLevel(G4int value)
static G4int GetNewIntValue(const char *paramString)
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:179
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:485
void SetVerboseLevel(G4int value)
Definition: G4VProcess.hh:412
virtual void DumpInfo() const
Definition: G4VProcess.cc:167

References activateCmd, G4UImanager::ApplyCommand(), G4UIcommand::CommandFailed(), currentProcess, dumpCmd, G4ProcessManager::DumpInfo(), G4VProcess::DumpInfo(), G4UIcmdWithAnInteger::GetNewIntValue(), G4UImanager::GetUIpointer(), inactivateCmd, SetCurrentParticle(), G4ProcessManager::SetProcessActivation(), G4ProcessManager::SetVerboseLevel(), G4VProcess::SetVerboseLevel(), theManager, and verboseCmd.

◆ StoB()

G4bool G4UImessenger::StoB ( G4String  s)
protectedinherited

Definition at line 137 of file G4UImessenger.cc.

138{
140 G4bool vl = false;
141 if(v == "Y" || v == "YES" || v == "1" || v == "T" || v == "TRUE")
142 {
143 vl = true;
144 }
145 return vl;
146}
bool G4bool
Definition: G4Types.hh:86
G4String to_upper_copy(G4String str)
Return uppercase copy of string.

References G4StrUtil::to_upper_copy().

Referenced by G4LocalThreadCoutMessenger::SetNewValue(), G4CascadeParamMessenger::SetNewValue(), G4ScoreQuantityMessenger::SetNewValue(), and G4ScoringMessenger::SetNewValue().

◆ StoD()

G4double G4UImessenger::StoD ( G4String  s)
protectedinherited

◆ StoI()

G4int G4UImessenger::StoI ( G4String  s)
protectedinherited

◆ StoL()

G4long G4UImessenger::StoL ( G4String  s)
protectedinherited

Definition at line 117 of file G4UImessenger.cc.

118{
119 G4long vl;
120 const char* t = str;
121 std::istringstream is(t);
122 is >> vl;
123 return vl;
124}
long G4long
Definition: G4Types.hh:87

Referenced by G4RunMessenger::SetNewValue().

Field Documentation

◆ activateCmd

G4UIcmdWithAnInteger* G4ProcessManagerMessenger::activateCmd = nullptr
private

◆ baseDir

G4UIdirectory* G4UImessenger::baseDir = nullptr
protectedinherited

◆ baseDirName

G4String G4UImessenger::baseDirName = ""
protectedinherited

◆ commandsShouldBeInMaster

G4bool G4UImessenger::commandsShouldBeInMaster = false
protectedinherited

◆ currentParticle

const G4ParticleDefinition* G4ProcessManagerMessenger::currentParticle = nullptr
private

Definition at line 85 of file G4ProcessManagerMessenger.hh.

Referenced by SetCurrentParticle().

◆ currentProcess

G4VProcess* G4ProcessManagerMessenger::currentProcess = nullptr
private

Definition at line 86 of file G4ProcessManagerMessenger.hh.

Referenced by SetNewValue().

◆ dumpCmd

G4UIcmdWithAnInteger* G4ProcessManagerMessenger::dumpCmd = nullptr
private

◆ inactivateCmd

G4UIcmdWithAnInteger* G4ProcessManagerMessenger::inactivateCmd = nullptr
private

◆ theManager

G4ProcessManager* G4ProcessManagerMessenger::theManager = nullptr
private

Definition at line 87 of file G4ProcessManagerMessenger.hh.

Referenced by GetCurrentValue(), SetCurrentParticle(), and SetNewValue().

◆ theParticleTable

G4ParticleTable* G4ProcessManagerMessenger::theParticleTable = nullptr
private

Definition at line 84 of file G4ProcessManagerMessenger.hh.

Referenced by G4ProcessManagerMessenger(), and SetCurrentParticle().

◆ theProcessList

G4ProcessVector* G4ProcessManagerMessenger::theProcessList = nullptr
private

Definition at line 88 of file G4ProcessManagerMessenger.hh.

Referenced by SetCurrentParticle().

◆ thisDirectory

G4UIdirectory* G4ProcessManagerMessenger::thisDirectory = nullptr
private

◆ verboseCmd

G4UIcommand* G4ProcessManagerMessenger::verboseCmd = nullptr
private

The documentation for this class was generated from the following files: