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) 2020 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  if (systems[iSys].iInRes == iPosOld) {
32  systems[iSys].iInRes = iPosNew;
33  }
34  for (int i = 0; i < sizeOut(iSys); ++i)
35  if (systems[iSys].iOut[i] == iPosOld) {
36  systems[iSys].iOut[i] = iPosNew;
37  return;
38  }
39 
40 }
41 
42 //--------------------------------------------------------------------------
43 
44 // Return index of any parton in system, list starting with beam remnants.
45 
46 int PartonSystems::getAll(int iSys, int iMem) const {
47 
48  if (hasInAB(iSys)) {
49  if (iMem == 0) return systems[iSys].iInA;
50  if (iMem == 1) return systems[iSys].iInB;
51  return systems[iSys].iOut[iMem - 2];
52  } else if (hasInRes(iSys)) {
53  if (iMem == 0) return systems[iSys].iInRes;
54  return systems[iSys].iOut[iMem - 1];
55  }
56  return systems[iSys].iOut[iMem];
57 
58 }
59 
60 //--------------------------------------------------------------------------
61 
62 // Find system of given outgoing parton, optionally also incoming one.
63 // If the parton is outgoing in one system and incoming in another (eg a
64 // decaying resonance), the system in which it is incoming will be returned if
65 // alsoIn == true, else the system in which it is outgoing will be returned.
66 
67 int PartonSystems::getSystemOf(int iPos, bool alsoIn) const {
68 
69  // If (alsoIn), first check if this parton appears as incoming in any system.
70  if (alsoIn) {
71  for (int iSys = 0; iSys < sizeSys(); ++iSys) {
72  if (systems[iSys].iInA == iPos) return iSys;
73  if (systems[iSys].iInB == iPos) return iSys;
74  if (systems[iSys].iInRes == iPos) return iSys;
75  }
76  }
77 
78  // Then check if it appears as outgoing in any system.
79  for (int iSys = 0; iSys < sizeSys(); ++iSys) {
80  for (int iMem = 0; iMem < sizeOut(iSys); ++iMem)
81  if (systems[iSys].iOut[iMem] == iPos) return iSys;
82  }
83 
84  // Failure signalled by return value -1.
85  return -1;
86 
87 }
88 
89 //--------------------------------------------------------------------------
90 
91 // Get the iMem index of iOut for an index into the event record
92 
93 int PartonSystems::getIndexOfOut(int iSys, int iPos) const {
94  for (int iMem = 0; iMem < sizeOut(iSys); ++iMem)
95  if (systems[iSys].iOut[iMem] == iPos) return iMem;
96 
97  // Failure signalled by return value -1.
98  return -1;
99 }
100 
101 
102 //--------------------------------------------------------------------------
103 
104 // Print members in systems; for debug mainly.
105 
106 void PartonSystems::list() const {
107 
108  // Header.
109  cout << "\n -------- PYTHIA Parton Systems Listing -------------------"
110  << "--------------------------------- "
111  << "\n \n no inA inB out members \n";
112 
113  // Loop over system list and over members in each system.
114  for (int iSys = 0; iSys < sizeSys(); ++iSys) {
115  cout << " " << setw(3) << iSys << " ";
116  if (hasInAB(iSys)) {
117  cout << setw(4) << systems[iSys].iInA
118  << " " << setw(4) << systems[iSys].iInB;
119  } else if (hasInRes(iSys)) {
120  cout << " (" << setw(4) << systems[iSys].iInRes
121  << ") ";
122  } else cout<< setw(9) <<" "<<endl;
123  for (int iMem = 0; iMem < sizeOut(iSys); ++iMem) {
124  if (iMem%16 == 0 && iMem > 0) cout << "\n ";
125  cout << " " << setw(4) << systems[iSys].iOut[iMem];
126  }
127  cout << "\n";
128  }
129 
130  // Alternative if no systems. Done.
131  if (sizeSys() == 0) cout << " no systems defined \n";
132  cout << "\n -------- End PYTHIA Parton Systems Listing ---------------"
133  << "---------------------------------" << endl;
134 
135 }
136 
137 //==========================================================================
138 
139 } // end namespace Pythia8