LCOV - code coverage report
Current view: top level - PYTHIA8/pythia8210dev/src - Info.cc (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 248 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 26 0.0 %

          Line data    Source code
       1             : // Info.cc is a part of the PYTHIA event generator.
       2             : // Copyright (C) 2015 Torbjorn Sjostrand.
       3             : // PYTHIA is licenced under the GNU GPL version 2, see COPYING for details.
       4             : // Please respect the MCnet Guidelines, see GUIDELINES for details.
       5             : 
       6             : // Function definitions (not found in the header) for the Info class.
       7             : 
       8             : #include "Pythia8/Info.h"
       9             : 
      10             : namespace Pythia8 {
      11             : 
      12             : //==========================================================================
      13             : 
      14             : // Info class.
      15             : // This class contains a mixed bag of information on the event generation
      16             : // activity, especially on the current subprocess properties.
      17             : 
      18             : //--------------------------------------------------------------------------
      19             : 
      20             : // Constants: could be changed here if desired, but normally should not.
      21             : // These are of technical nature, as described for each.
      22             : 
      23             : // Number of times the same error message will be repeated at most.
      24             : const int Info::TIMESTOPRINT = 1;
      25             : 
      26             : // LHA convention with cross section in pb may require conversion from mb.
      27             : const double Info::CONVERTMB2PB = 1e9;
      28             : 
      29             : //--------------------------------------------------------------------------
      30             : 
      31             : // List (almost) all information currently set.
      32             : 
      33             : void Info::list(ostream& os) const {
      34             : 
      35             :   // Header and beam info.
      36           0 :   os << "\n --------  PYTHIA Info Listing  ------------------------"
      37           0 :      << "---------------- \n \n"
      38           0 :      << scientific << setprecision(3)
      39           0 :      << " Beam A: id = " << setw(6) << idASave << ", pz = " << setw(10)
      40           0 :      << pzASave << ", e = " << setw(10) << eASave << ", m = " << setw(10)
      41           0 :      << mASave << ".\n"
      42           0 :      << " Beam B: id = " << setw(6) << idBSave << ", pz = " << setw(10)
      43           0 :      << pzBSave << ", e = " << setw(10) << eBSave << ", m = " << setw(10)
      44           0 :      << mBSave << ".\n\n";
      45             : 
      46             :   // Done if no subprocess has been defined.
      47           0 :   if (codeSave == 0 && nFinalSave == 0) {
      48           0 :     os << " No process has been set; something must have gone wrong! \n"
      49           0 :        << "\n --------  End PYTHIA Info Listing  --------------------"
      50           0 :        << "----------------" << endl;
      51           0 :     return;
      52             :   }
      53             : 
      54             :   // Colliding parton info.
      55           0 :   if (isRes) {
      56           0 :     os << " In 1: id = " << setw(4) << id1pdfSave[0] << ", x = "
      57           0 :        << setw(10) << x1pdfSave[0] << ", pdf = " << setw(10) << pdf1Save[0]
      58           0 :        << " at Q2 = " << setw(10) << Q2FacSave[0] << ".\n"
      59           0 :        << " In 2: id = " << setw(4) << id2pdfSave[0] << ", x = "
      60           0 :        << setw(10) << x2pdfSave[0] << ", pdf = " << setw(10) << pdf2Save[0]
      61           0 :        << " at same Q2.\n";
      62             :     bool matchIdX = true;
      63           0 :     if (id1pdfSave[0] != id1Save[0] || id2pdfSave[0] != id2Save[0])
      64           0 :       matchIdX = false;
      65           0 :     if (abs(x1pdfSave[0] - x1Save[0]) > 1e-4 * x1Save[0]) matchIdX = false;
      66           0 :     if (abs(x2pdfSave[0] - x2Save[0]) > 1e-4 * x2Save[0]) matchIdX = false;
      67           0 :     if (!matchIdX) os << " Warning: above flavour/x info does not match"
      68           0 :        << " incoming partons in event!\n";
      69           0 :     os << "\n";
      70           0 :   }
      71             : 
      72             :   // Process name and code.
      73           0 :   os << ((isRes && !hasSubSave[0]) ? " Subprocess " : " Process ") << nameSave
      74           0 :      << " with code " << codeSave << " is 2 -> " << nFinalSave << ".\n";
      75             : 
      76             :   // Subprocess name and code for nondiffractive processes.
      77           0 :   if (hasSubSave[0])
      78           0 :     os << " Subprocess " << nameSubSave[0] << " with code " << codeSubSave[0]
      79           0 :        << " is 2 -> " << nFinalSubSave[0] << ".\n";
      80             : 
      81             :   // Process-type-specific kinematics information.
      82           0 :   if ( isRes && nFinalSave == 1)
      83           0 :     os << " It has sHat = " << setw(10) << sH[0] << ".\n";
      84           0 :   else if ( isRes && nFinalSave == 2)
      85           0 :     os << " It has sHat = " << setw(10) << sH[0] << ",    tHat = "
      86           0 :        << setw(10) << tH[0] << ",    uHat = " << setw(10) << uH[0] << ",\n"
      87           0 :        << "       pTHat = " << setw(10) << pTH[0] << ",   m3Hat = "
      88           0 :        << setw(10) << m3H[0] << ",   m4Hat = " << setw(10) << m4H[0] << ",\n"
      89           0 :        << "    thetaHat = " << setw(10) << thetaH[0] << ",  phiHat = "
      90           0 :        << setw(10) << phiH[0] << ".\n";
      91           0 :   else if ( nFinalSave == 2)
      92           0 :     os << " It has s = " << setw(10) << sH[0] << ",    t = " << setw(10)
      93           0 :        << tH[0] << ",    u = " << setw(10) << uH[0] << ",\n"
      94           0 :        << "       pT = " << setw(10) << pTH[0] << ",   m3 = " << setw(10)
      95           0 :        << m3H[0] << ",   m4 = " << setw(10) << m4H[0] << ",\n"
      96           0 :        << "    theta = " << setw(10) << thetaH[0] << ",  phi = " << setw(10)
      97           0 :        << phiH[0] << ".\n";
      98           0 :   else if ( isRes && nFinalSave == 3)
      99           0 :     os << " It has sHat = " << setw(10) << sH[0] << ", <pTHat> = "
     100           0 :        << setw(10) << pTH[0] << ".\n";
     101           0 :   else if ( nFinalSave == 3)
     102           0 :     os << " It has s = " << setw(10) << sH[0] << ",  t_A = " << setw(10)
     103           0 :        << tH[0] << ",  t_B = " << setw(10) << uH[0] << ",\n"
     104           0 :        << "     <pT> = " << setw(10) << pTH[0] << ".\n";
     105             : 
     106             :   // Couplings.
     107           0 :   if (isRes) os << "     alphaEM = " << setw(10) << alphaEMSave[0]
     108           0 :     << ",  alphaS = " << setw(10) << alphaSSave[0] << "    at Q2 = "
     109           0 :     << setw(10) << Q2RenSave[0] << ".\n";
     110             : 
     111             :   // Diffractive subsystems.
     112           0 :   for (int iDS = 1; iDS < 4; ++iDS) if (id1Save[iDS] != 0) {
     113           0 :     if (iDS == 1) os << "\n Diffractive system on side A: \n";
     114           0 :     if (iDS == 2) os << "\n Diffractive system on side B: \n";
     115           0 :     if (iDS == 3) os << "\n Central diffractive system: \n";
     116           0 :     os << " In 1: id = " << setw(4) << id1pdfSave[iDS] << ", x = "
     117           0 :        << setw(10) << x1pdfSave[iDS] << ", pdf = " << setw(10)
     118           0 :        << pdf1Save[iDS] << " at Q2 = " << setw(10) << Q2FacSave[iDS]
     119           0 :        << ".\n" << " In 2: id = " << setw(4) << id2pdfSave[iDS]
     120           0 :        << ", x = " << setw(10) << x2pdfSave[iDS] << ", pdf = "
     121           0 :        << setw(10) << pdf2Save[iDS] << " at same Q2.\n";
     122           0 :     os << " Subprocess " << nameSubSave[iDS] << " with code "
     123           0 :        << codeSubSave[iDS] << " is 2 -> " << nFinalSubSave[iDS] << ".\n";
     124           0 :     if (nFinalSubSave[iDS] == 1)
     125           0 :       os << " It has sHat = " << setw(10) << sH[iDS] << ".\n";
     126           0 :     else if (nFinalSubSave[iDS] == 2)
     127           0 :       os << " It has sHat = " << setw(10) << sH[iDS] << ",    tHat = "
     128           0 :          << setw(10) << tH[iDS] << ",    uHat = " << setw(10) << uH[iDS]
     129           0 :          << ",\n" << "       pTHat = " << setw(10) << pTH[iDS]
     130           0 :          << ",   m3Hat = " << setw(10) << m3H[iDS] << ",   m4Hat = "
     131           0 :          << setw(10) << m4H[iDS] << ",\n" << "    thetaHat = " << setw(10)
     132           0 :          << thetaH[iDS] << ",  phiHat = "  << setw(10) << phiH[iDS] << ".\n";
     133           0 :       os << "     alphaEM = " << setw(10) << alphaEMSave[iDS]
     134           0 :       << ",  alphaS = " << setw(10) << alphaSSave[iDS] << "    at Q2 = "
     135           0 :       << setw(10) << Q2RenSave[iDS] << ".\n";
     136           0 :   }
     137             : 
     138             :   // Impact parameter.
     139           0 :   if (bIsSet) os << "\n Impact parameter b = " << setw(10) << bMPISave
     140           0 :     << " gives enhancement factor = " << setw(10) << enhanceMPISave
     141           0 :     << ".\n";
     142             : 
     143             :   // Multiparton interactions and shower evolution.
     144           0 :   if (evolIsSet) os << " Max pT scale for MPI = " << setw(10) << pTmaxMPISave
     145           0 :     << ", ISR = " << setw(10) << pTmaxISRSave << ", FSR = " << setw(10)
     146           0 :     << pTmaxISRSave << ".\n Number of MPI = " << setw(5) << nMPISave
     147           0 :     << ", ISR = " << setw(5) << nISRSave << ", FSRproc = " << setw(5)
     148           0 :     << nFSRinProcSave << ", FSRreson = " << setw(5) << nFSRinResSave
     149           0 :     << ".\n";
     150             : 
     151             :   // Listing finished.
     152           0 :   os << "\n --------  End PYTHIA Info Listing  --------------------"
     153           0 :      << "----------------" << endl;
     154             : 
     155           0 : }
     156             : 
     157             : //--------------------------------------------------------------------------
     158             : 
     159             : // Event weight and accumulated weight.
     160             : 
     161           0 : double Info::weight() const { return (abs(lhaStrategySave) == 4)
     162           0 :   ? CONVERTMB2PB * weightSave : weightSave;
     163             : }
     164             : 
     165           0 : double Info::weightSum() const {return (abs(lhaStrategySave) == 4)
     166           0 :   ? CONVERTMB2PB * wtAccSum : wtAccSum;
     167             : }
     168             : 
     169             : //--------------------------------------------------------------------------
     170             : 
     171             : // List of all hard processes switched on.
     172             : 
     173             : vector<int> Info::codesHard() {
     174           0 :   vector<int> codesNow;
     175           0 :   for (map<int, long>::iterator nTryEntry = nTryM.begin();
     176           0 :     nTryEntry != nTryM.end(); ++nTryEntry)
     177           0 :       codesNow.push_back( nTryEntry->first );
     178             :   return codesNow;
     179           0 : }
     180             : 
     181             : //--------------------------------------------------------------------------
     182             : 
     183             : // Print a message the first few times. Insert in database.
     184             : 
     185             :   void Info::errorMsg(string messageIn, string extraIn, bool showAlways,
     186             :     ostream& os) {
     187             : 
     188             :   // Recover number of times message occured. Also inserts new string.
     189           0 :   int times = messages[messageIn];
     190           0 :   ++messages[messageIn];
     191             : 
     192             :   // Print message the first few times.
     193           0 :   if (times < TIMESTOPRINT || showAlways) os << " PYTHIA "
     194           0 :     << messageIn << " " << extraIn << endl;
     195             : 
     196           0 : }
     197             : 
     198             : //--------------------------------------------------------------------------
     199             : 
     200             : // Provide total number of errors/aborts/warnings experienced to date.
     201             : 
     202             : int Info::errorTotalNumber() {
     203             : 
     204             :   int nTot = 0;
     205           0 :   for ( map<string, int>::iterator messageEntry = messages.begin();
     206           0 :     messageEntry != messages.end(); ++messageEntry)
     207           0 :     nTot += messageEntry->second;
     208           0 :   return nTot;
     209             : 
     210             : }
     211             : 
     212             : //--------------------------------------------------------------------------
     213             : 
     214             : // Print statistics on errors/aborts/warnings.
     215             : 
     216             : void Info::errorStatistics(ostream& os) {
     217             : 
     218             :   // Header.
     219           0 :   os << "\n *-------  PYTHIA Error and Warning Messages Statistics  "
     220           0 :      << "----------------------------------------------------------* \n"
     221           0 :      << " |                                                       "
     222           0 :      << "                                                          | \n"
     223           0 :      << " |  times   message                                      "
     224           0 :      << "                                                          | \n"
     225           0 :      << " |                                                       "
     226           0 :      << "                                                          | \n";
     227             : 
     228             :   // Loop over all messages
     229           0 :   map<string, int>::iterator messageEntry = messages.begin();
     230           0 :   if (messageEntry == messages.end())
     231           0 :     os << " |      0   no errors or warnings to report              "
     232           0 :        << "                                                          | \n";
     233           0 :   while (messageEntry != messages.end()) {
     234             :     // Message printout.
     235           0 :     string temp = messageEntry->first;
     236           0 :     int len = temp.length();
     237           0 :     temp.insert( len, max(0, 102 - len), ' ');
     238           0 :     os << " | " << setw(6) << messageEntry->second << "   "
     239           0 :        << temp << " | \n";
     240           0 :     ++messageEntry;
     241           0 :   }
     242             : 
     243             :   // Done.
     244           0 :   os << " |                                                       "
     245           0 :      << "                                                          | \n"
     246           0 :      << " *-------  End PYTHIA Error and Warning Messages Statistics"
     247           0 :      << "  ------------------------------------------------------* "
     248           0 :      << endl;
     249             : 
     250           0 : }
     251             : 
     252             : //--------------------------------------------------------------------------
     253             : 
     254             : // Return a list of all header key names
     255             : 
     256             : vector < string > Info::headerKeys() {
     257           0 :   vector < string > keys;
     258           0 :   for (map < string, string >::iterator it = headers.begin();
     259           0 :       it != headers.end(); it++)
     260           0 :     keys.push_back(it->first);
     261             :   return keys;
     262           0 : }
     263             : 
     264             : //--------------------------------------------------------------------------
     265             : 
     266             : // Set the LHEF3 objects read from the init and header blocks.
     267             : 
     268           0 : void Info::setLHEF3InitInfo() { initrwgt = 0;}
     269             : 
     270             : void Info::setLHEF3InitInfo( int LHEFversionIn, LHAinitrwgt *initrwgtIn,
     271             :   vector<LHAgenerator> *generatorsIn,
     272             :   map<string,LHAweightgroup> *weightgroupsIn,
     273             :   map<string,LHAweight> *init_weightsIn ) {
     274           0 :   LHEFversionSave = LHEFversionIn;
     275           0 :   initrwgt        = initrwgtIn;
     276           0 :   generators      = generatorsIn;
     277           0 :   weightgroups    = weightgroupsIn;
     278           0 :   init_weights    = init_weightsIn;
     279           0 : }
     280             : 
     281             : //--------------------------------------------------------------------------
     282             : 
     283             : // Set the LHEF3 objects read from the event block.
     284             : 
     285           0 : void Info::setLHEF3EventInfo() { scales = 0; weights = 0; rwgt = 0;}
     286             : 
     287             : void Info::setLHEF3EventInfo( map<string, string> *eventAttributesIn,
     288             :     map<string,double> *weights_detailedIn,
     289             :     vector<double> *weights_compressedIn,
     290             :     LHAscales *scalesIn, LHAweights *weightsIn,
     291             :     LHArwgt *rwgtIn ) {
     292           0 :     eventAttributes    = eventAttributesIn;
     293           0 :     weights_detailed   = weights_detailedIn;
     294           0 :     weights_compressed = weights_compressedIn;
     295           0 :     scales             = scalesIn;
     296           0 :     weights            = weightsIn;
     297           0 :     rwgt               = rwgtIn;
     298           0 :   }
     299             : 
     300             : //--------------------------------------------------------------------------
     301             : 
     302             : // Retrieve events tag information.
     303             : 
     304             : string Info::getEventAttribute(string key, bool doRemoveWhitespace) {
     305           0 :   if (!eventAttributes) return "";
     306           0 :   if ( eventAttributes->find(key) != eventAttributes->end() ) {
     307           0 :     string res = (*eventAttributes)[key];
     308           0 :     if (doRemoveWhitespace)
     309           0 :       res.erase (remove (res.begin(), res.end(), ' '), res.end());
     310             :     return res;
     311           0 :   }
     312           0 :   return "";
     313           0 : }
     314             : 
     315             : //--------------------------------------------------------------------------
     316             : 
     317             : // Retrieve LHEF version.
     318             : 
     319           0 : int Info::LHEFversion() { return LHEFversionSave;}
     320             : 
     321             : //--------------------------------------------------------------------------
     322             : 
     323             : // Retrieve initrwgt tag information.
     324             : 
     325             : unsigned int Info::getInitrwgtSize() {
     326           0 :   if (!initrwgt) return 0;
     327           0 :   return initrwgt->weights.size();
     328           0 : }
     329             : 
     330             : //--------------------------------------------------------------------------
     331             : 
     332             : // Retrieve generator tag information.
     333             : 
     334             : unsigned int Info::getGeneratorSize() {
     335           0 :   if (!generators) return 0;
     336           0 :   return generators->size();
     337           0 : }
     338             : 
     339             : string Info::getGeneratorValue(unsigned int n) {
     340           0 :   if (!generators || generators->size() < n+1) return "";
     341           0 :   return (*generators)[n].contents;
     342           0 : }
     343             : 
     344             : string Info::getGeneratorAttribute( unsigned int n, string key,
     345             :   bool doRemoveWhitespace) {
     346           0 :   if (!generators || generators->size() < n+1) return "";
     347           0 :   string res("");
     348           0 :   if ( key == "name") {
     349           0 :     res = (*generators)[n].name;
     350           0 :   } else if ( key == "version") {
     351           0 :     res = (*generators)[n].version;
     352           0 :   } else if ( (*generators)[n].attributes.find(key)
     353           0 :            != (*generators)[n].attributes.end() ) {
     354           0 :     res = (*generators)[n].attributes[key];
     355             :   }
     356           0 :   if (doRemoveWhitespace && res != "")
     357           0 :     res.erase (remove (res.begin(), res.end(), ' '), res.end());
     358           0 :   return res;
     359           0 : }
     360             : 
     361             : //--------------------------------------------------------------------------
     362             : 
     363             : // Retrieve rwgt tag information.
     364             : 
     365             : unsigned int Info::getWeightsDetailedSize() {
     366           0 :   if (!weights_detailed) return 0;
     367           0 :   return weights_detailed->size();
     368           0 : }
     369             : 
     370             : double Info::getWeightsDetailedValue(string n) {
     371           0 :   if (weights_detailed->empty()
     372           0 :     || weights_detailed->find(n) == weights_detailed->end()) return 0./0.;
     373           0 :   return (*weights_detailed)[n];
     374           0 : }
     375             : 
     376             : string Info::getWeightsDetailedAttribute(string n, string key,
     377             :   bool doRemoveWhitespace) {
     378           0 :   if (!rwgt || rwgt->wgts.find(n) == rwgt->wgts.end())
     379           0 :     return "";
     380           0 :   string res("");
     381           0 :   if ( key == "id") {
     382           0 :     res = rwgt->wgts[n].id;
     383           0 :   } else if ( rwgt->wgts[n].attributes.find(key)
     384           0 :            != rwgt->wgts[n].attributes.end() ) {
     385           0 :     res = rwgt->wgts[n].attributes[key];
     386             :   }
     387           0 :   if (doRemoveWhitespace && res != "")
     388           0 :     res.erase (remove (res.begin(), res.end(), ' '), res.end());
     389           0 :   return res;
     390           0 : }
     391             : 
     392             : //--------------------------------------------------------------------------
     393             : 
     394             : // Retrieve weights tag information.
     395             : 
     396             : unsigned int Info::getWeightsCompressedSize() {
     397           0 :   if (!weights_compressed) return 0;
     398           0 :   return weights_compressed->size();
     399           0 : }
     400             : 
     401             : double Info::getWeightsCompressedValue(unsigned int n) {
     402           0 :   if (weights_compressed->empty()
     403           0 :     || weights_compressed->size() < n+1) return 0./0.;
     404           0 :   return (*weights_compressed)[n];
     405           0 : }
     406             : 
     407             : string Info::getWeightsCompressedAttribute(string key,
     408             :   bool doRemoveWhitespace) {
     409           0 :   if (!weights || weights->attributes.find(key) == weights->attributes.end())
     410           0 :     return "";
     411           0 :   string res("");
     412           0 :   if ( weights->attributes.find(key)
     413           0 :            != weights->attributes.end() ) {
     414           0 :     res = weights->attributes[key];
     415             :   }
     416           0 :   if (doRemoveWhitespace && res != "")
     417           0 :     res.erase (remove (res.begin(), res.end(), ' '), res.end());
     418           0 :   return res;
     419           0 : }
     420             : 
     421             : //--------------------------------------------------------------------------
     422             : 
     423             : // Retrieve scales tag information.
     424             : 
     425             : string Info::getScalesValue(bool doRemoveWhitespace) {
     426           0 :   if (!scales) return "";
     427           0 :   string res = scales->contents;
     428           0 :   if (doRemoveWhitespace && res != "")
     429           0 :     res.erase (remove (res.begin(), res.end(), ' '), res.end());
     430           0 :   return res;
     431           0 : }
     432             : 
     433             : double Info::getScalesAttribute(string key) {
     434           0 :   if (!scales) return 0./0.;
     435             :   double res = 0./0.;
     436           0 :   if ( key == "muf") {
     437           0 :     res = scales->muf;
     438           0 :   } else if ( key == "mur") {
     439           0 :     res = scales->mur;
     440           0 :   } else if ( key == "mups") {
     441           0 :     res = scales->mups;
     442           0 :   } else if ( key == "SCALUP") {
     443           0 :     res = scales->SCALUP;
     444           0 :   } else if ( scales->attributes.find(key)
     445           0 :            != scales->attributes.end() ) {
     446           0 :     res = scales->attributes[key];
     447           0 :   }
     448             :   return res;
     449           0 : }
     450             : 
     451             : //==========================================================================
     452             : 
     453             : } // end namespace Pythia8

Generated by: LCOV version 1.11