StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Info.cc
1 // Info.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2012 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 "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  os << "\n -------- PYTHIA Info Listing ------------------------"
37  << "---------------- \n \n"
38  << scientific << setprecision(3)
39  << " Beam A: id = " << setw(6) << idASave << ", pz = " << setw(10)
40  << pzASave << ", e = " << setw(10) << eASave << ", m = " << setw(10)
41  << mASave << ".\n"
42  << " Beam B: id = " << setw(6) << idBSave << ", pz = " << setw(10)
43  << pzBSave << ", e = " << setw(10) << eBSave << ", m = " << setw(10)
44  << mBSave << ".\n\n";
45 
46  // Done if no subprocess has been defined.
47  if (codeSave == 0 && nFinalSave == 0) {
48  os << " No process has been set; something must have gone wrong! \n"
49  << "\n -------- End PYTHIA Info Listing --------------------"
50  << "----------------" << endl;
51  return;
52  }
53 
54  // Colliding parton info.
55  if (isRes)
56  os << " In 1: id = " << setw(4) << id1Save << ", x = " << setw(10)
57  << x1Save << ", pdf = " << setw(10) << pdf1Save << " at Q2 = "
58  << setw(10) << Q2FacSave << ".\n"
59  << " In 2: id = " << setw(4) << id2Save << ", x = " << setw(10)
60  << x2Save << ", pdf = " << setw(10) << pdf2Save << " at same Q2.\n\n";
61 
62  // Process name and code.
63  os << ((isRes && !hasSubSave) ? " Subprocess " : " Process ") << nameSave
64  << " with code " << codeSave << " is 2 -> " << nFinalSave << ".\n";
65 
66  // Subprocess name and code for minimum bias processes.
67  if (hasSubSave)
68  os << " Subprocess " << nameSubSave << " with code " << codeSubSave
69  << " is 2 -> " << nFinalSubSave << ".\n";
70 
71  // Process-type-specific kinematics information.
72  if (isRes && nFinalSave == 1)
73  os << " It has sHat = " << setw(10) << sH << ".\n";
74  else if ( isRes && nFinalSave == 2)
75  os << " It has sHat = " << setw(10) << sH << ", tHat = "
76  << setw(10) << tH << ", uHat = " << setw(10) << uH << ",\n"
77  << " pTHat = " << setw(10) << pTH << ", m3Hat = "
78  << setw(10) << m3H << ", m4Hat = " << setw(10) << m4H << ",\n"
79  << " thetaHat = " << setw(10) << thetaH << ", phiHat = "
80  << setw(10) << phiH << ".\n";
81  else if ( nFinalSave == 2)
82  os << " It has s = " << setw(10) << sH << ", t = " << setw(10)
83  << tH << ", u = " << setw(10) << uH << ",\n"
84  << " pT = " << setw(10) << pTH << ", m3 = " << setw(10)
85  << m3H << ", m4 = " << setw(10) << m4H << ",\n"
86  << " theta = " << setw(10) << thetaH << ", phi = " << setw(10)
87  << phiH << ".\n";
88  else if ( isRes && nFinalSave == 3)
89  os << " It has sHat = " << setw(10) << sH << ", <pTHat> = "
90  << setw(10) << pTH << ".\n";
91 
92  // Couplings.
93  if (isRes) os << " alphaEM = " << setw(10) << alphaEMSave
94  << ", alphaS = " << setw(10) << alphaSSave << " at Q2 = "
95  << setw(10) << Q2RenSave << ".\n";
96 
97  // Impact parameter.
98  if (bIsSet) os << "\n Impact parameter b = " << setw(10) << bMPISave
99  << " gives enhancement factor = " << setw(10) << enhanceMPISave
100  << ".\n";
101 
102  // Multiparton interactions and shower evolution.
103  if (evolIsSet) os << " Max pT scale for MPI = " << setw(10) << pTmaxMPISave
104  << ", ISR = " << setw(10) << pTmaxISRSave << ", FSR = " << setw(10)
105  << pTmaxISRSave << ".\n Number of MPI = " << setw(5) << nMPISave
106  << ", ISR = " << setw(5) << nISRSave << ", FSRproc = " << setw(5)
107  << nFSRinProcSave << ", FSRreson = " << setw(5) << nFSRinResSave
108  << ".\n";
109 
110  // Listing finished.
111  os << "\n -------- End PYTHIA Info Listing --------------------"
112  << "----------------" << endl;
113 
114 }
115 
116 //--------------------------------------------------------------------------
117 
118 // Event weight and accumulated weight.
119 
120 double Info::weight() const { return (abs(lhaStrategySave) == 4)
121  ? CONVERTMB2PB * weightSave : weightSave;
122 }
123 
124 double Info::weightSum() const {return (abs(lhaStrategySave) == 4)
125  ? CONVERTMB2PB * wtAccSum : wtAccSum;
126 }
127 
128 //--------------------------------------------------------------------------
129 
130 // Print a message the first few times. Insert in database.
131 
132  void Info::errorMsg(string messageIn, string extraIn, bool showAlways,
133  ostream& os) {
134 
135  // Recover number of times message occured. Also inserts new string.
136  int times = messages[messageIn];
137  ++messages[messageIn];
138 
139  // Print message the first few times.
140  if (times < TIMESTOPRINT || showAlways) os << " PYTHIA "
141  << messageIn << " " << extraIn << endl;
142 
143 }
144 
145 //--------------------------------------------------------------------------
146 
147 // Provide total number of errors/aborts/warnings experienced to date.
148 
149 int Info::errorTotalNumber() {
150 
151  int nTot = 0;
152  for ( map<string, int>::iterator messageEntry = messages.begin();
153  messageEntry != messages.end(); ++messageEntry)
154  nTot += messageEntry->second;
155  return nTot;
156 
157 }
158 
159 //--------------------------------------------------------------------------
160 
161 // Print statistics on errors/aborts/warnings.
162 
163 void Info::errorStatistics(ostream& os) {
164 
165  // Header.
166  os << "\n *------- PYTHIA Error and Warning Messages Statistics "
167  << "----------------------------------------------------------* \n"
168  << " | "
169  << " | \n"
170  << " | times message "
171  << " | \n"
172  << " | "
173  << " | \n";
174 
175  // Loop over all messages
176  map<string, int>::iterator messageEntry = messages.begin();
177  if (messageEntry == messages.end())
178  os << " | 0 no errors or warnings to report "
179  << " | \n";
180  while (messageEntry != messages.end()) {
181  // Message printout.
182  string temp = messageEntry->first;
183  int len = temp.length();
184  temp.insert( len, max(0, 102 - len), ' ');
185  os << " | " << setw(6) << messageEntry->second << " "
186  << temp << " | \n";
187  ++messageEntry;
188  }
189 
190  // Done.
191  os << " | "
192  << " | \n"
193  << " *------- End PYTHIA Error and Warning Messages Statistics"
194  << " ------------------------------------------------------* "
195  << endl;
196 
197 }
198 
199 //==========================================================================
200 
201 } // end namespace Pythia8
202