Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 09:06:42

0001 // HIInfo.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2025 Torbjorn Sjostrand.
0003 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
0004 // Please respect the MCnet Guidelines, see GUIDELINES for details.
0005 
0006 // This file contains the definition of the HIInfo, EventInfo and
0007 // HIUserHooks classes.
0008 //
0009 // EventInfo: stores full nucleon-nucleon events with corresponding Info.
0010 // HIInfo: info about a Heavy Ion run and its produced events.
0011 // HIUserHooks: User hooks for HeavyIons models.
0012 
0013 #ifndef Pythia8_HIInfo_H
0014 #define Pythia8_HIInfo_H
0015 
0016 #include "Pythia8/Pythia.h"
0017 #include "Pythia8/HIBasics.h"
0018 #include "Pythia8/HISubCollisionModel.h"
0019 
0020 namespace Pythia8 {
0021 
0022 //==========================================================================
0023 
0024 // Class for collecting info about a Heavy Ion run and its produced
0025 // events.
0026 
0027 class HIInfo {
0028 
0029 public:
0030 
0031   friend class HeavyIons;
0032   friend class Angantyr;
0033 
0034   // Constructor.
0035   HIInfo() = default;
0036 
0037   // The impact-parameter distance in the current event.
0038   double b() const { return bSave; }
0039 
0040   // The impact parameter angle.
0041   double phi() const { return phiSave; }
0042 
0043   // The summed elastic amplitude.
0044   double T() { return TSave; }
0045 
0046   // The average NN non-diffractive impact parameter to be used to
0047   // communicate to Pythia's MPI machinery.
0048   double avNDb() const { return avNDbSave; }
0049 
0050   // The number of attempted impact parameter points.
0051   long nAttempts() const { return NSave; }
0052 
0053   // The number of produced events.
0054   long nAccepted() const { return NAccSave; }
0055 
0056   // The total number of sub-collisions in the event.
0057   int nCollTot() const { return nCollSave[0]; }
0058 
0059   // The number of non-diffractive sub-collisions in the event
0060   int nCollND() const { return nCollSave[1]; }
0061 
0062   // The number of single diffractive projectile excitation
0063   // sub-collisions in the event
0064   int nCollSDP() const { return nCollSave[2]; }
0065 
0066   // The number of single diffractive target excitation
0067   // sub-collisions in the event
0068   int nCollSDT() const { return nCollSave[3]; }
0069 
0070   // The number of double diffractive sub-collisions in the event
0071   int nCollDD() const { return nCollSave[4]; }
0072 
0073   // The number of central diffractive sub-collisions in the event
0074   int nCollCD() const { return nCollSave[5]; }
0075 
0076   // The number of elastic sub-collisions in the event
0077   int nCollEl() const { return nCollSave[6]; }
0078 
0079   // The total number of interacting projectile nucleons in the event.
0080   int nPartProj() const { return nProjSave[0]; }
0081 
0082   // The number of absorptively wounded projectile nucleons in the event.
0083   int nAbsProj() const { return nProjSave[1]; }
0084 
0085   // The number of diffractively wounded projectile nucleons in the event.
0086   int nDiffProj() const { return nProjSave[2]; }
0087 
0088   // The number of elastically scattered target nucleons in the event.
0089   int nElProj() const { return nProjSave[3]; }
0090 
0091   // The total number of interacting target nucleons in the event.
0092   int nPartTarg() const { return nTargSave[0]; }
0093 
0094   // The number of absorptively wounded target nucleons in the event.
0095   int nAbsTarg() const { return nTargSave[1]; }
0096 
0097   // The number of diffractively wounded target nucleons in the event.
0098   int nDiffTarg() const { return nTargSave[2]; }
0099 
0100   // The number of elastically scattered target nucleons in the event.
0101   int nElTarg() const { return nTargSave[3]; }
0102 
0103   // The weight for this collision.
0104   double weight() const { return weightSave; }
0105 
0106   // The sum of weights of the produced events.
0107   double weightSum() const { return weightSumSave; }
0108 
0109   // The number of failed nucleon excitations in the current event.
0110   int nFail() const {
0111     return nFailSave;
0112   }
0113 
0114   // Register a failed nucleon excitation.
0115   void failedExcitation(const SubCollision& subColl) {
0116     subColl.failed = true;
0117     ++nFailSave;
0118   }
0119 
0120   // Reset Glauber statistics.
0121   void glauberReset();
0122 
0123   // The total cross section from the Glauber calculation.
0124   double glauberTot() const {
0125     return sigmaTotSave*FMSQ2MB;
0126   }
0127 
0128   // The error on the total cross section from the Glauber
0129   // calculation.
0130   double glauberTotErr() const {
0131     return sqrt(sigErr2TotSave/max(1.0, double(NSave)))*FMSQ2MB;
0132   }
0133 
0134   // The non-diffractive cross section from the Glauber calculation.
0135   double glauberND() const {
0136     return sigmaNDSave*FMSQ2MB;
0137   }
0138 
0139   // The error on the non-diffractive cross section from the Glauber
0140   // calculation.
0141   double glauberNDErr() const {
0142     return sqrt(sigErr2NDSave/max(1.0, double(NSave)))*FMSQ2MB;
0143   }
0144 
0145   // The total inelastic cross section from the Glauber calculation.
0146   double glauberINEL() const {
0147     return sigmaINELSave*FMSQ2MB;
0148   }
0149 
0150   // The error on the total inelastic cross section from the Glauber
0151   // calculation.
0152   double glauberINELErr() const {
0153     return sqrt(sigErr2INELSave/max(1.0, double(NSave)))*FMSQ2MB;
0154   }
0155 
0156   // The elastic cross section from the Glauber calculation.
0157   double glauberEL() const {
0158     return sigmaELSave*FMSQ2MB;
0159   }
0160 
0161   // The error on the elastic cross section from the Glauber
0162   // calculation.
0163   double glauberELErr() const {
0164     return sqrt(sigErr2ELSave/max(1.0, double(NSave)))*FMSQ2MB;
0165   }
0166 
0167   // The diffractive taget excitation cross section from the Glauber
0168   // calculation.
0169   double glauberDiffT() const {
0170     return sigmaDiffTSave*FMSQ2MB;
0171   }
0172 
0173   // The error on the diffractive taget excitation cross section from the
0174   // Glauber calculation.
0175   double glauberDiffTErr() const {
0176     return sqrt(sigErr2DiffTSave/max(1.0, double(NSave)))*FMSQ2MB;
0177   }
0178 
0179   // The diffractive projectile excitation cross section from the Glauber
0180   // calculation.
0181   double glauberDiffP() const {
0182     return sigmaDiffPSave*FMSQ2MB;
0183   }
0184 
0185   // The error on the diffractive projectile excitation cross section
0186   // from the Glauber calculation.
0187   double glauberDiffPErr() const {
0188     return sqrt(sigErr2DiffPSave/max(1.0, double(NSave)))*FMSQ2MB;
0189   }
0190 
0191   // The doubly diffractive excitation cross section from the Glauber
0192   // calculation.
0193   double glauberDDiff() const {
0194     return sigmaDDiffSave*FMSQ2MB;
0195   }
0196 
0197   // The error on the doubly diffractive excitation cross section from
0198   // the Glauber calculation.
0199   double glauberDDiffErr() const {
0200     return sqrt(sigErr2DDiffSave/max(1.0, double(NSave)))*FMSQ2MB;
0201   }
0202 
0203   // The elastic slope parameter.
0204   double glauberBSlope() const {
0205     return slopeSave/(sigmaTotSave*pow2(HBARC));
0206   }
0207 
0208   // The error on the elastic slope parameter.
0209   double glauberBSlopeErr() const {
0210     return sqrt((slopeErrSave/pow2(slopeSave) +
0211                  sigErr2TotSave/pow2(sigmaTotSave))/max(1.0, double(NSave)))*
0212                 glauberBSlope();
0213   }
0214 
0215 private:
0216 
0217   // Register a tried impact parameter point giving the total elastic
0218   // amplitude, the impact parameter and impact parameter generation
0219   // weight, together with the cross section scale.
0220   void addAttempt(double T, double bin, double phiin,
0221                   double bweight, double xSecScale);
0222 
0223   // Reweight event for whatever reason.
0224   void reweight(double w) {
0225     weightSave *= w;
0226   }
0227 
0228   // Select the primary process.
0229   void select(Info & in) {
0230     primInfo = in;
0231     primInfo.hiInfo = this;
0232   }
0233 
0234   // Accept an event and update statistics in info.
0235   void accept();
0236 
0237   // Reject an attmpted event.
0238   void reject() {}
0239 
0240   // Register Glauber statistics of the event.
0241   void glauberStatistics();
0242 
0243   // Collect running averages for Glauber cross section:
0244   static void runAvg(double & sig, double & sigErr2, double N,
0245     double w) {
0246     double delta = w - sig;
0247     sig += delta/N;
0248     sigErr2 += (delta*(w - sig) - sigErr2)/N;
0249   }
0250 
0251   // Id of the colliding nuclei.
0252   int idProjSave = 0, idTargSave = 0;
0253 
0254   // Impact parameter.
0255   double bSave = 0.0;
0256   double phiSave = 0.0;
0257 
0258   // Amplitude, attempts and weight.
0259   long NSave = 0, NAccSave = 0;
0260   double TSave = 0.0;
0261   // OBS: Cross sections should be accessed through the main info class.
0262   double sigmaTotSave = {}, sigmaNDSave = {},
0263          sigmaELSave = {}, sigmaINELSave = {},
0264          sigmaDiffPSave = {}, sigmaDiffTSave = {}, sigmaDDiffSave = {},
0265          slopeSave ={};
0266   double sigErr2TotSave = {}, sigErr2NDSave = {},
0267          sigErr2ELSave = {}, sigErr2INELSave = {},
0268          sigErr2DiffPSave = {}, sigErr2DiffTSave = {}, sigErr2DDiffSave = {},
0269          slopeErrSave ={};
0270   double avNDbSave = {};
0271   double weightSave = {}, weightSumSave = {}, xSecScaleSave = {};
0272 
0273   // Number of collisions and paricipants. See accessor functions for
0274   // indices.
0275   vector<int> nCollSave{}, nProjSave{}, nTargSave{};
0276 
0277   // Map of primary processes and the number of events and the sum of
0278   // weights.
0279   map<int,double> sumPrimW{}, sumPrimW2{};
0280   map<int,int> NPrim{};
0281   map<int,string> NamePrim{};
0282 
0283   // The info object of the primary process.
0284   Info primInfo{};
0285 
0286   // Number of failed nucleon excitations.
0287   int nFailSave = 0;
0288 
0289 public:
0290 
0291   // Access to subcollision to be extracted by the user.
0292   const SubCollisionSet* subCollisionsPtr() { return subCollisionsPtrSave; }
0293 
0294 private:
0295 
0296   // Set the subcollision pointer.
0297   void setSubCollisions(const SubCollisionSet* subCollisionsPtrIn) {
0298     subCollisionsPtrSave = subCollisionsPtrIn; }
0299 
0300   // Full information about the Glauber calculation, consisting of
0301   // all subcollisions.
0302   const SubCollisionSet* subCollisionsPtrSave{};
0303 
0304 };
0305 
0306 //==========================================================================
0307 
0308 // This is the heavy ion user hooks class which in the future may be
0309 // used inside a Pythia object to generate heavy ion collisons. For
0310 // now it is used outside Pythia and requires access to a number of
0311 // Pythia objects.
0312 
0313 class HIUserHooks {
0314 
0315 public:
0316 
0317   // The default constructor is empty.
0318   HIUserHooks(): idProjSave(0), idTargSave(0) {}
0319 
0320   // Virtual destructor.
0321   virtual ~HIUserHooks() {}
0322 
0323   // Initialize this user hook.
0324   virtual void init(int idProjIn, int idTargIn) {
0325     idProjSave = idProjIn;
0326     idTargSave = idTargIn;
0327   }
0328 
0329   // A user-supplied impact parameter generator.
0330   virtual bool hasImpactParameterGenerator() const { return false; }
0331   virtual shared_ptr<ImpactParameterGenerator> impactParameterGenerator()
0332     const { return nullptr; }
0333 
0334   // A user-supplied NucleusModel for the projectile and target.
0335   virtual bool hasProjectileModel() const { return false; }
0336   virtual shared_ptr<NucleusModel> projectileModel() const { return nullptr; }
0337   virtual bool hasTargetModel() const { return false; }
0338   virtual shared_ptr<NucleusModel> targetModel() const { return nullptr; }
0339 
0340   // A user-supplied SubCollisionModel for generating nucleon-nucleon
0341   // subcollisions.
0342   virtual bool hasSubCollisionModel() { return false; }
0343   virtual shared_ptr<SubCollisionModel> subCollisionModel() { return nullptr; }
0344 
0345   // A user-supplied ordering of events in (inverse) hardness.
0346   virtual bool hasEventOrdering() const { return false; }
0347   virtual double eventOrdering(const Event &, const Info &) { return -1; }
0348 
0349   // A user-supplied method for fixing up proton-neutron mismatch in
0350   // generated beams.
0351   virtual bool canFixIsoSpin() const { return false; }
0352   virtual bool fixIsoSpin(EventInfo &) { return false; }
0353 
0354   // A user-supplied method for shifting the event in impact parameter space.
0355   virtual bool canShiftEvent() const { return false; }
0356   virtual EventInfo & shiftEvent(EventInfo & ei) const { return ei; }
0357 
0358   // A user-supplied method of adding a diffractive excitation event
0359   // to another event, optionally connecting their colours.
0360   bool canAddNucleonExcitation() const { return false; }
0361   bool addNucleonExcitation(EventInfo &, EventInfo &, bool) const {
0362     return false; }
0363 
0364   // A user supplied wrapper around the Pythia::forceHadronLevel()
0365   virtual bool canForceHadronLevel() const { return false; }
0366   virtual bool forceHadronLevel(Pythia &) { return false; }
0367 
0368   // A user-supplied way of finding the remnants of an
0369   // non-diffrcative pp collision (on the target side if tside is
0370   // true) to be used to give momentum when adding.
0371   virtual bool canFindRecoilers() const { return false; }
0372   virtual vector<int>
0373   findRecoilers(const Event &, bool /* tside */, int /* beam */, int /* end */,
0374                const Vec4 & /* pdiff */, const Vec4 & /* pbeam */) const {
0375     return vector<int>();
0376   }
0377 
0378 protected:
0379 
0380   // Information set in the init() function.
0381   // The PDG id of the projectile and target nuclei.
0382   int idProjSave, idTargSave;
0383 
0384 };
0385 
0386 //==========================================================================
0387 
0388 } // end namespace Pythia8
0389 
0390 #endif // Pythia8_HIInfo_H