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