StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HadronScatter.h
1 // HadronScatter.h 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 #ifndef Pythia8_HadronScatter_H
7 #define Pythia8_HadronScatter_H
8 
9 #include "Pythia8/Event.h"
10 #include "Pythia8/Info.h"
11 #include "Pythia8/ParticleData.h"
12 #include "Pythia8/PythiaStdlib.h"
13 #include "Pythia8/PythiaComplex.h"
14 
15 namespace Pythia8 {
16 
17 //==========================================================================
18 
19 class SigmaPartialWave {
20 public:
21  // Initialisation
22  bool init(int, string, string, Info *, ParticleData *, Rndm *);
23 
24  // Read data file
25  bool readFile(string, string);
26 
27  // Set the subprocess/incoming particles
28  bool setSubprocess(int);
29  bool setSubprocess(int, int);
30 
31  // Return sigma total/elastic, dSigma/dCos(theta)
32  double sigmaEl(double Wcm) { return sigma(0, Wcm); }
33  double sigmaTot(double Wcm) { return sigma(1, Wcm); }
34  double dSigma(double Wcm, double cTheta) { return sigma(2, Wcm, cTheta); }
35 
36  // Return a cos(theta) value
37  double pickCosTheta(double);
38 
39  // Return maximum sigma elastic
40  double getSigmaElMax() { return sigElMax; }
41 
42 private:
43 
44  // Pointers
45  Info *infoPtr;
46  ParticleData *particleDataPtr;
47  Rndm *rndmPtr;
48 
49  // Constants
50  static const int LSHIFT, ISHIFT, SUBBIN, ITER;
51  static const double CONVERT2MB, WCMBIN, CTBIN, MASSSAFETY, GRIDSAFETY;
52  static const complex BINEND;
53 
54  // Settings
55  int process, subprocess, subprocessMax, norm;
56 
57  // Current incoming and maximum L/I values
58  int idA, idB, Lmax, Imax;
59 
60  // Masses of incoming, last bin, maximum sigma elastic
61  double mA, mB, binMax, sigElMax;
62 
63  // Map subprocess to incoming and vice versa:
64  // sp2in[subprocess] = idA, idB
65  // in2sp[idA, idB] = subprocess
66  map < int, pair < int, int > > sp2in;
67  map < pair < int, int >, int > in2sp;
68 
69  // Isospin coefficients isoCoeff[subprocess][2I]
70  map < int, map < int, double > > isoCoeff;
71 
72  // Storage for partial wave data:
73  // pwData[L * LSHIFT + 2I * ISHIFT + 2J][eNow] = T
74  map < int, map < double, complex > > pwData;
75 
76  // Values of Pl and Pl' as computed by legendreP
77  vector < double > PlVec, PlpVec;
78 
79  // Integration grid [subprocess][WcmBin][cosThetaBin]
80  vector < vector < vector < double > > > gridMax;
81  vector < vector < double > > gridNorm;
82 
83  // Setup subprocesses (including isospin coefficients)
84  void setupSubprocesses();
85 
86  // Setup grids for integration
87  void setupGrid();
88 
89  // Routine for calculating sigma total/elastic and dSigma/dCos(theta)
90  double sigma(int, double, double = 0.);
91 
92  // Generate Legendre polynomials (and optionally derivatives)
93  void legendreP(double, bool = false);
94 
95 };
96 
97 //==========================================================================
98 
99 // HadronScatterPair class
100 // Simple class to hold details of a pair of hadrons which will scatter.
101 // Stores indices in event record and the measure used for ordering
102 
103 // Store a pair of indices
104 typedef pair < int, int > HSIndex;
105 
106 class HadronScatterPair {
107 public:
108  // Constructors.
109  HadronScatterPair() {}
110  HadronScatterPair(const HSIndex &i1in, int yt1in, int pt1in,
111  const HSIndex &i2in, int yt2in, int pt2in,
112  double measureIn) :
113  i1(i1in), yt1(yt1in), pt1(pt1in),
114  i2(i2in), yt2(yt2in), pt2(pt2in),
115  measure(measureIn) {}
116 
117  // Operator for sorting according to ordering measure
118  bool operator<(const HadronScatterPair& in) const {
119  return this->measure < in.measure;
120  }
121 
122  // Indices into event record of hadrons to scatter
123  HSIndex i1;
124  int yt1, pt1;
125  HSIndex i2;
126  int yt2, pt2;
127  // Ordering measure
128  double measure;
129 };
130 
131 
132 //==========================================================================
133 
134 // HadronScatter class
135 
136 class HadronScatter {
137 
138 public:
139 
140  // Constructor.
141  HadronScatter() {}
142 
143  // Initialisation
144  bool init(Info* infoPtrIn, Settings& settings, Rndm* rndmPtrIn,
145  ParticleData *particleDataPtr);
146 
147  // Perform all hadron scatterings - new version. Collective flow.
148  void scatter(Event&);
149 
150  // Perform all hadron scatterings - old version.
151  void scatterOld(Event&);
152 
153 private:
154 
155  // Pointer to various information on the generation.
156  Info* infoPtr;
157  Rndm* rndmPtr;
158 
159  // Settings for new model.
160  bool scatSameString, scatMultTimes;
161  int scatterMode;
162  double p2max, yDiffMax, Rmax, maxProbDS, neighNear, neighFar,
163  minProbSS, maxProbSS;
164 
165  // Settings for old model.
166  bool doOldScatter, afterDecay, allowDecayProd,
167  scatterRepeat, doTile;
168  int hadronSelect, scatterProb;
169  double Npar, kPar, pPar, jPar, rMax, rMax2;
170  double pTsigma, pTsigma2, pT0MPI;
171 
172  // Methods for the old model.
173  // Tiling.
174  int ytMax, ptMax;
175  double yMin, yMax, ytSize, ptSize;
176  vector < vector < set < HSIndex > > > tile;
177 
178  // Keep track of scattered pairs.
179  set < HSIndex > scattered;
180 
181  // Partial wave amplitudes.
182  SigmaPartialWave sigmaPW[3];
183 
184  // Maximum sigma elastic.
185  double sigElMax;
186 
187  // Decide if a hadron can scatter.
188  bool canScatter(Event &, int);
189 
190  // Probability for a pair of hadrons to scatter.
191  bool doesScatter(Event &, const HSIndex &, const HSIndex &);
192 
193  // Calculate measure for ordering of scatterings.
194  double measure(Event &, int, int);
195 
196  // Perform a single hadron scattering
197  bool hadronScatter(Event &, HadronScatterPair &);
198 
199  // Tiling functions.
200  bool tileIntProb(vector < HadronScatterPair > &, Event &,
201  const HSIndex &, int, int, bool);
202  int yTile(Event& event, int idx) {
203  return (doTile) ? int((event[idx].y() - yMin) / ytSize) : 0;
204  }
205  int pTile(Event& event, int idx) {
206  return (doTile) ? int((event[idx].phi() + M_PI) / ptSize) : 0;
207  }
208 
209  // Methods for the new model.
210  // Functions for presorting the hadrons according to rapidity.
211  void mergeSortCollFlow(vector< pair<int,double> >& sort,
212  int iStart = 1, int iEnd = -1);
213  void mergeCollFlow(vector< pair<int,double> >& sort, int iStart,
214  int iDivide, int iEnd);
215 
216  // Debug
217  void debugOutput();
218 };
219 
220 //==========================================================================
221 
222 
223 } // end namespace Pythia8
224 
225 #endif // Pythia8_HadronScatter_H
Definition: AgUStep.h:26