Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4AdjointSimMessenger.cc
이 파일의 문서화 페이지로 가기
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 98735 2016-08-09 10:54:06Z gcosmo $
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 "G4RunManager.hh"
40 #include "G4AdjointSimManager.hh"
41 #include "G4UIdirectory.hh"
42 #include "G4UIcmdWithABool.hh"
43 #include "G4UIcmdWithAnInteger.hh"
45 #include "G4UIcmdWithADouble.hh"
47 #include "G4UIcmdWithAString.hh"
48 #include "G4UnitsTable.hh"
50 /*
51 #ifdef G4MULTITHREADED
52 #include "G4MTAdjointSimManager.hh"
53 #endif
54 */
56 //
58  : theAdjointRunManager(pAdjointRunManager)
59 /*
60 #ifdef G4MULTITHREADED
61  ,theMTAdjointRunManager(0),beamOnCmd(0)
62 #endif
63 */
64 
65 {
66  AdjointSimDir = new G4UIdirectory("/adjoint/");
67  AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
68 
69 
70  //Start and adjoint Run
71  //---------------------
72  //if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM){
73  beamOnCmd = new G4UIcommand("/adjoint/start_run",this);
74  beamOnCmd->SetGuidance("Start an adjoint Run.");
75  beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
77  G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
78  p1->SetDefaultValue(1);
79  p1->SetParameterRange("numberOfEvent >= 0");
81  //}
82 
83  //Commands to define parameters relative to the external source
84  //------------------------------------------------------------
85 
86  G4UIparameter* pos_x_par = new G4UIparameter("X",'d',true);
87 
88  G4UIparameter* pos_y_par = new G4UIparameter("Y",'d',true);
89 
90  G4UIparameter* pos_z_par = new G4UIparameter("Z",'d',true);
91 
92  G4UIparameter* radius_par = new G4UIparameter("R",'d',true);
93 
94  radius_par->SetParameterRange("R >= 0");
95 
96  G4UIparameter* unit_par = new G4UIparameter("unit",'s',true);
97 
98  DefineSpherExtSourceCmd = new G4UIcommand("/adjoint/DefineSphericalExtSource",this);
99  DefineSpherExtSourceCmd->SetGuidance("Define a spherical external source.");
105 
106  G4UIparameter* phys_vol_name_par = new G4UIparameter("phys_vol_name",'s',true);
107 
108  DefineSpherExtSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalExtSourceCenteredOnAVolume",this);
109  DefineSpherExtSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical external source with the center located at the center of a physical volume");
113 
114  DefineExtSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineExtSourceOnExtSurfaceOfAVolume",this);
115  DefineExtSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the external source on the external surface of a physical volume");
117 
118  setExtSourceEMaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetExtSourceEmax",this);
119  setExtSourceEMaxCmd->SetGuidance("Set the maximum energy of the external source");
120  setExtSourceEMaxCmd->SetParameterName("Emax",false);
123 
124  //Commands to define the adjoint source
125  //------------------------------------------------------------
126 
127  DefineSpherAdjSourceCmd = new G4UIcommand("/adjoint/DefineSphericalAdjSource",this);
128  DefineSpherAdjSourceCmd->SetGuidance("Define a spherical adjoint source.");
134 
135  DefineSpherAdjSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalAdjSourceCenteredOnAVolume",this);
136  DefineSpherAdjSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical adjoint source with the center located at the center of a physical volume");
140 
141  DefineAdjSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume",this);
142  DefineAdjSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the adjoint source on the external surface of physical volume");
144 
145  setAdjSourceEminCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmin",this);
146  setAdjSourceEminCmd->SetGuidance("Set the minimum energy of the adjoint source");
147  setAdjSourceEminCmd->SetParameterName("Emin",false);
150 
151  setAdjSourceEmaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmax",this);
152  setAdjSourceEmaxCmd->SetGuidance("Set the maximum energy of the adjoint source");
153  setAdjSourceEmaxCmd->SetParameterName("Emax",false);
156 
157  ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
158  ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
160  ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
161 
162  NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
163  NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the list of primaries");
165  NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
166 
167 
169  new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryFwdGammasPerEvent",this);
170  setNbOfPrimaryFwdGammasPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
173 
175  new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjGammasPerEvent",this);
176  setNbOfPrimaryAdjGammasPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
179 
181  new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjElectronsPerEvent",this);
182  setNbOfPrimaryAdjElectronsPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
185 
186 
187 
188 
189 }
191 //
192 /*
193 #ifdef G4MULTITHREADED
194 G4AdjointSimMessenger::G4AdjointSimMessenger(G4MTAdjointSimManager* pAdjointRunManager)
195  : theAdjointRunManager(0),theMTAdjointRunManager(pAdjointRunManager),DefineSpherExtSourceCmd(0),
196  DefineSpherExtSourceCenteredOnAVolumeCmd(0), DefineExtSourceOnAVolumeExtSurfaceCmd(0),
197  setExtSourceEMaxCmd(0),DefineSpherAdjSourceCmd(0),DefineSpherAdjSourceCenteredOnAVolumeCmd(0),
198  DefineAdjSourceOnAVolumeExtSurfaceCmd(0),setAdjSourceEminCmd(0),setAdjSourceEmaxCmd(0),
199  ConsiderParticleAsPrimaryCmd(0),NeglectParticleAsPrimaryCmd(0)
200 {
201  AdjointSimDir = new G4UIdirectory("/adjoint/");
202  AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
203 
204 
205  //Start and adjoint Run
206  //---------------------
207  beamOnCmd = new G4UIcommand("/adjoint/start_run",this);
208  beamOnCmd->SetGuidance("Start an adjoint Run.");
209  beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
210  beamOnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
211  G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
212  p1->SetDefaultValue(1);
213  p1->SetParameterRange("numberOfEvent >= 0");
214  beamOnCmd->SetParameter(p1);
215 
216 
217  ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
218  ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
219  ConsiderParticleAsPrimaryCmd->SetParameterName("particle",false);
220  ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
221 
222  NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
223  NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the lits of primaries");
224  NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
225  NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
226 
227 
228 }
229 #endif
230 */
231 
233 //
234 
236 {
237  if (beamOnCmd) delete beamOnCmd;
238 }
239 
241 //
242 
244 {
245  if (!command) return;
246  if( command==beamOnCmd )
247  {
248  G4int nev;
249  const char* nv = (const char*)newValue;
250  std::istringstream is(nv);
251  is >> nev ;
253 /*
254 #ifdef G4MULTITHREADED
255  else if (theMTAdjointRunManager) theMTAdjointRunManager->RunAdjointSimulation(nev);
256  else if (theAdjointRunManager) theAdjointRunManager->SwitchToAdjointSimulationMode();
257 #endif
258 */
259  //G4cout<<"G4AdjointSimMessenger::SetNewValue BeamOnCmd out"<<std::endl;
260  }
261  else if ( command==ConsiderParticleAsPrimaryCmd){
263  }
264  else if ( command==NeglectParticleAsPrimaryCmd){
266  }
267 /*
268 #ifdef G4MULTITHREADED
269  if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::masterRM) return;
270 #endif
271 */
272  if ( command==DefineSpherExtSourceCmd){
273 
274  G4double x,y,z,r;
275  G4String unit;
276  const char* nv = (const char*)newValue;
277  std::istringstream is(nv);
278  is >> x>>y>>z>>r>>unit;
279 
285  }
286  else if ( command==DefineSpherExtSourceCenteredOnAVolumeCmd){
287 
288  G4double r;
289  G4String vol_name, unit;
290  const char* nv = (const char*)newValue;
291  std::istringstream is(nv);
292  is >>vol_name>>r>>unit;
295  }
296  else if ( command==DefineExtSourceOnAVolumeExtSurfaceCmd){
298  }
299  else if ( command== setExtSourceEMaxCmd){
300 
302  }
303  else if ( command==DefineSpherAdjSourceCmd){
304 
305  G4double x,y,z,r;
306  G4String unit;
307  const char* nv = (const char*)newValue;
308  std::istringstream is(nv);
309  is >> x>>y>>z>>r>>unit;
310 
316  }
317  else if ( command==DefineSpherAdjSourceCenteredOnAVolumeCmd){
318 
319  G4double r;
320  G4String vol_name, unit;
321  const char* nv = (const char*)newValue;
322  std::istringstream is(nv);
323  is >>vol_name>>r>>unit;
326  }
327  else if ( command==DefineAdjSourceOnAVolumeExtSurfaceCmd){
328 
330  }
331  else if ( command== setAdjSourceEminCmd){
332 
334  }
335  else if ( command== setAdjSourceEmaxCmd){
336 
338  }
339  else if ( command== setNbOfPrimaryFwdGammasPerEventCmd){
341  }
342  else if ( command== setNbOfPrimaryAdjGammasPerEventCmd){
344  }
345  else if ( command== setNbOfPrimaryAdjElectronsPerEventCmd){
347  }
348 
349 
350 }
351 
Float_t x
Definition: compare.C:6
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:80
CLHEP::Hep3Vector G4ThreeVector
void RunAdjointSimulation(G4int nb_evt)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4AdjointSimManager * theAdjointRunManager
G4bool DefineSphericalAdjointSource(G4double radius, G4ThreeVector pos)
Float_t y
Definition: compare.C:6
Double_t z
void SetNbOfPrimaryFwdGammasPerEvent(G4int)
G4bool DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String &volume_name)
void SetNbAdjointPrimaryGammasPerEvent(G4int)
void SetParameterRange(const char *theRange)
void SetExtSourceEmax(G4double Emax)
G4bool DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String &volume_name)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetDefaultValue(const char *theDefaultValue)
static G4double GetNewDoubleValue(const char *paramString)
double G4double
Definition: G4Types.hh:76
G4bool DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String &volume_name)
void SetAdjointSourceEmax(G4double Emax)
void SetUnitCategory(const char *unitCategory)
G4AdjointSimMessenger(G4AdjointSimManager *)
G4UIcommand * DefineSpherAdjSourceCenteredOnAVolumeCmd
static G4double GetValueOf(const G4String &)
void SetCandidates(const char *candidateList)
G4bool DefineAdjointSourceOnTheExtSurfaceOfAVolume(const G4String &volume_name)
G4UIcmdWithAnInteger * setNbOfPrimaryAdjElectronsPerEventCmd
void SetNbAdjointPrimaryElectronsPerEvent(G4int)
G4UIcmdWithAString * NeglectParticleAsPrimaryCmd
G4UIcmdWithAnInteger * setNbOfPrimaryAdjGammasPerEventCmd
G4UIcmdWithADoubleAndUnit * setAdjSourceEminCmd
int G4int
Definition: G4Types.hh:78
G4UIcmdWithADoubleAndUnit * setAdjSourceEmaxCmd
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void NeglectParticleAsPrimary(const G4String &particle_name)
G4UIcmdWithAString * DefineExtSourceOnAVolumeExtSurfaceCmd
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
G4UIcmdWithAString * DefineAdjSourceOnAVolumeExtSurfaceCmd
G4UIcommand * DefineSpherExtSourceCenteredOnAVolumeCmd
G4UIcmdWithAnInteger * setNbOfPrimaryFwdGammasPerEventCmd
void ConsiderParticleAsPrimary(const G4String &particle_name)
G4UIcmdWithADoubleAndUnit * setExtSourceEMaxCmd
G4bool DefineSphericalExtSource(G4double radius, G4ThreeVector pos)
void SetAdjointSourceEmin(G4double Emin)
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
G4UIcmdWithAString * ConsiderParticleAsPrimaryCmd
void SetNewValue(G4UIcommand *, G4String)