G4INCLConfig.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // INCL++ intra-nuclear cascade model
00027 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
00028 // Davide Mancusi, CEA
00029 // Alain Boudard, CEA
00030 // Sylvie Leray, CEA
00031 // Joseph Cugnon, University of Liege
00032 //
00033 #define INCLXX_IN_GEANT4_MODE 1
00034 
00035 #include "globals.hh"
00036 
00037 #include "G4INCLParticleType.hh"
00038 #include "G4INCLConfig.hh"
00039 #include "G4INCLParticleSpecies.hh"
00040 #include "G4INCLParticleTable.hh"
00041 
00042 #ifdef HAS_BOOST_PROGRAM_OPTIONS
00043 #include <boost/program_options/options_description.hpp>
00044 #include <boost/program_options/parsers.hpp>
00045 #include <boost/program_options/variables_map.hpp>
00046 #include <iostream>
00047 #include <fstream>
00048 #include <sstream>
00049 #include <cstdlib>
00050 #include "G4INCLCascade.hh"
00051 #include "G4INCLLogger.hh"
00052 #endif
00053 
00054 namespace G4INCL {
00055 
00056   Config::Config()
00057   {
00058     init();
00059   }
00060 
00061   Config::Config(G4int /*A*/, G4int /*Z*/, G4INCL::ParticleSpecies proj, G4double projectileE)
00062   {
00063     init();
00064     projectileSpecies = proj;
00065     projectileKineticEnergy = projectileE;
00066   }
00067 
00068   // NOT used in Geant4 mode
00069 #ifdef HAS_BOOST_PROGRAM_OPTIONS
00070   Config::Config(G4int argc, char *argv[], G4bool isFullRun) : naturalTarget(false) {
00071     const std::string suggestHelpMsg("You might want to run `INCLCascade -h' to get a help message.\n");
00072 
00073     try {
00074 
00075       // Hidden options
00076       boost::program_options::options_description hiddenOptDesc("Hidden options");
00077       hiddenOptDesc.add_options()
00078         ("input-file", boost::program_options::value<std::string>(&inputFileName), "input file")
00079         ("impact-parameter", boost::program_options::value<G4double>(&impactParameter)->default_value(-1.), "impact parameter")
00080         ;
00081 
00082       // Generic options
00083       std::stringstream verbosityDescription;
00084       verbosityDescription << "set verbosity level:\n"
00085         << "  0: \tquiet, suppress all output messages\n"
00086         << "  " << InfoMsg << ": \tminimal logging\n"
00087         << "  " << FatalMsg << ": \tlog fatal error messages as well\n"
00088         << "  " << ErrorMsg << ": \tlog error messages as well\n"
00089         << "  " << WarningMsg << ": \tlog warning messages as well\n"
00090         << "  " << DebugMsg << ": \tlog debug messages as well\n"
00091         << "  " << DataBlockMsg << ": \tlog data-block messages as well";
00092 
00093       boost::program_options::options_description genericOptDesc("Generic options");
00094       genericOptDesc.add_options()
00095         ("help,h", "produce this help message")
00096         ("version", "print version string and exit")
00097         ;
00098 
00099       // Run-specific options
00100       boost::program_options::options_description runOptDesc("Run options");
00101       runOptDesc.add_options()
00102         ("title", boost::program_options::value<std::string>(&title)->default_value("INCL default run title"), "run title")
00103         ("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")
00104         ("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")
00105         ("number-shots,N", boost::program_options::value<G4int>(&nShots), "* number of shots")
00106         ("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.")
00107         ("projectile,p", boost::program_options::value<std::string>(&projectileString), "* projectile name:\n"
00108          "  \tproton, p\n"
00109          "  \tneutron, n\n"
00110          "  \tpi+, piplus, pion+, pionplus\n"
00111          "  \tpi0, pizero, pion0, pionzero\n"
00112          "  \tpi-, piminus, pion-, pionminus\n"
00113          "  \td, t, a, deuteron, triton, alpha\n"
00114          "  \tHe-4, He4, 4He (and so on)\n")
00115         ("energy,E", boost::program_options::value<G4float>(&projectileKineticEnergy), "* total kinetic energy of the projectile, in MeV")
00116         ("verbose-event", boost::program_options::value<G4int>(&verboseEvent)->default_value(-1), "request verbose logging for the specified event only")
00117         ("random-seed-1", boost::program_options::value<G4int>(&randomSeed1)->default_value(666), "first seed for the random-number generator")
00118         ("random-seed-2", boost::program_options::value<G4int>(&randomSeed2)->default_value(777), "second seed for the random-number generator")
00119         ("inclxx-datafile-path", boost::program_options::value<std::string>(&INCLXXDataFilePath)->default_value("./data/"))
00120 #ifdef INCL_DEEXCITATION_ABLAXX
00121         ("ablav3p-cxx-datafile-path", boost::program_options::value<std::string>(&ablav3pCxxDataFilePath)->default_value("./de-excitation/ablaxx/data/G4ABLA3.0/"))
00122 #endif
00123 #ifdef INCL_DEEXCITATION_ABLA07
00124         ("abla07-datafile-path", boost::program_options::value<std::string>(&abla07DataFilePath)->default_value("./de-excitation/abla07/upstream/tables/"))
00125 #endif
00126 #ifdef INCL_DEEXCITATION_GEMINIXX
00127         ("geminixx-datafile-path", boost::program_options::value<std::string>(&geminixxDataFilePath)->default_value("./de-excitation/geminixx/upstream/"))
00128 #endif
00129         ("verbosity,v", boost::program_options::value<G4int>(&verbosity)->default_value(4), verbosityDescription.str().c_str())
00130         ;
00131 
00132       // Physics options
00133       boost::program_options::options_description physicsOptDesc("Physics options");
00134       physicsOptDesc.add_options()
00135         ("pauli", boost::program_options::value<std::string>(&pauliString)->default_value("strict-statistical"), "Pauli-blocking algorithm:\n"
00136          "  \tstrict-statistical (default)\n"
00137          "  \tstrict\n"
00138          "  \tstatistical\n"
00139          "  \tglobal\n"
00140          "  \tnone")
00141         ("cdpp", boost::program_options::value<G4bool>(&CDPP)->default_value(true), "whether to apply CDPP after collisions:\n  \ttrue, 1 (default)\n  \tfalse, 0")
00142         ("coulomb", boost::program_options::value<std::string>(&coulombString)->default_value("non-relativistic"), "Coulomb-distortion algorithm:\n  \tnon-relativistic (default)\n  \tnone")
00143         ("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")
00144         ("pion-potential", boost::program_options::value<G4bool>(&pionPotential)->default_value("true"), "whether to use a pion potential:\n  \ttrue, 1 (default)\n  \tfalse, 0")
00145         ("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")
00146         ("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")
00147         ("de-excitation", boost::program_options::value<std::string>(&deExcitationString)->default_value("none"), "which de-excitation model to use:"
00148          "\n  \tnone (default)"
00149 #ifdef INCL_DEEXCITATION_ABLAXX
00150          "\n  \tABLAv3p"
00151 #endif
00152 #ifdef INCL_DEEXCITATION_ABLA07
00153          "\n  \tABLA07"
00154 #endif
00155 #ifdef INCL_DEEXCITATION_SMM
00156          "\n  \tSMM"
00157 #endif
00158 #ifdef INCL_DEEXCITATION_GEMINIXX
00159          "\n  \tGEMINIXX"
00160 #endif
00161          )
00162         ("cluster-algorithm", boost::program_options::value<std::string>(&clusterAlgorithmString)->default_value("intercomparison"), "clustering algorithm for production of composites:\n  \tintercomparison (default)\n  \tnone")
00163         ("cluster-max-mass", boost::program_options::value<G4int>(&clusterMaxMass)->default_value(8), "maximum mass of produced composites:\n  \tminimum 2\n  \tmaximum 12")
00164         ("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")
00165         ("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")
00166         ("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")
00167         ;
00168 
00169       // Select options allowed on the command line
00170       boost::program_options::options_description cmdLineOptions;
00171       cmdLineOptions.add(hiddenOptDesc).add(genericOptDesc).add(runOptDesc).add(physicsOptDesc);
00172 
00173       // Select options allowed in config files
00174       boost::program_options::options_description configFileOptions;
00175       configFileOptions.add(runOptDesc).add(physicsOptDesc);
00176 
00177       // Select visible options
00178       boost::program_options::options_description visibleOptions;
00179       visibleOptions.add(genericOptDesc).add(runOptDesc).add(physicsOptDesc);
00180 
00181       // Declare input-file as a positional option (if we just provide a file
00182       // name on the command line, it should be interpreted as an input-file
00183       // option).
00184       boost::program_options::positional_options_description p;
00185       p.add("input-file", 1);
00186 
00187       // Disable guessing of option names
00188       G4int cmdstyle =
00189         boost::program_options::command_line_style::default_style &
00190         ~boost::program_options::command_line_style::allow_guessing;
00191 
00192       // Result of the option processing
00193       boost::program_options::variables_map variablesMap;
00194       boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
00195           style(cmdstyle).
00196           options(cmdLineOptions).positional(p).run(), variablesMap);
00197       boost::program_options::notify(variablesMap);
00198 
00199       // If an input file was specified, merge the options with the command-line
00200       // options.
00201       if(variablesMap.count("input-file")) {
00202         std::ifstream inputFileStream(inputFileName.c_str());
00203         if(!inputFileStream) {
00204           std::cerr << "Cannot open input file: " << inputFileName << std::endl;
00205           std::exit(EXIT_FAILURE);
00206         } else {
00207           // Merge options from the input file
00208           boost::program_options::parsed_options parsedOptions = boost::program_options::parse_config_file(inputFileStream, configFileOptions, true);
00209 
00210           // Make sure that the unhandled options are all "*-datafile-path"
00211           std::vector<std::string> unhandledOptions =
00212             boost::program_options::collect_unrecognized(parsedOptions.options, boost::program_options::exclude_positional);
00213           G4bool ignoreNext = false;
00214           const std::string match = "-datafile-path";
00215           for(std::vector<std::string>::const_iterator i=unhandledOptions.begin(); i!=unhandledOptions.end(); ++i) {
00216             if(ignoreNext) {
00217               ignoreNext=false;
00218               continue;
00219             }
00220             if(i->rfind(match) == i->length()-match.length()) {
00221               std::cerr << "Ignoring unrecognized option " << *i << std::endl;
00222               ignoreNext = true;
00223             } else {
00224               std::cerr << "Error: unrecognized option " << *i << std::endl;
00225               std::cerr << suggestHelpMsg;
00226               std::exit(EXIT_FAILURE);
00227             }
00228           }
00229 
00230           // Store the option values in the variablesMap
00231           boost::program_options::store(parsedOptions, variablesMap);
00232           boost::program_options::notify(variablesMap);
00233         }
00234         inputFileStream.close();
00235       }
00236 
00237       // Process the options from the user-specific config file ~/.inclxxrc
00238       std::string configFileName;
00239       const char * const configFileVar = getenv("INCLXXRC");
00240       if(configFileVar)
00241         configFileName = configFileVar;
00242       else {
00243         const char * const homeDirectoryPointer = getenv("HOME");
00244         if(homeDirectoryPointer) { // Check if we can find the home directory
00245           std::string homeDirectory(homeDirectoryPointer);
00246           configFileName = homeDirectory + "/.inclxxrc";
00247         } else {
00248           std::cerr << "Could not determine the user's home directory. "
00249             << "Are you running Linux, Unix or BSD?"<< std::endl;
00250           std::exit(EXIT_FAILURE);
00251         }
00252       }
00253 
00254       std::ifstream configFileStream(configFileName.c_str());
00255       std::cout << "Reading config file " << configFileName << std::endl;
00256       if(!configFileStream) {
00257         std::cerr << "INCL++ config file " << configFileName
00258           << " not found. Continuing the run regardless."
00259           << std::endl;
00260       } else {
00261         // Merge options from the input file
00262         boost::program_options::parsed_options parsedOptions = boost::program_options::parse_config_file(configFileStream, configFileOptions, true);
00263         boost::program_options::store(parsedOptions, variablesMap);
00264 
00265         // Make sure that the unhandled options are all "*-datafile-path"
00266         std::vector<std::string> unhandledOptions =
00267           boost::program_options::collect_unrecognized(parsedOptions.options, boost::program_options::exclude_positional);
00268         G4bool ignoreNext = false;
00269         const std::string match = "-datafile-path";
00270         for(std::vector<std::string>::const_iterator i=unhandledOptions.begin(); i!=unhandledOptions.end(); ++i) {
00271           if(ignoreNext) {
00272             ignoreNext=false;
00273             continue;
00274           }
00275           if(i->rfind(match) == i->length()-match.length()) {
00276             std::cerr << "Ignoring unrecognized option " << *i << std::endl;
00277             ignoreNext = true;
00278           } else {
00279             std::cerr << "Error: unrecognized option " << *i << std::endl;
00280             std::cerr << suggestHelpMsg;
00281             std::exit(EXIT_FAILURE);
00282           }
00283         }
00284 
00285         // Store the option values in the variablesMap
00286         boost::program_options::store(parsedOptions, variablesMap);
00287         boost::program_options::notify(variablesMap);
00288       }
00289       configFileStream.close();
00290 
00291       /* *******************
00292        * Process the options
00293        * *******************/
00294 
00295       // -h/--help: print the help message and exit successfully
00296       if(variablesMap.count("help")) {
00297         std::cout << "Usage: INCLCascade [options] <input_file>" << std::endl;
00298         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;
00299         std::cout << visibleOptions << std::endl;
00300         std::exit(EXIT_SUCCESS);
00301       }
00302 
00303       // --version: print the version string and exit successfully
00304       if(variablesMap.count("version")) {
00305         std::cout <<"INCL++ version " << getVersionID() << std::endl;
00306         std::exit(EXIT_SUCCESS);
00307       }
00308 
00309       // Check if the required options are present
00310       if(isFullRun) {
00311         std::string missingOption("");
00312         if(!variablesMap.count("number-shots"))
00313           missingOption = "number-shots";
00314         else if(!variablesMap.count("target"))
00315           missingOption = "target";
00316         else if(!variablesMap.count("projectile"))
00317           missingOption = "projectile";
00318         else if(!variablesMap.count("energy"))
00319           missingOption = "energy";
00320         if(!missingOption.empty()) {
00321           std::cerr << "Required option " << missingOption << " is missing." << std::endl;
00322           std::cerr << suggestHelpMsg;
00323           std::exit(EXIT_FAILURE);
00324         }
00325       } else {
00326         std::cout <<"Not performing a full run. This had better be a test..." << std::endl;
00327       }
00328 
00329       // -p/--projectile: projectile species
00330       projectileSpecies = ParticleSpecies(projectileString);
00331       if(projectileSpecies.theType == G4INCL::UnknownParticle && isFullRun) {
00332         std::cerr << "Error: unrecognized particle type " << projectileString << std::endl;
00333         std::cerr << suggestHelpMsg;
00334         std::exit(EXIT_FAILURE);
00335       }
00336 
00337       // -t/--target: target species
00338       if(variablesMap.count("target")) {
00339         targetSpecies = ParticleSpecies(targetString);
00340         if(targetSpecies.theType!=Composite) {
00341           std::cerr << "Unrecognized target. You specified: " << targetString << std::endl
00342             << "  The target nuclide must be specified in one of the following forms:" << std::endl
00343             << "    Fe56, 56Fe, Fe-56, 56-Fe, Fe_56, 56_Fe, Fe" << std::endl
00344             << "  You can also use IUPAC element names (such as Uuh)." << std::endl;
00345           std::cerr << suggestHelpMsg;
00346           std::exit(EXIT_FAILURE);
00347         }
00348         if(targetSpecies.theA==0)
00349           naturalTarget = true;
00350       }
00351 
00352       // --pauli
00353       if(variablesMap.count("pauli")) {
00354         std::string pauliNorm = pauliString;
00355         std::transform(pauliNorm.begin(), pauliNorm.end(), pauliNorm.begin(), ::tolower);
00356         if(pauliNorm=="statistical")
00357           pauliType = StatisticalPauli;
00358         else if(pauliNorm=="strict")
00359           pauliType = StrictPauli;
00360         else if(pauliNorm=="strict-statistical")
00361           pauliType = StrictStatisticalPauli;
00362         else if(pauliNorm=="global")
00363           pauliType = GlobalPauli;
00364         else if(pauliNorm=="none")
00365           pauliType = NoPauli;
00366         else {
00367           std::cerr << "Unrecognized Pauli-blocking algorithm. Must be one of:" << std::endl
00368             << "  strict-statistical (default)" << std::endl
00369             << "  strict" << std::endl
00370             << "  statistical" << std::endl
00371             << "  global" << std::endl
00372             << "  none" << std::endl;
00373           std::cerr << suggestHelpMsg;
00374           std::exit(EXIT_FAILURE);
00375         }
00376       }
00377 
00378       // --coulomb
00379       if(variablesMap.count("coulomb")) {
00380         std::string coulombNorm = coulombString;
00381         std::transform(coulombNorm.begin(), coulombNorm.end(), coulombNorm.begin(), ::tolower);
00382         if(coulombNorm=="non-relativistic")
00383           coulombType = NonRelativisticCoulomb;
00384         else if(coulombNorm=="none")
00385           coulombType = NoCoulomb;
00386         else {
00387           std::cerr << "Unrecognized Coulomb-distortion algorithm. Must be one of:" << std::endl
00388             << "  non-relativistic-heavy-ion (default)" << std::endl
00389             << "  non-relativistic" << std::endl
00390             << "  none" << std::endl;
00391           std::cerr << suggestHelpMsg;
00392           std::exit(EXIT_FAILURE);
00393         }
00394       }
00395 
00396       // --potential
00397       if(variablesMap.count("potential")) {
00398         std::string potentialNorm = potentialString;
00399         std::transform(potentialNorm.begin(), potentialNorm.end(), potentialNorm.begin(), ::tolower);
00400         if(potentialNorm=="isospin-energy-smooth") {
00401           potentialType = IsospinEnergySmoothPotential;
00402         } else if(potentialNorm=="isospin-energy") {
00403           potentialType = IsospinEnergyPotential;
00404         } else if(potentialNorm=="isospin")
00405           potentialType = IsospinPotential;
00406         else if(potentialNorm=="constant")
00407           potentialType = ConstantPotential;
00408         else {
00409           std::cerr << "Unrecognized potential type. Must be one of:" << std::endl
00410             << "  isospin-energy-smooth" << std::endl
00411             << "  isospin-energy (default)" << std::endl
00412             << "  isospin" << std::endl
00413             << "  constant" << std::endl;
00414           std::cerr << suggestHelpMsg;
00415           std::exit(EXIT_FAILURE);
00416         }
00417       }
00418 
00419       // --local-energy-BB
00420       if(variablesMap.count("local-energy-BB")) {
00421         std::string localEnergyBBNorm = localEnergyBBString;
00422         std::transform(localEnergyBBNorm.begin(), localEnergyBBNorm.end(), localEnergyBBNorm.begin(), ::tolower);
00423         if(localEnergyBBNorm=="always") {
00424           localEnergyBBType = AlwaysLocalEnergy;
00425         } else if(localEnergyBBNorm=="first-collision")
00426           localEnergyBBType = FirstCollisionLocalEnergy;
00427         else if(localEnergyBBNorm=="never")
00428           localEnergyBBType = NeverLocalEnergy;
00429         else {
00430           std::cerr << "Unrecognized local-energy-BB type. Must be one of:" << std::endl
00431             << "  always" << std::endl
00432             << "  first-collision (default)" << std::endl
00433             << "  never" << std::endl;
00434           std::cerr << suggestHelpMsg;
00435           std::exit(EXIT_FAILURE);
00436         }
00437       }
00438 
00439       // --local-energy-pi
00440       if(variablesMap.count("local-energy-pi")) {
00441         std::string localEnergyPiNorm = localEnergyPiString;
00442         std::transform(localEnergyPiNorm.begin(), localEnergyPiNorm.end(), localEnergyPiNorm.begin(), ::tolower);
00443         if(localEnergyPiNorm=="always") {
00444           localEnergyPiType = AlwaysLocalEnergy;
00445         } else if(localEnergyPiNorm=="first-collision")
00446           localEnergyPiType = FirstCollisionLocalEnergy;
00447         else if(localEnergyPiNorm=="never")
00448           localEnergyPiType = NeverLocalEnergy;
00449         else {
00450           std::cerr << "Unrecognized local-energy-pi type. Must be one of:" << std::endl
00451             << "  always" << std::endl
00452             << "  first-collision" << std::endl
00453             << "  never (default)" << std::endl;
00454           std::cerr << suggestHelpMsg;
00455           std::exit(EXIT_FAILURE);
00456         }
00457       }
00458 
00459       // --de-excitation
00460       if(variablesMap.count("de-excitation")) {
00461         std::string deExcitationNorm = deExcitationString;
00462         std::transform(deExcitationNorm.begin(),
00463             deExcitationNorm.end(),
00464             deExcitationNorm.begin(), ::tolower);
00465         if(deExcitationNorm=="none")
00466           deExcitationType = DeExcitationNone;
00467 #ifdef INCL_DEEXCITATION_ABLAXX
00468         else if(deExcitationNorm=="ablav3p")
00469           deExcitationType = DeExcitationABLAv3p;
00470 #endif
00471 #ifdef INCL_DEEXCITATION_ABLA07
00472         else if(deExcitationNorm=="abla07")
00473           deExcitationType = DeExcitationABLA07;
00474 #endif
00475 #ifdef INCL_DEEXCITATION_SMM
00476         else if(deExcitationNorm=="smm")
00477           deExcitationType = DeExcitationSMM;
00478 #endif
00479 #ifdef INCL_DEEXCITATION_GEMINIXX
00480         else if(deExcitationNorm=="geminixx")
00481           deExcitationType = DeExcitationGEMINIXX;
00482 #endif
00483         else {
00484           std::cerr << "Unrecognized de-excitation model. "
00485             << "Must be one of:" << std::endl
00486             << "  none (default)" << std::endl
00487 #ifdef INCL_DEEXCITATION_ABLAXX
00488             << "  ABLAv3p" << std::endl
00489 #endif
00490 #ifdef INCL_DEEXCITATION_ABLA07
00491             << "  ABLA07" << std::endl
00492 #endif
00493 #ifdef INCL_DEEXCITATION_SMM
00494             << "  SMM" << std::endl
00495 #endif
00496 #ifdef INCL_DEEXCITATION_GEMINIXX
00497             << "  GEMINIXX" << std::endl
00498 #endif
00499             ;
00500           std::cerr << suggestHelpMsg;
00501           std::exit(EXIT_FAILURE);
00502         }
00503       } else {
00504         deExcitationType = DeExcitationNone;
00505       }
00506 
00507       // --cluster-algorithm
00508       if(variablesMap.count("cluster-algorithm")) {
00509         std::string clusterAlgorithmNorm = clusterAlgorithmString;
00510         std::transform(clusterAlgorithmNorm.begin(),
00511             clusterAlgorithmNorm.end(),
00512             clusterAlgorithmNorm.begin(), ::tolower);
00513         if(clusterAlgorithmNorm=="none")
00514           clusterAlgorithmType = NoClusterAlgorithm;
00515         else if(clusterAlgorithmNorm=="intercomparison")
00516           clusterAlgorithmType = IntercomparisonClusterAlgorithm;
00517         else {
00518           std::cerr << "Unrecognized cluster algorithm. "
00519             << "Must be one of:" << std::endl
00520             << "  intercomparison (default)" << std::endl
00521             << "  none" << std::endl;
00522           std::cerr << suggestHelpMsg;
00523           std::exit(EXIT_FAILURE);
00524         }
00525       } else {
00526         clusterAlgorithmType = IntercomparisonClusterAlgorithm;
00527       }
00528 
00529       // --cluster-max-mass
00530       if(variablesMap.count("cluster-max-mass") && clusterMaxMass < 2 && clusterMaxMass > 12) {
00531         std::cerr << "Maximum cluster mass outside the allowed range. Must be between 2 and 12 (included)"
00532           << std::endl
00533           << suggestHelpMsg;
00534           std::exit(EXIT_FAILURE);
00535       }
00536 
00537       // --separation-energies
00538       if(variablesMap.count("separation-energies")) {
00539         std::string separationEnergyNorm = separationEnergyString;
00540         std::transform(separationEnergyNorm.begin(),
00541             separationEnergyNorm.end(),
00542             separationEnergyNorm.begin(), ::tolower);
00543         if(separationEnergyNorm=="incl")
00544           separationEnergyType = INCLSeparationEnergy;
00545         else if(separationEnergyNorm=="real")
00546           separationEnergyType = RealSeparationEnergy;
00547         else if(separationEnergyNorm=="real-light")
00548           separationEnergyType = RealForLightSeparationEnergy;
00549         else {
00550           std::cerr << "Unrecognized separation-energies option. "
00551             << "Must be one of:" << std::endl
00552             << "  INCL (default)" << std::endl
00553             << "  real" << std::endl
00554             << "  real-light" << std::endl;
00555           std::cerr << suggestHelpMsg;
00556           std::exit(EXIT_FAILURE);
00557         }
00558       } else {
00559         separationEnergyType = INCLSeparationEnergy;
00560       }
00561 
00562       // --output: construct a reasonable output file root if not specified
00563       if(!variablesMap.count("output") && isFullRun) {
00564         // If an input file was specified, use its name as the output file root
00565         if(variablesMap.count("input-file"))
00566           outputFileRoot = inputFileName;
00567         else {
00568           std::stringstream outputFileRootStream;
00569           outputFileRootStream.precision(0);
00570           outputFileRootStream.setf(std::ios::fixed, std::ios::floatfield);
00571           outputFileRootStream <<
00572             ParticleTable::getShortName(projectileSpecies) << "_" <<
00573             ParticleTable::getShortName(targetSpecies) << "_" <<
00574             projectileKineticEnergy;
00575 
00576           // Append suffixes to the output file root for each explicitly specified CLI option
00577           typedef boost::program_options::variables_map::const_iterator BPOVMIter;
00578           for(BPOVMIter i=variablesMap.begin(); i!=variablesMap.end(); ++i) {
00579             std::string const &name = i->first;
00580             // Only process CLI options
00581             if(name!="projectile"
00582                 && name!="target"
00583                 && name!="energy"
00584                 && name!="number-shots"
00585                 && name!="random-seed-1"
00586                 && name!="random-seed-2"
00587                 && name!="inclxx-datafile-path"
00588 #ifdef INCL_DEEXCITATION_ABLA07
00589                 && name!="abla07-datafile-path"
00590 #endif
00591 #ifdef INCL_DEEXCITATION_ABLAXX
00592                 && name!="ablav3p-cxx-datafile-path"
00593 #endif
00594 #ifdef INCL_DEEXCITATION_GEMINIXX
00595                 && name!="geminixx-datafile-path"
00596 #endif
00597                 ) {
00598               boost::program_options::variable_value v = i->second;
00599               if(!v.defaulted()) {
00600                 const std::type_info &type = v.value().type();
00601                 if(type==typeid(std::string))
00602                   outputFileRootStream << "_" << name << "=" << v.as<std::string>();
00603                 else if(type==typeid(G4float))
00604                   outputFileRootStream << "_" << name << "=" << v.as<G4float>();
00605                 else if(type==typeid(G4int))
00606                   outputFileRootStream << "_" << name << "=" << v.as<G4int>();
00607                 else if(type==typeid(G4bool))
00608                   outputFileRootStream << "_" << name << "=" << v.as<G4bool>();
00609               }
00610             }
00611           }
00612 
00613           outputFileRoot = outputFileRootStream.str();
00614         }
00615       }
00616 
00617       // -l/--logfile
00618       if(!variablesMap.count("logfile"))
00619         logFileName = outputFileRoot + ".log";
00620 
00621     }
00622     catch(std::exception& e)
00623     {
00624       std::cerr << e.what() << "\n";
00625       std::cerr << suggestHelpMsg;
00626       std::exit(EXIT_FAILURE);
00627     }
00628 
00629   }
00630 #else
00631     Config::Config(G4int /*argc*/, char * /*argv*/ [], G4bool /*isFullRun*/)
00632     {
00633       init();
00634     }
00635 #endif
00636 
00637   Config::~Config()
00638   {}
00639 
00640   void Config::init() {
00641       verbosity = 1;
00642       inputFileName = "";
00643       title = "INCL default run title";
00644       nShots = 1000;
00645       naturalTarget = false;
00646       projectileString = "proton";
00647       projectileSpecies = G4INCL::Proton;
00648       projectileKineticEnergy = 1000.0;
00649       verboseEvent = -1;
00650       randomSeed1 = 666;
00651       randomSeed2 = 777;
00652       pauliString = "strict-statistical";
00653       pauliType = StrictStatisticalPauli;
00654       CDPP = true;
00655       coulombString = "non-relativistic";
00656       coulombType = NonRelativisticCoulomb;
00657       potentialString = "isospin-energy";
00658       potentialType = IsospinEnergyPotential;
00659       pionPotential = true;
00660       localEnergyBBString = "first-collision";
00661       localEnergyBBType = FirstCollisionLocalEnergy;
00662       localEnergyPiString = "first-collision";
00663       localEnergyPiType = FirstCollisionLocalEnergy;
00664       deExcitationString = "none";
00665       deExcitationType = DeExcitationNone;
00666       clusterAlgorithmString = "intercomparison";
00667       clusterAlgorithmType = IntercomparisonClusterAlgorithm;
00668       clusterMaxMass = 8;
00669       backToSpectator = true;
00670       useRealMasses = true;
00671       impactParameter = -1.;
00672       separationEnergyString = "INCL";
00673       separationEnergyType = INCLSeparationEnergy;
00674   }
00675 
00676   std::string Config::summary() {
00677     std::stringstream message;
00678     message << "INCL++ version " << getVersionID() << std::endl;
00679     if(projectileSpecies.theType != Composite)
00680       message << "Projectile: " << ParticleTable::getName(projectileSpecies) << std::endl;
00681     else
00682       message << "Projectile: composite, A=" << projectileSpecies.theA << ", Z=" << projectileSpecies.theZ << std::endl;
00683     message << "  energy = " << projectileKineticEnergy << std::endl;
00684     if(targetSpecies.theA>0)
00685       message << "Target: A = " << targetSpecies.theA << " Z = " << targetSpecies.theZ << std::endl;
00686     else
00687       message << "Target: natural isotopic composition, Z = " << targetSpecies.theZ << std::endl;
00688     message << "Number of requested shots = " << nShots << std::endl;
00689     return message.str();
00690   }
00691 
00692   std::string const Config::echo() const {
00693     std::stringstream ss;
00694     ss << std::boolalpha;
00695     ss << "###########################" << std::endl
00696       << "### Start of input echo ###" << std::endl
00697       << "###########################" << std::endl << std::endl
00698       << " # You may re-use this snippet of the log file as an input file!" << std::endl
00699       << " # Options marked with a * are compulsory." << std::endl
00700       << std::endl
00701       << "# Run options" << std::endl
00702       << "title = " << title << "\t# run title" << std::endl
00703       << "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
00704       << "logfile = " << logFileName << "\t# log file name. Defaults to `<output_root>.log'. Use `-' if you want to redirect logging to stdout" << std::endl
00705       << "number-shots = " << nShots << "\t# * number of shots" << std::endl
00706       << "inclxx-datafile-path = " << INCLXXDataFilePath << std::endl
00707 #ifdef INCL_DEEXCITATION_ABLAXX
00708       << "ablav3p-cxx-datafile-path = " << ablav3pCxxDataFilePath << std::endl
00709 #endif
00710 #ifdef INCL_DEEXCITATION_ABLA07
00711       << "abla07-datafile-path = " << abla07DataFilePath << std::endl
00712 #endif
00713 #ifdef INCL_DEEXCITATION_GEMINIXX
00714       << "geminixx-datafile-path = " << geminixxDataFilePath << std::endl
00715 #endif
00716       << std::endl << "# Projectile and target definitions" << std::endl
00717       << "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
00718       << "         " << "# the target nuclide was parsed as Z=" << targetSpecies.theZ;
00719     if(targetSpecies.theA>0)
00720       ss << ", A=" << targetSpecies.theA;
00721     else
00722       ss << ", natural target";
00723     ss << std::endl
00724       << "projectile = " << projectileString << "\t# * projectile name (proton, neutron, pi+, pi0, pi-, d, t, a, He-4...)" << std::endl
00725       << "         " << "# the projectile nuclide was parsed as Z=" << projectileSpecies.theZ << ", A=" << projectileSpecies.theA << std::endl
00726       << "energy = " << projectileKineticEnergy << "\t# * total kinetic energy of the projectile, in MeV" << std::endl
00727       << std::endl << "# Physics options " << std::endl
00728       << "pauli = " << pauliString << "\t# Pauli-blocking algorithm. Must be one of: strict-statistical (default), strict, statistical, global, none" << std::endl
00729       << "cdpp = " << CDPP << "\t# whether to apply CDPP after collisions" << std::endl
00730       << "coulomb = " << coulombString << "\t# Coulomb-distortion algorithm. Must be one of: non-relativistic (default), none" << std::endl
00731       << "potential = " << potentialString << "\t# nucleon potential. Must be one of: isospin-energy-smooth, isospin-energy (default), isospin, constant" << std::endl
00732       << "pion-potential = " << pionPotential << "\t# whether to use a pion potential" << std::endl
00733       << "local-energy-BB = " << localEnergyBBString << "\t# local energy in baryon-baryon collisions. Must be one of: always, first-collision (default), never" << std::endl
00734       << "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
00735       << "de-excitation = " << deExcitationString << "\t # which de-excitation model to use. Must be one of:"
00736       " none (default)"
00737 #ifdef INCL_DEEXCITATION_ABLAXX
00738       ", ABLAv3p"
00739 #endif
00740 #ifdef INCL_DEEXCITATION_ABLA07
00741       ", ABLA07"
00742 #endif
00743 #ifdef INCL_DEEXCITATION_SMM
00744       ", SMM"
00745 #endif
00746 #ifdef INCL_DEEXCITATION_GEMINIXX
00747       ", GEMINIXX"
00748 #endif
00749       << std::endl
00750       << "cluster-algorithm = " << clusterAlgorithmString << "\t# clustering algorithm for production of composites. Must be one of: intercomparison (default), none" << std::endl
00751       << "cluster-max-mass = " << clusterMaxMass << "\t# maximum mass of produced composites. Must be between 2 and 12 (included)" << std::endl
00752       << "back-to-spectator = " << backToSpectator << "\t# whether to use back-to-spectator" << std::endl
00753       << "use-real-masses = " << useRealMasses << "\t# whether to use real masses for the outgoing particle energies" << std::endl
00754       << "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
00755       << std::endl << "# Technical options " << std::endl
00756       << "verbosity = " << verbosity << "\t# from 0 (quiet) to 10 (most verbose)" << std::endl
00757       << "verbose-event = " << verboseEvent << "\t# request verbose logging for the specified event only" << std::endl
00758       << "random-seed-1 = " << randomSeed1 << "\t# first seed for the random-number generator" << std::endl
00759       << "random-seed-2 = " << randomSeed2 << "\t# second seed for the random-number generator" << std::endl
00760       << std::endl << "#########################" << std::endl
00761       << "### End of input echo ###" << std::endl
00762       << "#########################" << std::endl;
00763 
00764     return ss.str();
00765   }
00766 
00767 }

Generated on Mon May 27 17:48:34 2013 for Geant4 by  doxygen 1.4.7