Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 #include"G4HadronicDeveloperParameters.hh" 27 28 G4HadronicDeveloperParameters& G4HadronicDevel 29 static G4HadronicDeveloperParameters inst 30 return instance; 31 } 32 33 G4HadronicDeveloperParameters::G4HadronicDevel 34 } 35 36 G4HadronicDeveloperParameters::G4HadronicDevel 37 } 38 39 G4bool G4HadronicDeveloperParameters::SetDefau 40 G4bool status = false; 41 const std::map< G4String , const G4bool >:: 42 if ( it == b_defaults.cend() ) { 43 status = true; 44 b_defaults.insert( std::pair<G4String, c 45 b_values.insert( std::pair<G4String, G4b 46 } else { 47 /*error*/ 48 issue_is_already_defined( name ); 49 } 50 return status; 51 } 52 53 G4bool G4HadronicDeveloperParameters::SetDefau 54 G4bool status = false; 55 const std::map< G4String , const G4int >::c 56 if ( it == i_defaults.cend() ) { 57 status = true; 58 i_defaults.insert( std::pair<G4String, c 59 i_values.insert( std::pair<G4String, G4i 60 i_limits.insert( std::pair< G4String,std 61 } else { 62 /*error*/ 63 issue_is_already_defined( name ); 64 } 65 return status; 66 } 67 68 G4bool G4HadronicDeveloperParameters::SetDefau 69 G4bool status = false; 70 const std::map< G4String , const G4double > 71 if ( it == defaults.cend() ) { 72 status = true; 73 defaults.insert( std::pair<G4String, con 74 values.insert( std::pair<G4String, G4dou 75 limits.insert( std::pair< G4String,std:: 76 } else { 77 /*error*/ 78 issue_is_already_defined( name ); 79 } 80 return status; 81 } 82 83 G4bool G4HadronicDeveloperParameters::Set( con 84 G4bool status = false; 85 const std::map<G4String,G4bool>::iterator i 86 if ( it != b_values.cend() ) { 87 if ( it->second == b_defaults.find(name) 88 status = true; 89 it->second = value; 90 } else { 91 /*change more than once*/ 92 issue_has_changed( name ); 93 } 94 } else { 95 /*Parameter of "name" does not exist*/ 96 issue_no_param( name ); 97 } 98 return status; 99 } 100 101 G4bool G4HadronicDeveloperParameters::Set( con 102 G4bool status = false; 103 const std::map<G4String,G4int>::iterator it 104 if ( it != i_values.cend() ) { 105 if ( it->second == i_defaults.find(name) 106 if ( check_value_within_limits( i_lim 107 /*value is OK*/ 108 status = true; 109 it->second = value; 110 } else { 111 /*Value is outside of valid range* 112 issue_non_eligible_value( name ); 113 } 114 } else { 115 /*change more than once*/ 116 issue_has_changed( name ); 117 } 118 } else { 119 /*Parameter of "name" does not exist*/ 120 issue_no_param( name ); 121 } 122 return status; 123 } 124 125 G4bool G4HadronicDeveloperParameters::Set( con 126 G4bool status = false; 127 const std::map<G4String,G4double>::iterator 128 if ( it != values.cend() ) { 129 if ( it->second == defaults.find(name)-> 130 if ( check_value_within_limits( limit 131 /*value is OK*/ 132 status = true; 133 it->second = value; 134 } else { 135 /*Value is outside of valid range* 136 issue_non_eligible_value( name ); 137 } 138 } else { 139 /*change more than once*/ 140 issue_has_changed( name ); 141 } 142 } else { 143 /*Parameter of "name" does not exist*/ 144 issue_no_param( name ); 145 } 146 return status; 147 } 148 149 G4bool G4HadronicDeveloperParameters::GetDefau 150 G4bool status = false; 151 const std::map<G4String,const G4bool>::cons 152 if ( it != b_defaults.cend() ) { 153 status = true; 154 value = it->second; 155 } else { 156 /*Parameter of "name" does not exist*/ 157 issue_no_param( name ); 158 } 159 return status; 160 } 161 162 G4bool G4HadronicDeveloperParameters::GetDefau 163 G4bool status = false; 164 const std::map<G4String,const G4int>::const 165 if ( it != i_defaults.cend() ) { 166 status = true; 167 value = it->second; 168 } else { 169 /*Parameter of "name" does not exist*/ 170 issue_no_param( name ); 171 } 172 return status; 173 } 174 175 G4bool G4HadronicDeveloperParameters::GetDefau 176 G4bool status = false; 177 const std::map<G4String,const G4double>::co 178 if ( it != defaults.cend() ) { 179 status = true; 180 value = it->second; 181 } else { 182 /*Parameter of "name" does not exist*/ 183 issue_no_param( name ); 184 } 185 return status; 186 } 187 188 G4bool G4HadronicDeveloperParameters::Get( con 189 return get( name , value ); 190 } 191 192 G4bool G4HadronicDeveloperParameters::Develope 193 return get( name , value , true ); 194 } 195 196 G4bool G4HadronicDeveloperParameters::get( con 197 G4bool status = false; 198 const std::map<G4String,G4bool>::const_iter 199 if ( it != b_values.cend() ) { 200 status = true; 201 value = it->second; 202 if ( check_change && value != b_defaults 203 //Parameter "name" has changed from d 204 issue_is_modified( name ); 205 } 206 } else { 207 //Parameter of "name" does not exist 208 issue_no_param( name ); 209 } 210 return status; 211 } 212 213 G4bool G4HadronicDeveloperParameters::Get( con 214 return get( name , value ); 215 } 216 217 G4bool G4HadronicDeveloperParameters::Develope 218 return get( name , value , true ); 219 } 220 221 G4bool G4HadronicDeveloperParameters::get( con 222 G4bool status = false; 223 const std::map<G4String,G4int>::const_itera 224 if ( it != i_values.cend() ) { 225 status = true; 226 value = it->second; 227 if ( check_change && value != i_defaults 228 //Parameter "name" has changed from d 229 issue_is_modified( name ); 230 } 231 } else { 232 //Parameter of "name" does not exist 233 issue_no_param( name ); 234 } 235 return status; 236 } 237 238 G4bool G4HadronicDeveloperParameters::Get( con 239 return get( name , value ); 240 } 241 242 G4bool G4HadronicDeveloperParameters::Develope 243 return get( name , value , true ); 244 } 245 246 G4bool G4HadronicDeveloperParameters::get( con 247 G4bool status = false; 248 const std::map<G4String,G4double>::const_it 249 if ( it != values.cend() ) { 250 status = true; 251 value = it->second; 252 if ( check_change && value != defaults.f 253 /*Parameter "name" has changed from d 254 issue_is_modified( name ); 255 } 256 } else { 257 /*Parameter of "name" does not exist*/ 258 issue_no_param( name ); 259 } 260 return status; 261 } 262 263 void G4HadronicDeveloperParameters::Dump( cons 264 //const std::map<G4String,G4double>::const_ 265 if ( b_values.find( name ) != b_values.cend 266 G4cout << "G4HadronicDeveloperParameters 267 << "name = " << name 268 << ", default value = " << b_defaults.fi 269 << ", current value = " << b_values.find 270 << "." << G4endl; 271 } else if ( i_values.find( name ) != i_valu 272 G4cout << "G4HadronicDeveloperParameters 273 << "name = " << name 274 << ", default value = " << i_defaults.fi 275 << ", lower limit = " << i_limits.find( 276 << ", upper limit = " << i_limits.find( 277 << ", current value = " << i_values.find 278 << "." << G4endl; 279 } else if ( values.find( name ) != values.c 280 G4cout << "G4HadronicDeveloperParameters 281 << "name = " << name 282 << ", default value = " << defaults.find 283 << ", lower limit = " << limits.find( na 284 << ", upper limit = " << limits.find( na 285 << ", current value = " << values.find( 286 << "." << G4endl; 287 } else { 288 /*Parameter of "name" does not exist*/ 289 issue_no_param( name ); 290 } 291 } 292 293 G4bool G4HadronicDeveloperParameters::check_va 294 if ( alimits.first <= value && value <= ali 295 return true; 296 } else { 297 return false; 298 } 299 } 300 301 G4bool G4HadronicDeveloperParameters::check_va 302 if ( alimits.first <= value && value <= ali 303 return true; 304 } else { 305 return false; 306 } 307 } 308 309 void G4HadronicDeveloperParameters::issue_no_p 310 G4String text("Parameter "); 311 text += name; 312 text += " does not exist."; 313 G4Exception( "G4HadronicDeveloperParameters 314 } 315 316 void G4HadronicDeveloperParameters::issue_has_ 317 G4String text("Parameter "); 318 text += name; 319 text += " has already been changed once."; 320 G4Exception( "G4HadronicDeveloperParameters 321 } 322 void G4HadronicDeveloperParameters::issue_non_ 323 G4String text("The value of the parameter " 324 text += name; 325 text += " is outside the allowable range."; 326 G4Exception( "G4HadronicDeveloperParameters 327 } 328 void G4HadronicDeveloperParameters::issue_is_a 329 G4String text("Parameter "); 330 text += name; 331 text += " is already defined."; 332 G4Exception( "G4HadronicDeveloperParameters 333 } 334 void G4HadronicDeveloperParameters::issue_is_m 335 G4String text("Parameter "); 336 text += name; 337 text += " has changed from default value."; 338 G4Exception( "G4HadronicDeveloperParameters 339 } 340