StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
PartonSystems.cc
1 // PartonSystems.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2018 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL v2 or later, 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
7 // PartonSystem and PartonSystems classes.
8 
9 #include "Pythia8/PartonSystems.h"
10 
11 namespace Pythia8 {
12 
13 //==========================================================================
14 
15 // The PartonSystems class.
16 
17 //--------------------------------------------------------------------------
18 
19 // Replace the index of an incoming or outgoing parton by a new index.
20 
21 void PartonSystems::replace(int iSys, int iPosOld, int iPosNew) {
22 
23  if (systems[iSys].iInA == iPosOld) {
24  systems[iSys].iInA = iPosNew;
25  return;
26  }
27  if (systems[iSys].iInB == iPosOld) {
28  systems[iSys].iInB = iPosNew;
29  return;
30  }
31  for (int i = 0; i < sizeOut(iSys); ++i)
32  if (systems[iSys].iOut[i] == iPosOld) {
33  systems[iSys].iOut[i] = iPosNew;
34  return;
35  }
36 
37 }
38 
39 //--------------------------------------------------------------------------
40 
41 // Return index of any parton in system, list starting with beam remnants.
42 
43 int PartonSystems::getAll(int iSys, int iMem) const {
44 
45  if (hasInAB(iSys)) {
46  if (iMem == 0) return systems[iSys].iInA;
47  if (iMem == 1) return systems[iSys].iInB;
48  return systems[iSys].iOut[iMem - 2];
49  } else return systems[iSys].iOut[iMem];
50 
51 }
52 
53 //--------------------------------------------------------------------------
54 
55 // Find system of given outgoing parton, optionally also incoming one.
56 
57 int PartonSystems::getSystemOf(int iPos, bool alsoIn) const {
58 
59  // Loop over systems and over final-state members in each system.
60  for (int iSys = 0; iSys < sizeSys(); ++iSys) {
61  if (alsoIn) {
62  if (systems[iSys].iInA == iPos) return iSys;
63  if (systems[iSys].iInB == iPos) return iSys;
64  }
65  for (int iMem = 0; iMem < sizeOut(iSys); ++iMem)
66  if (systems[iSys].iOut[iMem] == iPos) return iSys;
67  }
68 
69  // Failure signalled by return value -1.
70  return -1;
71 
72 }
73 
74 //--------------------------------------------------------------------------
75 
76 // Get the iMem index of iOut for an index into the event record
77 
78 int PartonSystems::getIndexOfOut(int iSys, int iPos) const {
79  for (int iMem = 0; iMem < sizeOut(iSys); ++iMem)
80  if (systems[iSys].iOut[iMem] == iPos) return iMem;
81 
82  // Failure signalled by return value -1.
83  return -1;
84 }
85 
86 
87 //--------------------------------------------------------------------------
88 
89 // Print members in systems; for debug mainly.
90 
91 void PartonSystems::list() const {
92 
93  // Header.
94  cout << "\n -------- PYTHIA Parton Systems Listing -------------------"
95  << "--------------------------------- "
96  << "\n \n no inA inB out members \n";
97 
98  // Loop over system list and over members in each system.
99  for (int iSys = 0; iSys < sizeSys(); ++iSys) {
100  cout << " " << setw(3) << iSys << " " << setw(4) << systems[iSys].iInA
101  << " " << setw(4) << systems[iSys].iInB;
102  for (int iMem = 0; iMem < sizeOut(iSys); ++iMem) {
103  if (iMem%16 == 0 && iMem > 0) cout << "\n ";
104  cout << " " << setw(4) << systems[iSys].iOut[iMem];
105  }
106  cout << "\n";
107  }
108 
109  // Alternative if no systems. Done.
110  if (sizeSys() == 0) cout << " no systems defined \n";
111  cout << "\n -------- End PYTHIA Parton Systems Listing ---------------"
112  << "---------------------------------" << endl;
113 
114 }
115 
116 //==========================================================================
117 
118 } // end namespace Pythia8