StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DireBasics.cc
1 // DireBasics.cc is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 Stefan Prestel, 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 Dire basics.
7 
8 #include "Pythia8/DireBasics.h"
9 
10 namespace Pythia8 {
11 
12 bool checkSIJ(const Event& e, double minSIJ) {
13  double sijmin=1e10;
14  for (int i=0; i < e.size(); ++i) {
15  if (!e[i].isFinal() && e[i].mother1() !=1 && e[i].mother1() !=2) continue;
16  for (int j=0; j < e.size(); ++j) {
17  if (i==j) continue;
18  if (!e[j].isFinal() && e[j].mother1() !=1 && e[j].mother1() !=2)
19  continue;
20  sijmin=min(sijmin,abs(2.*e[i].p()*e[j].p()));
21  }
22  }
23  return (sijmin>minSIJ);
24 }
25 
26 //--------------------------------------------------------------------------
27 
28 void printSI(const Event& e) {
29  for (int i=0; i < e.size(); ++i) {
30  if (!e[i].isFinal() && e[i].mother1() !=1 && e[i].mother1() !=2) continue;
31  cout << " [" << e[i].isFinal()
32  << " s("<< i << ")="
33  << e[i].p().m2Calc() << "],\n";
34  }
35 }
36 
37 //--------------------------------------------------------------------------
38 
39 void printSIJ(const Event& e) {
40  for (int i=0; i < e.size(); ++i) {
41  if (!e[i].isFinal() && e[i].mother1() !=1 && e[i].mother1() !=2) continue;
42  for (int j=0; j < e.size(); ++j) {
43  if (i==j) continue;
44  if (!e[j].isFinal() && e[j].mother1() !=1 && e[j].mother1() !=2)
45  continue;
46  cout << " [" << e[i].isFinal() << e[j].isFinal()
47  << " s("<< i << "," << j << ")="
48  << 2.*e[i].p()*e[j].p() << "],\n";
49  }
50  }
51 }
52 
53 //--------------------------------------------------------------------------
54 
55 // Function to hash string into long integer.
56 
57 ulong shash(const std::string& str) {
58  ulong hash = 5381;
59  for (size_t i = 0; i < str.size(); ++i)
60  hash = 33 * hash + (unsigned char)str[i];
61  return hash;
62 }
63 
64 //--------------------------------------------------------------------------
65 
66 // Helper function to calculate dilogarithm.
67 
68 double polev(double x,double* coef,int N ) {
69  double ans;
70  int i;
71  double *p;
72 
73  p = coef;
74  ans = *p++;
75  i = N;
76 
77  do
78  ans = ans * x + *p++;
79  while( --i );
80 
81  return ans;
82 }
83 
84 //--------------------------------------------------------------------------
85 
86 // Function to calculate dilogarithm.
87 
88 double dilog(double x) {
89 
90  static double cof_A[8] = {
91  4.65128586073990045278E-5,
92  7.31589045238094711071E-3,
93  1.33847639578309018650E-1,
94  8.79691311754530315341E-1,
95  2.71149851196553469920E0,
96  4.25697156008121755724E0,
97  3.29771340985225106936E0,
98  1.00000000000000000126E0,
99  };
100  static double cof_B[8] = {
101  6.90990488912553276999E-4,
102  2.54043763932544379113E-2,
103  2.82974860602568089943E-1,
104  1.41172597751831069617E0,
105  3.63800533345137075418E0,
106  5.03278880143316990390E0,
107  3.54771340985225096217E0,
108  9.99999999999999998740E-1,
109  };
110 
111  if( x >1. ) {
112  return -dilog(1./x)+M_PI*M_PI/3.-0.5*pow2(log(x));
113  }
114 
115  x = 1.-x;
116  double w, y, z;
117  int flag;
118  if( x == 1.0 )
119  return( 0.0 );
120  if( x == 0.0 )
121  return( M_PI*M_PI/6.0 );
122 
123  flag = 0;
124 
125  if( x > 2.0 ) {
126  x = 1.0/x;
127  flag |= 2;
128  }
129 
130  if( x > 1.5 ) {
131  w = (1.0/x) - 1.0;
132  flag |= 2;
133  }
134 
135  else if( x < 0.5 ) {
136  w = -x;
137  flag |= 1;
138  }
139 
140  else
141  w = x - 1.0;
142 
143  y = -w * polev( w, cof_A, 7) / polev( w, cof_B, 7 );
144 
145  if( flag & 1 )
146  y = (M_PI * M_PI)/6.0 - log(x) * log(1.0-x) - y;
147 
148  if( flag & 2 ) {
149  z = log(x);
150  y = -0.5 * z * z - y;
151  }
152 
153  return y;
154 
155 }
156 
157 double lABC(double a, double b, double c) { return pow2(a-b-c) - 4.*b*c;}
158 double bABC(double a, double b, double c) {
159  double ret = 0.;
160  if ((a-b-c) > 0.) ret = sqrt(lABC(a,b,c));
161  else if ((a-b-c) < 0.) ret =-sqrt(lABC(a,b,c));
162  else ret = 0.;
163  return ret; }
164 double gABC(double a, double b, double c) { return 0.5*(a-b-c+bABC(a,b,c));}
165 
166 //==========================================================================
167 
168 } // end namespace Pythia8
Definition: AgUStep.h:26