Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file biasing/ReverseMC01/src/RMC01Analysi 26 /// \file biasing/ReverseMC01/src/RMC01AnalysisManagerMessenger.cc 27 /// \brief Implementation of the RMC01Analysis 27 /// \brief Implementation of the RMC01AnalysisManagerMessenger class 28 // 28 // >> 29 // $Id$ 29 // 30 // 30 ////////////////////////////////////////////// 31 ////////////////////////////////////////////////////////////// 31 // Class Name: RMC01AnalysisManage 32 // Class Name: RMC01AnalysisManagerMessenger 32 // Author: L. Desorgher 33 // Author: L. Desorgher 33 // Organisation: SpaceIT GmbH 34 // Organisation: SpaceIT GmbH 34 // Contract: ESA contract 21435/ 35 // Contract: ESA contract 21435/08/NL/AT 35 // Customer: ESA/ESTEC 36 // Customer: ESA/ESTEC 36 ////////////////////////////////////////////// 37 ////////////////////////////////////////////////////////////// 37 38 38 #include "RMC01AnalysisManagerMessenger.hh" 39 #include "RMC01AnalysisManagerMessenger.hh" 39 40 40 #include "RMC01AnalysisManager.hh" 41 #include "RMC01AnalysisManager.hh" 41 << 42 #include "G4SystemOfUnits.hh" << 43 #include "G4UIcmdWithADouble.hh" << 44 #include "G4UIdirectory.hh" 42 #include "G4UIdirectory.hh" >> 43 #include "G4UIcmdWithADouble.hh" 45 #include "G4UnitsTable.hh" 44 #include "G4UnitsTable.hh" >> 45 #include "G4SystemOfUnits.hh" 46 46 47 //....oooOO0OOooo........oooOO0OOooo........oo 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 48 48 49 RMC01AnalysisManagerMessenger::RMC01AnalysisMa << 49 RMC01AnalysisManagerMessenger::RMC01AnalysisManagerMessenger( 50 : G4UImessenger(), << 50 RMC01AnalysisManager* analysisManager) 51 fAnalysisManager(analysisManager), << 51 :fAnalysisManager(analysisManager) 52 fAnalysisDir(0), << 52 { 53 fSetPrecisionForConvergenceTestCmd(0), << 54 fSetExpSpectrumToNormaliseAdjResCmd(0), << 55 fSetPowerLawSpectrumToNormaliseAdjResCmd(0 << 56 { << 57 fAnalysisDir = new G4UIdirectory("/RMC01/ana 53 fAnalysisDir = new G4UIdirectory("/RMC01/analysis/"); 58 fAnalysisDir->SetGuidance("Analysis commands 54 fAnalysisDir->SetGuidance("Analysis commands"); 59 << 55 60 G4UIparameter* fluence_par = new G4UIparamet << 56 G4UIparameter* fluence_par = new G4UIparameter("Fluence",'d',true); 61 fluence_par->SetParameterRange("Fluence > 0" 57 fluence_par->SetParameterRange("Fluence > 0"); 62 fluence_par->SetGuidance("Omnidirectional fl 58 fluence_par->SetGuidance("Omnidirectional fluence for primary spectrum"); 63 << 59 64 G4UIparameter* fluence_unit_par = new G4UIpa << 60 G4UIparameter* fluence_unit_par = new G4UIparameter("Fluence_unit",'s',true); 65 fluence_unit_par->SetParameterCandidates("1/ 61 fluence_unit_par->SetParameterCandidates("1/cm2 1/m2 cm-2 m-2"); 66 << 62 67 G4UIparameter* alpha_par = new G4UIparameter << 63 G4UIparameter* alpha_par = new G4UIparameter("alpha",'d',true); 68 << 64 69 G4UIparameter* e0_par = new G4UIparameter("E << 65 G4UIparameter* e0_par = new G4UIparameter("E0",'d',true); 70 e0_par->SetParameterRange("E0 > 0"); 66 e0_par->SetParameterRange("E0 > 0"); 71 << 67 72 G4UIparameter* e1_par = new G4UIparameter("E << 68 G4UIparameter* e1_par = new G4UIparameter("E1",'d',true); 73 e1_par->SetParameterRange("E1 > 0"); 69 e1_par->SetParameterRange("E1 > 0"); 74 << 70 75 G4UIparameter* e2_par = new G4UIparameter("E << 71 G4UIparameter* e2_par = new G4UIparameter("E2",'d',true); 76 e2_par->SetParameterRange("E2 > 0"); 72 e2_par->SetParameterRange("E2 > 0"); 77 << 73 78 G4UIparameter* e_unit_par = new G4UIparamete << 74 G4UIparameter* e_unit_par = new G4UIparameter("E_unit",'s',true); 79 e_unit_par->SetParameterCandidates("eV keV M 75 e_unit_par->SetParameterCandidates("eV keV MeV GeV TeV"); 80 << 76 81 G4UIparameter* part_name_par = new G4UIparam << 77 G4UIparameter* part_name_par = new G4UIparameter("particle_name",'s',true); 82 part_name_par->SetParameterCandidates("e- ga 78 part_name_par->SetParameterCandidates("e- gamma proton "); 83 << 79 84 fSetPowerLawSpectrumToNormaliseAdjResCmd = 80 fSetPowerLawSpectrumToNormaliseAdjResCmd = 85 new G4UIcommand("/RMC01/analysis/SetPowerL << 81 new G4UIcommand("/RMC01/analysis/SetPowerLawPrimSpectrumForAdjointSim",this); 86 fSetPowerLawSpectrumToNormaliseAdjResCmd->Se << 82 fSetPowerLawSpectrumToNormaliseAdjResCmd 87 "Set the primary spectrum to which adjoint << 83 ->SetGuidance("Set the primary spectrum to which adjoint simulation results will be normalised as a power law (Ekin^-alpha)."); 88 "results will be normalised as a power law << 89 fSetPowerLawSpectrumToNormaliseAdjResCmd->Se 84 fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(part_name_par); 90 fSetPowerLawSpectrumToNormaliseAdjResCmd->Se 85 fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_par); 91 fSetPowerLawSpectrumToNormaliseAdjResCmd->Se 86 fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(fluence_unit_par); 92 fSetPowerLawSpectrumToNormaliseAdjResCmd->Se 87 fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(alpha_par); 93 fSetPowerLawSpectrumToNormaliseAdjResCmd->Se 88 fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e1_par); 94 fSetPowerLawSpectrumToNormaliseAdjResCmd->Se 89 fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e2_par); 95 fSetPowerLawSpectrumToNormaliseAdjResCmd->Se 90 fSetPowerLawSpectrumToNormaliseAdjResCmd->SetParameter(e_unit_par); 96 fSetPowerLawSpectrumToNormaliseAdjResCmd->Av << 91 fSetPowerLawSpectrumToNormaliseAdjResCmd 97 << 92 ->AvailableForStates(G4State_PreInit,G4State_Idle); 98 fSetExpSpectrumToNormaliseAdjResCmd = new G4 << 93 99 "/RMC01/analysis/" << 94 100 "SetExponentialSpectrumForAdjointSim", << 95 fSetExpSpectrumToNormaliseAdjResCmd = new G4UIcommand("/RMC01/analysis/SetExponentialSpectrumForAdjointSim",this); 101 this); << 96 fSetExpSpectrumToNormaliseAdjResCmd 102 fSetExpSpectrumToNormaliseAdjResCmd->SetGuid << 97 ->SetGuidance("Set the primary spectrum to which adjoint simulation results will be normalised as exponential (exp(-Ekin/E0))."); 103 "Set the primary spectrum to which adjoint << 98 fSetExpSpectrumToNormaliseAdjResCmd 104 "will be normalised as exponential (exp(-E << 99 ->SetParameter(new G4UIparameter(*part_name_par)); 105 fSetExpSpectrumToNormaliseAdjResCmd->SetPara << 100 fSetExpSpectrumToNormaliseAdjResCmd 106 fSetExpSpectrumToNormaliseAdjResCmd->SetPara << 101 ->SetParameter(new G4UIparameter(*fluence_par)); 107 fSetExpSpectrumToNormaliseAdjResCmd->SetPara << 102 fSetExpSpectrumToNormaliseAdjResCmd 108 fSetExpSpectrumToNormaliseAdjResCmd->SetPara << 103 ->SetParameter(new G4UIparameter(*fluence_unit_par)); 109 fSetExpSpectrumToNormaliseAdjResCmd->SetPara << 104 fSetExpSpectrumToNormaliseAdjResCmd 110 fSetExpSpectrumToNormaliseAdjResCmd->SetPara << 105 ->SetParameter(new G4UIparameter(*e0_par)); 111 fSetExpSpectrumToNormaliseAdjResCmd->SetPara << 106 fSetExpSpectrumToNormaliseAdjResCmd 112 fSetExpSpectrumToNormaliseAdjResCmd->Availab << 107 ->SetParameter(new G4UIparameter(*e1_par)); 113 << 108 fSetExpSpectrumToNormaliseAdjResCmd 114 fSetPrecisionForConvergenceTestCmd = new G4U << 109 ->SetParameter(new G4UIparameter(*e2_par)); 115 "/RMC01/analysis/" << 110 fSetExpSpectrumToNormaliseAdjResCmd 116 "SetExpectedPrecisionOfResults", << 111 ->SetParameter(new G4UIparameter(*e_unit_par)); 117 this); << 112 fSetExpSpectrumToNormaliseAdjResCmd 118 fSetPrecisionForConvergenceTestCmd->SetGuida << 113 ->AvailableForStates(G4State_PreInit,G4State_Idle); 119 "Set the precision in % that the computed << 114 120 "in the sensitive volume should reached. I << 115 121 " before the end of the run, the run is ab << 116 fSetPrecisionForConvergenceTestCmd = new G4UIcmdWithADouble("/RMC01/analysis/SetExpectedPrecisionOfResults",this); 122 "registered."); << 117 fSetPrecisionForConvergenceTestCmd 123 fSetPrecisionForConvergenceTestCmd->SetParam << 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."); 124 fSetPrecisionForConvergenceTestCmd->Availabl << 119 fSetPrecisionForConvergenceTestCmd->SetParameterName("Precision",true); >> 120 fSetPrecisionForConvergenceTestCmd >> 121 ->AvailableForStates(G4State_PreInit,G4State_Idle); 125 } 122 } 126 123 127 //....oooOO0OOooo........oooOO0OOooo........oo 124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 128 125 129 RMC01AnalysisManagerMessenger::~RMC01AnalysisM 126 RMC01AnalysisManagerMessenger::~RMC01AnalysisManagerMessenger() 130 { 127 { 131 delete fAnalysisDir; 128 delete fAnalysisDir; 132 } 129 } 133 130 134 //....oooOO0OOooo........oooOO0OOooo........oo 131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 135 132 136 void RMC01AnalysisManagerMessenger::SetNewValu << 133 void RMC01AnalysisManagerMessenger::SetNewValue( >> 134 G4UIcommand* command,G4String newValue) 137 { 135 { 138 if (command == fSetPowerLawSpectrumToNormali << 136 if( command == fSetPowerLawSpectrumToNormaliseAdjResCmd){ 139 G4double alpha, e1, e2, fluence; << 137 G4double alpha,e1,e2,fluence; 140 G4String f_unit, e_unit, part_name; << 138 G4String f_unit,e_unit,part_name; 141 const char* nv = (const char*)newValue; 139 const char* nv = (const char*)newValue; 142 std::istringstream is(nv); 140 std::istringstream is(nv); 143 is >> part_name >> fluence >> f_unit >> al << 141 is >> part_name>>fluence>>f_unit>>alpha>>e1>>e2>>e_unit; 144 << 142 145 G4double factor_f_unit = 1 / cm2; << 143 G4double factor_f_unit=1/cm2; 146 if (f_unit == "1/m2" || f_unit == "m-2") f << 144 if (f_unit == "1/m2" || f_unit =="m-2") factor_f_unit=1/m2; 147 fluence *= factor_f_unit; << 145 fluence*=factor_f_unit; 148 e1 *= G4UnitDefinition::GetValueOf(e_unit) << 146 e1*= G4UnitDefinition::GetValueOf(e_unit); 149 e2 *= G4UnitDefinition::GetValueOf(e_unit) << 147 e2*= G4UnitDefinition::GetValueOf(e_unit); 150 fAnalysisManager->SetPrimaryPowerLawSpectr << 148 fAnalysisManager->SetPrimaryPowerLawSpectrumForAdjointSim( >> 149 part_name, fluence, alpha, e1, e2); 151 } 150 } 152 else if (command == fSetExpSpectrumToNormali << 151 else if( command == fSetExpSpectrumToNormaliseAdjResCmd){ 153 G4double e0, e1, e2, fluence; << 152 G4double e0,e1,e2,fluence; 154 G4String f_unit, e_unit, part_name; << 153 G4String f_unit,e_unit,part_name; 155 const char* nv = (const char*)newValue; 154 const char* nv = (const char*)newValue; 156 std::istringstream is(nv); 155 std::istringstream is(nv); 157 is >> part_name >> fluence >> f_unit >> e0 << 156 is >> part_name>>fluence>>f_unit>>e0>>e1>>e2>>e_unit; 158 << 157 159 G4double factor_f_unit = 1 / cm2; << 158 G4double factor_f_unit=1/cm2; 160 if (f_unit == "1/m2" || f_unit == "m-2") f << 159 if (f_unit == "1/m2" || f_unit =="m-2") factor_f_unit=1/m2; 161 << 160 162 fluence *= factor_f_unit; << 161 fluence*=factor_f_unit; 163 e0 *= G4UnitDefinition::GetValueOf(e_unit) << 162 e0*= G4UnitDefinition::GetValueOf(e_unit); 164 e1 *= G4UnitDefinition::GetValueOf(e_unit) << 163 e1*= G4UnitDefinition::GetValueOf(e_unit); 165 e2 *= G4UnitDefinition::GetValueOf(e_unit) << 164 e2*= G4UnitDefinition::GetValueOf(e_unit); 166 << 165 167 fAnalysisManager->SetPrimaryExpSpectrumFor << 166 fAnalysisManager->SetPrimaryExpSpectrumForAdjointSim(part_name, >> 167 fluence, e0, e1, e2); >> 168 168 } 169 } 169 else if (command == fSetPrecisionForConverge << 170 else if( command == fSetPrecisionForConvergenceTestCmd){ 170 fAnalysisManager->SetPrecision(fSetPrecisi << 171 fAnalysisManager->SetPrecision( >> 172 fSetPrecisionForConvergenceTestCmd->GetNewDoubleValue(newValue)); 171 } 173 } 172 } 174 } 173 175 174 //....oooOO0OOooo........oooOO0OOooo........oo 176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 175 177