Geant4 11.2.2
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 () override
 
void SetNewValue (G4UIcommand *, G4String) override
 
- 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)
 
G4bool CommandsShouldBeInMaster () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String LtoS (G4long l)
 
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 54 of file G4AdjointSimMessenger.cc.

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

◆ ~G4AdjointSimMessenger()

G4AdjointSimMessenger::~G4AdjointSimMessenger ( )
override

Definition at line 193 of file G4AdjointSimMessenger.cc.

194{
195 delete setNbOfPrimaryAdjElectronsPerEventCmd;
196 delete setNbOfPrimaryAdjGammasPerEventCmd;
197 delete setNbOfPrimaryFwdGammasPerEventCmd;
198 delete NeglectParticleAsPrimaryCmd;
199 delete ConsiderParticleAsPrimaryCmd;
200 delete setAdjSourceEmaxCmd;
201 delete setAdjSourceEminCmd;
202 delete DefineAdjSourceOnAVolumeExtSurfaceCmd;
203 delete DefineSpherAdjSourceCenteredOnAVolumeCmd;
204 delete DefineSpherAdjSourceCmd;
205 delete setExtSourceEMaxCmd;
206 delete DefineExtSourceOnAVolumeExtSurfaceCmd;
207 delete DefineSpherExtSourceCenteredOnAVolumeCmd;
208 delete DefineSpherExtSourceCmd;
209 delete beamOnCmd;
210 delete AdjointSimDir;
211}

Member Function Documentation

◆ SetNewValue()

void G4AdjointSimMessenger::SetNewValue ( G4UIcommand * command,
G4String newValue )
overridevirtual

Reimplemented from G4UImessenger.

Definition at line 215 of file G4AdjointSimMessenger.cc.

216{
217 if (command == nullptr) return;
218 if (command == beamOnCmd) {
219 G4int nev;
220 const auto nv = (const char*)newValue;
221 std::istringstream is(nv);
222 is >> nev;
223 if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM)
224 theAdjointRunManager->RunAdjointSimulation(nev);
225 }
226 else if (command == ConsiderParticleAsPrimaryCmd) {
227 theAdjointRunManager->ConsiderParticleAsPrimary(newValue);
228 }
229 else if (command == NeglectParticleAsPrimaryCmd) {
230 theAdjointRunManager->NeglectParticleAsPrimary(newValue);
231 }
232 if (command == DefineSpherExtSourceCmd) {
233 G4double x, y, z, r;
234 G4String unit;
235 const auto nv = (const char*)newValue;
236 std::istringstream is(nv);
237 is >> x >> y >> z >> r >> unit;
238
243 theAdjointRunManager->DefineSphericalExtSource(r, G4ThreeVector(x, y, z));
244 }
245 else if (command == DefineSpherExtSourceCenteredOnAVolumeCmd) {
246 G4double r;
247 G4String vol_name, unit;
248 const auto nv = (const char*)newValue;
249 std::istringstream is(nv);
250 is >> vol_name >> r >> unit;
252 theAdjointRunManager->DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(r, vol_name);
253 }
254 else if (command == DefineExtSourceOnAVolumeExtSurfaceCmd) {
255 theAdjointRunManager->DefineExtSourceOnTheExtSurfaceOfAVolume(newValue);
256 }
257 else if (command == setExtSourceEMaxCmd) {
258 theAdjointRunManager->SetExtSourceEmax(setExtSourceEMaxCmd->GetNewDoubleValue(newValue));
259 }
260 else if (command == DefineSpherAdjSourceCmd) {
261 G4double x, y, z, r;
262 G4String unit;
263 const auto nv = (const char*)newValue;
264 std::istringstream is(nv);
265 is >> x >> y >> z >> r >> unit;
266
271 theAdjointRunManager->DefineSphericalAdjointSource(r, G4ThreeVector(x, y, z));
272 }
273 else if (command == DefineSpherAdjSourceCenteredOnAVolumeCmd) {
274 G4double r;
275 G4String vol_name, unit;
276 const auto nv = (const char*)newValue;
277 std::istringstream is(nv);
278 is >> vol_name >> r >> unit;
280 theAdjointRunManager->DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(r, vol_name);
281 }
282 else if (command == DefineAdjSourceOnAVolumeExtSurfaceCmd) {
283 theAdjointRunManager->DefineAdjointSourceOnTheExtSurfaceOfAVolume(newValue);
284 }
285 else if (command == setAdjSourceEminCmd) {
286 theAdjointRunManager->SetAdjointSourceEmin(setAdjSourceEminCmd->GetNewDoubleValue(newValue));
287 }
288 else if (command == setAdjSourceEmaxCmd) {
289 theAdjointRunManager->SetAdjointSourceEmax(setAdjSourceEmaxCmd->GetNewDoubleValue(newValue));
290 }
291 else if (command == setNbOfPrimaryFwdGammasPerEventCmd) {
292 theAdjointRunManager->SetNbOfPrimaryFwdGammasPerEvent(
293 setNbOfPrimaryFwdGammasPerEventCmd->GetNewIntValue(newValue));
294 }
295 else if (command == setNbOfPrimaryAdjGammasPerEventCmd) {
296 theAdjointRunManager->SetNbAdjointPrimaryGammasPerEvent(
297 setNbOfPrimaryAdjGammasPerEventCmd->GetNewIntValue(newValue));
298 }
299 else if (command == setNbOfPrimaryAdjElectronsPerEventCmd) {
300 theAdjointRunManager->SetNbAdjointPrimaryElectronsPerEvent(
301 setNbOfPrimaryAdjElectronsPerEventCmd->GetNewIntValue(newValue));
302 }
303}
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: