Geant4  9.6.p02
 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$
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 :fAnalysisManager(analysisManager)
52 {
53  fAnalysisDir = new G4UIdirectory("/RMC01/analysis/");
54  fAnalysisDir->SetGuidance("Analysis commands");
55 
56  G4UIparameter* fluence_par = new G4UIparameter("Fluence",'d',true);
57  fluence_par->SetParameterRange("Fluence > 0");
58  fluence_par->SetGuidance("Omnidirectional fluence for primary spectrum");
59 
60  G4UIparameter* fluence_unit_par = new G4UIparameter("Fluence_unit",'s',true);
61  fluence_unit_par->SetParameterCandidates("1/cm2 1/m2 cm-2 m-2");
62 
63  G4UIparameter* alpha_par = new G4UIparameter("alpha",'d',true);
64 
65  G4UIparameter* e0_par = new G4UIparameter("E0",'d',true);
66  e0_par->SetParameterRange("E0 > 0");
67 
68  G4UIparameter* e1_par = new G4UIparameter("E1",'d',true);
69  e1_par->SetParameterRange("E1 > 0");
70 
71  G4UIparameter* e2_par = new G4UIparameter("E2",'d',true);
72  e2_par->SetParameterRange("E2 > 0");
73 
74  G4UIparameter* e_unit_par = new G4UIparameter("E_unit",'s',true);
75  e_unit_par->SetParameterCandidates("eV keV MeV GeV TeV");
76 
77  G4UIparameter* part_name_par = new G4UIparameter("particle_name",'s',true);
78  part_name_par->SetParameterCandidates("e- gamma proton ");
79 
80  fSetPowerLawSpectrumToNormaliseAdjResCmd =
81  new G4UIcommand("/RMC01/analysis/SetPowerLawPrimSpectrumForAdjointSim",this);
82  fSetPowerLawSpectrumToNormaliseAdjResCmd
83  ->SetGuidance("Set the primary spectrum to which adjoint simulation results will be normalised as a power law (Ekin^-alpha).");
84  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(part_name_par);
85  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_par);
86  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_unit_par);
87  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(alpha_par);
88  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e1_par);
89  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e2_par);
90  fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e_unit_par);
91  fSetPowerLawSpectrumToNormaliseAdjResCmd
93 
94 
95  fSetExpSpectrumToNormaliseAdjResCmd = new G4UIcommand("/RMC01/analysis/SetExponentialSpectrumForAdjointSim",this);
96  fSetExpSpectrumToNormaliseAdjResCmd
97  ->SetGuidance("Set the primary spectrum to which adjoint simulation results will be normalised as exponential (exp(-Ekin/E0)).");
98  fSetExpSpectrumToNormaliseAdjResCmd
99  ->SetParameter(new G4UIparameter(*part_name_par));
100  fSetExpSpectrumToNormaliseAdjResCmd
101  ->SetParameter(new G4UIparameter(*fluence_par));
102  fSetExpSpectrumToNormaliseAdjResCmd
103  ->SetParameter(new G4UIparameter(*fluence_unit_par));
104  fSetExpSpectrumToNormaliseAdjResCmd
105  ->SetParameter(new G4UIparameter(*e0_par));
106  fSetExpSpectrumToNormaliseAdjResCmd
107  ->SetParameter(new G4UIparameter(*e1_par));
108  fSetExpSpectrumToNormaliseAdjResCmd
109  ->SetParameter(new G4UIparameter(*e2_par));
110  fSetExpSpectrumToNormaliseAdjResCmd
111  ->SetParameter(new G4UIparameter(*e_unit_par));
112  fSetExpSpectrumToNormaliseAdjResCmd
114 
115 
116  fSetPrecisionForConvergenceTestCmd = new G4UIcmdWithADouble("/RMC01/analysis/SetExpectedPrecisionOfResults",this);
117  fSetPrecisionForConvergenceTestCmd
118  ->SetGuidance("Set the precision in % that the computed energy deposited in the sensitive volume should reached. If this precision is reached before the end of the run, the run is aborted and the results are registered.");
119  fSetPrecisionForConvergenceTestCmd->SetParameterName("Precision",true);
120  fSetPrecisionForConvergenceTestCmd
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 
127 {
128  delete fAnalysisDir;
129 }
130 
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 
134  G4UIcommand* command,G4String newValue)
135 {
136  if( command == fSetPowerLawSpectrumToNormaliseAdjResCmd){
137  G4double alpha,e1,e2,fluence;
138  G4String f_unit,e_unit,part_name;
139  const char* nv = (const char*)newValue;
140  std::istringstream is(nv);
141  is >> part_name>>fluence>>f_unit>>alpha>>e1>>e2>>e_unit;
142 
143  G4double factor_f_unit=1/cm2;
144  if (f_unit == "1/m2" || f_unit =="m-2") factor_f_unit=1/m2;
145  fluence*=factor_f_unit;
146  e1*= G4UnitDefinition::GetValueOf(e_unit);
147  e2*= G4UnitDefinition::GetValueOf(e_unit);
148  fAnalysisManager->SetPrimaryPowerLawSpectrumForAdjointSim(
149  part_name, fluence, alpha, e1, e2);
150  }
151  else if( command == fSetExpSpectrumToNormaliseAdjResCmd){
152  G4double e0,e1,e2,fluence;
153  G4String f_unit,e_unit,part_name;
154  const char* nv = (const char*)newValue;
155  std::istringstream is(nv);
156  is >> part_name>>fluence>>f_unit>>e0>>e1>>e2>>e_unit;
157 
158  G4double factor_f_unit=1/cm2;
159  if (f_unit == "1/m2" || f_unit =="m-2") factor_f_unit=1/m2;
160 
161  fluence*=factor_f_unit;
162  e0*= G4UnitDefinition::GetValueOf(e_unit);
163  e1*= G4UnitDefinition::GetValueOf(e_unit);
164  e2*= G4UnitDefinition::GetValueOf(e_unit);
165 
166  fAnalysisManager->SetPrimaryExpSpectrumForAdjointSim(part_name,
167  fluence, e0, e1, e2);
168 
169  }
170  else if( command == fSetPrecisionForConvergenceTestCmd){
171  fAnalysisManager->SetPrecision(
172  fSetPrecisionForConvergenceTestCmd->GetNewDoubleValue(newValue));
173  }
174 }
175 
176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......