Geant4-11
G4AdjointSimMessenger.cc
Go to the documentation of this file.
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// G4AdjointSimMessenger implementation
27//
28// --------------------------------------------------------------------
29// Class Name: G4AdjointSimMessenger
30// Author: L. Desorgher, 2007-2009
31// Organisation: SpaceIT GmbH
32// Contract: ESA contract 21435/08/NL/AT
33// Customer: ESA/ESTEC
34// --------------------------------------------------------------------
35
36#include <sstream>
37
40#include "G4RunManager.hh"
42#include "G4UIcmdWithABool.hh"
43#include "G4UIcmdWithADouble.hh"
45#include "G4UIcmdWithAString.hh"
48#include "G4UIdirectory.hh"
49#include "G4UnitsTable.hh"
50
51// --------------------------------------------------------------------
52//
55 : theAdjointRunManager(pAdjointRunManager)
56{
57 AdjointSimDir = new G4UIdirectory("/adjoint/");
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");
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
89 new G4UIcommand("/adjoint/DefineSphericalExtSource", this);
90 DefineSpherExtSourceCmd->SetGuidance("Define a spherical external source.");
96
97 G4UIparameter* phys_vol_name_par =
98 new G4UIparameter("phys_vol_name", 's', true);
99
101 new G4UIcommand("/adjoint/DefineSphericalExtSourceCenteredOnAVolume", this);
103 "Define a spherical external source with the center located at the center "
104 "of a "
105 "physical volume");
109
111 "/adjoint/DefineExtSourceOnExtSurfaceOfAVolume", this);
113 "Set the external source on the external surface of a physical volume");
115 false);
116
118 new G4UIcmdWithADoubleAndUnit("/adjoint/SetExtSourceEmax", this);
120 "Set the maximum energy of the external source");
124
125 // Commands to define the adjoint source
126 //------------------------------------------------------------
127
129 new G4UIcommand("/adjoint/DefineSphericalAdjSource", this);
130 DefineSpherAdjSourceCmd->SetGuidance("Define a spherical adjoint source.");
136
138 new G4UIcommand("/adjoint/DefineSphericalAdjSourceCenteredOnAVolume", this);
140 "Define a spherical adjoint source with the center located at the center "
141 "of a "
142 "physical volume");
146
148 "/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume", this);
150 "Set the adjoint source on the external surface of physical volume");
152 false);
153
155 new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmin", this);
157 "Set the minimum energy of the adjoint source");
161
163 new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmax", this);
165 "Set the maximum energy of the adjoint source");
169
171 new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary", this);
173 "Set the selected particle as primary");
175 ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
176
178 new G4UIcmdWithAString("/adjoint/NeglectAsPrimary", this);
180 "Remove the selected particle from the list of primaries");
182 NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
183
185 new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryFwdGammasPerEvent", this);
187 "Set the nb of primary fwd gamm generated on the adjoint source");
191
193 new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjGammasPerEvent", this);
195 "Set the nb of primary fwd gamm generated on the adjoint source");
199
201 "/adjoint/SetNbOfPrimaryAdjElectronsPerEvent", this);
203 "Set the nb of primary fwd gamm generated on the adjoint source");
207}
208
209// --------------------------------------------------------------------
210//
212{
218 delete setAdjSourceEmaxCmd;
219 delete setAdjSourceEminCmd;
223 delete setExtSourceEMaxCmd;
227 delete beamOnCmd;
228 delete AdjointSimDir;
229}
230
231// --------------------------------------------------------------------
232//
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() ==
246 }
247 else if(command == ConsiderParticleAsPrimaryCmd)
248 {
250 }
251 else if(command == NeglectParticleAsPrimaryCmd)
252 {
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
268 }
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;
279 }
280 else if(command == DefineExtSourceOnAVolumeExtSurfaceCmd)
281 {
283 }
284 else if(command == setExtSourceEMaxCmd)
285 {
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
302 G4ThreeVector(x, y, z));
303 }
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;
314 }
315 else if(command == DefineAdjSourceOnAVolumeExtSurfaceCmd)
316 {
318 }
319 else if(command == setAdjSourceEminCmd)
320 {
323 }
324 else if(command == setAdjSourceEmaxCmd)
325 {
328 }
329 else if(command == setNbOfPrimaryFwdGammasPerEventCmd)
330 {
333 }
334 else if(command == setNbOfPrimaryAdjGammasPerEventCmd)
335 {
338 }
339 else if(command == setNbOfPrimaryAdjElectronsPerEventCmd)
340 {
343 }
344}
@ G4State_Idle
@ G4State_PreInit
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)
G4UIcmdWithADoubleAndUnit * setAdjSourceEminCmd
G4AdjointSimManager * theAdjointRunManager
G4AdjointSimMessenger(G4AdjointSimManager *)
G4UIcmdWithAnInteger * setNbOfPrimaryAdjGammasPerEventCmd
G4UIcmdWithAnInteger * setNbOfPrimaryFwdGammasPerEventCmd
G4UIcmdWithADoubleAndUnit * setAdjSourceEmaxCmd
void SetNewValue(G4UIcommand *, G4String)
G4UIcmdWithADoubleAndUnit * setExtSourceEMaxCmd
G4UIcommand * DefineSpherAdjSourceCenteredOnAVolumeCmd
G4UIcmdWithAString * NeglectParticleAsPrimaryCmd
G4UIcmdWithAString * DefineExtSourceOnAVolumeExtSurfaceCmd
G4UIcommand * DefineSpherExtSourceCenteredOnAVolumeCmd
G4UIcmdWithAString * ConsiderParticleAsPrimaryCmd
G4UIcmdWithAString * DefineAdjSourceOnAVolumeExtSurfaceCmd
G4UIcmdWithAnInteger * setNbOfPrimaryAdjElectronsPerEventCmd
static G4RunManager * GetRunManager()
void SetUnitCategory(const char *unitCategory)
static G4double GetNewDoubleValue(const char *paramString)
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)
static G4int GetNewIntValue(const char *paramString)
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:288
void SetDefaultValue(const char *theDefaultValue)
void SetParameterRange(const char *theRange)
static G4double GetValueOf(const G4String &)