Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RMC01AnalysisManagerMessenger.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 //
28 //
29 // $Id: RMC01AnalysisManagerMessenger.cc 71233 2013-06-12 13:16:05Z gcosmo $
30 //
32 // Class Name: RMC01AnalysisManagerMessenger
33 // Author: L. Desorgher
34 // Organisation: SpaceIT GmbH
35 // Contract: ESA contract 21435/08/NL/AT
36 // Customer: ESA/ESTEC
38 
40 
41 #include "RMC01AnalysisManager.hh"
42 #include "G4UIdirectory.hh"
43 #include "G4UIcmdWithADouble.hh"
44 #include "G4UnitsTable.hh"
45 #include "G4SystemOfUnits.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50  RMC01AnalysisManager* analysisManager)
51 : G4UImessenger(),
52  fAnalysisManager(analysisManager),
53  fAnalysisDir(0),
54  fSetPrecisionForConvergenceTestCmd(0),
55  fSetExpSpectrumToNormaliseAdjResCmd(0),
56  fSetPowerLawSpectrumToNormaliseAdjResCmd(0)
57 {
58  fAnalysisDir = new G4UIdirectory("/RMC01/analysis/");
59  fAnalysisDir->SetGuidance("Analysis commands");
60 
61  G4UIparameter* fluence_par = new G4UIparameter("Fluence",'d',true);
62  fluence_par->SetParameterRange("Fluence > 0");
63  fluence_par->SetGuidance("Omnidirectional fluence for primary spectrum");
64 
65  G4UIparameter* fluence_unit_par = new G4UIparameter("Fluence_unit",'s',true);
66  fluence_unit_par->SetParameterCandidates("1/cm2 1/m2 cm-2 m-2");
67 
68  G4UIparameter* alpha_par = new G4UIparameter("alpha",'d',true);
69 
70  G4UIparameter* e0_par = new G4UIparameter("E0",'d',true);
71  e0_par->SetParameterRange("E0 > 0");
72 
73  G4UIparameter* e1_par = new G4UIparameter("E1",'d',true);
74  e1_par->SetParameterRange("E1 > 0");
75 
76  G4UIparameter* e2_par = new G4UIparameter("E2",'d',true);
77  e2_par->SetParameterRange("E2 > 0");
78 
79  G4UIparameter* e_unit_par = new G4UIparameter("E_unit",'s',true);
80  e_unit_par->SetParameterCandidates("eV keV MeV GeV TeV");
81 
82  G4UIparameter* part_name_par = new G4UIparameter("particle_name",'s',true);
83  part_name_par->SetParameterCandidates("e- gamma proton ");
84 
85  fSetPowerLawSpectrumToNormaliseAdjResCmd =
86  new G4UIcommand("/RMC01/analysis/SetPowerLawPrimSpectrumForAdjointSim",this);
87  fSetPowerLawSpectrumToNormaliseAdjResCmd
88  ->SetGuidance("Set the primary spectrum to which adjoint simulation "
89  "results will be normalised as a power law (Ekin^-alpha).");
90  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(part_name_par);
91  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_par);
92  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_unit_par);
93  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(alpha_par);
94  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e1_par);
95  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e2_par);
96  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e_unit_par);
97  fSetPowerLawSpectrumToNormaliseAdjResCmd
99 
100 
101  fSetExpSpectrumToNormaliseAdjResCmd = new G4UIcommand("/RMC01/analysis/"
102  "SetExponentialSpectrumForAdjointSim",this);
103  fSetExpSpectrumToNormaliseAdjResCmd
104  ->SetGuidance("Set the primary spectrum to which adjoint simulation results"
105  "will be normalised as exponential (exp(-Ekin/E0)).");
106  fSetExpSpectrumToNormaliseAdjResCmd
107  ->SetParameter(new G4UIparameter(*part_name_par));
108  fSetExpSpectrumToNormaliseAdjResCmd
109  ->SetParameter(new G4UIparameter(*fluence_par));
110  fSetExpSpectrumToNormaliseAdjResCmd
111  ->SetParameter(new G4UIparameter(*fluence_unit_par));
112  fSetExpSpectrumToNormaliseAdjResCmd
113  ->SetParameter(new G4UIparameter(*e0_par));
114  fSetExpSpectrumToNormaliseAdjResCmd
115  ->SetParameter(new G4UIparameter(*e1_par));
116  fSetExpSpectrumToNormaliseAdjResCmd
117  ->SetParameter(new G4UIparameter(*e2_par));
118  fSetExpSpectrumToNormaliseAdjResCmd
119  ->SetParameter(new G4UIparameter(*e_unit_par));
120  fSetExpSpectrumToNormaliseAdjResCmd
122 
123 
124  fSetPrecisionForConvergenceTestCmd = new G4UIcmdWithADouble("/RMC01/analysis/"
125  "SetExpectedPrecisionOfResults",this);
126  fSetPrecisionForConvergenceTestCmd
127  ->SetGuidance("Set the precision in % that the computed energy deposited "
128  "in the sensitive volume should reached. If this precision is reached"
129  " before the end of the run, the run is aborted and the results are "
130  "registered.");
131  fSetPrecisionForConvergenceTestCmd->SetParameterName("Precision",true);
132  fSetPrecisionForConvergenceTestCmd
134 }
135 
136 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
137 
139 {
140  delete fAnalysisDir;
141 }
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144 
146  G4UIcommand* command,G4String newValue)
147 {
148  if( command == fSetPowerLawSpectrumToNormaliseAdjResCmd){
149  G4double alpha,e1,e2,fluence;
150  G4String f_unit,e_unit,part_name;
151  const char* nv = (const char*)newValue;
152  std::istringstream is(nv);
153  is >> part_name>>fluence>>f_unit>>alpha>>e1>>e2>>e_unit;
154 
155  G4double factor_f_unit=1/cm2;
156  if (f_unit == "1/m2" || f_unit =="m-2") factor_f_unit=1/m2;
157  fluence*=factor_f_unit;
158  e1*= G4UnitDefinition::GetValueOf(e_unit);
159  e2*= G4UnitDefinition::GetValueOf(e_unit);
160  fAnalysisManager->SetPrimaryPowerLawSpectrumForAdjointSim(
161  part_name, fluence, alpha, e1, e2);
162  }
163  else if( command == fSetExpSpectrumToNormaliseAdjResCmd){
164  G4double e0,e1,e2,fluence;
165  G4String f_unit,e_unit,part_name;
166  const char* nv = (const char*)newValue;
167  std::istringstream is(nv);
168  is >> part_name>>fluence>>f_unit>>e0>>e1>>e2>>e_unit;
169 
170  G4double factor_f_unit=1/cm2;
171  if (f_unit == "1/m2" || f_unit =="m-2") factor_f_unit=1/m2;
172 
173  fluence*=factor_f_unit;
174  e0*= G4UnitDefinition::GetValueOf(e_unit);
175  e1*= G4UnitDefinition::GetValueOf(e_unit);
176  e2*= G4UnitDefinition::GetValueOf(e_unit);
177 
178  fAnalysisManager->SetPrimaryExpSpectrumForAdjointSim(part_name,
179  fluence, e0, e1, e2);
180 
181  }
182  else if( command == fSetPrecisionForConvergenceTestCmd){
183  fAnalysisManager->SetPrecision(
184  fSetPrecisionForConvergenceTestCmd->GetNewDoubleValue(newValue));
185  }
186 }
187 
188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetPrimaryPowerLawSpectrumForAdjointSim(const G4String &particle_name, G4double fluence, G4double alpha, G4double Emin, G4double Emax)
static constexpr double cm2
Definition: G4SIunits.hh:120
void SetParameterRange(const char *theRange)
void SetParameterCandidates(const char *theString)
void SetPrimaryExpSpectrumForAdjointSim(const G4String &particle_name, G4double fluence, G4double E0, G4double Emin, G4double Emax)
static G4double GetValueOf(const G4String &)
void SetPrecision(G4double precision)
virtual void SetNewValue(G4UIcommand *, G4String)
static G4double GetNewDoubleValue(const char *paramString)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:240
Definition of the RMC01AnalysisManager class.
Definition of the RMC01AnalysisManagerMessenger class.
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
RMC01AnalysisManagerMessenger(RMC01AnalysisManager *)
double G4double
Definition: G4Types.hh:76
void SetGuidance(const char *theGuidance)
static const G4double alpha
static constexpr double m2
Definition: G4SIunits.hh:130