Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AdjointSimMessenger Class Reference

#include <G4AdjointSimMessenger.hh>

+ Inheritance diagram for G4AdjointSimMessenger:

Public Member Functions

 G4AdjointSimMessenger (G4AdjointSimManager *)
 
 ~G4AdjointSimMessenger ()
 
void SetNewValue (G4UIcommand *, G4String)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()=default
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool operator!= (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (const G4String &s)
 
G4long StoL (const G4String &s)
 
G4double StoD (const G4String &s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 123 of file G4AdjointSimMessenger.hh.

Constructor & Destructor Documentation

◆ G4AdjointSimMessenger()

G4AdjointSimMessenger::G4AdjointSimMessenger ( G4AdjointSimManager pAdjointRunManager)

Definition at line 53 of file G4AdjointSimMessenger.cc.

55 : theAdjointRunManager(pAdjointRunManager)
56{
57 AdjointSimDir = new G4UIdirectory("/adjoint/");
58 AdjointSimDir->SetGuidance(
59 "Control of the adjoint or reverse monte carlo simulation");
60
61 // Start and adjoint Run
62 //---------------------
63
64 beamOnCmd = new G4UIcommand("/adjoint/start_run", this);
65 beamOnCmd->SetGuidance("Start an adjoint Run.");
66 beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
68 G4UIparameter* p1 = new G4UIparameter("numberOfEvent", 'i', true);
69 p1->SetDefaultValue(1);
70 p1->SetParameterRange("numberOfEvent >= 0");
71 beamOnCmd->SetParameter(p1);
72
73 // Commands to define parameters relative to the external source
74 //------------------------------------------------------------
75
76 G4UIparameter* pos_x_par = new G4UIparameter("X", 'd', true);
77
78 G4UIparameter* pos_y_par = new G4UIparameter("Y", 'd', true);
79
80 G4UIparameter* pos_z_par = new G4UIparameter("Z", 'd', true);
81
82 G4UIparameter* radius_par = new G4UIparameter("R", 'd', true);
83
84 radius_par->SetParameterRange("R >= 0");
85
86 G4UIparameter* unit_par = new G4UIparameter("unit", 's', true);
87
88 DefineSpherExtSourceCmd =
89 new G4UIcommand("/adjoint/DefineSphericalExtSource", this);
90 DefineSpherExtSourceCmd->SetGuidance("Define a spherical external source.");
91 DefineSpherExtSourceCmd->SetParameter(pos_x_par);
92 DefineSpherExtSourceCmd->SetParameter(pos_y_par);
93 DefineSpherExtSourceCmd->SetParameter(pos_z_par);
94 DefineSpherExtSourceCmd->SetParameter(radius_par);
95 DefineSpherExtSourceCmd->SetParameter(unit_par);
96
97 G4UIparameter* phys_vol_name_par =
98 new G4UIparameter("phys_vol_name", 's', true);
99
100 DefineSpherExtSourceCenteredOnAVolumeCmd =
101 new G4UIcommand("/adjoint/DefineSphericalExtSourceCenteredOnAVolume", this);
102 DefineSpherExtSourceCenteredOnAVolumeCmd->SetGuidance(
103 "Define a spherical external source with the center located at the center "
104 "of a "
105 "physical volume");
106 DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(phys_vol_name_par);
107 DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(radius_par);
108 DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(unit_par);
109
110 DefineExtSourceOnAVolumeExtSurfaceCmd = new G4UIcmdWithAString(
111 "/adjoint/DefineExtSourceOnExtSurfaceOfAVolume", this);
112 DefineExtSourceOnAVolumeExtSurfaceCmd->SetGuidance(
113 "Set the external source on the external surface of a physical volume");
114 DefineExtSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",
115 false);
116
117 setExtSourceEMaxCmd =
118 new G4UIcmdWithADoubleAndUnit("/adjoint/SetExtSourceEmax", this);
119 setExtSourceEMaxCmd->SetGuidance(
120 "Set the maximum energy of the external source");
121 setExtSourceEMaxCmd->SetParameterName("Emax", false);
122 setExtSourceEMaxCmd->SetUnitCategory("Energy");
123 setExtSourceEMaxCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
124
125 // Commands to define the adjoint source
126 //------------------------------------------------------------
127
128 DefineSpherAdjSourceCmd =
129 new G4UIcommand("/adjoint/DefineSphericalAdjSource", this);
130 DefineSpherAdjSourceCmd->SetGuidance("Define a spherical adjoint source.");
131 DefineSpherAdjSourceCmd->SetParameter(pos_x_par);
132 DefineSpherAdjSourceCmd->SetParameter(pos_y_par);
133 DefineSpherAdjSourceCmd->SetParameter(pos_z_par);
134 DefineSpherAdjSourceCmd->SetParameter(radius_par);
135 DefineSpherAdjSourceCmd->SetParameter(unit_par);
136
137 DefineSpherAdjSourceCenteredOnAVolumeCmd =
138 new G4UIcommand("/adjoint/DefineSphericalAdjSourceCenteredOnAVolume", this);
139 DefineSpherAdjSourceCenteredOnAVolumeCmd->SetGuidance(
140 "Define a spherical adjoint source with the center located at the center "
141 "of a "
142 "physical volume");
143 DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(phys_vol_name_par);
144 DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(radius_par);
145 DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(unit_par);
146
147 DefineAdjSourceOnAVolumeExtSurfaceCmd = new G4UIcmdWithAString(
148 "/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume", this);
149 DefineAdjSourceOnAVolumeExtSurfaceCmd->SetGuidance(
150 "Set the adjoint source on the external surface of physical volume");
151 DefineAdjSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",
152 false);
153
154 setAdjSourceEminCmd =
155 new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmin", this);
156 setAdjSourceEminCmd->SetGuidance(
157 "Set the minimum energy of the adjoint source");
158 setAdjSourceEminCmd->SetParameterName("Emin", false);
159 setAdjSourceEminCmd->SetUnitCategory("Energy");
160 setAdjSourceEminCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
161
162 setAdjSourceEmaxCmd =
163 new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmax", this);
164 setAdjSourceEmaxCmd->SetGuidance(
165 "Set the maximum energy of the adjoint source");
166 setAdjSourceEmaxCmd->SetParameterName("Emax", false);
167 setAdjSourceEmaxCmd->SetUnitCategory("Energy");
168 setAdjSourceEmaxCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
169
170 ConsiderParticleAsPrimaryCmd =
171 new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary", this);
172 ConsiderParticleAsPrimaryCmd->SetGuidance(
173 "Set the selected particle as primary");
174 ConsiderParticleAsPrimaryCmd->SetParameterName("particle", false);
175 ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
176
177 NeglectParticleAsPrimaryCmd =
178 new G4UIcmdWithAString("/adjoint/NeglectAsPrimary", this);
179 NeglectParticleAsPrimaryCmd->SetGuidance(
180 "Remove the selected particle from the list of primaries");
181 NeglectParticleAsPrimaryCmd->SetParameterName("particle", false);
182 NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
183
184 setNbOfPrimaryFwdGammasPerEventCmd =
185 new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryFwdGammasPerEvent", this);
186 setNbOfPrimaryFwdGammasPerEventCmd->SetGuidance(
187 "Set the nb of primary fwd gamm generated on the adjoint source");
188 setNbOfPrimaryFwdGammasPerEventCmd->SetParameterName("Nb_gammas", false);
189 setNbOfPrimaryFwdGammasPerEventCmd->AvailableForStates(G4State_PreInit,
191
192 setNbOfPrimaryAdjGammasPerEventCmd =
193 new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjGammasPerEvent", this);
194 setNbOfPrimaryAdjGammasPerEventCmd->SetGuidance(
195 "Set the nb of primary fwd gamm generated on the adjoint source");
196 setNbOfPrimaryAdjGammasPerEventCmd->SetParameterName("Nb_gammas", false);
197 setNbOfPrimaryAdjGammasPerEventCmd->AvailableForStates(G4State_PreInit,
199
200 setNbOfPrimaryAdjElectronsPerEventCmd = new G4UIcmdWithAnInteger(
201 "/adjoint/SetNbOfPrimaryAdjElectronsPerEvent", this);
202 setNbOfPrimaryAdjElectronsPerEventCmd->SetGuidance(
203 "Set the nb of primary fwd gamm generated on the adjoint source");
204 setNbOfPrimaryAdjElectronsPerEventCmd->SetParameterName("Nb_gammas", false);
205 setNbOfPrimaryAdjElectronsPerEventCmd->AvailableForStates(G4State_PreInit,
207}
@ G4State_Idle
@ G4State_PreInit
void SetUnitCategory(const char *unitCategory)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetCandidates(const char *candidateList)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:147
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:157
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:287
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)

◆ ~G4AdjointSimMessenger()

G4AdjointSimMessenger::~G4AdjointSimMessenger ( )

Definition at line 211 of file G4AdjointSimMessenger.cc.

212{
213 delete setNbOfPrimaryAdjElectronsPerEventCmd;
214 delete setNbOfPrimaryAdjGammasPerEventCmd;
215 delete setNbOfPrimaryFwdGammasPerEventCmd;
216 delete NeglectParticleAsPrimaryCmd;
217 delete ConsiderParticleAsPrimaryCmd;
218 delete setAdjSourceEmaxCmd;
219 delete setAdjSourceEminCmd;
220 delete DefineAdjSourceOnAVolumeExtSurfaceCmd;
221 delete DefineSpherAdjSourceCenteredOnAVolumeCmd;
222 delete DefineSpherAdjSourceCmd;
223 delete setExtSourceEMaxCmd;
224 delete DefineExtSourceOnAVolumeExtSurfaceCmd;
225 delete DefineSpherExtSourceCenteredOnAVolumeCmd;
226 delete DefineSpherExtSourceCmd;
227 delete beamOnCmd;
228 delete AdjointSimDir;
229}

Member Function Documentation

◆ SetNewValue()

void G4AdjointSimMessenger::SetNewValue ( G4UIcommand command,
G4String  newValue 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 233 of file G4AdjointSimMessenger.cc.

234{
235 if(command == nullptr)
236 return;
237 if(command == beamOnCmd)
238 {
239 G4int nev;
240 const char* nv = (const char*) newValue;
241 std::istringstream is(nv);
242 is >> nev;
243 if(G4RunManager::GetRunManager()->GetRunManagerType() ==
245 theAdjointRunManager->RunAdjointSimulation(nev);
246 }
247 else if(command == ConsiderParticleAsPrimaryCmd)
248 {
249 theAdjointRunManager->ConsiderParticleAsPrimary(newValue);
250 }
251 else if(command == NeglectParticleAsPrimaryCmd)
252 {
253 theAdjointRunManager->NeglectParticleAsPrimary(newValue);
254 }
255 if(command == DefineSpherExtSourceCmd)
256 {
257 G4double x, y, z, r;
258 G4String unit;
259 const char* nv = (const char*) newValue;
260 std::istringstream is(nv);
261 is >> x >> y >> z >> r >> unit;
262
267 theAdjointRunManager->DefineSphericalExtSource(r, G4ThreeVector(x, y, z));
268 }
269 else if(command == DefineSpherExtSourceCenteredOnAVolumeCmd)
270 {
271 G4double r;
272 G4String vol_name, unit;
273 const char* nv = (const char*) newValue;
274 std::istringstream is(nv);
275 is >> vol_name >> r >> unit;
277 theAdjointRunManager
279 }
280 else if(command == DefineExtSourceOnAVolumeExtSurfaceCmd)
281 {
282 theAdjointRunManager->DefineExtSourceOnTheExtSurfaceOfAVolume(newValue);
283 }
284 else if(command == setExtSourceEMaxCmd)
285 {
286 theAdjointRunManager->SetExtSourceEmax(
287 setExtSourceEMaxCmd->GetNewDoubleValue(newValue));
288 }
289 else if(command == DefineSpherAdjSourceCmd)
290 {
291 G4double x, y, z, r;
292 G4String unit;
293 const char* nv = (const char*) newValue;
294 std::istringstream is(nv);
295 is >> x >> y >> z >> r >> unit;
296
301 theAdjointRunManager->DefineSphericalAdjointSource(r,
302 G4ThreeVector(x, y, z));
303 }
304 else if(command == DefineSpherAdjSourceCenteredOnAVolumeCmd)
305 {
306 G4double r;
307 G4String vol_name, unit;
308 const char* nv = (const char*) newValue;
309 std::istringstream is(nv);
310 is >> vol_name >> r >> unit;
312 theAdjointRunManager
314 }
315 else if(command == DefineAdjSourceOnAVolumeExtSurfaceCmd)
316 {
317 theAdjointRunManager->DefineAdjointSourceOnTheExtSurfaceOfAVolume(newValue);
318 }
319 else if(command == setAdjSourceEminCmd)
320 {
321 theAdjointRunManager->SetAdjointSourceEmin(
322 setAdjSourceEminCmd->GetNewDoubleValue(newValue));
323 }
324 else if(command == setAdjSourceEmaxCmd)
325 {
326 theAdjointRunManager->SetAdjointSourceEmax(
327 setAdjSourceEmaxCmd->GetNewDoubleValue(newValue));
328 }
329 else if(command == setNbOfPrimaryFwdGammasPerEventCmd)
330 {
331 theAdjointRunManager->SetNbOfPrimaryFwdGammasPerEvent(
332 setNbOfPrimaryFwdGammasPerEventCmd->GetNewIntValue(newValue));
333 }
334 else if(command == setNbOfPrimaryAdjGammasPerEventCmd)
335 {
336 theAdjointRunManager->SetNbAdjointPrimaryGammasPerEvent(
337 setNbOfPrimaryAdjGammasPerEventCmd->GetNewIntValue(newValue));
338 }
339 else if(command == setNbOfPrimaryAdjElectronsPerEventCmd)
340 {
341 theAdjointRunManager->SetNbAdjointPrimaryElectronsPerEvent(
342 setNbOfPrimaryAdjElectronsPerEventCmd->GetNewIntValue(newValue));
343 }
344}
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
G4bool DefineAdjointSourceOnTheExtSurfaceOfAVolume(const G4String &volume_name)
G4bool DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String &volume_name)
void RunAdjointSimulation(G4int nb_evt)
G4bool DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String &volume_name)
void SetNbAdjointPrimaryGammasPerEvent(G4int)
void ConsiderParticleAsPrimary(const G4String &particle_name)
void SetExtSourceEmax(G4double Emax)
void SetAdjointSourceEmax(G4double Emax)
void SetAdjointSourceEmin(G4double Emin)
void NeglectParticleAsPrimary(const G4String &particle_name)
G4bool DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String &volume_name)
void SetNbAdjointPrimaryElectronsPerEvent(G4int)
void SetNbOfPrimaryFwdGammasPerEvent(G4int)
G4bool DefineSphericalExtSource(G4double radius, G4ThreeVector pos)
G4bool DefineSphericalAdjointSource(G4double radius, G4ThreeVector pos)
static G4RunManager * GetRunManager()
static G4double GetNewDoubleValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
static G4double GetValueOf(const G4String &)

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