Geant4 10.7.0
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 ()
 
 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 (G4String s)
 
G4long StoL (G4String s)
 
G4double StoD (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 151 of file G4AdjointSimMessenger.hh.

Constructor & Destructor Documentation

◆ G4AdjointSimMessenger()

G4AdjointSimMessenger::G4AdjointSimMessenger ( G4AdjointSimManager pAdjointRunManager)

Definition at line 56 of file G4AdjointSimMessenger.cc.

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

◆ ~G4AdjointSimMessenger()

G4AdjointSimMessenger::~G4AdjointSimMessenger ( )

Definition at line 271 of file G4AdjointSimMessenger.cc.

272{
273 if(beamOnCmd)
274 delete beamOnCmd;
275}

Member Function Documentation

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 280 of file G4AdjointSimMessenger.cc.

281{
282 if(!command)
283 return;
284 if(command == beamOnCmd)
285 {
286 G4int nev;
287 const char* nv = (const char*) newValue;
288 std::istringstream is(nv);
289 is >> nev;
290 if(G4RunManager::GetRunManager()->GetRunManagerType() ==
292 theAdjointRunManager->RunAdjointSimulation(nev);
293 /*
294 #ifdef G4MULTITHREADED
295 else if (theMTAdjointRunManager)
296 theMTAdjointRunManager->RunAdjointSimulation(nev); else if
297 (theAdjointRunManager)
298 theAdjointRunManager->SwitchToAdjointSimulationMode(); #endif
299 */
300 // G4cout<<"G4AdjointSimMessenger::SetNewValue BeamOnCmd out"<<std::endl;
301 }
302 else if(command == ConsiderParticleAsPrimaryCmd)
303 {
304 theAdjointRunManager->ConsiderParticleAsPrimary(newValue);
305 }
306 else if(command == NeglectParticleAsPrimaryCmd)
307 {
308 theAdjointRunManager->NeglectParticleAsPrimary(newValue);
309 }
310 /*
311 #ifdef G4MULTITHREADED
312 if (G4RunManager::GetRunManager()->GetRunManagerType() ==
313 G4RunManager::masterRM) return; #endif
314 */
315 if(command == DefineSpherExtSourceCmd)
316 {
317 G4double x, y, z, r;
318 G4String unit;
319 const char* nv = (const char*) newValue;
320 std::istringstream is(nv);
321 is >> x >> y >> z >> r >> unit;
322
327 theAdjointRunManager->DefineSphericalExtSource(r, G4ThreeVector(x, y, z));
328 }
329 else if(command == DefineSpherExtSourceCenteredOnAVolumeCmd)
330 {
331 G4double r;
332 G4String vol_name, unit;
333 const char* nv = (const char*) newValue;
334 std::istringstream is(nv);
335 is >> vol_name >> r >> unit;
337 theAdjointRunManager
339 }
340 else if(command == DefineExtSourceOnAVolumeExtSurfaceCmd)
341 {
342 theAdjointRunManager->DefineExtSourceOnTheExtSurfaceOfAVolume(newValue);
343 }
344 else if(command == setExtSourceEMaxCmd)
345 {
346 theAdjointRunManager->SetExtSourceEmax(
347 setExtSourceEMaxCmd->GetNewDoubleValue(newValue));
348 }
349 else if(command == DefineSpherAdjSourceCmd)
350 {
351 G4double x, y, z, r;
352 G4String unit;
353 const char* nv = (const char*) newValue;
354 std::istringstream is(nv);
355 is >> x >> y >> z >> r >> unit;
356
361 theAdjointRunManager->DefineSphericalAdjointSource(r,
362 G4ThreeVector(x, y, z));
363 }
364 else if(command == DefineSpherAdjSourceCenteredOnAVolumeCmd)
365 {
366 G4double r;
367 G4String vol_name, unit;
368 const char* nv = (const char*) newValue;
369 std::istringstream is(nv);
370 is >> vol_name >> r >> unit;
372 theAdjointRunManager
374 }
375 else if(command == DefineAdjSourceOnAVolumeExtSurfaceCmd)
376 {
377 theAdjointRunManager->DefineAdjointSourceOnTheExtSurfaceOfAVolume(newValue);
378 }
379 else if(command == setAdjSourceEminCmd)
380 {
381 theAdjointRunManager->SetAdjointSourceEmin(
382 setAdjSourceEminCmd->GetNewDoubleValue(newValue));
383 }
384 else if(command == setAdjSourceEmaxCmd)
385 {
386 theAdjointRunManager->SetAdjointSourceEmax(
387 setAdjSourceEmaxCmd->GetNewDoubleValue(newValue));
388 }
389 else if(command == setNbOfPrimaryFwdGammasPerEventCmd)
390 {
391 theAdjointRunManager->SetNbOfPrimaryFwdGammasPerEvent(
392 setNbOfPrimaryFwdGammasPerEventCmd->GetNewIntValue(newValue));
393 }
394 else if(command == setNbOfPrimaryAdjGammasPerEventCmd)
395 {
396 theAdjointRunManager->SetNbAdjointPrimaryGammasPerEvent(
397 setNbOfPrimaryAdjGammasPerEventCmd->GetNewIntValue(newValue));
398 }
399 else if(command == setNbOfPrimaryAdjElectronsPerEventCmd)
400 {
401 theAdjointRunManager->SetNbAdjointPrimaryElectronsPerEvent(
402 setNbOfPrimaryAdjElectronsPerEventCmd->GetNewIntValue(newValue));
403 }
404}
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()
Definition: G4RunManager.cc:84
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: