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 // INCL++ intra-nuclear cascade model 26 // INCL++ intra-nuclear cascade model 27 // Alain Boudard, CEA-Saclay, France << 27 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics 28 // Joseph Cugnon, University of Liege, Belgium << 28 // Davide Mancusi, CEA 29 // Jean-Christophe David, CEA-Saclay, France << 29 // Alain Boudard, CEA 30 // Pekka Kaitaniemi, CEA-Saclay, France, and H << 30 // Sylvie Leray, CEA 31 // Sylvie Leray, CEA-Saclay, France << 31 // Joseph Cugnon, University of Liege 32 // Davide Mancusi, CEA-Saclay, France << 32 // >> 33 // INCL++ revision: v5.1.8 33 // 34 // 34 #define INCLXX_IN_GEANT4_MODE 1 35 #define INCLXX_IN_GEANT4_MODE 1 35 36 36 #include "globals.hh" 37 #include "globals.hh" 37 38 38 #include "G4INCLParticleType.hh" 39 #include "G4INCLParticleType.hh" 39 #include "G4INCLConfig.hh" 40 #include "G4INCLConfig.hh" 40 #include "G4INCLParticleSpecies.hh" 41 #include "G4INCLParticleSpecies.hh" 41 #include "G4INCLParticleTable.hh" 42 #include "G4INCLParticleTable.hh" 42 43 >> 44 #ifdef HAS_BOOST_PROGRAM_OPTIONS >> 45 #include <boost/program_options/options_description.hpp> >> 46 #include <boost/program_options/parsers.hpp> >> 47 #include <boost/program_options/variables_map.hpp> >> 48 #include <iostream> >> 49 #include <fstream> >> 50 #include <sstream> >> 51 #include <cstdlib> >> 52 #include "G4INCLCascade.hh" >> 53 #include "G4INCLLogger.hh" >> 54 #endif >> 55 43 namespace G4INCL { 56 namespace G4INCL { 44 << 57 45 Config::Config() { << 58 Config::Config() >> 59 { >> 60 init(); >> 61 } >> 62 >> 63 Config::Config(G4int /*A*/, G4int /*Z*/, G4INCL::ParticleSpecies proj, G4double projectileE) >> 64 { 46 init(); 65 init(); >> 66 projectileSpecies = proj; >> 67 projectileKineticEnergy = projectileE; >> 68 } >> 69 >> 70 // NOT used in Geant4 mode >> 71 #ifdef HAS_BOOST_PROGRAM_OPTIONS >> 72 Config::Config(G4int argc, char *argv[], G4bool isFullRun) : naturalTarget(false) { >> 73 const std::string suggestHelpMsg("You might want to run `INCLCascade -h' to get a help message.\n"); >> 74 >> 75 try { >> 76 >> 77 // Hidden options >> 78 boost::program_options::options_description hiddenOptDesc("Hidden options"); >> 79 hiddenOptDesc.add_options() >> 80 ("input-file", boost::program_options::value<std::string>(&inputFileName), "input file") >> 81 ("impact-parameter", boost::program_options::value<G4double>(&impactParameter)->default_value(-1.), "impact parameter") >> 82 ; >> 83 >> 84 // Generic options >> 85 std::stringstream verbosityDescription; >> 86 verbosityDescription << "set verbosity level:\n" >> 87 << " 0: \tquiet, suppress all output messages\n" >> 88 << " " << InfoMsg << ": \tminimal logging\n" >> 89 << " " << FatalMsg << ": \tlog fatal error messages as well\n" >> 90 << " " << ErrorMsg << ": \tlog error messages as well\n" >> 91 << " " << WarningMsg << ": \tlog warning messages as well\n" >> 92 << " " << DebugMsg << ": \tlog debug messages as well\n" >> 93 << " " << DataBlockMsg << ": \tlog data-block messages as well"; >> 94 >> 95 boost::program_options::options_description genericOptDesc("Generic options"); >> 96 genericOptDesc.add_options() >> 97 ("help,h", "produce this help message") >> 98 ("version", "print version string and exit") >> 99 ; >> 100 >> 101 // Run-specific options >> 102 boost::program_options::options_description runOptDesc("Run options"); >> 103 runOptDesc.add_options() >> 104 ("title", boost::program_options::value<std::string>(&title)->default_value("INCL default run title"), "run title") >> 105 ("output,o", boost::program_options::value<std::string>(&outputFileRoot), "root for generating output file names. Suffixes (.root, .out, etc.) will be appended to this root. Defaults to the input file name, if given; otherwise, defaults to a string composed of the explicitly specified options") >> 106 ("logfile,l", boost::program_options::value<std::string>(&logFileName), "log file name. Defaults to `<output_root>.log'. Use `-' if you want to redirect logging to stdout") >> 107 ("number-shots,N", boost::program_options::value<G4int>(&nShots), "* number of shots") >> 108 ("target,t", boost::program_options::value<std::string>(&targetString), "* target nuclide. Can be specified as Fe56, 56Fe, Fe-56, 56-Fe, Fe_56, 56_Fe or Fe. If the mass number is omitted, natural target composition is assumed.") >> 109 ("projectile,p", boost::program_options::value<std::string>(&projectileString), "* projectile name:\n" >> 110 " \tproton, p\n" >> 111 " \tneutron, n\n" >> 112 " \tpi+, piplus, pion+, pionplus\n" >> 113 " \tpi0, pizero, pion0, pionzero\n" >> 114 " \tpi-, piminus, pion-, pionminus\n" >> 115 " \td, t, a, deuteron, triton, alpha\n" >> 116 " \tHe-4, He4, 4He (and so on)\n") >> 117 ("energy,E", boost::program_options::value<G4float>(&projectileKineticEnergy), "* total kinetic energy of the projectile, in MeV") >> 118 ("verbose-event", boost::program_options::value<G4int>(&verboseEvent)->default_value(-1), "request verbose logging for the specified event only") >> 119 ("random-seed-1", boost::program_options::value<G4int>(&randomSeed1)->default_value(666), "first seed for the random-number generator") >> 120 ("random-seed-2", boost::program_options::value<G4int>(&randomSeed2)->default_value(777), "second seed for the random-number generator") >> 121 ("inclxx-datafile-path", boost::program_options::value<std::string>(&INCLXXDataFilePath)->default_value("./data/")) >> 122 #ifdef INCL_DEEXCITATION_ABLAXX >> 123 ("ablav3p-cxx-datafile-path", boost::program_options::value<std::string>(&ablav3pCxxDataFilePath)->default_value("./de-excitation/ablaxx/data/G4ABLA3.0/")) >> 124 #endif >> 125 #ifdef INCL_DEEXCITATION_ABLA07 >> 126 ("abla07-datafile-path", boost::program_options::value<std::string>(&abla07DataFilePath)->default_value("./de-excitation/abla07/upstream/tables/")) >> 127 #endif >> 128 #ifdef INCL_DEEXCITATION_GEMINIXX >> 129 ("geminixx-datafile-path", boost::program_options::value<std::string>(&geminixxDataFilePath)->default_value("./de-excitation/geminixx/upstream/")) >> 130 #endif >> 131 ("verbosity,v", boost::program_options::value<G4int>(&verbosity)->default_value(4), verbosityDescription.str().c_str()) >> 132 ; >> 133 >> 134 // Physics options >> 135 boost::program_options::options_description physicsOptDesc("Physics options"); >> 136 physicsOptDesc.add_options() >> 137 ("pauli", boost::program_options::value<std::string>(&pauliString)->default_value("strict-statistical"), "Pauli-blocking algorithm:\n" >> 138 " \tstrict-statistical (default)\n" >> 139 " \tstrict\n" >> 140 " \tstatistical\n" >> 141 " \tglobal\n" >> 142 " \tnone") >> 143 ("cdpp", boost::program_options::value<G4bool>(&CDPP)->default_value(true), "whether to apply CDPP after collisions:\n \ttrue, 1 (default)\n \tfalse, 0") >> 144 ("coulomb", boost::program_options::value<std::string>(&coulombString)->default_value("non-relativistic"), "Coulomb-distortion algorithm:\n \tnon-relativistic (default)\n \tnone") >> 145 ("potential", boost::program_options::value<std::string>(&potentialString)->default_value("isospin-energy"), "nucleon potential:\n \tisospin-energy-smooth\n \tisospin-energy (default)\n \tisospin\n \tconstant") >> 146 ("pion-potential", boost::program_options::value<G4bool>(&pionPotential)->default_value("true"), "whether to use a pion potential:\n \ttrue, 1 (default)\n \tfalse, 0") >> 147 ("local-energy-BB", boost::program_options::value<std::string>(&localEnergyBBString)->default_value("first-collision"), "local energy in baryon-baryon collisions:\n \talways\n \tfirst-collision (default)\n \tnever") >> 148 ("local-energy-pi", boost::program_options::value<std::string>(&localEnergyPiString)->default_value("first-collision"), "local energy in pi-N collisions and in delta decays:\n \talways\n \tfirst-collision (default)\n \tnever") >> 149 ("de-excitation", boost::program_options::value<std::string>(&deExcitationString)->default_value("none"), "which de-excitation model to use:" >> 150 "\n \tnone (default)" >> 151 #ifdef INCL_DEEXCITATION_ABLAXX >> 152 "\n \tABLAv3p" >> 153 #endif >> 154 #ifdef INCL_DEEXCITATION_ABLA07 >> 155 "\n \tABLA07" >> 156 #endif >> 157 #ifdef INCL_DEEXCITATION_SMM >> 158 "\n \tSMM" >> 159 #endif >> 160 #ifdef INCL_DEEXCITATION_GEMINIXX >> 161 "\n \tGEMINIXX" >> 162 #endif >> 163 ) >> 164 ("cluster-algorithm", boost::program_options::value<std::string>(&clusterAlgorithmString)->default_value("intercomparison"), "clustering algorithm for production of composites:\n \tintercomparison (default)\n \tnone") >> 165 ("cluster-max-mass", boost::program_options::value<G4int>(&clusterMaxMass)->default_value(8), "maximum mass of produced composites:\n \tminimum 2\n \tmaximum 12") >> 166 ("back-to-spectator", boost::program_options::value<G4bool>(&backToSpectator)->default_value("true"), "whether to use back-to-spectator:\n \ttrue, 1 (default)\n \tfalse, 0") >> 167 ("use-real-masses", boost::program_options::value<G4bool>(&useRealMasses)->default_value("true"), "whether to use real masses for the outgoing particle energies:\n \ttrue, 1 (default)\n \tfalse, 0") >> 168 ("separation-energies", boost::program_options::value<std::string>(&separationEnergyString)->default_value("INCL"), "how to assign the separation energies of the INCL nucleus:\n \tINCL (default)\n \treal\n \treal-light") >> 169 ; >> 170 >> 171 // Select options allowed on the command line >> 172 boost::program_options::options_description cmdLineOptions; >> 173 cmdLineOptions.add(hiddenOptDesc).add(genericOptDesc).add(runOptDesc).add(physicsOptDesc); >> 174 >> 175 // Select options allowed in config files >> 176 boost::program_options::options_description configFileOptions; >> 177 configFileOptions.add(runOptDesc).add(physicsOptDesc); >> 178 >> 179 // Select visible options >> 180 boost::program_options::options_description visibleOptions; >> 181 visibleOptions.add(genericOptDesc).add(runOptDesc).add(physicsOptDesc); >> 182 >> 183 // Declare input-file as a positional option (if we just provide a file >> 184 // name on the command line, it should be interpreted as an input-file >> 185 // option). >> 186 boost::program_options::positional_options_description p; >> 187 p.add("input-file", 1); >> 188 >> 189 // Disable guessing of option names >> 190 G4int cmdstyle = >> 191 boost::program_options::command_line_style::default_style & >> 192 ~boost::program_options::command_line_style::allow_guessing; >> 193 >> 194 // Result of the option processing >> 195 boost::program_options::variables_map variablesMap; >> 196 boost::program_options::store(boost::program_options::command_line_parser(argc, argv). >> 197 style(cmdstyle). >> 198 options(cmdLineOptions).positional(p).run(), variablesMap); >> 199 boost::program_options::notify(variablesMap); >> 200 >> 201 // If an input file was specified, merge the options with the command-line >> 202 // options. >> 203 if(variablesMap.count("input-file")) { >> 204 std::ifstream inputFileStream(inputFileName.c_str()); >> 205 if(!inputFileStream) { >> 206 std::cerr << "Cannot open input file: " << inputFileName << std::endl; >> 207 std::exit(EXIT_FAILURE); >> 208 } else { >> 209 // Merge options from the input file >> 210 boost::program_options::parsed_options parsedOptions = boost::program_options::parse_config_file(inputFileStream, configFileOptions, true); >> 211 >> 212 // Make sure that the unhandled options are all "*-datafile-path" >> 213 std::vector<std::string> unhandledOptions = >> 214 boost::program_options::collect_unrecognized(parsedOptions.options, boost::program_options::exclude_positional); >> 215 G4bool ignoreNext = false; >> 216 const std::string match = "-datafile-path"; >> 217 for(std::vector<std::string>::const_iterator i=unhandledOptions.begin(); i!=unhandledOptions.end(); ++i) { >> 218 if(ignoreNext) { >> 219 ignoreNext=false; >> 220 continue; >> 221 } >> 222 if(i->rfind(match) == i->length()-match.length()) { >> 223 std::cerr << "Ignoring unrecognized option " << *i << std::endl; >> 224 ignoreNext = true; >> 225 } else { >> 226 std::cerr << "Error: unrecognized option " << *i << std::endl; >> 227 std::cerr << suggestHelpMsg; >> 228 std::exit(EXIT_FAILURE); >> 229 } >> 230 } >> 231 >> 232 // Store the option values in the variablesMap >> 233 boost::program_options::store(parsedOptions, variablesMap); >> 234 boost::program_options::notify(variablesMap); >> 235 } >> 236 inputFileStream.close(); >> 237 } >> 238 >> 239 // Process the options from the user-specific config file ~/.inclxxrc >> 240 std::string configFileName; >> 241 const char * const configFileVar = getenv("INCLXXRC"); >> 242 if(configFileVar) >> 243 configFileName = configFileVar; >> 244 else { >> 245 const char * const homeDirectoryPointer = getenv("HOME"); >> 246 if(homeDirectoryPointer) { // Check if we can find the home directory >> 247 std::string homeDirectory(homeDirectoryPointer); >> 248 configFileName = homeDirectory + "/.inclxxrc"; >> 249 } else { >> 250 std::cerr << "Could not determine the user's home directory. " >> 251 << "Are you running Linux, Unix or BSD?"<< std::endl; >> 252 std::exit(EXIT_FAILURE); >> 253 } >> 254 } >> 255 >> 256 std::ifstream configFileStream(configFileName.c_str()); >> 257 std::cout << "Reading config file " << configFileName << std::endl; >> 258 if(!configFileStream) { >> 259 std::cerr << "INCL++ config file " << configFileName >> 260 << " not found. Continuing the run regardless." >> 261 << std::endl; >> 262 } else { >> 263 // Merge options from the input file >> 264 boost::program_options::parsed_options parsedOptions = boost::program_options::parse_config_file(configFileStream, configFileOptions, true); >> 265 boost::program_options::store(parsedOptions, variablesMap); >> 266 >> 267 // Make sure that the unhandled options are all "*-datafile-path" >> 268 std::vector<std::string> unhandledOptions = >> 269 boost::program_options::collect_unrecognized(parsedOptions.options, boost::program_options::exclude_positional); >> 270 G4bool ignoreNext = false; >> 271 const std::string match = "-datafile-path"; >> 272 for(std::vector<std::string>::const_iterator i=unhandledOptions.begin(); i!=unhandledOptions.end(); ++i) { >> 273 if(ignoreNext) { >> 274 ignoreNext=false; >> 275 continue; >> 276 } >> 277 if(i->rfind(match) == i->length()-match.length()) { >> 278 std::cerr << "Ignoring unrecognized option " << *i << std::endl; >> 279 ignoreNext = true; >> 280 } else { >> 281 std::cerr << "Error: unrecognized option " << *i << std::endl; >> 282 std::cerr << suggestHelpMsg; >> 283 std::exit(EXIT_FAILURE); >> 284 } >> 285 } >> 286 >> 287 // Store the option values in the variablesMap >> 288 boost::program_options::store(parsedOptions, variablesMap); >> 289 boost::program_options::notify(variablesMap); >> 290 } >> 291 configFileStream.close(); >> 292 >> 293 /* ******************* >> 294 * Process the options >> 295 * *******************/ >> 296 >> 297 // -h/--help: print the help message and exit successfully >> 298 if(variablesMap.count("help")) { >> 299 std::cout << "Usage: INCLCascade [options] <input_file>" << std::endl; >> 300 std::cout << std::endl << "Options marked with a * are compulsory, i.e. they must be provided either on\nthe command line or in the input file." << std::endl; >> 301 std::cout << visibleOptions << std::endl; >> 302 std::exit(EXIT_SUCCESS); >> 303 } >> 304 >> 305 // --version: print the version string and exit successfully >> 306 if(variablesMap.count("version")) { >> 307 std::cout <<"INCL++ version " << getVersionID() << std::endl; >> 308 std::exit(EXIT_SUCCESS); >> 309 } >> 310 >> 311 // Check if the required options are present >> 312 if(isFullRun) { >> 313 std::string missingOption(""); >> 314 if(!variablesMap.count("number-shots")) >> 315 missingOption = "number-shots"; >> 316 else if(!variablesMap.count("target")) >> 317 missingOption = "target"; >> 318 else if(!variablesMap.count("projectile")) >> 319 missingOption = "projectile"; >> 320 else if(!variablesMap.count("energy")) >> 321 missingOption = "energy"; >> 322 if(!missingOption.empty()) { >> 323 std::cerr << "Required option " << missingOption << " is missing." << std::endl; >> 324 std::cerr << suggestHelpMsg; >> 325 std::exit(EXIT_FAILURE); >> 326 } >> 327 } else { >> 328 std::cout <<"Not performing a full run. This had better be a test..." << std::endl; >> 329 } >> 330 >> 331 // -p/--projectile: projectile species >> 332 projectileSpecies = ParticleSpecies(projectileString); >> 333 if(projectileSpecies.theType == G4INCL::UnknownParticle && isFullRun) { >> 334 std::cerr << "Error: unrecognized particle type " << projectileString << std::endl; >> 335 std::cerr << suggestHelpMsg; >> 336 std::exit(EXIT_FAILURE); >> 337 } >> 338 >> 339 // -t/--target: target species >> 340 if(variablesMap.count("target")) { >> 341 targetSpecies = ParticleSpecies(targetString); >> 342 if(targetSpecies.theType!=Composite) { >> 343 std::cerr << "Unrecognized target. You specified: " << targetString << std::endl >> 344 << " The target nuclide must be specified in one of the following forms:" << std::endl >> 345 << " Fe56, 56Fe, Fe-56, 56-Fe, Fe_56, 56_Fe, Fe" << std::endl >> 346 << " You can also use IUPAC element names (such as Uuh)." << std::endl; >> 347 std::cerr << suggestHelpMsg; >> 348 std::exit(EXIT_FAILURE); >> 349 } >> 350 if(targetSpecies.theA==0) >> 351 naturalTarget = true; >> 352 } >> 353 >> 354 // --pauli >> 355 if(variablesMap.count("pauli")) { >> 356 std::string pauliNorm = pauliString; >> 357 std::transform(pauliNorm.begin(), pauliNorm.end(), pauliNorm.begin(), ::tolower); >> 358 if(pauliNorm=="statistical") >> 359 pauliType = StatisticalPauli; >> 360 else if(pauliNorm=="strict") >> 361 pauliType = StrictPauli; >> 362 else if(pauliNorm=="strict-statistical") >> 363 pauliType = StrictStatisticalPauli; >> 364 else if(pauliNorm=="global") >> 365 pauliType = GlobalPauli; >> 366 else if(pauliNorm=="none") >> 367 pauliType = NoPauli; >> 368 else { >> 369 std::cerr << "Unrecognized Pauli-blocking algorithm. Must be one of:" << std::endl >> 370 << " strict-statistical (default)" << std::endl >> 371 << " strict" << std::endl >> 372 << " statistical" << std::endl >> 373 << " global" << std::endl >> 374 << " none" << std::endl; >> 375 std::cerr << suggestHelpMsg; >> 376 std::exit(EXIT_FAILURE); >> 377 } >> 378 } >> 379 >> 380 // --coulomb >> 381 if(variablesMap.count("coulomb")) { >> 382 std::string coulombNorm = coulombString; >> 383 std::transform(coulombNorm.begin(), coulombNorm.end(), coulombNorm.begin(), ::tolower); >> 384 if(coulombNorm=="non-relativistic") >> 385 coulombType = NonRelativisticCoulomb; >> 386 else if(coulombNorm=="none") >> 387 coulombType = NoCoulomb; >> 388 else { >> 389 std::cerr << "Unrecognized Coulomb-distortion algorithm. Must be one of:" << std::endl >> 390 << " non-relativistic-heavy-ion (default)" << std::endl >> 391 << " non-relativistic" << std::endl >> 392 << " none" << std::endl; >> 393 std::cerr << suggestHelpMsg; >> 394 std::exit(EXIT_FAILURE); >> 395 } >> 396 } >> 397 >> 398 // --potential >> 399 if(variablesMap.count("potential")) { >> 400 std::string potentialNorm = potentialString; >> 401 std::transform(potentialNorm.begin(), potentialNorm.end(), potentialNorm.begin(), ::tolower); >> 402 if(potentialNorm=="isospin-energy-smooth") { >> 403 potentialType = IsospinEnergySmoothPotential; >> 404 } else if(potentialNorm=="isospin-energy") { >> 405 potentialType = IsospinEnergyPotential; >> 406 } else if(potentialNorm=="isospin") >> 407 potentialType = IsospinPotential; >> 408 else if(potentialNorm=="constant") >> 409 potentialType = ConstantPotential; >> 410 else { >> 411 std::cerr << "Unrecognized potential type. Must be one of:" << std::endl >> 412 << " isospin-energy-smooth" << std::endl >> 413 << " isospin-energy (default)" << std::endl >> 414 << " isospin" << std::endl >> 415 << " constant" << std::endl; >> 416 std::cerr << suggestHelpMsg; >> 417 std::exit(EXIT_FAILURE); >> 418 } >> 419 } >> 420 >> 421 // --local-energy-BB >> 422 if(variablesMap.count("local-energy-BB")) { >> 423 std::string localEnergyBBNorm = localEnergyBBString; >> 424 std::transform(localEnergyBBNorm.begin(), localEnergyBBNorm.end(), localEnergyBBNorm.begin(), ::tolower); >> 425 if(localEnergyBBNorm=="always") { >> 426 localEnergyBBType = AlwaysLocalEnergy; >> 427 } else if(localEnergyBBNorm=="first-collision") >> 428 localEnergyBBType = FirstCollisionLocalEnergy; >> 429 else if(localEnergyBBNorm=="never") >> 430 localEnergyBBType = NeverLocalEnergy; >> 431 else { >> 432 std::cerr << "Unrecognized local-energy-BB type. Must be one of:" << std::endl >> 433 << " always" << std::endl >> 434 << " first-collision (default)" << std::endl >> 435 << " never" << std::endl; >> 436 std::cerr << suggestHelpMsg; >> 437 std::exit(EXIT_FAILURE); >> 438 } >> 439 } >> 440 >> 441 // --local-energy-pi >> 442 if(variablesMap.count("local-energy-pi")) { >> 443 std::string localEnergyPiNorm = localEnergyPiString; >> 444 std::transform(localEnergyPiNorm.begin(), localEnergyPiNorm.end(), localEnergyPiNorm.begin(), ::tolower); >> 445 if(localEnergyPiNorm=="always") { >> 446 localEnergyPiType = AlwaysLocalEnergy; >> 447 } else if(localEnergyPiNorm=="first-collision") >> 448 localEnergyPiType = FirstCollisionLocalEnergy; >> 449 else if(localEnergyPiNorm=="never") >> 450 localEnergyPiType = NeverLocalEnergy; >> 451 else { >> 452 std::cerr << "Unrecognized local-energy-pi type. Must be one of:" << std::endl >> 453 << " always" << std::endl >> 454 << " first-collision" << std::endl >> 455 << " never (default)" << std::endl; >> 456 std::cerr << suggestHelpMsg; >> 457 std::exit(EXIT_FAILURE); >> 458 } >> 459 } >> 460 >> 461 // --de-excitation >> 462 if(variablesMap.count("de-excitation")) { >> 463 std::string deExcitationNorm = deExcitationString; >> 464 std::transform(deExcitationNorm.begin(), >> 465 deExcitationNorm.end(), >> 466 deExcitationNorm.begin(), ::tolower); >> 467 if(deExcitationNorm=="none") >> 468 deExcitationType = DeExcitationNone; >> 469 #ifdef INCL_DEEXCITATION_ABLAXX >> 470 else if(deExcitationNorm=="ablav3p") >> 471 deExcitationType = DeExcitationABLAv3p; >> 472 #endif >> 473 #ifdef INCL_DEEXCITATION_ABLA07 >> 474 else if(deExcitationNorm=="abla07") >> 475 deExcitationType = DeExcitationABLA07; >> 476 #endif >> 477 #ifdef INCL_DEEXCITATION_SMM >> 478 else if(deExcitationNorm=="smm") >> 479 deExcitationType = DeExcitationSMM; >> 480 #endif >> 481 #ifdef INCL_DEEXCITATION_GEMINIXX >> 482 else if(deExcitationNorm=="geminixx") >> 483 deExcitationType = DeExcitationGEMINIXX; >> 484 #endif >> 485 else { >> 486 std::cerr << "Unrecognized de-excitation model. " >> 487 << "Must be one of:" << std::endl >> 488 << " none (default)" << std::endl >> 489 #ifdef INCL_DEEXCITATION_ABLAXX >> 490 << " ABLAv3p" << std::endl >> 491 #endif >> 492 #ifdef INCL_DEEXCITATION_ABLA07 >> 493 << " ABLA07" << std::endl >> 494 #endif >> 495 #ifdef INCL_DEEXCITATION_SMM >> 496 << " SMM" << std::endl >> 497 #endif >> 498 #ifdef INCL_DEEXCITATION_GEMINIXX >> 499 << " GEMINIXX" << std::endl >> 500 #endif >> 501 ; >> 502 std::cerr << suggestHelpMsg; >> 503 std::exit(EXIT_FAILURE); >> 504 } >> 505 } else { >> 506 deExcitationType = DeExcitationNone; >> 507 } >> 508 >> 509 // --cluster-algorithm >> 510 if(variablesMap.count("cluster-algorithm")) { >> 511 std::string clusterAlgorithmNorm = clusterAlgorithmString; >> 512 std::transform(clusterAlgorithmNorm.begin(), >> 513 clusterAlgorithmNorm.end(), >> 514 clusterAlgorithmNorm.begin(), ::tolower); >> 515 if(clusterAlgorithmNorm=="none") >> 516 clusterAlgorithmType = NoClusterAlgorithm; >> 517 else if(clusterAlgorithmNorm=="intercomparison") >> 518 clusterAlgorithmType = IntercomparisonClusterAlgorithm; >> 519 else { >> 520 std::cerr << "Unrecognized cluster algorithm. " >> 521 << "Must be one of:" << std::endl >> 522 << " intercomparison (default)" << std::endl >> 523 << " none" << std::endl; >> 524 std::cerr << suggestHelpMsg; >> 525 std::exit(EXIT_FAILURE); >> 526 } >> 527 } else { >> 528 clusterAlgorithmType = IntercomparisonClusterAlgorithm; >> 529 } >> 530 >> 531 // --cluster-max-mass >> 532 if(variablesMap.count("cluster-max-mass") && clusterMaxMass < 2 && clusterMaxMass > 12) { >> 533 std::cerr << "Maximum cluster mass outside the allowed range. Must be between 2 and 12 (included)" >> 534 << std::endl >> 535 << suggestHelpMsg; >> 536 std::exit(EXIT_FAILURE); >> 537 } >> 538 >> 539 // --separation-energies >> 540 if(variablesMap.count("separation-energies")) { >> 541 std::string separationEnergyNorm = separationEnergyString; >> 542 std::transform(separationEnergyNorm.begin(), >> 543 separationEnergyNorm.end(), >> 544 separationEnergyNorm.begin(), ::tolower); >> 545 if(separationEnergyNorm=="incl") >> 546 separationEnergyType = INCLSeparationEnergy; >> 547 else if(separationEnergyNorm=="real") >> 548 separationEnergyType = RealSeparationEnergy; >> 549 else if(separationEnergyNorm=="real-light") >> 550 separationEnergyType = RealForLightSeparationEnergy; >> 551 else { >> 552 std::cerr << "Unrecognized separation-energies option. " >> 553 << "Must be one of:" << std::endl >> 554 << " INCL (default)" << std::endl >> 555 << " real" << std::endl >> 556 << " real-light" << std::endl; >> 557 std::cerr << suggestHelpMsg; >> 558 std::exit(EXIT_FAILURE); >> 559 } >> 560 } else { >> 561 separationEnergyType = INCLSeparationEnergy; >> 562 } >> 563 >> 564 // --output: construct a reasonable output file root if not specified >> 565 if(!variablesMap.count("output") && isFullRun) { >> 566 // If an input file was specified, use its name as the output file root >> 567 if(variablesMap.count("input-file")) >> 568 outputFileRoot = inputFileName; >> 569 else { >> 570 std::stringstream outputFileRootStream; >> 571 outputFileRootStream.precision(0); >> 572 outputFileRootStream.setf(std::ios::fixed, std::ios::floatfield); >> 573 outputFileRootStream << >> 574 ParticleTable::getShortName(projectileSpecies) << "_" << >> 575 ParticleTable::getShortName(targetSpecies) << "_" << >> 576 projectileKineticEnergy; >> 577 >> 578 // Append suffixes to the output file root for each explicitly specified CLI option >> 579 typedef boost::program_options::variables_map::const_iterator BPOVMIter; >> 580 for(BPOVMIter i=variablesMap.begin(); i!=variablesMap.end(); ++i) { >> 581 std::string const &name = i->first; >> 582 // Only process CLI options >> 583 if(name!="projectile" >> 584 && name!="target" >> 585 && name!="energy" >> 586 && name!="number-shots" >> 587 && name!="random-seed-1" >> 588 && name!="random-seed-2" >> 589 && name!="inclxx-datafile-path" >> 590 #ifdef INCL_DEEXCITATION_ABLA07 >> 591 && name!="abla07-datafile-path" >> 592 #endif >> 593 #ifdef INCL_DEEXCITATION_ABLAXX >> 594 && name!="ablav3p-cxx-datafile-path" >> 595 #endif >> 596 #ifdef INCL_DEEXCITATION_GEMINIXX >> 597 && name!="geminixx-datafile-path" >> 598 #endif >> 599 ) { >> 600 boost::program_options::variable_value v = i->second; >> 601 if(!v.defaulted()) { >> 602 const std::type_info &type = v.value().type(); >> 603 if(type==typeid(std::string)) >> 604 outputFileRootStream << "_" << name << "=" << v.as<std::string>(); >> 605 else if(type==typeid(G4float)) >> 606 outputFileRootStream << "_" << name << "=" << v.as<G4float>(); >> 607 else if(type==typeid(G4int)) >> 608 outputFileRootStream << "_" << name << "=" << v.as<G4int>(); >> 609 else if(type==typeid(G4bool)) >> 610 outputFileRootStream << "_" << name << "=" << v.as<G4bool>(); >> 611 } >> 612 } >> 613 } >> 614 >> 615 outputFileRoot = outputFileRootStream.str(); >> 616 } >> 617 } >> 618 >> 619 // -l/--logfile >> 620 if(!variablesMap.count("logfile")) >> 621 logFileName = outputFileRoot + ".log"; >> 622 >> 623 } >> 624 catch(std::exception& e) >> 625 { >> 626 std::cerr << e.what() << "\n"; >> 627 std::cerr << suggestHelpMsg; >> 628 std::exit(EXIT_FAILURE); >> 629 } >> 630 47 } 631 } >> 632 #else >> 633 Config::Config(G4int /*argc*/, char * /*argv*/ [], G4bool /*isFullRun*/) >> 634 { >> 635 init(); >> 636 } >> 637 #endif 48 638 49 Config::~Config() {} << 639 Config::~Config() >> 640 {} 50 641 51 void Config::init() { 642 void Config::init() { 52 verbosity = 1; << 643 verbosity = 1; 53 logFileName = "-"; << 644 inputFileName = ""; 54 inputFileName = ""; << 645 title = "INCL default run title"; 55 title = "INCL default run title"; << 646 nShots = 1000; 56 nShots = 1000; << 647 naturalTarget = false; 57 naturalTarget = false; << 648 projectileString = "proton"; 58 projectileString = "proton"; << 649 projectileSpecies = G4INCL::Proton; 59 projectileSpecies = G4INCL::Proton; << 650 projectileKineticEnergy = 1000.0; 60 projectileKineticEnergy = 1000.0; << 651 verboseEvent = -1; 61 verboseEvent = -1; << 652 randomSeed1 = 666; 62 randomSeeds = ""; << 653 randomSeed2 = 777; 63 randomSeedVector.push_back(666); << 654 pauliString = "strict-statistical"; 64 randomSeedVector.push_back(777); << 655 pauliType = StrictStatisticalPauli; 65 randomSeedVector.push_back(1234); << 656 CDPP = true; 66 pauliString = "strict-statistical"; << 657 coulombString = "non-relativistic"; 67 pauliType = StrictStatisticalPauli; << 658 coulombType = NonRelativisticCoulomb; 68 CDPP = true; << 659 potentialString = "isospin-energy"; 69 coulombString = "non-relativistic"; << 660 potentialType = IsospinEnergyPotential; 70 coulombType = NonRelativisticCoulomb; << 661 pionPotential = true; 71 potentialString = "isospin-energy"; << 662 localEnergyBBString = "first-collision"; 72 potentialType = IsospinEnergyPotential; << 663 localEnergyBBType = FirstCollisionLocalEnergy; 73 pionPotential = true; << 664 localEnergyPiString = "first-collision"; 74 localEnergyBBString = "first-collision"; << 665 localEnergyPiType = FirstCollisionLocalEnergy; 75 localEnergyBBType = FirstCollisionLocalEne << 666 deExcitationString = "none"; 76 localEnergyPiString = "first-collision"; << 667 deExcitationType = DeExcitationNone; 77 localEnergyPiType = FirstCollisionLocalEne << 668 clusterAlgorithmString = "intercomparison"; 78 deExcitationString = "none"; << 669 clusterAlgorithmType = IntercomparisonClusterAlgorithm; 79 deExcitationType = DeExcitationNone; << 670 clusterMaxMass = 8; 80 clusterAlgorithmString = "intercomparison" << 671 backToSpectator = true; 81 clusterAlgorithmType = IntercomparisonClus << 672 useRealMasses = true; 82 clusterMaxMass = 8; << 673 impactParameter = -1.; 83 backToSpectator = true; << 674 separationEnergyString = "INCL"; 84 useRealMasses = true; << 675 separationEnergyType = INCLSeparationEnergy; 85 impactParameter = -1.; << 86 separationEnergyString = "INCL"; << 87 separationEnergyType = INCLSeparationEnerg << 88 fermiMomentumString = "constant"; << 89 fermiMomentumType = ConstantFermiMomentum; << 90 fermiMomentum = -1.; << 91 cutNN = 1910.; << 92 #ifdef INCL_DEEXCITATION_FERMI_BREAKUP << 93 maxMassFermiBreakUp = 16; << 94 maxChargeFermiBreakUp = 8; << 95 #endif << 96 rpCorrelationCoefficient = 0.98; << 97 rpCorrelationCoefficientProton = 0.5; << 98 rpCorrelationCoefficientNeutron = 0.73; << 99 neutronSkin = 0.; << 100 neutronHalo = 0.; << 101 refraction=false; << 102 phaseSpaceGenerator = "Raubold-Lynch"; << 103 phaseSpaceGeneratorType = RauboldLynchType << 104 cascadeAction = "default"; << 105 cascadeActionType = DefaultActionType; << 106 randomNumberGenerator = "Ranecu"; << 107 rngType = RanecuType; << 108 autosaveFrequency = 10000; << 109 maxNumberMultipions = -1; << 110 crossSectionsString = "antiparticles"; << 111 crossSectionsType = AntiparticlesCrossSect << 112 hadronizationTime = 0.; << 113 #ifdef INCL_ROOT_USE << 114 conciseROOTTree = false; << 115 #endif << 116 inverseKinematics = false; << 117 decayTimeThreshold = 1.e-20; << 118 bias = 1.; << 119 atrestThreshold = 200.; << 120 } 676 } 121 677 122 std::string Config::summary() { 678 std::string Config::summary() { 123 std::stringstream message; 679 std::stringstream message; 124 message << "INCL++ version " << getVersion << 680 message << "INCL++ version " << getVersionID() << std::endl; 125 if(projectileSpecies.theType != Composite) 681 if(projectileSpecies.theType != Composite) 126 message << "Projectile: " << ParticleTab << 682 message << "Projectile: " << ParticleTable::getName(projectileSpecies) << std::endl; 127 else 683 else 128 message << "Projectile: composite, A=" < << 684 message << "Projectile: composite, A=" << projectileSpecies.theA << ", Z=" << projectileSpecies.theZ << std::endl; 129 message << " energy = " << projectileKine << 685 message << " energy = " << projectileKineticEnergy << std::endl; 130 if(targetSpecies.theA>0) 686 if(targetSpecies.theA>0) 131 message << "Target: A = " << targetSpeci << 687 message << "Target: A = " << targetSpecies.theA << " Z = " << targetSpecies.theZ << std::endl; 132 else 688 else 133 message << "Target: natural isotopic com << 689 message << "Target: natural isotopic composition, Z = " << targetSpecies.theZ << std::endl; 134 message << "Number of requested shots = " << 690 message << "Number of requested shots = " << nShots << std::endl; 135 return message.str(); 691 return message.str(); >> 692 } >> 693 >> 694 std::string const Config::echo() const { >> 695 std::stringstream ss; >> 696 ss << std::boolalpha; >> 697 ss << "###########################" << std::endl >> 698 << "### Start of input echo ###" << std::endl >> 699 << "###########################" << std::endl << std::endl >> 700 << " # You may re-use this snippet of the log file as an input file!" << std::endl >> 701 << " # Options marked with a * are compulsory." << std::endl >> 702 << std::endl >> 703 << "# Run options" << std::endl >> 704 << "title = " << title << "\t# run title" << std::endl >> 705 << "output = " << outputFileRoot << "\t# root for generating output file names. Suffixes (.root, .out, etc.) will be appended to this root. Defaults to the input file name, if given; otherwise, defaults to a string composed of the explicitly specified options" << std::endl >> 706 << "logfile = " << logFileName << "\t# log file name. Defaults to `<output_root>.log'. Use `-' if you want to redirect logging to stdout" << std::endl >> 707 << "number-shots = " << nShots << "\t# * number of shots" << std::endl >> 708 << "inclxx-datafile-path = " << INCLXXDataFilePath << std::endl >> 709 #ifdef INCL_DEEXCITATION_ABLAXX >> 710 << "ablav3p-cxx-datafile-path = " << ablav3pCxxDataFilePath << std::endl >> 711 #endif >> 712 #ifdef INCL_DEEXCITATION_ABLA07 >> 713 << "abla07-datafile-path = " << abla07DataFilePath << std::endl >> 714 #endif >> 715 #ifdef INCL_DEEXCITATION_GEMINIXX >> 716 << "geminixx-datafile-path = " << geminixxDataFilePath << std::endl >> 717 #endif >> 718 << std::endl << "# Projectile and target definitions" << std::endl >> 719 << "target = " << targetString << "\t# * target nuclide. Can be specified as Fe56, 56Fe, Fe-56, 56-Fe, Fe_56, 56_Fe or Fe. If the mass number is omitted, natural target composition is assumed." << std::endl >> 720 << " " << "# the target nuclide was parsed as Z=" << targetSpecies.theZ; >> 721 if(targetSpecies.theA>0) >> 722 ss << ", A=" << targetSpecies.theA; >> 723 else >> 724 ss << ", natural target"; >> 725 ss << std::endl >> 726 << "projectile = " << projectileString << "\t# * projectile name (proton, neutron, pi+, pi0, pi-, d, t, a, He-4...)" << std::endl >> 727 << " " << "# the projectile nuclide was parsed as Z=" << projectileSpecies.theZ << ", A=" << projectileSpecies.theA << std::endl >> 728 << "energy = " << projectileKineticEnergy << "\t# * total kinetic energy of the projectile, in MeV" << std::endl >> 729 << std::endl << "# Physics options " << std::endl >> 730 << "pauli = " << pauliString << "\t# Pauli-blocking algorithm. Must be one of: strict-statistical (default), strict, statistical, global, none" << std::endl >> 731 << "cdpp = " << CDPP << "\t# whether to apply CDPP after collisions" << std::endl >> 732 << "coulomb = " << coulombString << "\t# Coulomb-distortion algorithm. Must be one of: non-relativistic (default), none" << std::endl >> 733 << "potential = " << potentialString << "\t# nucleon potential. Must be one of: isospin-energy-smooth, isospin-energy (default), isospin, constant" << std::endl >> 734 << "pion-potential = " << pionPotential << "\t# whether to use a pion potential" << std::endl >> 735 << "local-energy-BB = " << localEnergyBBString << "\t# local energy in baryon-baryon collisions. Must be one of: always, first-collision (default), never" << std::endl >> 736 << "local-energy-pi = " << localEnergyPiString << "\t# local energy in pi-N collisions and in delta decays. Must be one of: always, first-collision (default), never" << std::endl >> 737 << "de-excitation = " << deExcitationString << "\t # which de-excitation model to use. Must be one of:" >> 738 " none (default)" >> 739 #ifdef INCL_DEEXCITATION_ABLAXX >> 740 ", ABLAv3p" >> 741 #endif >> 742 #ifdef INCL_DEEXCITATION_ABLA07 >> 743 ", ABLA07" >> 744 #endif >> 745 #ifdef INCL_DEEXCITATION_SMM >> 746 ", SMM" >> 747 #endif >> 748 #ifdef INCL_DEEXCITATION_GEMINIXX >> 749 ", GEMINIXX" >> 750 #endif >> 751 << std::endl >> 752 << "cluster-algorithm = " << clusterAlgorithmString << "\t# clustering algorithm for production of composites. Must be one of: intercomparison (default), none" << std::endl >> 753 << "cluster-max-mass = " << clusterMaxMass << "\t# maximum mass of produced composites. Must be between 2 and 12 (included)" << std::endl >> 754 << "back-to-spectator = " << backToSpectator << "\t# whether to use back-to-spectator" << std::endl >> 755 << "use-real-masses = " << useRealMasses << "\t# whether to use real masses for the outgoing particle energies" << std::endl >> 756 << "separation-energies = " << separationEnergyString << "\t# how to assign the separation energies of the INCL nucleus. Must be one of: INCL (default), real, real-light" << std::endl >> 757 << std::endl << "# Technical options " << std::endl >> 758 << "verbosity = " << verbosity << "\t# from 0 (quiet) to 10 (most verbose)" << std::endl >> 759 << "verbose-event = " << verboseEvent << "\t# request verbose logging for the specified event only" << std::endl >> 760 << "random-seed-1 = " << randomSeed1 << "\t# first seed for the random-number generator" << std::endl >> 761 << "random-seed-2 = " << randomSeed2 << "\t# second seed for the random-number generator" << std::endl >> 762 << std::endl << "#########################" << std::endl >> 763 << "### End of input echo ###" << std::endl >> 764 << "#########################" << std::endl; >> 765 >> 766 return ss.str(); 136 } 767 } 137 768 138 } 769 } 139 770