00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00029
00030
00031
00032
00033
00035
00036 #include <sstream>
00037
00038 #include "G4AdjointSimMessenger.hh"
00039 #include "G4AdjointSimManager.hh"
00040 #include "G4UIdirectory.hh"
00041 #include "G4UIcmdWithABool.hh"
00042 #include "G4UIcmdWithAnInteger.hh"
00043 #include "G4UIcmdWithADoubleAndUnit.hh"
00044 #include "G4UIcmdWithADouble.hh"
00045 #include "G4UIcmdWithoutParameter.hh"
00046 #include "G4UIcmdWithAString.hh"
00047 #include "G4UnitsTable.hh"
00048 #include "G4UIcmdWith3VectorAndUnit.hh"
00050
00051 G4AdjointSimMessenger::G4AdjointSimMessenger(G4AdjointSimManager* pAdjointRunManager)
00052 : theAdjointRunManager(pAdjointRunManager)
00053 {
00054 AdjointSimDir = new G4UIdirectory("/adjoint/");
00055 AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
00056
00057
00058
00059
00060 beamOnCmd = new G4UIcommand("/adjoint/start_run",this);
00061 beamOnCmd->SetGuidance("Start an adjoint Run.");
00062 beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
00063 beamOnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00064 G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
00065 p1->SetDefaultValue(1);
00066 p1->SetParameterRange("numberOfEvent >= 0");
00067 beamOnCmd->SetParameter(p1);
00068
00069
00070
00071
00072 G4UIparameter* pos_x_par = new G4UIparameter("X",'d',true);
00073
00074 G4UIparameter* pos_y_par = new G4UIparameter("Y",'d',true);
00075
00076 G4UIparameter* pos_z_par = new G4UIparameter("Z",'d',true);
00077
00078 G4UIparameter* radius_par = new G4UIparameter("R",'d',true);
00079
00080 radius_par->SetParameterRange("R >= 0");
00081
00082 G4UIparameter* unit_par = new G4UIparameter("unit",'s',true);
00083
00084 DefineSpherExtSourceCmd = new G4UIcommand("/adjoint/DefineSphericalExtSource",this);
00085 DefineSpherExtSourceCmd->SetGuidance("Define a spherical external source.");
00086 DefineSpherExtSourceCmd->SetParameter(pos_x_par);
00087 DefineSpherExtSourceCmd->SetParameter(pos_y_par);
00088 DefineSpherExtSourceCmd->SetParameter(pos_z_par);
00089 DefineSpherExtSourceCmd->SetParameter(radius_par);
00090 DefineSpherExtSourceCmd->SetParameter(unit_par);
00091
00092 G4UIparameter* phys_vol_name_par = new G4UIparameter("phys_vol_name",'s',true);
00093
00094 DefineSpherExtSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalExtSourceCenteredOnAVolume",this);
00095 DefineSpherExtSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical external source with the center located at the center of a physical volume");
00096 DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(phys_vol_name_par);
00097 DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(radius_par);
00098 DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(unit_par);
00099
00100 DefineExtSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineExtSourceOnExtSurfaceOfAVolume",this);
00101 DefineExtSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the external source on the external surface of a physical volume");
00102 DefineExtSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",false);
00103
00104 setExtSourceEMaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetExtSourceEmax",this);
00105 setExtSourceEMaxCmd->SetGuidance("Set the maximum energy of the external source");
00106 setExtSourceEMaxCmd->SetParameterName("Emax",false);
00107 setExtSourceEMaxCmd->SetUnitCategory("Energy");
00108 setExtSourceEMaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00109
00110
00111
00112
00113 DefineSpherAdjSourceCmd = new G4UIcommand("/adjoint/DefineSphericalAdjSource",this);
00114 DefineSpherAdjSourceCmd->SetGuidance("Define a spherical adjoint source.");
00115 DefineSpherAdjSourceCmd->SetParameter(pos_x_par);
00116 DefineSpherAdjSourceCmd->SetParameter(pos_y_par);
00117 DefineSpherAdjSourceCmd->SetParameter(pos_z_par);
00118 DefineSpherAdjSourceCmd->SetParameter(radius_par);
00119 DefineSpherAdjSourceCmd->SetParameter(unit_par);
00120
00121 DefineSpherAdjSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalAdjSourceCenteredOnAVolume",this);
00122 DefineSpherAdjSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical adjoint source with the center located at the center of a physical volume");
00123 DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(phys_vol_name_par);
00124 DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(radius_par);
00125 DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(unit_par);
00126
00127 DefineAdjSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume",this);
00128 DefineAdjSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the adjoint source on the external surface of physical volume");
00129 DefineAdjSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",false);
00130
00131 setAdjSourceEminCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmin",this);
00132 setAdjSourceEminCmd->SetGuidance("Set the minimum energy of the adjoint source");
00133 setAdjSourceEminCmd->SetParameterName("Emin",false);
00134 setAdjSourceEminCmd->SetUnitCategory("Energy");
00135 setAdjSourceEminCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00136
00137 setAdjSourceEmaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmax",this);
00138 setAdjSourceEmaxCmd->SetGuidance("Set the maximum energy of the adjoint source");
00139 setAdjSourceEmaxCmd->SetParameterName("Emax",false);
00140 setAdjSourceEmaxCmd->SetUnitCategory("Energy");
00141 setAdjSourceEmaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
00142
00143 ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
00144 ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
00145 ConsiderParticleAsPrimaryCmd->SetParameterName("particle",false);
00146 ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
00147
00148 NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
00149 NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the lits of primaries");
00150 NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
00151 NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
00152 }
00153
00155
00156
00157 G4AdjointSimMessenger::~G4AdjointSimMessenger()
00158 {
00159 delete beamOnCmd;
00160 }
00161
00163
00164
00165 void G4AdjointSimMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
00166 {
00167 if( command==beamOnCmd )
00168 {
00169 G4int nev;
00170 const char* nv = (const char*)newValue;
00171 std::istringstream is(nv);
00172 is >> nev ;
00173 theAdjointRunManager->RunAdjointSimulation(nev);
00174 }
00175 else if ( command==DefineSpherExtSourceCmd){
00176
00177 G4double x,y,z,r;
00178 G4String unit;
00179 const char* nv = (const char*)newValue;
00180 std::istringstream is(nv);
00181 is >> x>>y>>z>>r>>unit;
00182
00183 x*=G4UnitDefinition::GetValueOf(unit);
00184 y*=G4UnitDefinition::GetValueOf(unit);
00185 z*=G4UnitDefinition::GetValueOf(unit);
00186 r*=G4UnitDefinition::GetValueOf(unit);
00187 theAdjointRunManager->DefineSphericalExtSource(r,G4ThreeVector(x,y,z));
00188 }
00189 else if ( command==DefineSpherExtSourceCenteredOnAVolumeCmd){
00190
00191 G4double r;
00192 G4String vol_name, unit;
00193 const char* nv = (const char*)newValue;
00194 std::istringstream is(nv);
00195 is >>vol_name>>r>>unit;
00196 r*=G4UnitDefinition::GetValueOf(unit);
00197 theAdjointRunManager->DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(r,vol_name);
00198 }
00199 else if ( command==DefineExtSourceOnAVolumeExtSurfaceCmd){
00200 theAdjointRunManager->DefineExtSourceOnTheExtSurfaceOfAVolume(newValue);
00201 }
00202 else if ( command== setExtSourceEMaxCmd){
00203
00204 theAdjointRunManager->SetExtSourceEmax(setExtSourceEMaxCmd->GetNewDoubleValue(newValue));
00205 }
00206 else if ( command==DefineSpherAdjSourceCmd){
00207
00208 G4double x,y,z,r;
00209 G4String unit;
00210 const char* nv = (const char*)newValue;
00211 std::istringstream is(nv);
00212 is >> x>>y>>z>>r>>unit;
00213
00214 x*=G4UnitDefinition::GetValueOf(unit);
00215 y*=G4UnitDefinition::GetValueOf(unit);
00216 z*=G4UnitDefinition::GetValueOf(unit);
00217 r*=G4UnitDefinition::GetValueOf(unit);
00218 theAdjointRunManager->DefineSphericalAdjointSource(r,G4ThreeVector(x,y,z));
00219 }
00220 else if ( command==DefineSpherAdjSourceCenteredOnAVolumeCmd){
00221
00222 G4double r;
00223 G4String vol_name, unit;
00224 const char* nv = (const char*)newValue;
00225 std::istringstream is(nv);
00226 is >>vol_name>>r>>unit;
00227 r*=G4UnitDefinition::GetValueOf(unit);
00228 theAdjointRunManager->DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(r,vol_name);
00229 }
00230 else if ( command==DefineAdjSourceOnAVolumeExtSurfaceCmd){
00231
00232 theAdjointRunManager->DefineAdjointSourceOnTheExtSurfaceOfAVolume(newValue);
00233 }
00234 else if ( command== setAdjSourceEminCmd){
00235
00236 theAdjointRunManager->SetAdjointSourceEmin(setAdjSourceEminCmd->GetNewDoubleValue(newValue));
00237 }
00238 else if ( command== setAdjSourceEmaxCmd){
00239
00240 theAdjointRunManager->SetAdjointSourceEmax(setAdjSourceEmaxCmd->GetNewDoubleValue(newValue));
00241 }
00242 else if ( command==ConsiderParticleAsPrimaryCmd){
00243
00244 theAdjointRunManager->ConsiderParticleAsPrimary(newValue);
00245 }
00246 else if ( command==NeglectParticleAsPrimaryCmd){
00247
00248 theAdjointRunManager->NeglectParticleAsPrimary(newValue);
00249 }
00250 }
00251