File indexing completed on 2025-01-18 10:06:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef Pythia8_HISubCollisionModel_H
0018 #define Pythia8_HISubCollisionModel_H
0019
0020 #include "Pythia8/Pythia.h"
0021 #include "Pythia8/HINucleusModel.h"
0022
0023 namespace Pythia8 {
0024
0025
0026
0027
0028
0029
0030 class SubCollision {
0031
0032 public:
0033
0034
0035 enum CollisionType {
0036 NONE,
0037 ELASTIC,
0038 SDEP,
0039 SDET,
0040 DDE,
0041 CDE,
0042 ABS
0043 };
0044
0045
0046 SubCollision(Nucleon & projIn, Nucleon & targIn,
0047 double bIn, double bpIn, CollisionType typeIn)
0048 : proj(&projIn), targ(&targIn), b(bIn), bp(bpIn), type(typeIn) {}
0049
0050
0051 SubCollision()
0052 : proj(0), targ(0), b(0.0), bp(0.0), type(NONE) {}
0053
0054
0055 bool operator< (const SubCollision& s) const { return b < s.b; }
0056
0057
0058
0059 int nucleons() const {return ( abs(targ->id()) == 2112? 1: 0 ) +
0060 ( abs(proj->id()) == 2112? 2: 0 );}
0061
0062
0063 Nucleon* proj;
0064
0065
0066 Nucleon* targ;
0067
0068
0069 double b;
0070
0071
0072
0073 double bp;
0074
0075
0076 CollisionType type;
0077
0078 };
0079
0080
0081
0082
0083
0084 class SubCollisionSet {
0085
0086 public:
0087
0088
0089 SubCollisionSet() = default;
0090
0091
0092 SubCollisionSet(multiset<SubCollision> subCollisionsIn, double TIn)
0093 : subCollisionsSave(subCollisionsIn), TSave(TIn) {}
0094
0095
0096 bool empty() const { return subCollisionsSave.empty(); }
0097
0098
0099 double T() const { return TSave; }
0100
0101
0102 multiset<SubCollision>::const_iterator begin() const {
0103 return subCollisionsSave.begin(); }
0104 multiset<SubCollision>::const_iterator end() const {
0105 return subCollisionsSave.end(); }
0106
0107 private:
0108
0109
0110 multiset<SubCollision> subCollisionsSave;
0111 double TSave;
0112
0113 };
0114
0115
0116
0117
0118
0119
0120
0121 class SubCollisionModel {
0122
0123 public:
0124
0125
0126 struct SigEst {
0127
0128 vector<double> sig;
0129
0130
0131 vector<double> dsig2;
0132
0133
0134 vector<bool> fsig;
0135
0136
0137
0138 double avNDb, davNDb2;
0139
0140
0141 SigEst(): sig(8, 0.0), dsig2(8, 0.0), fsig(8, false),
0142 avNDb(0.0), davNDb2(0.0) {}
0143
0144 };
0145
0146
0147 SubCollisionModel(int nParm): sigTarg(8, 0.0), sigErr(8, 0.05),
0148 parmSave(nParm),
0149 NInt(100000), NPop(20), sigFuzz(0.2), impactFudge(1),
0150 fitPrint(true), avNDb(1.0*femtometer),
0151 projPtr(), targPtr(), sigTotPtr(), settingsPtr(), infoPtr(), rndmPtr() {}
0152
0153
0154 virtual ~SubCollisionModel() {}
0155
0156
0157 static shared_ptr<SubCollisionModel> create(int model);
0158
0159
0160 virtual bool init(int idAIn, int idBIn, double eCMIn);
0161
0162
0163 void initPtr(NucleusModel & projIn, NucleusModel & targIn,
0164 SigmaTotal & sigTotIn, Settings & settingsIn,
0165 Info & infoIn, Rndm & rndmIn) {
0166 projPtr = &projIn;
0167 targPtr = &targIn;
0168 sigTotPtr = &sigTotIn;
0169 settingsPtr = &settingsIn;
0170 infoPtr = &infoIn;
0171 rndmPtr = &rndmIn;
0172 loggerPtr = infoIn.loggerPtr;
0173 }
0174
0175
0176
0177
0178
0179 double sigTot() const { return sigTarg[0]; }
0180
0181
0182 double sigEl() const { return sigTarg[6]; }
0183
0184
0185 double sigCDE() const { return sigTarg[5]; }
0186
0187
0188 double sigSDE() const { return sigTarg[3] + sigTarg[4]; }
0189
0190
0191 double sigSDEP() const { return sigTarg[3]; }
0192
0193
0194 double sigSDET() const { return sigTarg[4]; }
0195
0196
0197 double sigDDE() const { return sigTarg[2]; }
0198
0199
0200 double sigND() const { return sigTarg[1]; }
0201
0202
0203 double bSlope() const { return sigTarg[7]; }
0204
0205
0206 double avNDB() const { return avNDb; }
0207
0208
0209 void updateSig();
0210
0211
0212 double Chi2(const SigEst & sigs, int npar) const;
0213
0214
0215 void setKinematics(double eCMIn);
0216
0217
0218 void setIDA(int idA);
0219
0220
0221 bool evolve(int nGenerations, double eCM);
0222
0223
0224 int nParms() const { return parmSave.size(); }
0225
0226
0227 void setParm(const vector<double>& parmIn) {
0228 for (size_t i = 0; i < parmSave.size(); ++i)
0229 parmSave[i] = parmIn[i];
0230 }
0231
0232
0233 vector<double> getParm() const { return parmSave; }
0234
0235
0236 virtual vector<double> minParm() const = 0;
0237
0238
0239 virtual vector<double> defParm() const = 0;
0240
0241
0242 virtual vector<double> maxParm() const = 0;
0243
0244
0245
0246 virtual SubCollisionSet getCollisions(Nucleus& proj, Nucleus& targ) = 0;
0247
0248
0249 virtual SigEst getSig() const = 0;
0250
0251 private:
0252
0253
0254
0255 vector<double> sigTarg, sigErr;
0256
0257
0258 bool genParms();
0259
0260
0261 bool saveParms(string fileName) const;
0262 bool loadParms(string fileName);
0263
0264 protected:
0265
0266
0267 vector<double> parmSave;
0268
0269
0270
0271 int NInt, NPop;
0272 double sigFuzz;
0273 double impactFudge;
0274 bool fitPrint;
0275
0276
0277
0278 double avNDb;
0279
0280
0281 NucleusModel* projPtr;
0282 NucleusModel* targPtr;
0283 SigmaTotal* sigTotPtr;
0284 Settings* settingsPtr;
0285 Info* infoPtr;
0286 Rndm* rndmPtr;
0287 Logger* loggerPtr;
0288
0289
0290 int idASave, idBSave;
0291 bool doVarECM, doVarBeams;
0292 double eMin, eMax, eSave;
0293 int eCMPts;
0294
0295
0296 vector<int> idAList;
0297
0298
0299
0300 vector<LogInterpolator> *subCollParms;
0301
0302
0303 map<int, vector<LogInterpolator>> subCollParmsMap;
0304
0305 };
0306
0307
0308
0309
0310
0311
0312
0313 class BlackSubCollisionModel : public SubCollisionModel {
0314
0315 public:
0316
0317
0318 BlackSubCollisionModel() : SubCollisionModel(0) {}
0319
0320
0321 virtual ~BlackSubCollisionModel() override {}
0322
0323
0324 vector<double> minParm() const override { return vector<double>(); }
0325 vector<double> defParm() const override { return vector<double>(); }
0326 vector<double> maxParm() const override { return vector<double>(); }
0327
0328
0329 virtual SigEst getSig() const override {
0330 SigEst s;
0331 s.sig[0] = sigTot();
0332 s.sig[1] = sigND();
0333 s.sig[6] = s.sig[0] - s.sig[1];
0334 s.sig[7] = bSlope();
0335 return s;
0336 }
0337
0338
0339 virtual SubCollisionSet getCollisions(Nucleus& proj, Nucleus& targ) override;
0340
0341 };
0342
0343
0344
0345
0346
0347
0348
0349 class NaiveSubCollisionModel : public SubCollisionModel {
0350
0351 public:
0352
0353
0354 NaiveSubCollisionModel() : SubCollisionModel(0) {}
0355
0356
0357 virtual ~NaiveSubCollisionModel() override {}
0358
0359
0360 vector<double> minParm() const override { return vector<double>(); }
0361 vector<double> defParm() const override { return vector<double>(); }
0362 vector<double> maxParm() const override { return vector<double>(); }
0363
0364
0365 virtual SigEst getSig() const override {
0366 SigEst s;
0367 s.sig[0] = sigTot();
0368 s.sig[1] = sigND();
0369 s.sig[3] = sigSDEP();
0370 s.sig[4] = sigSDET();
0371 s.sig[2] = sigDDE();
0372 s.sig[6] = sigEl();
0373 s.sig[7] = bSlope();
0374 return s;
0375 }
0376
0377
0378 virtual SubCollisionSet getCollisions(Nucleus& proj, Nucleus& targ) override;
0379
0380 };
0381
0382
0383
0384
0385
0386
0387
0388
0389 class FluctuatingSubCollisionModel : public SubCollisionModel {
0390
0391 public:
0392
0393
0394 FluctuatingSubCollisionModel(int nParmIn, int modein)
0395 : SubCollisionModel(nParmIn + 2),
0396 sigd(parmSave[nParmIn]), alpha(parmSave[nParmIn + 1]),
0397 opacityMode(modein) {}
0398
0399
0400 virtual ~FluctuatingSubCollisionModel() override {}
0401
0402
0403
0404 virtual SubCollisionSet getCollisions(Nucleus& proj, Nucleus& targ) override;
0405
0406
0407 virtual SigEst getSig() const override;
0408
0409 protected:
0410
0411
0412 virtual double pickRadiusProj() const = 0;
0413 virtual double pickRadiusTarg() const = 0;
0414
0415 private:
0416
0417
0418 double& sigd;
0419
0420
0421 double& alpha;
0422
0423
0424 int opacityMode;
0425
0426
0427 double opacity(double sig) const {
0428 sig /= sigd;
0429 if ( opacityMode == 1 ) sig = 1.0/sig;
0430 return sig > numeric_limits<double>::epsilon() ?
0431 pow(-expm1(-1.0/sig), alpha) : 1.0;
0432 }
0433
0434
0435
0436 double Tpt(const Nucleon::State & p,
0437 const Nucleon::State & t, double b) const {
0438 double sig = M_PI*pow2(p[0] + t[0]);
0439 double grey = opacity(sig);
0440 return sig/grey > b*b*2.0*M_PI? grey: 0.0;
0441 }
0442
0443 };
0444
0445
0446
0447
0448
0449
0450 class DoubleStrikmanSubCollisionModel : public FluctuatingSubCollisionModel {
0451
0452 public:
0453
0454
0455 DoubleStrikmanSubCollisionModel(int modeIn = 0)
0456 : FluctuatingSubCollisionModel(1, modeIn), k0(parmSave[0]) {}
0457
0458
0459 virtual ~DoubleStrikmanSubCollisionModel() override {}
0460
0461
0462 vector<double> minParm() const override { return { 0.01, 1.0, 0.0 }; }
0463 vector<double> defParm() const override { return { 2.15, 17.24, 0.33 }; }
0464 vector<double> maxParm() const override { return { 60.00, 60.0, 20.0 }; }
0465
0466 protected:
0467
0468 double pickRadiusProj() const override { return rndmPtr->gamma(k0, r0()); }
0469 double pickRadiusTarg() const override { return rndmPtr->gamma(k0, r0()); }
0470
0471 private:
0472
0473
0474 double& k0;
0475
0476
0477
0478 double r0() const {
0479 return sqrt(sigTot() / (M_PI * (2.0 * k0 + 4.0 * k0 * k0)));
0480 }
0481
0482 };
0483
0484
0485
0486
0487
0488
0489
0490
0491 class ImpactParameterGenerator {
0492
0493 public:
0494
0495
0496
0497 ImpactParameterGenerator()
0498 : widthSave(0.0), collPtr(0), projPtr(0), targPtr(0),
0499 settingsPtr(0), rndmPtr(0) {}
0500
0501
0502 virtual ~ImpactParameterGenerator() {}
0503
0504
0505 virtual bool init();
0506 void initPtr(Info & infoIn, SubCollisionModel & collIn,
0507 NucleusModel & projIn, NucleusModel & targIn);
0508
0509
0510 virtual Vec4 generate(double & weight) const;
0511
0512
0513 void width(double widthIn) { widthSave = widthIn; }
0514
0515
0516 double width() const { return widthSave; }
0517
0518
0519 void updateWidth();
0520
0521 private:
0522
0523
0524 double widthSave;
0525
0526 protected:
0527
0528
0529 Info* infoPtr;
0530 SubCollisionModel* collPtr;
0531 NucleusModel* projPtr;
0532 NucleusModel* targPtr;
0533 Settings* settingsPtr;
0534 Rndm* rndmPtr;
0535 Logger* loggerPtr;
0536
0537 };
0538
0539
0540
0541
0542
0543
0544
0545
0546 class LogNormalSubCollisionModel : public FluctuatingSubCollisionModel {
0547
0548 public:
0549
0550
0551 LogNormalSubCollisionModel(int modeIn = 0)
0552 : FluctuatingSubCollisionModel(4, modeIn),
0553 kProj(parmSave[0]), kTarg(parmSave[1]),
0554 rProj(parmSave[2]), rTarg(parmSave[3]) {}
0555
0556
0557 virtual ~LogNormalSubCollisionModel() {}
0558
0559
0560
0561
0562 vector<double> minParm() const override {
0563 return { 0.01, 0.01, 0.10, 0.10, 1.00, 0.00 }; }
0564 vector<double> defParm() const override {
0565 return { 1.00, 1.00, 0.54, 0.54, 17.24, 0.33 }; }
0566 vector<double> maxParm() const override {
0567 return { 2.00, 2.00, 4.00, 4.00, 20.00, 2.00 }; }
0568
0569 protected:
0570
0571 double pickRadiusProj() const override { return pickRadius(kProj, rProj); }
0572 double pickRadiusTarg() const override { return pickRadius(kTarg, rTarg); }
0573
0574 private:
0575
0576
0577 double& kProj;
0578 double& kTarg;
0579
0580
0581 double& rProj;
0582 double& rTarg;
0583
0584 double pickRadius(double k0, double r0) const {
0585 double logSig = log(M_PI * pow2(r0)) + k0 * rndmPtr->gauss();
0586 return sqrt(exp(logSig) / M_PI);
0587 }
0588 };
0589
0590
0591
0592 }
0593
0594 #endif