22 #ifndef Pythia8_HIUserHooks_H
23 #define Pythia8_HIUserHooks_H
25 #include "Pythia8/Pythia.h"
43 const double femtometer = 1.0;
44 const double millimeter = 1.0e12;
47 const double femtometer2 = 1.0;
48 const double millibarn = 0.1;
49 const double nanobarn = 1.0e-7;
53 using namespace HIUnits;
64 friend class SubCollisionModel;
82 : idSave(idIn), indexSave(indexIn), nPosSave(pos), bPosSave(pos),
83 statusSave(UNWOUNDED),eventp(0), isDone(0) {}
88 int id()
const {
return idSave; }
91 int index()
const {
return indexSave; }
106 bool done()
const {
return isDone; }
116 static State nullstate;
117 return i < int(altStatesSave.size())? altStatesSave[i]: nullstate;
166 vector<State> altStatesSave;
176 statusSave = UNWOUNDED;
177 altStatesSave.clear();
206 double bIn,
double bpIn, Type typeIn)
207 : proj(&projIn), targ(&targIn), b(bIn), bp(bpIn), type(typeIn) {}
210 : proj(0), targ(0), b(0.0), bp(0.0), type(NONE) {}
213 bool operator< (
const SubCollision & s)
const {
return b < s.b; }
217 int nucleons()
const {
218 return ( abs(targ->id()) == 2112? 1: 0 ) +
219 ( abs(proj->id()) == 2112? 2: 0 );
252 : idSave(0), ISave(0), ASave(0), ZSave(0), LSave(0), RSave(0.0),
253 settingsPtr(0), particleDataPtr(0), rndPtr(0) {}
259 void initPtr(
int idIn,
Settings & settingsIn,
263 virtual Particle produceIon(
bool istarg);
267 virtual vector<Nucleon> generate()
const = 0;
270 int id()
const {
return idSave; }
271 int I()
const {
return ISave; }
272 int A()
const {
return ASave; }
273 int Z()
const {
return ZSave; }
274 int L()
const {
return LSave; }
275 double R()
const {
return RSave; }
283 int ISave, ASave, ZSave, LSave;
289 Settings * settingsPtr;
290 ParticleData * particleDataPtr;
299 class WoodsSaxonModel:
public NucleusModel {
306 inthi0(0.0), inthi1(0.0), inthi2(0.0) {}
309 double a()
const {
return aSave; }
315 Vec4 generateNucleon()
const;
323 intlo = R()*R()*R()/3.0;
324 inthi0 = a()*R()*R();
325 inthi1 = 2.0*a()*a()*R();
326 inthi2 = 2.0*a()*a()*a();
327 return NucleusModel::init();
340 double intlo, inthi0, inthi1, inthi2;
351 class GLISSANDOModel:
public WoodsSaxonModel {
366 virtual vector<Nucleon> generate()
const;
369 double Rh()
const {
return RhSave; }
371 double RhGauss()
const {
return RhSave*abs(rndPtr->gauss()); };
386 class SubCollisionModel;
394 class ImpactParameterGenerator {
401 : widthSave(0.0), collPtr(0), projPtr(0), targPtr(0),
402 settingsPtr(0), rndPtr(0) {}
417 virtual Vec4 generate(
double & weight)
const;
420 void width(
double widthIn) { widthSave = widthIn; }
423 double width()
const {
return widthSave; }
448 class SubCollisionModel {
458 vector<double> dsig2;
465 double avNDb, davNDb2;
468 SigEst(): sig(8, 0.0), dsig2(8, 0.0), fsig(8, false),
469 avNDb(0.0), davNDb2(0.0) {}
477 NGen(20), NPop(20), sigFuzz(0.2), fitPrint(true), avNDb(1.0*femtometer),
478 projPtr(), targPtr(), sigTotPtr(), settingsPtr(), infoPtr(), rndPtr() {}
491 sigTotPtr = &sigTotIn;
492 settingsPtr = &settingsIn;
504 virtual multiset<SubCollision> getCollisions(vector<Nucleon> & proj,
505 vector<Nucleon> & targ,
518 double sigEl()
const {
return sigTarg[6]; }
521 double sigCDE()
const {
return sigTarg[5]; }
524 double sigSDE()
const {
return sigTarg[3] + sigTarg[4]; }
533 double sigDDE()
const {
return sigTarg[2]; }
536 double sigND()
const {
return sigTarg[1]; }
539 double bSlope()
const {
return sigTarg[7]; }
552 double Chi2(
const SigEst & sigs,
int npar)
const;
555 virtual bool evolve();
558 virtual void setParm(
const vector<double> &) {}
563 return vector<double>();
565 virtual vector<double> minParm()
const {
566 return vector<double>();
568 virtual vector<double> maxParm()
const {
569 return vector<double>();
576 vector<double> sigTarg, sigErr;
582 int NInt, NGen, NPop;
591 NucleusModel * projPtr;
592 NucleusModel * targPtr;
593 SigmaTotal * sigTotPtr;
594 Settings * settingsPtr;
621 virtual multiset<SubCollision>
622 getCollisions(vector<Nucleon> & proj, vector<Nucleon> & targ,
623 const Vec4 & bvec,
double & T);
633 class NaiveSubCollisionModel:
public SubCollisionModel {
647 virtual multiset<SubCollision>
648 getCollisions(vector<Nucleon> & proj, vector<Nucleon> & targ,
649 const Vec4 & bvec,
double & T);
658 class DoubleStrikman:
public SubCollisionModel {
665 : r0(0.0), k0(4.0), sigd(75.0), alpha(0.5), opacityMode(modein) {}
673 virtual multiset<SubCollision>
674 getCollisions(vector<Nucleon> & proj, vector<Nucleon> & targ,
675 const Vec4 & bvec,
double & T);
678 double gamma()
const;
684 if ( opacityMode == 1 ) sig = 1.0/sig;
685 return sig > std::numeric_limits<double>::epsilon()?
686 pow(-expm1(-1.0/sig), alpha): 1.0;
693 double sig = M_PI*pow2(p[0] + t[0]);
694 double grey = opacity(sig);
695 return sig/grey > b*b*2.0*M_PI? grey: 0.0;
699 SigEst getSig()
const;
702 virtual void setParm(
const vector<double> &);
706 virtual vector<double> getParm()
const;
707 virtual vector<double> minParm()
const;
708 virtual vector<double> maxParm()
const;
711 static void shuffle(
double PND1,
double PND2,
712 double & PW1,
double & PW2);
713 static void shuffel(
double & PEL11,
double P11,
714 double P12,
double P21,
double P22);
715 static double PNW(
double PWp,
double PWt,
double PND) {
716 return ( 1.0 - PWp <= 0.0 || 1.0 - PWt <= 0.0 )?
717 0.0: (1.0 - PWp)*(1.0 - PWt)/(1.0 - PND);
745 class MultiRadial:
public SubCollisionModel {
753 dR = T0 = c = phi = vector<double>(Nr, 0.0);
762 virtual multiset<SubCollision>
763 getCollisions(vector<Nucleon> & proj, vector<Nucleon> & targ,
764 const Vec4 & bvec,
double & T);
770 return b < p[0] + t[0]? p[1]*t[1]: 0.0;
774 SigEst getSig()
const;
777 virtual void setParm(
const vector<double> &);
781 virtual vector<double> getParm()
const;
782 virtual vector<double> minParm()
const;
783 virtual vector<double> maxParm()
const;
821 EventInfo(): code(0), ordering(-1.0), coll(0), ok(false) {}
834 bool operator<(
const EventInfo & ei)
const {
846 map<Nucleon *, pair<int,int> > projs, targs;
859 friend class HeavyIons;
860 friend class Angantyr;
864 : idProjSave(0), idTargSave(0), bSave(0.0), NSave(0), NAccSave(0),
865 sigmaTotSave(0.0), sigmaNDSave(0.0), sigErr2TotSave(0.0),
866 sigErr2NDSave(0.0), weightSave(0.0), weightSumSave(0.0),
867 nCollSave(10, 0), nProjSave(10, 0), nTargSave(10, 0), nFailSave(0),
877 return sigmaTotSave/millibarn;
882 return sqrt(sigErr2TotSave/max(1.0,
double(NSave)))/millibarn;
888 return sigmaNDSave/millibarn;
893 return sqrt(sigErr2NDSave/max(1.0,
double(NSave)));
914 int nCollNDTot()
const {
return nProjSave[1] + nTargSave[1] - nCollSave[1]; }
968 double weight()
const {
return weightSave; }
988 void addAttempt(
double T,
double bin,
double bweight);
991 void reweight(
double w) {
996 void select(Info & in) {
998 primInfo.hiInfo =
this;
1008 int addSubCollision(
const SubCollision & c);
1011 int addProjectileNucleon(
const Nucleon & n);
1012 int addTargetNucleon(
const Nucleon & n);
1016 int idProjSave, idTargSave;
1022 long NSave, NAccSave;
1023 double sigmaTotSave, sigmaNDSave, sigErr2TotSave, sigErr2NDSave;
1024 double weightSave, weightSumSave;
1028 vector<int> nCollSave, nProjSave, nTargSave;
1032 map<int,double> sumPrimW, sumPrimW2;
1034 map<int,string> NamePrim;
1045 multiset<SubCollision>* subCollisionsPtr() {
return subColsPtr; }
1047 void subCollisionsPtr(multiset<SubCollision> * sPtrIn) {
1048 subColsPtr = sPtrIn; }
1054 multiset<SubCollision>* subColsPtr;
1076 virtual void init(
int idProjIn,
int idTargIn) {
1077 idProjSave = idProjIn;
1078 idTargSave = idTargIn;
1088 virtual NucleusModel * projectileModel()
const {
return 0; }
1089 virtual bool hasTargetModel()
const {
return false; }
1090 virtual NucleusModel * targetModel()
const {
return 0; }
1099 virtual double eventOrdering(
const Event &,
const Info &) {
return -1; }
1104 virtual bool fixIsoSpin(
EventInfo &) {
return false; }
1118 virtual bool forceHadronLevel(
Pythia &) {
return false; }
1125 findRecoilers(
const Event &,
bool ,
int ,
int ,
1126 const Vec4 & ,
const Vec4 & )
const {
1127 return vector<int>();
1134 int idProjSave, idTargSave;
1142 #endif // Pythia8_HIUserHooks_H
void status(Status s)
Manipulating functions:
virtual SigEst getSig() const
Calculate the cross sections for the given set of parameters.
virtual ~DoubleStrikman()
Virtual destructor,.
bool done() const
Check if nucleon has been assigned.
const Vec4 & bPos() const
The absolute position in impact parameter space.
double opacity(double sig) const
The opacity of the collision at a given sigma.
int id() const
Accessor functions:
int nCollTot() const
The total number of separate sub-collisions.
vector< double > State
The state of a nucleon is a general vector of doubles.
virtual vector< double > getParm() const
virtual bool hasProjectileModel() const
A suser-supplied NucleusModel for the projectile and target.
int code
The code for the subprocess.
void select()
Select this nucleon to be assigned to an event.
EventInfo * event() const
The event this nucleon is assigned to.
virtual ~ImpactParameterGenerator()
Virtual destructor.
double bSlope() const
The elastic b-slope parameter.
void state(State s)
Set the physical state.
Type
This defines the type of a bunary nucleon collison.
DoubleStrikman(int modein=0)
double sigDDE() const
The double diffractive excitation cross section.
double avNDB() const
Return the average non-diffractive impact parameter.
double sigmaNDErr() const
The estimated statistical error on sigmaND().
double ordering
The ordering variable of this event.
virtual bool canFixIsoSpin() const
double width() const
Get the width.
virtual bool canFindRecoilers() const
virtual bool hasImpactParameterGenerator() const
A user-supplied impact parameter generator.
bool canAddNucleonExcitation() const
double weightSum() const
The sum of weights of the produced events.
double sigND() const
The non-diffractive (absorptive) cross section.
void failedExcitation()
Register a failed nucleon excitation.
virtual bool canShiftEvent() const
A user-supplied method for shifting the event in impact parameter space.
long nAccepted() const
The number of produced events.
int nFail() const
The number of failed nuclon excitations in the current event.
SigEst()
Constructor for zeros.
virtual ~BlackSubCollisionModel()
Virtual destructor,.
void width(double widthIn)
Set the width (in femtometers).
void select(EventInfo &evp, Status s)
Select an event for this nucleon.
const Vec4 & nPos() const
The position of this nucleon relative to the nucleus center.
double sigEl() const
The total cross section.
SubCollisionModel()
The default constructor is empty.
double b() const
The impact-parameter distance in the current event.
double Rh() const
Accessor functions.
double sigSDEP() const
The single diffractive excitation cross section (excited projectile).
void addAltState(State s)
Add an alternative state.
virtual bool hasEventOrdering() const
A user-supplied ordering of events in (inverse) hardness.
virtual bool hasSubCollisionModel()
virtual void setParm(const vector< double > &)
Set the parameters of this model.
GLISSANDOModel()
Default constructor.
double sigSDE() const
The single diffractive excitation cross section (both sides summed).
int nCollEL() const
The number of separate elastic sub collisions.
Internal class to report cross section estimates.
virtual void init(int idProjIn, int idTargIn)
Initialize this user hook.
virtual ~NucleusModel()
Virtual destructor.
virtual ~WoodsSaxonModel()
Virtual destructor.
HIUserHooks()
The default constructor is empty.
int id() const
Accessor functions.
const State & altState(int i=0)
Return an alternative state.
const Vec4 & bShift(const Vec4 &bvec)
Shift the absolute position in impact parameter space.
double sigmaTot() const
The Monte Carlo integrated total cross section in the current run.
double Tpt(const Nucleon::State &p, const Nucleon::State &t, double b) const
ImpactParameterGenerator()
long nAttempts() const
The number of attempted impact parameter points.
double a() const
Accessor functions:
Status status() const
The status.
int index() const
The nucleon type.
EventInfo()
Empty constructor.
double sigSDET() const
The single diffractive excitation cross section (excited target).
virtual ~NaiveSubCollisionModel()
Virtual destructor,.
int nCollNDTot() const
The total number of non-diffractive sub collisions in the current event.
virtual ~MultiRadial()
Virtual destructor,.
double sigmaTotErr() const
The estimated statistical error on sigmaTot().
virtual ~HIUserHooks()
Virtual destructor.
Status
Enum for specifying the status of a nucleon.
double sigCDE() const
The central diffractive excitation cross section.
virtual ~SubCollisionModel()
Virtual destructor,.
virtual bool canForceHadronLevel() const
A user supplied wrapper around the Pythia::forceHadronLevel()
double weight() const
The weight for this collision.
virtual ~GLISSANDOModel()
Virtual destructor.
double sigTot() const
The total cross section.
double Tpt(const Nucleon::State &p, const Nucleon::State &t, double b) const
const State & state() const
The physical state of the incoming nucleon.