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 name: G4NistMessenger 26 // File name: G4NistMessenger 27 // 27 // 28 // Author: Vladimir Ivanchenko 28 // Author: Vladimir Ivanchenko 29 // 29 // 30 // Creation date: 23.12.2004 30 // Creation date: 23.12.2004 31 // 31 // 32 // Modifications: 32 // Modifications: 33 // 33 // 34 // 34 // 35 // ------------------------------------------- 35 // ------------------------------------------------------------------- 36 36 37 #include "G4NistMessenger.hh" 37 #include "G4NistMessenger.hh" 38 38 39 #include "G4ApplicationState.hh" << 40 #include "G4DensityEffectData.hh" 39 #include "G4DensityEffectData.hh" 41 #include "G4IonisParamMat.hh" 40 #include "G4IonisParamMat.hh" 42 #include "G4NistManager.hh" 41 #include "G4NistManager.hh" 43 #include "G4UIcmdWithAString.hh" 42 #include "G4UIcmdWithAString.hh" 44 #include "G4UIcmdWithAnInteger.hh" 43 #include "G4UIcmdWithAnInteger.hh" 45 #include "G4UIdirectory.hh" 44 #include "G4UIdirectory.hh" 46 #include "G4UIcommand.hh" << 47 #include "G4UIparameter.hh" << 48 << 49 #include <sstream> << 50 45 51 //....oooOO0OOooo........oooOO0OOooo........oo 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 52 47 53 G4NistMessenger::G4NistMessenger(G4NistManager 48 G4NistMessenger::G4NistMessenger(G4NistManager* man) : manager(man) 54 { 49 { 55 matDir = new G4UIdirectory("/material/"); 50 matDir = new G4UIdirectory("/material/"); 56 matDir->SetGuidance("Commands for materials" 51 matDir->SetGuidance("Commands for materials"); 57 52 58 verCmd = new G4UIcmdWithAnInteger("/material 53 verCmd = new G4UIcmdWithAnInteger("/material/verbose", this); 59 verCmd->SetGuidance("Set verbose level."); 54 verCmd->SetGuidance("Set verbose level."); 60 verCmd->AvailableForStates(G4State_PreInit, << 61 verCmd->SetToBeBroadcasted(false); << 62 55 63 nistDir = new G4UIdirectory("/material/nist/ 56 nistDir = new G4UIdirectory("/material/nist/"); 64 nistDir->SetGuidance("Commands for the nist 57 nistDir->SetGuidance("Commands for the nist dataBase"); 65 58 66 prtElmCmd = new G4UIcmdWithAString("/materia 59 prtElmCmd = new G4UIcmdWithAString("/material/nist/printElement", this); 67 prtElmCmd->SetGuidance("print element(s) in 60 prtElmCmd->SetGuidance("print element(s) in dataBase."); 68 prtElmCmd->SetGuidance("symbol = element."); 61 prtElmCmd->SetGuidance("symbol = element."); 69 prtElmCmd->SetGuidance("all = all element 62 prtElmCmd->SetGuidance("all = all elements."); 70 prtElmCmd->SetParameterName("symbol", true); 63 prtElmCmd->SetParameterName("symbol", true); 71 prtElmCmd->SetDefaultValue("all"); 64 prtElmCmd->SetDefaultValue("all"); 72 prtElmCmd->AvailableForStates(G4State_PreIni << 73 prtElmCmd->SetToBeBroadcasted(false); << 74 65 75 przElmCmd = new G4UIcmdWithAnInteger("/mater 66 przElmCmd = new G4UIcmdWithAnInteger("/material/nist/printElementZ", this); 76 przElmCmd->SetGuidance("print element Z in d 67 przElmCmd->SetGuidance("print element Z in dataBase."); 77 przElmCmd->SetGuidance("0 = all elements."); 68 przElmCmd->SetGuidance("0 = all elements."); 78 przElmCmd->SetParameterName("Z", true); 69 przElmCmd->SetParameterName("Z", true); 79 przElmCmd->SetDefaultValue(0); 70 przElmCmd->SetDefaultValue(0); 80 przElmCmd->SetRange("0<=Z && Z<108"); 71 przElmCmd->SetRange("0<=Z && Z<108"); 81 przElmCmd->AvailableForStates(G4State_PreIni << 82 przElmCmd->SetToBeBroadcasted(false); << 83 72 84 lisMatCmd = new G4UIcmdWithAString("/materia 73 lisMatCmd = new G4UIcmdWithAString("/material/nist/listMaterials", this); 85 lisMatCmd->SetGuidance("Materials in Geant4 74 lisMatCmd->SetGuidance("Materials in Geant4 dataBase."); 86 lisMatCmd->SetGuidance("simple - simple NIST 75 lisMatCmd->SetGuidance("simple - simple NIST materials."); 87 lisMatCmd->SetGuidance("compound - compound 76 lisMatCmd->SetGuidance("compound - compound NIST materials."); 88 lisMatCmd->SetGuidance("hep - HEP materials. 77 lisMatCmd->SetGuidance("hep - HEP materials."); 89 lisMatCmd->SetGuidance("bio - biomedical mat 78 lisMatCmd->SetGuidance("bio - biomedical materials."); 90 lisMatCmd->SetGuidance("all - list of all Ge 79 lisMatCmd->SetGuidance("all - list of all Geant4 materials."); 91 lisMatCmd->SetParameterName("matlist", true) 80 lisMatCmd->SetParameterName("matlist", true); 92 // lisMatCmd->SetCandidates("simple compound 81 // lisMatCmd->SetCandidates("simple compound hep bio all"); 93 lisMatCmd->SetDefaultValue("all"); 82 lisMatCmd->SetDefaultValue("all"); 94 lisMatCmd->AvailableForStates(G4State_PreIni << 95 lisMatCmd->SetToBeBroadcasted(false); << 96 83 97 g4Dir = new G4UIdirectory("/material/g4/"); 84 g4Dir = new G4UIdirectory("/material/g4/"); 98 g4Dir->SetGuidance("Commands for G4MaterialT 85 g4Dir->SetGuidance("Commands for G4MaterialTable"); 99 86 100 g4ElmCmd = new G4UIcmdWithAString("/material 87 g4ElmCmd = new G4UIcmdWithAString("/material/g4/printElement", this); 101 g4ElmCmd->SetGuidance("print Element from G4 88 g4ElmCmd->SetGuidance("print Element from G4ElementTable."); 102 g4ElmCmd->SetGuidance("all - all elements.") 89 g4ElmCmd->SetGuidance("all - all elements."); 103 g4ElmCmd->SetParameterName("elm", true); 90 g4ElmCmd->SetParameterName("elm", true); 104 g4ElmCmd->SetDefaultValue("all"); 91 g4ElmCmd->SetDefaultValue("all"); 105 92 106 g4MatCmd = new G4UIcmdWithAString("/material 93 g4MatCmd = new G4UIcmdWithAString("/material/g4/printMaterial", this); 107 g4MatCmd->SetGuidance("print Material from G 94 g4MatCmd->SetGuidance("print Material from G4MaterialTable."); 108 g4MatCmd->SetGuidance("all - all materials") 95 g4MatCmd->SetGuidance("all - all materials"); 109 g4MatCmd->SetParameterName("pmat", true); 96 g4MatCmd->SetParameterName("pmat", true); 110 g4MatCmd->SetDefaultValue("all"); 97 g4MatCmd->SetDefaultValue("all"); 111 g4MatCmd->AvailableForStates(G4State_PreInit << 112 g4MatCmd->SetToBeBroadcasted(false); << 113 98 114 g4DensCmd = new G4UIcmdWithAString("/materia 99 g4DensCmd = new G4UIcmdWithAString("/material/g4/printDensityEffParam", this); 115 g4DensCmd->SetGuidance("print Material from 100 g4DensCmd->SetGuidance("print Material from G4DensityEffectData."); 116 g4DensCmd->SetGuidance("all - all materials" 101 g4DensCmd->SetGuidance("all - all materials"); 117 g4DensCmd->SetParameterName("dmat", true); 102 g4DensCmd->SetParameterName("dmat", true); 118 g4DensCmd->SetDefaultValue("all"); 103 g4DensCmd->SetDefaultValue("all"); 119 g4DensCmd->AvailableForStates(G4State_PreIni << 120 g4DensCmd->SetToBeBroadcasted(false); << 121 104 122 densCmd = new G4UIcmdWithAString("/material/ 105 densCmd = new G4UIcmdWithAString("/material/g4/enableDensityEffOnFly", this); 123 densCmd->SetGuidance("enable accurate comput 106 densCmd->SetGuidance("enable accurate computation of density effect."); 124 densCmd->SetGuidance("all - all materials.") 107 densCmd->SetGuidance("all - all materials."); 125 densCmd->SetParameterName("dens", true); 108 densCmd->SetParameterName("dens", true); 126 densCmd->SetDefaultValue("all"); 109 densCmd->SetDefaultValue("all"); 127 densCmd->AvailableForStates(G4State_PreInit) << 128 lisMatCmd->SetToBeBroadcasted(false); << 129 110 130 adensCmd = new G4UIcmdWithAString("/material 111 adensCmd = new G4UIcmdWithAString("/material/g4/disableDensityEffOnFly", this); 131 adensCmd->SetGuidance("disable accurate comp 112 adensCmd->SetGuidance("disable accurate computation of density effect."); 132 adensCmd->SetGuidance("all - all materials." 113 adensCmd->SetGuidance("all - all materials."); 133 adensCmd->SetParameterName("dens", true); 114 adensCmd->SetParameterName("dens", true); 134 adensCmd->SetDefaultValue("all"); 115 adensCmd->SetDefaultValue("all"); 135 adensCmd->AvailableForStates(G4State_PreInit << 136 adensCmd->SetToBeBroadcasted(false); << 137 << 138 fPosiCmd = new G4UIcommand("/material/g4/ort << 139 fPosiCmd->SetGuidance("defined orto-positron << 140 fPosiCmd->SetGuidance("via material name, al << 141 fPosiCmd->AvailableForStates(G4State_PreInit << 142 fPosiCmd->SetToBeBroadcasted(false); << 143 << 144 auto p1 = new G4UIparameter("matname",'s', f << 145 fPosiCmd->SetParameter(p1); << 146 << 147 auto p2 = new G4UIparameter("fraction", 'd', << 148 p2->SetParameterRange("fraction>=0. && fract << 149 fPosiCmd->SetParameter(p2); << 150 } 116 } 151 117 152 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 153 119 154 G4NistMessenger::~G4NistMessenger() 120 G4NistMessenger::~G4NistMessenger() 155 { 121 { 156 delete verCmd; 122 delete verCmd; 157 delete prtElmCmd; 123 delete prtElmCmd; 158 delete przElmCmd; 124 delete przElmCmd; 159 delete lisMatCmd; 125 delete lisMatCmd; 160 delete nistDir; 126 delete nistDir; 161 127 162 delete g4ElmCmd; 128 delete g4ElmCmd; 163 delete g4MatCmd; 129 delete g4MatCmd; 164 delete g4DensCmd; 130 delete g4DensCmd; 165 delete densCmd; 131 delete densCmd; 166 delete adensCmd; 132 delete adensCmd; 167 delete fPosiCmd; << 168 << 169 delete g4Dir; 133 delete g4Dir; 170 delete matDir; 134 delete matDir; 171 } 135 } 172 136 173 //....oooOO0OOooo........oooOO0OOooo........oo 137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 174 138 175 void G4NistMessenger::SetNewValue(G4UIcommand* 139 void G4NistMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 176 { 140 { 177 // G4cout << "G4NistMessenger::SetNewValue < 141 // G4cout << "G4NistMessenger::SetNewValue <" << newValue << ">" << G4endl; 178 if (command == verCmd) { 142 if (command == verCmd) { 179 manager->SetVerbose(verCmd->GetNewIntValue 143 manager->SetVerbose(verCmd->GetNewIntValue(newValue)); 180 } 144 } 181 else if (command == prtElmCmd) { 145 else if (command == prtElmCmd) { 182 manager->PrintElement(newValue); 146 manager->PrintElement(newValue); 183 } 147 } 184 else if (command == przElmCmd) { 148 else if (command == przElmCmd) { 185 G4int Z = przElmCmd->GetNewIntValue(newVal 149 G4int Z = przElmCmd->GetNewIntValue(newValue); 186 if (Z >= 0 && Z < 108) { 150 if (Z >= 0 && Z < 108) { 187 manager->PrintElement(Z); 151 manager->PrintElement(Z); 188 } 152 } 189 } 153 } 190 else if (command == lisMatCmd) { 154 else if (command == lisMatCmd) { 191 manager->ListMaterials(newValue); 155 manager->ListMaterials(newValue); 192 } 156 } 193 else if (command == g4ElmCmd) { 157 else if (command == g4ElmCmd) { 194 manager->PrintG4Element(newValue); 158 manager->PrintG4Element(newValue); 195 } 159 } 196 else if (command == g4MatCmd) { 160 else if (command == g4MatCmd) { 197 manager->PrintG4Material(newValue); 161 manager->PrintG4Material(newValue); 198 } 162 } 199 else if (command == g4DensCmd) { 163 else if (command == g4DensCmd) { 200 G4IonisParamMat::GetDensityEffectData()->P 164 G4IonisParamMat::GetDensityEffectData()->PrintData(newValue); 201 } 165 } 202 else if (command == densCmd) { 166 else if (command == densCmd) { 203 manager->SetDensityEffectCalculatorFlag(ne 167 manager->SetDensityEffectCalculatorFlag(newValue, true); 204 } 168 } 205 else if (command == adensCmd) { 169 else if (command == adensCmd) { 206 manager->SetDensityEffectCalculatorFlag(ne 170 manager->SetDensityEffectCalculatorFlag(newValue, false); 207 } << 208 else if (command == fPosiCmd) { << 209 G4String mnam{""}; << 210 G4double f{0.0}; << 211 std::istringstream ss(newValue); << 212 ss >> mnam >> f; << 213 // set fraction for all materials << 214 if (mnam == "all" || mnam == "none") { << 215 if (mnam == "none" || f < 0.0) { f = 0.0 << 216 auto mtable = G4Material::GetMaterialTab << 217 for ( auto const & mat : *mtable ) { << 218 mat->GetIonisation()->SetOrtoPositroniumFrac << 219 } << 220 } else { << 221 // set fraction for one material << 222 auto mat = manager->FindOrBuildMaterial( << 223 if (nullptr != mat) { << 224 mat->GetIonisation()->SetOrtoPositroniumFrac << 225 } << 226 } << 227 } 171 } 228 } 172 } 229 173