ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4AdjointSimMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file 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 //
28 // Class Name: G4AdjointCrossSurfChecker
29 // Author: L. Desorgher
30 // Organisation: SpaceIT GmbH
31 // Contract: ESA contract 21435/08/NL/AT
32 // Customer: ESA/ESTEC
34 
35 #include <sstream>
36 
37 #include "G4AdjointSimMessenger.hh"
38 #include "G4RunManager.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"
49 /*
50 #ifdef G4MULTITHREADED
51 #include "G4MTAdjointSimManager.hh"
52 #endif
53 */
55 //
57  : theAdjointRunManager(pAdjointRunManager)
58 /*
59 #ifdef G4MULTITHREADED
60  ,theMTAdjointRunManager(0),beamOnCmd(0)
61 #endif
62 */
63 
64 {
65  AdjointSimDir = new G4UIdirectory("/adjoint/");
66  AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
67 
68 
69  //Start and adjoint Run
70  //---------------------
71  //if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM){
72  beamOnCmd = new G4UIcommand("/adjoint/start_run",this);
73  beamOnCmd->SetGuidance("Start an adjoint Run.");
74  beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
76  G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
77  p1->SetDefaultValue(1);
78  p1->SetParameterRange("numberOfEvent >= 0");
80  //}
81 
82  //Commands to define parameters relative to the external source
83  //------------------------------------------------------------
84 
85  G4UIparameter* pos_x_par = new G4UIparameter("X",'d',true);
86 
87  G4UIparameter* pos_y_par = new G4UIparameter("Y",'d',true);
88 
89  G4UIparameter* pos_z_par = new G4UIparameter("Z",'d',true);
90 
91  G4UIparameter* radius_par = new G4UIparameter("R",'d',true);
92 
93  radius_par->SetParameterRange("R >= 0");
94 
95  G4UIparameter* unit_par = new G4UIparameter("unit",'s',true);
96 
97  DefineSpherExtSourceCmd = new G4UIcommand("/adjoint/DefineSphericalExtSource",this);
98  DefineSpherExtSourceCmd->SetGuidance("Define a spherical external source.");
104 
105  G4UIparameter* phys_vol_name_par = new G4UIparameter("phys_vol_name",'s',true);
106 
107  DefineSpherExtSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalExtSourceCenteredOnAVolume",this);
108  DefineSpherExtSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical external source with the center located at the center of a physical volume");
112 
113  DefineExtSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineExtSourceOnExtSurfaceOfAVolume",this);
114  DefineExtSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the external source on the external surface of a physical volume");
116 
117  setExtSourceEMaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetExtSourceEmax",this);
118  setExtSourceEMaxCmd->SetGuidance("Set the maximum energy of the external source");
119  setExtSourceEMaxCmd->SetParameterName("Emax",false);
122 
123  //Commands to define the adjoint source
124  //------------------------------------------------------------
125 
126  DefineSpherAdjSourceCmd = new G4UIcommand("/adjoint/DefineSphericalAdjSource",this);
127  DefineSpherAdjSourceCmd->SetGuidance("Define a spherical adjoint source.");
133 
134  DefineSpherAdjSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalAdjSourceCenteredOnAVolume",this);
135  DefineSpherAdjSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical adjoint source with the center located at the center of a physical volume");
139 
140  DefineAdjSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume",this);
141  DefineAdjSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the adjoint source on the external surface of physical volume");
143 
144  setAdjSourceEminCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmin",this);
145  setAdjSourceEminCmd->SetGuidance("Set the minimum energy of the adjoint source");
146  setAdjSourceEminCmd->SetParameterName("Emin",false);
149 
150  setAdjSourceEmaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmax",this);
151  setAdjSourceEmaxCmd->SetGuidance("Set the maximum energy of the adjoint source");
152  setAdjSourceEmaxCmd->SetParameterName("Emax",false);
155 
156  ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
157  ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
159  ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
160 
161  NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
162  NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the list of primaries");
164  NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
165 
166 
168  new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryFwdGammasPerEvent",this);
169  setNbOfPrimaryFwdGammasPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
172 
174  new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjGammasPerEvent",this);
175  setNbOfPrimaryAdjGammasPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
178 
180  new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjElectronsPerEvent",this);
181  setNbOfPrimaryAdjElectronsPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
184 
185 
186 
187 
188 }
190 //
191 /*
192 #ifdef G4MULTITHREADED
193 G4AdjointSimMessenger::G4AdjointSimMessenger(G4MTAdjointSimManager* pAdjointRunManager)
194  : theAdjointRunManager(0),theMTAdjointRunManager(pAdjointRunManager),DefineSpherExtSourceCmd(0),
195  DefineSpherExtSourceCenteredOnAVolumeCmd(0), DefineExtSourceOnAVolumeExtSurfaceCmd(0),
196  setExtSourceEMaxCmd(0),DefineSpherAdjSourceCmd(0),DefineSpherAdjSourceCenteredOnAVolumeCmd(0),
197  DefineAdjSourceOnAVolumeExtSurfaceCmd(0),setAdjSourceEminCmd(0),setAdjSourceEmaxCmd(0),
198  ConsiderParticleAsPrimaryCmd(0),NeglectParticleAsPrimaryCmd(0)
199 {
200  AdjointSimDir = new G4UIdirectory("/adjoint/");
201  AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
202 
203 
204  //Start and adjoint Run
205  //---------------------
206  beamOnCmd = new G4UIcommand("/adjoint/start_run",this);
207  beamOnCmd->SetGuidance("Start an adjoint Run.");
208  beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
209  beamOnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
210  G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
211  p1->SetDefaultValue(1);
212  p1->SetParameterRange("numberOfEvent >= 0");
213  beamOnCmd->SetParameter(p1);
214 
215 
216  ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
217  ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
218  ConsiderParticleAsPrimaryCmd->SetParameterName("particle",false);
219  ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
220 
221  NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
222  NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the lits of primaries");
223  NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
224  NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
225 
226 
227 }
228 #endif
229 */
230 
232 //
233 
235 {
236  if (beamOnCmd) delete beamOnCmd;
237 }
238 
240 //
241 
243 {
244  if (!command) return;
245  if( command==beamOnCmd )
246  {
247  G4int nev;
248  const char* nv = (const char*)newValue;
249  std::istringstream is(nv);
250  is >> nev ;
252 /*
253 #ifdef G4MULTITHREADED
254  else if (theMTAdjointRunManager) theMTAdjointRunManager->RunAdjointSimulation(nev);
255  else if (theAdjointRunManager) theAdjointRunManager->SwitchToAdjointSimulationMode();
256 #endif
257 */
258  //G4cout<<"G4AdjointSimMessenger::SetNewValue BeamOnCmd out"<<std::endl;
259  }
260  else if ( command==ConsiderParticleAsPrimaryCmd){
262  }
263  else if ( command==NeglectParticleAsPrimaryCmd){
265  }
266 /*
267 #ifdef G4MULTITHREADED
268  if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::masterRM) return;
269 #endif
270 */
271  if ( command==DefineSpherExtSourceCmd){
272 
273  G4double x,y,z,r;
274  G4String unit;
275  const char* nv = (const char*)newValue;
276  std::istringstream is(nv);
277  is >> x>>y>>z>>r>>unit;
278 
284  }
285  else if ( command==DefineSpherExtSourceCenteredOnAVolumeCmd){
286 
287  G4double r;
288  G4String vol_name, unit;
289  const char* nv = (const char*)newValue;
290  std::istringstream is(nv);
291  is >>vol_name>>r>>unit;
294  }
295  else if ( command==DefineExtSourceOnAVolumeExtSurfaceCmd){
297  }
298  else if ( command== setExtSourceEMaxCmd){
299 
301  }
302  else if ( command==DefineSpherAdjSourceCmd){
303 
304  G4double x,y,z,r;
305  G4String unit;
306  const char* nv = (const char*)newValue;
307  std::istringstream is(nv);
308  is >> x>>y>>z>>r>>unit;
309 
315  }
316  else if ( command==DefineSpherAdjSourceCenteredOnAVolumeCmd){
317 
318  G4double r;
319  G4String vol_name, unit;
320  const char* nv = (const char*)newValue;
321  std::istringstream is(nv);
322  is >>vol_name>>r>>unit;
325  }
326  else if ( command==DefineAdjSourceOnAVolumeExtSurfaceCmd){
327 
329  }
330  else if ( command== setAdjSourceEminCmd){
331 
333  }
334  else if ( command== setAdjSourceEmaxCmd){
335 
337  }
338  else if ( command== setNbOfPrimaryFwdGammasPerEventCmd){
340  }
341  else if ( command== setNbOfPrimaryAdjGammasPerEventCmd){
343  }
344  else if ( command== setNbOfPrimaryAdjElectronsPerEventCmd){
346  }
347 
348 
349 }
350