Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id$
27 //
29 // Class Name: G4AdjointCrossSurfChecker
30 // Author: L. Desorgher
31 // Organisation: SpaceIT GmbH
32 // Contract: ESA contract 21435/08/NL/AT
33 // Customer: ESA/ESTEC
35 
36 #include <sstream>
37 
38 #include "G4AdjointSimMessenger.hh"
39 #include "G4AdjointSimManager.hh"
40 #include "G4UIdirectory.hh"
41 #include "G4UIcmdWithABool.hh"
42 #include "G4UIcmdWithAnInteger.hh"
44 #include "G4UIcmdWithADouble.hh"
46 #include "G4UIcmdWithAString.hh"
47 #include "G4UnitsTable.hh"
50 //
52  : theAdjointRunManager(pAdjointRunManager)
53 {
54  AdjointSimDir = new G4UIdirectory("/adjoint/");
55  AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
56 
57  //Start and adjoint Run
58  //---------------------
59 
60  beamOnCmd = new G4UIcommand("/adjoint/start_run",this);
61  beamOnCmd->SetGuidance("Start an adjoint Run.");
62  beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
64  G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
65  p1->SetDefaultValue(1);
66  p1->SetParameterRange("numberOfEvent >= 0");
67  beamOnCmd->SetParameter(p1);
68 
69  //Commands to define parameters relative to the external source
70  //------------------------------------------------------------
71 
72  G4UIparameter* pos_x_par = new G4UIparameter("X",'d',true);
73 
74  G4UIparameter* pos_y_par = new G4UIparameter("Y",'d',true);
75 
76  G4UIparameter* pos_z_par = new G4UIparameter("Z",'d',true);
77 
78  G4UIparameter* radius_par = new G4UIparameter("R",'d',true);
79 
80  radius_par->SetParameterRange("R >= 0");
81 
82  G4UIparameter* unit_par = new G4UIparameter("unit",'s',true);
83 
84  DefineSpherExtSourceCmd = new G4UIcommand("/adjoint/DefineSphericalExtSource",this);
85  DefineSpherExtSourceCmd->SetGuidance("Define a spherical external source.");
86  DefineSpherExtSourceCmd->SetParameter(pos_x_par);
87  DefineSpherExtSourceCmd->SetParameter(pos_y_par);
88  DefineSpherExtSourceCmd->SetParameter(pos_z_par);
89  DefineSpherExtSourceCmd->SetParameter(radius_par);
90  DefineSpherExtSourceCmd->SetParameter(unit_par);
91 
92  G4UIparameter* phys_vol_name_par = new G4UIparameter("phys_vol_name",'s',true);
93 
94  DefineSpherExtSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalExtSourceCenteredOnAVolume",this);
95  DefineSpherExtSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical external source with the center located at the center of a physical volume");
96  DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(phys_vol_name_par);
97  DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(radius_par);
98  DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(unit_par);
99 
100  DefineExtSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineExtSourceOnExtSurfaceOfAVolume",this);
101  DefineExtSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the external source on the external surface of a physical volume");
102  DefineExtSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",false);
103 
104  setExtSourceEMaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetExtSourceEmax",this);
105  setExtSourceEMaxCmd->SetGuidance("Set the maximum energy of the external source");
106  setExtSourceEMaxCmd->SetParameterName("Emax",false);
107  setExtSourceEMaxCmd->SetUnitCategory("Energy");
108  setExtSourceEMaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
109 
110  //Commands to define the adjoint source
111  //------------------------------------------------------------
112 
113  DefineSpherAdjSourceCmd = new G4UIcommand("/adjoint/DefineSphericalAdjSource",this);
114  DefineSpherAdjSourceCmd->SetGuidance("Define a spherical adjoint source.");
115  DefineSpherAdjSourceCmd->SetParameter(pos_x_par);
116  DefineSpherAdjSourceCmd->SetParameter(pos_y_par);
117  DefineSpherAdjSourceCmd->SetParameter(pos_z_par);
118  DefineSpherAdjSourceCmd->SetParameter(radius_par);
119  DefineSpherAdjSourceCmd->SetParameter(unit_par);
120 
121  DefineSpherAdjSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalAdjSourceCenteredOnAVolume",this);
122  DefineSpherAdjSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical adjoint source with the center located at the center of a physical volume");
123  DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(phys_vol_name_par);
124  DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(radius_par);
125  DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(unit_par);
126 
127  DefineAdjSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume",this);
128  DefineAdjSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the adjoint source on the external surface of physical volume");
129  DefineAdjSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",false);
130 
131  setAdjSourceEminCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmin",this);
132  setAdjSourceEminCmd->SetGuidance("Set the minimum energy of the adjoint source");
133  setAdjSourceEminCmd->SetParameterName("Emin",false);
134  setAdjSourceEminCmd->SetUnitCategory("Energy");
135  setAdjSourceEminCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
136 
137  setAdjSourceEmaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmax",this);
138  setAdjSourceEmaxCmd->SetGuidance("Set the maximum energy of the adjoint source");
139  setAdjSourceEmaxCmd->SetParameterName("Emax",false);
140  setAdjSourceEmaxCmd->SetUnitCategory("Energy");
141  setAdjSourceEmaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
142 
143  ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
144  ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
145  ConsiderParticleAsPrimaryCmd->SetParameterName("particle",false);
146  ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
147 
148  NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
149  NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the lits of primaries");
150  NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
151  NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
152 }
153 
155 //
156 
158 {
159  delete beamOnCmd;
160 }
161 
163 //
164 
166 {
167  if( command==beamOnCmd )
168  {
169  G4int nev;
170  const char* nv = (const char*)newValue;
171  std::istringstream is(nv);
172  is >> nev ;
173  theAdjointRunManager->RunAdjointSimulation(nev);
174  }
175  else if ( command==DefineSpherExtSourceCmd){
176 
177  G4double x,y,z,r;
178  G4String unit;
179  const char* nv = (const char*)newValue;
180  std::istringstream is(nv);
181  is >> x>>y>>z>>r>>unit;
182 
187  theAdjointRunManager->DefineSphericalExtSource(r,G4ThreeVector(x,y,z));
188  }
189  else if ( command==DefineSpherExtSourceCenteredOnAVolumeCmd){
190 
191  G4double r;
192  G4String vol_name, unit;
193  const char* nv = (const char*)newValue;
194  std::istringstream is(nv);
195  is >>vol_name>>r>>unit;
197  theAdjointRunManager->DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(r,vol_name);
198  }
199  else if ( command==DefineExtSourceOnAVolumeExtSurfaceCmd){
200  theAdjointRunManager->DefineExtSourceOnTheExtSurfaceOfAVolume(newValue);
201  }
202  else if ( command== setExtSourceEMaxCmd){
203 
204  theAdjointRunManager->SetExtSourceEmax(setExtSourceEMaxCmd->GetNewDoubleValue(newValue));
205  }
206  else if ( command==DefineSpherAdjSourceCmd){
207 
208  G4double x,y,z,r;
209  G4String unit;
210  const char* nv = (const char*)newValue;
211  std::istringstream is(nv);
212  is >> x>>y>>z>>r>>unit;
213 
218  theAdjointRunManager->DefineSphericalAdjointSource(r,G4ThreeVector(x,y,z));
219  }
220  else if ( command==DefineSpherAdjSourceCenteredOnAVolumeCmd){
221 
222  G4double r;
223  G4String vol_name, unit;
224  const char* nv = (const char*)newValue;
225  std::istringstream is(nv);
226  is >>vol_name>>r>>unit;
228  theAdjointRunManager->DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(r,vol_name);
229  }
230  else if ( command==DefineAdjSourceOnAVolumeExtSurfaceCmd){
231 
232  theAdjointRunManager->DefineAdjointSourceOnTheExtSurfaceOfAVolume(newValue);
233  }
234  else if ( command== setAdjSourceEminCmd){
235 
236  theAdjointRunManager->SetAdjointSourceEmin(setAdjSourceEminCmd->GetNewDoubleValue(newValue));
237  }
238  else if ( command== setAdjSourceEmaxCmd){
239 
240  theAdjointRunManager->SetAdjointSourceEmax(setAdjSourceEmaxCmd->GetNewDoubleValue(newValue));
241  }
242  else if ( command==ConsiderParticleAsPrimaryCmd){
243 
244  theAdjointRunManager->ConsiderParticleAsPrimary(newValue);
245  }
246  else if ( command==NeglectParticleAsPrimaryCmd){
247 
248  theAdjointRunManager->NeglectParticleAsPrimary(newValue);
249  }
250 }
251