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) 2014 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  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) << id1pdfSave[0] << ", x = "
57  << setw(10) << x1pdfSave[0] << ", pdf = " << setw(10) << pdf1Save[0]
58  << " at Q2 = " << setw(10) << Q2FacSave[0] << ".\n"
59  << " In 2: id = " << setw(4) << id2pdfSave[0] << ", x = "
60  << setw(10) << x2pdfSave[0] << ", pdf = " << setw(10) << pdf2Save[0]
61  << " at same Q2.\n";
62  bool matchIdX = true;
63  if (id1pdfSave[0] != id1Save[0] || id2pdfSave[0] != id2Save[0])
64  matchIdX = false;
65  if (abs(x1pdfSave[0] - x1Save[0]) > 1e-4 * x1Save[0]) matchIdX = false;
66  if (abs(x2pdfSave[0] - x2Save[0]) > 1e-4 * x2Save[0]) matchIdX = false;
67  if (!matchIdX) os << " Warning: above flavour/x info does not match"
68  << " incoming partons in event!\n";
69  os << "\n";
70  }
71 
72  // Process name and code.
73  os << ((isRes && !hasSubSave[0]) ? " Subprocess " : " Process ") << nameSave
74  << " with code " << codeSave << " is 2 -> " << nFinalSave << ".\n";
75 
76  // Subprocess name and code for nondiffractive processes.
77  if (hasSubSave[0])
78  os << " Subprocess " << nameSubSave[0] << " with code " << codeSubSave[0]
79  << " is 2 -> " << nFinalSubSave[0] << ".\n";
80 
81  // Process-type-specific kinematics information.
82  if ( isRes && nFinalSave == 1)
83  os << " It has sHat = " << setw(10) << sH[0] << ".\n";
84  else if ( isRes && nFinalSave == 2)
85  os << " It has sHat = " << setw(10) << sH[0] << ", tHat = "
86  << setw(10) << tH[0] << ", uHat = " << setw(10) << uH[0] << ",\n"
87  << " pTHat = " << setw(10) << pTH[0] << ", m3Hat = "
88  << setw(10) << m3H[0] << ", m4Hat = " << setw(10) << m4H[0] << ",\n"
89  << " thetaHat = " << setw(10) << thetaH[0] << ", phiHat = "
90  << setw(10) << phiH[0] << ".\n";
91  else if ( nFinalSave == 2)
92  os << " It has s = " << setw(10) << sH[0] << ", t = " << setw(10)
93  << tH[0] << ", u = " << setw(10) << uH[0] << ",\n"
94  << " pT = " << setw(10) << pTH[0] << ", m3 = " << setw(10)
95  << m3H[0] << ", m4 = " << setw(10) << m4H[0] << ",\n"
96  << " theta = " << setw(10) << thetaH[0] << ", phi = " << setw(10)
97  << phiH[0] << ".\n";
98  else if ( isRes && nFinalSave == 3)
99  os << " It has sHat = " << setw(10) << sH[0] << ", <pTHat> = "
100  << setw(10) << pTH[0] << ".\n";
101  else if ( nFinalSave == 3)
102  os << " It has s = " << setw(10) << sH[0] << ", t_A = " << setw(10)
103  << tH[0] << ", t_B = " << setw(10) << uH[0] << ",\n"
104  << " <pT> = " << setw(10) << pTH[0] << ".\n";
105 
106  // Couplings.
107  if (isRes) os << " alphaEM = " << setw(10) << alphaEMSave[0]
108  << ", alphaS = " << setw(10) << alphaSSave[0] << " at Q2 = "
109  << setw(10) << Q2RenSave[0] << ".\n";
110 
111  // Diffractive subsystems.
112  for (int iDS = 1; iDS < 4; ++iDS) if (id1Save[iDS] != 0) {
113  if (iDS == 1) os << "\n Diffractive system on side A: \n";
114  if (iDS == 2) os << "\n Diffractive system on side B: \n";
115  if (iDS == 3) os << "\n Central diffractive system: \n";
116  os << " In 1: id = " << setw(4) << id1pdfSave[iDS] << ", x = "
117  << setw(10) << x1pdfSave[iDS] << ", pdf = " << setw(10)
118  << pdf1Save[iDS] << " at Q2 = " << setw(10) << Q2FacSave[iDS]
119  << ".\n" << " In 2: id = " << setw(4) << id2pdfSave[iDS]
120  << ", x = " << setw(10) << x2pdfSave[iDS] << ", pdf = "
121  << setw(10) << pdf2Save[iDS] << " at same Q2.\n";
122  os << " Subprocess " << nameSubSave[iDS] << " with code "
123  << codeSubSave[iDS] << " is 2 -> " << nFinalSubSave[iDS] << ".\n";
124  if (nFinalSubSave[iDS] == 1)
125  os << " It has sHat = " << setw(10) << sH[iDS] << ".\n";
126  else if (nFinalSubSave[iDS] == 2)
127  os << " It has sHat = " << setw(10) << sH[iDS] << ", tHat = "
128  << setw(10) << tH[iDS] << ", uHat = " << setw(10) << uH[iDS]
129  << ",\n" << " pTHat = " << setw(10) << pTH[iDS]
130  << ", m3Hat = " << setw(10) << m3H[iDS] << ", m4Hat = "
131  << setw(10) << m4H[iDS] << ",\n" << " thetaHat = " << setw(10)
132  << thetaH[iDS] << ", phiHat = " << setw(10) << phiH[iDS] << ".\n";
133  os << " alphaEM = " << setw(10) << alphaEMSave[iDS]
134  << ", alphaS = " << setw(10) << alphaSSave[iDS] << " at Q2 = "
135  << setw(10) << Q2RenSave[iDS] << ".\n";
136  }
137 
138  // Impact parameter.
139  if (bIsSet) os << "\n Impact parameter b = " << setw(10) << bMPISave
140  << " gives enhancement factor = " << setw(10) << enhanceMPISave
141  << ".\n";
142 
143  // Multiparton interactions and shower evolution.
144  if (evolIsSet) os << " Max pT scale for MPI = " << setw(10) << pTmaxMPISave
145  << ", ISR = " << setw(10) << pTmaxISRSave << ", FSR = " << setw(10)
146  << pTmaxISRSave << ".\n Number of MPI = " << setw(5) << nMPISave
147  << ", ISR = " << setw(5) << nISRSave << ", FSRproc = " << setw(5)
148  << nFSRinProcSave << ", FSRreson = " << setw(5) << nFSRinResSave
149  << ".\n";
150 
151  // Listing finished.
152  os << "\n -------- End PYTHIA Info Listing --------------------"
153  << "----------------" << endl;
154 
155 }
156 
157 //--------------------------------------------------------------------------
158 
159 // Event weight and accumulated weight.
160 
161 double Info::weight() const { return (abs(lhaStrategySave) == 4)
162  ? CONVERTMB2PB * weightSave : weightSave;
163 }
164 
165 double Info::weightSum() const {return (abs(lhaStrategySave) == 4)
166  ? CONVERTMB2PB * wtAccSum : wtAccSum;
167 }
168 
169 //--------------------------------------------------------------------------
170 
171 // List of all hard processes switched on.
172 
173 vector<int> Info::codesHard() {
174  vector<int> codesNow;
175  for (map<int, long>::iterator nTryEntry = nTryM.begin();
176  nTryEntry != nTryM.end(); ++nTryEntry)
177  codesNow.push_back( nTryEntry->first );
178  return codesNow;
179 }
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  int times = messages[messageIn];
190  ++messages[messageIn];
191 
192  // Print message the first few times.
193  if (times < TIMESTOPRINT || showAlways) os << " PYTHIA "
194  << messageIn << " " << extraIn << endl;
195 
196 }
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  for ( map<string, int>::iterator messageEntry = messages.begin();
206  messageEntry != messages.end(); ++messageEntry)
207  nTot += messageEntry->second;
208  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  os << "\n *------- PYTHIA Error and Warning Messages Statistics "
220  << "----------------------------------------------------------* \n"
221  << " | "
222  << " | \n"
223  << " | times message "
224  << " | \n"
225  << " | "
226  << " | \n";
227 
228  // Loop over all messages
229  map<string, int>::iterator messageEntry = messages.begin();
230  if (messageEntry == messages.end())
231  os << " | 0 no errors or warnings to report "
232  << " | \n";
233  while (messageEntry != messages.end()) {
234  // Message printout.
235  string temp = messageEntry->first;
236  int len = temp.length();
237  temp.insert( len, max(0, 102 - len), ' ');
238  os << " | " << setw(6) << messageEntry->second << " "
239  << temp << " | \n";
240  ++messageEntry;
241  }
242 
243  // Done.
244  os << " | "
245  << " | \n"
246  << " *------- End PYTHIA Error and Warning Messages Statistics"
247  << " ------------------------------------------------------* "
248  << endl;
249 
250 }
251 
252 //==========================================================================
253 
254 } // end namespace Pythia8