Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ProcessManagerMessenger.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4ProcessManagerMessenger.cc 108134 2018-01-09 13:29:12Z gcosmo $
28 //
29 //
30 //---------------------------------------------------------------
31 //
32 // G4ProcessManagerMessenger.cc
33 //
34 // Description:
35 // This is a messenger class to interface to exchange information
36 // between ProcessManagerand UI.
37 //
38 // History:
39 // 13 June 1997, H. Kurashige : The 1st version created.
40 // 10 Nov. 1997 H. Kurashige : fixed bugs
41 // 08 jan. 1998 H. Kurashige : new UIcommnds
42 // 02 June 2006 M. Maire : add physicsModified in activate/inactivate
43 //
44 //---------------------------------------------------------------
45 
46 
47 #include "G4UImanager.hh"
48 #include "G4UIdirectory.hh"
50 #include "G4UIcmdWithAnInteger.hh"
51 
52 #include "G4VProcess.hh"
53 #include "G4ProcessManager.hh"
54 #include "G4ParticleTable.hh"
55 
57 #include "G4ios.hh" // Include from 'system'
58 #include <iomanip> // Include from 'system'
59 
60 #include <sstream>
61 
63  :theParticleTable(pTable),
64  currentParticle(0),
65  currentProcess(0),
66  theManager(0),
67  theProcessList(0)
68 {
70 
71  //Commnad /particle/process
72  thisDirectory = new G4UIdirectory("/particle/process/");
73  thisDirectory->SetGuidance("Process Manager control commands.");
74 
75  //Commnad /particle/process/dump
76  dumpCmd = new G4UIcmdWithAnInteger("/particle/process/dump",this);
77  dumpCmd->SetGuidance("dump process manager or process information");
78  dumpCmd->SetGuidance(" dump [process index]");
79  dumpCmd->SetGuidance(" process index: -1 for process manager");
80  dumpCmd->SetParameterName("index", true);
82 
83  //Commnad /particle/process/verbose
84  verboseCmd = new G4UIcommand("/particle/process/verbose",this);
85  verboseCmd->SetGuidance("Set Verbose Level for Process or Process Manager");
86  verboseCmd->SetGuidance(" Verbose [Verbose] [process index]");
87  verboseCmd->SetGuidance(" process index: -1 for process manager");
88  G4UIparameter* param = new G4UIparameter("Verbose",'i',true);
89  param->SetDefaultValue(1);
90  verboseCmd->SetParameter(param);
91  param = new G4UIparameter("index",'i',true);
92  param->SetDefaultValue(-1);
93  verboseCmd->SetParameter(param);
95 
96  //Commnad /particle/process/activate
97  activateCmd = new G4UIcmdWithAnInteger("/particle/process/activate",this);
98  activateCmd->SetGuidance("Activate process ");
99  activateCmd->SetGuidance(" Activate [process index]");
100  activateCmd->SetParameterName("index", false);
102  activateCmd->SetRange("index >=0");
104 
105  //Commnad /particle/process/inactivate
106  inactivateCmd = new G4UIcmdWithAnInteger("/particle/process/inactivate",this);
107  inactivateCmd->SetGuidance("Inactivate process ");
108  inactivateCmd->SetGuidance(" inactivate [process index]");
109  inactivateCmd->SetParameterName("index", false);
111  inactivateCmd->SetRange("index >=0");
113 
114 }
115 
117 {
118  delete activateCmd;
119  delete inactivateCmd;
120  delete verboseCmd;
121  delete dumpCmd;
122  delete thisDirectory;
123 }
124 
126 {
127  // set currentParticle pointer
128  // get particle name by asking G4ParticleMessenger
129  G4String particleName = G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
130 
132  if (currentParticle == 0) {
133  theManager = 0;
134  G4cout << "G4ProcessManagerMessenger::SetCurrentParticle() ";
135  G4cout << particleName << " not found " << G4endl;
136  } else {
139  }
140  return currentParticle;
141 }
142 
144 {
146  if (SetCurrentParticle()==0) {
147  ed << "Particle is not selected yet !! Command ignored.";
148  command->CommandFailed(ed);
149  return;
150  }
151  if( command == dumpCmd ){
152  //Commnad /particle/process/dump
153  G4int index = dumpCmd->GetNewIntValue(newValue);
154  if (index <0) {
155  theManager->DumpInfo();
156  } else if ( index < theManager->GetProcessListLength()){
157  currentProcess = (*theProcessList)(index);
158  if (currentProcess == 0) {
159  ed << " no process at index of " << index
160  << " in the Process Vector";
161  command->CommandFailed(ed);
162  } else {
164  }
165  } else {
166  ed << " illegal index !!! ";
167  command->CommandFailed(ed);
168  currentProcess = 0;
169  }
170 
171  } else if( command==activateCmd ) {
172  //Commnad /particle/process/activate
174  G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
175 
176  } else if( command==inactivateCmd ) {
177  //Commnad /particle/process/inactivate
179  G4UImanager::GetUIpointer()->ApplyCommand("/run/physicsModified");
180 
181  } else if( command==verboseCmd ) {
182  //Commnad /particle/process/Verbose
183  // inputstream for newValues
184  const char* temp = (const char*)(newValue);
185  std::istringstream is((char*)temp);
186  G4int Verbose, index;
187  is >>Verbose >>index;
188  if (index <0) {
189  theManager->SetVerboseLevel(Verbose);
190 
191  } else if ( index < theManager->GetProcessListLength()){
192  currentProcess = (*theProcessList)(index);
193  if (currentProcess == 0) {
194  ed << " no process at index of " << index
195  << " in the Process Vector";
196  command->CommandFailed(ed);
197  } else {
199  }
200  } else {
201  ed << " illegal index !!! ";
202  command->CommandFailed(ed);
203  currentProcess = 0;
204  }
205  }
206 }
207 
208 
210 {
211  if(SetCurrentParticle() == 0) return "";
212 
213  if( command==verboseCmd ){
214  //Commnad /particle/process/Verbose
216  } else {
217  return "";
218  }
219 }
220 
221 
222 
223 
224 
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void CommandFailed(G4int errCode, G4ExceptionDescription &ed)
Definition: G4UIcommand.hh:202
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
static G4ParticleTable * GetParticleTable()
G4ProcessManagerMessenger(G4ParticleTable *pTable=0)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
void SetDefaultValue(G4int defVal)
#define G4endl
Definition: G4ios.hh:61
virtual void SetNewValue(G4UIcommand *command, G4String newValues)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
G4ParticleDefinition * SetCurrentParticle()
G4ProcessVector * GetProcessList() const
virtual G4String GetCurrentValue(G4UIcommand *command)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetVerboseLevel(G4int value)
Definition: G4VProcess.hh:440
void SetDefaultValue(const char *theDefaultValue)
G4VProcess * SetProcessActivation(G4VProcess *aProcess, G4bool fActive)
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
int G4int
Definition: G4Types.hh:78
G4ProcessManager * GetProcessManager() const
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
G4GLOB_DLL std::ostream G4cout
void SetVerboseLevel(G4int value)
virtual void DumpInfo() const
Definition: G4VProcess.cc:179
G4ParticleDefinition * currentParticle
G4int GetVerboseLevel() const
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
G4String GetCurrentStringValue(const char *aCommand, G4int parameterNumber=1, G4bool reGet=true)
Definition: G4UImanager.cc:202
G4UIcmdWithAnInteger * inactivateCmd