8 #include "Pythia8/BoseEinstein.h"
22 const int BoseEinstein::IDHADRON[9] = { 211, -211, 111, 321, -321,
24 const int BoseEinstein::ITABLE[9] = { 0, 0, 0, 1, 1, 1, 1, 2, 3 };
27 const double BoseEinstein::STEPSIZE = 0.05;
30 const double BoseEinstein::Q2MIN = 1e-8;
34 const double BoseEinstein::COMPRELERR = 1e-10;
35 const double BoseEinstein::COMPFACMAX = 1000.;
36 const int BoseEinstein::NCOMPSTEP = 10;
42 bool BoseEinstein::init(Info* infoPtrIn, Settings& settings,
43 ParticleData& particleData) {
49 doPion = settings.flag(
"BoseEinstein:Pion");
50 doKaon = settings.flag(
"BoseEinstein:Kaon");
51 doEta = settings.flag(
"BoseEinstein:Eta");
54 lambda = settings.parm(
"BoseEinstein:lambda");
55 QRef = settings.parm(
"BoseEinstein:QRef");
60 R2Ref = 1. / (QRef * QRef);
61 R2Ref2 = 1. / (QRef2 * QRef2);
62 R2Ref3 = 1. / (QRef3 * QRef3);
65 for (
int iSpecies = 0; iSpecies < 9; ++iSpecies)
66 mHadron[iSpecies] = particleData.m0( IDHADRON[iSpecies] );
69 mPair[0] = 2. * mHadron[0];
70 mPair[1] = 2. * mHadron[3];
71 mPair[2] = 2. * mHadron[7];
72 mPair[3] = 2. * mHadron[8];
75 double Qnow, Q2now, centerCorr;
76 for (
int iTab = 0; iTab < 4; ++iTab) {
77 m2Pair[iTab] = mPair[iTab] * mPair[iTab];
80 deltaQ[iTab] = STEPSIZE * min(mPair[iTab], QRef);
81 nStep[iTab] = min( 199, 1 +
int(3. * QRef / deltaQ[iTab]) );
82 maxQ[iTab] = (nStep[iTab] - 0.1) * deltaQ[iTab];
83 centerCorr = deltaQ[iTab] * deltaQ[iTab] / 12.;
87 for (
int i = 1; i <= nStep[iTab]; ++i) {
88 Qnow = deltaQ[iTab] * (i - 0.5);
90 shift[iTab][i] = shift[iTab][i - 1] + exp(-Q2now * R2Ref)
91 * deltaQ[iTab] * (Q2now + centerCorr) / sqrt(Q2now + m2Pair[iTab]);
95 deltaQ3[iTab] = STEPSIZE * min(mPair[iTab], QRef3);
96 nStep3[iTab] = min( 199, 1 +
int(9. * QRef / deltaQ3[iTab]) );
97 maxQ3[iTab] = (nStep3[iTab] - 0.1) * deltaQ3[iTab];
98 centerCorr = deltaQ3[iTab] * deltaQ3[iTab] / 12.;
101 shift3[iTab][0] = 0.;
102 for (
int i = 1; i <= nStep3[iTab]; ++i) {
103 Qnow = deltaQ3[iTab] * (i - 0.5);
105 shift3[iTab][i] = shift3[iTab][i - 1] + exp(-Q2now * R2Ref3)
106 * deltaQ3[iTab] * (Q2now + centerCorr) / sqrt(Q2now + m2Pair[iTab]);
120 bool BoseEinstein::shiftEvent(
Event& event) {
127 for (
int iSpecies = 0; iSpecies < 9; ++iSpecies) {
128 nStored[iSpecies + 1] = nStored[iSpecies];
129 if (!doPion && iSpecies <= 2)
continue;
130 if (!doKaon && iSpecies >= 3 && iSpecies <= 6)
continue;
131 if (!doEta && iSpecies >= 7)
continue;
134 int idNow = IDHADRON[ iSpecies ];
135 int iTab = ITABLE[ iSpecies ];
138 for (
int i = 0; i <
event.size(); ++i)
139 if ( event[i].
id() == idNow &&
event[i].isFinal() )
141 BoseEinsteinHadron( idNow, i, event[i].p(), event[i].m() ) );
142 nStored[iSpecies + 1] = hadronBE.size();
145 for (
int i1 = nStored[iSpecies]; i1 < nStored[iSpecies+1] - 1; ++i1)
146 for (
int i2 = i1 + 1; i2 < nStored[iSpecies+1]; ++i2)
147 shiftPair( i1, i2, iTab);
151 if (nStored[9] < 2)
return true;
154 double eSumOriginal = 0.;
155 double eSumShifted = 0.;
156 double eDiffByComp = 0.;
157 for (
int i = 0; i < nStored[9]; ++i) {
158 eSumOriginal += hadronBE[i].p.e();
159 hadronBE[i].p += hadronBE[i].pShift;
160 hadronBE[i].p.e( sqrt( hadronBE[i].p.pAbs2() + hadronBE[i].m2 ) );
161 eSumShifted += hadronBE[i].p.e();
162 eDiffByComp += dot3( hadronBE[i].pComp, hadronBE[i].p)
168 while ( abs(eSumShifted - eSumOriginal) > COMPRELERR * eSumOriginal
169 && abs(eSumShifted - eSumOriginal) < COMPFACMAX * abs(eDiffByComp)
170 && iStep < NCOMPSTEP ) {
172 double compFac = (eSumOriginal - eSumShifted) / eDiffByComp;
175 for (
int i = 0; i < nStored[9]; ++i) {
176 hadronBE[i].p += compFac * hadronBE[i].pComp;
177 hadronBE[i].p.e( sqrt( hadronBE[i].p.pAbs2() + hadronBE[i].m2 ) );
178 eSumShifted += hadronBE[i].p.e();
179 eDiffByComp += dot3( hadronBE[i].pComp, hadronBE[i].p)
186 if ( abs(eSumShifted - eSumOriginal) > COMPRELERR * eSumOriginal ) {
187 infoPtr->errorMsg(
"Warning in BoseEinstein::shiftEvent: "
188 "no consistent BE shift topology found, so skip BE");
193 for (
int i = 0; i < nStored[9]; ++i) {
194 int iNew =
event.copy( hadronBE[i].iPos, 99);
195 event[ iNew ].p( hadronBE[i].p );
207 void BoseEinstein::shiftPair(
int i1,
int i2,
int iTab) {
210 double Q2old = m2(hadronBE[i1].p, hadronBE[i2].p) - m2Pair[iTab];
211 if (Q2old < Q2MIN)
return;
212 double Qold = sqrt(Q2old);
213 double psFac = sqrt(Q2old + m2Pair[iTab]) / Q2old;
217 if (Qold < deltaQ[iTab]) Qmove = Qold / 3.;
218 else if (Qold < maxQ[iTab]) {
219 double realQbin = Qold / deltaQ[iTab];
220 int intQbin = int( realQbin );
221 double inter = (pow3(realQbin) - pow3(intQbin))
222 / (3 * intQbin * (intQbin + 1) + 1);
223 Qmove = ( shift[iTab][intQbin] + inter * (shift[iTab][intQbin + 1]
224 - shift[iTab][intQbin]) ) * psFac;
226 else Qmove = shift[iTab][nStep[iTab]] * psFac;
227 double Q2new = Q2old * pow( Qold / (Qold + 3. * lambda * Qmove), 2. / 3.);
230 double Q2Diff = Q2new - Q2old;
231 double p2DiffAbs = (hadronBE[i1].p - hadronBE[i2].p).pAbs2();
232 double p2AbsDiff = hadronBE[i1].p.pAbs2() - hadronBE[i2].p.pAbs2();
233 double eSum = hadronBE[i1].p.e() + hadronBE[i2].p.e();
234 double eDiff = hadronBE[i1].p.e() - hadronBE[i2].p.e();
235 double sumQ2E = Q2Diff + eSum * eSum;
236 double rootA = eSum * eDiff * p2AbsDiff - p2DiffAbs * sumQ2E;
237 double rootB = p2DiffAbs * sumQ2E - p2AbsDiff * p2AbsDiff;
238 double factor = 0.5 * ( rootA + sqrtpos(rootA * rootA
239 + Q2Diff * (sumQ2E - eDiff * eDiff) * rootB) ) / rootB;
242 Vec4 pDiff = factor * (hadronBE[i1].p - hadronBE[i2].p);
243 hadronBE[i1].pShift += pDiff;
244 hadronBE[i2].pShift -= pDiff;
248 if (Qold < deltaQ3[iTab]) Qmove3 = Qold / 3.;
249 else if (Qold < maxQ3[iTab]) {
250 double realQbin = Qold / deltaQ3[iTab];
251 int intQbin = int( realQbin );
252 double inter = (pow3(realQbin) - pow3(intQbin))
253 / (3 * intQbin * (intQbin + 1) + 1);
254 Qmove3 = ( shift3[iTab][intQbin] + inter * (shift3[iTab][intQbin + 1]
255 - shift3[iTab][intQbin]) ) * psFac;
257 else Qmove3 = shift3[iTab][nStep3[iTab]] *psFac;
258 double Q2new3 = Q2old * pow( Qold / (Qold + 3. * lambda * Qmove3), 2. / 3.);
261 Q2Diff = Q2new3 - Q2old;
262 sumQ2E = Q2Diff + eSum * eSum;
263 rootA = eSum * eDiff * p2AbsDiff - p2DiffAbs * sumQ2E;
264 rootB = p2DiffAbs * sumQ2E - p2AbsDiff * p2AbsDiff;
265 factor = 0.5 * ( rootA + sqrtpos(rootA * rootA
266 + Q2Diff * (sumQ2E - eDiff * eDiff) * rootB) ) / rootB;
269 factor *= 1. - exp(-Q2old * R2Ref2);
272 pDiff = factor * (hadronBE[i1].p - hadronBE[i2].p);
273 hadronBE[i1].pComp += pDiff;
274 hadronBE[i2].pComp -= pDiff;