PYTHIA  8.312
HIInfo.h
1 // HIInfo.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2024 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 // This file contains the definition of the HIInfo, EventInfo and
7 // HIUserHooks classes, as well as the HIUnits namespace.
8 //
9 // EventInfo: stores full nucleon-nucleon events with corresponding Info.
10 // HIInfo: info about a Heavy Ion run and its produced events.
11 // HIUserHooks: User hooks for HeavyIons models.
12 
13 #ifndef Pythia8_HIInfo_H
14 #define Pythia8_HIInfo_H
15 
16 #include "Pythia8/Pythia.h"
17 #include "Pythia8/HIBasics.h"
18 #include "Pythia8/HISubCollisionModel.h"
19 
20 namespace Pythia8 {
21 
22 //==========================================================================
23 
24 // Class for collecting info about a Heavy Ion run and its produced
25 // events.
26 
27 class HIInfo {
28 
29 public:
30 
31  friend class HeavyIons;
32  friend class Angantyr;
33 
34  // Constructor.
36  : idProjSave(0), idTargSave(0), bSave(0.0), NSave(0), NAccSave(0),
37  sigmaTotSave(0.0), sigmaNDSave(0.0), sigErr2TotSave(0.0),
38  sigErr2NDSave(0.0), avNDbSave(0.0), weightSave(0.0), weightSumSave(0.0),
39  nCollSave(10, 0), nProjSave(10, 0), nTargSave(10, 0), nFailSave(0),
40  subCollisionsPtrSave(nullptr) {}
41 
42  // The impact-parameter distance in the current event.
43  double b() const {
44  return bSave;
45  }
46 
47  // The impact parameter angle.
48  double phi() const {
49  return phiSave;
50  }
51 
52  // The Monte Carlo integrated total cross section in the current run.
53  double sigmaTot() const {
54  return sigmaTotSave/millibarn;
55  }
56 
57  // The estimated statistical error on sigmaTot().
58  double sigmaTotErr() const {
59  return sqrt(sigErr2TotSave/max(1.0, double(NSave)))/millibarn;
60  }
61 
62  // The Monte Carlo integrated non-diffractive cross section in the
63  // current run.
64  double sigmaND() const {
65  return sigmaNDSave/millibarn;
66  }
67 
68  // The estimated statistical error on sigmaND().
69  double sigmaNDErr() const {
70  return sqrt(sigErr2NDSave/max(1.0, double(NSave)));
71  }
72 
73  // The average NN non-diffractive impact parameter to be used to
74  // communicate to Pythia's MPI machinery.
75  double avNDb() const {
76  return avNDbSave;
77  }
78 
79  // The number of attempted impact parameter points.
80  long nAttempts() const {
81  return NSave;
82  }
83 
84  // The number of produced events.
85  long nAccepted() const {
86  return NAccSave;
87  }
88 
89  // The total number of separate sub-collisions.
90  int nCollTot() const { return nCollSave[0]; }
91 
92  // The number of separate non-diffractive sub collisions in the
93  // current event.
94  int nCollND() const { return nCollSave[1]; }
95 
96  // The total number of non-diffractive sub collisions in the current event.
97  int nCollNDTot() const { return nProjSave[1] + nTargSave[1] - nCollSave[1]; }
98 
99  // The number of separate single diffractive projectile excitation
100  // sub collisions in the current event.
101  int nCollSDP() const { return nCollSave[2]; }
102 
103  // The number of separate single diffractive target excitation sub
104  // collisions in the current event.
105  int nCollSDT() const { return nCollSave[3]; }
106 
107  // The number of separate double diffractive sub collisions in the
108  // current event.
109  int nCollDD() const { return nCollSave[4]; }
110 
111  // The number of separate central diffractive sub collisions in the
112  // current event.
113  int nCollCD() const { return nCollSave[5]; }
114 
115  // The number of separate elastic sub collisions.
116  int nCollEL() const { return nCollSave[6]; }
117 
118  // The number of interacting projectile nucleons in the current event.
119  int nPartProj() const { return nProjSave[0]; }
120 
121  // The number of absorptively wounded projectile nucleons in the
122  // current event.
123  int nAbsProj() const { return nProjSave[1]; }
124 
125  // The number of diffractively wounded projectile nucleons in the
126  // current event.
127  int nDiffProj() const { return nProjSave[2]; }
128 
129  // The number of elastically scattered projectile nucleons in the
130  // current event.
131  int nElProj() const { return nProjSave[3]; }
132 
133  // The number of interacting projectile nucleons in the current
134  // event.
135  int nPartTarg() const { return nTargSave[0]; }
136 
137  // The number of absorptively wounded projectile nucleons in the
138  // current event.
139  int nAbsTarg() const { return nTargSave[1]; }
140 
141  // The number of diffractively wounded projectile nucleons in the
142  // current event.
143  int nDiffTarg() const { return nTargSave[2]; }
144 
145  // The number of elastically scattered projectile nucleons in the
146  // current event.
147  int nElTarg() const { return nTargSave[3]; }
148 
149  // The weight for this collision.
150  double weight() const { return weightSave; }
151 
152  // The sum of weights of the produced events.
153  double weightSum() const { return weightSumSave; }
154 
155  // The number of failed nucleon excitations in the current event.
156  int nFail() const {
157  return nFailSave;
158  }
159 
160  // Register a failed nucleon excitation.
162  ++nFailSave;
163  }
164 
165 private:
166 
167  // Register a tried impact parameter point giving the total elastic
168  // amplitude, the impact parameter and impact parameter generation weight.
169  void addAttempt(double T, double bin, double phiin, double bweight);
170 
171  // Reweight event for whatever reason.
172  void reweight(double w) {
173  weightSave *= w;
174  }
175 
176  // Select the primary process.
177  void select(Info & in) {
178  primInfo = in;
179  primInfo.hiInfo = this;
180  }
181 
182  // Accept an event and update statistics in info.
183  void accept();
184 
185  // Reject an attmpted event.
186  void reject() {}
187 
188  // Register a full sub collision.
189  int addSubCollision(const SubCollision & c);
190 
191  // Register a participating projectile/target nucleon.
192  int addProjectileNucleon(const Nucleon & n);
193  int addTargetNucleon(const Nucleon & n);
194 
195  // Id of the colliding nuclei.
196  int idProjSave, idTargSave;
197 
198  // Impact parameter.
199  double bSave;
200  double phiSave;
201 
202  // Cross section estimates.
203  long NSave, NAccSave;
204  double sigmaTotSave, sigmaNDSave, sigErr2TotSave, sigErr2NDSave;
205  double avNDbSave;
206  double weightSave, weightSumSave;
207 
208  // Number of collisions and paricipants. See accessor functions for
209  // indices.
210  vector<int> nCollSave, nProjSave, nTargSave;
211 
212  // Map of primary processes and the number of events and the sum of
213  // weights.
214  map<int,double> sumPrimW, sumPrimW2;
215  map<int,int> NPrim;
216  map<int,string> NamePrim;
217 
218  // The info object of the primary process.
219  Info primInfo;
220 
221  // Number of failed nucleon excitations.
222  int nFailSave;
223 
224 public:
225 
226  // Access to subcollision to be extracted by the user.
227  const SubCollisionSet* subCollisionsPtr() { return subCollisionsPtrSave; }
228 
229 private:
230 
231  // Set the subcollision pointer.
232  void setSubCollisions(const SubCollisionSet* subCollisionsPtrIn) {
233  subCollisionsPtrSave = subCollisionsPtrIn; }
234 
235  // Full information about the Glauber calculation, consisting of
236  // all subcollisions.
237  const SubCollisionSet* subCollisionsPtrSave;
238 
239 };
240 
241 //==========================================================================
242 
243 // This is the heavy ion user hooks class which in the future may be
244 // used inside a Pythia object to generate heavy ion collisons. For
245 // now it is used outside Pythia and requires access to a number of
246 // Pythia objects.
247 
248 class HIUserHooks {
249 
250 public:
251 
252  // The default constructor is empty.
253  HIUserHooks(): idProjSave(0), idTargSave(0) {}
254 
255  // Virtual destructor.
256  virtual ~HIUserHooks() {}
257 
258  // Initialize this user hook.
259  virtual void init(int idProjIn, int idTargIn) {
260  idProjSave = idProjIn;
261  idTargSave = idTargIn;
262  }
263 
264  // A user-supplied impact parameter generator.
265  virtual bool hasImpactParameterGenerator() const { return false; }
266  virtual shared_ptr<ImpactParameterGenerator> impactParameterGenerator()
267  const { return nullptr; }
268 
269  // A user-supplied NucleusModel for the projectile and target.
270  virtual bool hasProjectileModel() const { return false; }
271  virtual shared_ptr<NucleusModel> projectileModel() const { return nullptr; }
272  virtual bool hasTargetModel() const { return false; }
273  virtual shared_ptr<NucleusModel> targetModel() const { return nullptr; }
274 
275  // A user-supplied SubCollisionModel for generating nucleon-nucleon
276  // subcollisions.
277  virtual bool hasSubCollisionModel() { return false; }
278  virtual shared_ptr<SubCollisionModel> subCollisionModel() { return nullptr; }
279 
280  // A user-supplied ordering of events in (inverse) hardness.
281  virtual bool hasEventOrdering() const { return false; }
282  virtual double eventOrdering(const Event &, const Info &) { return -1; }
283 
284  // A user-supplied method for fixing up proton-neutron mismatch in
285  // generated beams.
286  virtual bool canFixIsoSpin() const { return false; }
287  virtual bool fixIsoSpin(EventInfo &) { return false; }
288 
289  // A user-supplied method for shifting the event in impact parameter space.
290  virtual bool canShiftEvent() const { return false; }
291  virtual EventInfo & shiftEvent(EventInfo & ei) const { return ei; }
292 
293  // A user-supplied method of adding a diffractive excitation event
294  // to another event, optionally connecting their colours.
295  bool canAddNucleonExcitation() const { return false; }
296  bool addNucleonExcitation(EventInfo &, EventInfo &, bool) const {
297  return false; }
298 
299  // A user supplied wrapper around the Pythia::forceHadronLevel()
300  virtual bool canForceHadronLevel() const { return false; }
301  virtual bool forceHadronLevel(Pythia &) { return false; }
302 
303  // A user-supplied way of finding the remnants of an
304  // non-diffrcative pp collision (on the target side if tside is
305  // true) to be used to give momentum when adding.
306  virtual bool canFindRecoilers() const { return false; }
307  virtual vector<int>
308  findRecoilers(const Event &, bool /* tside */, int /* beam */, int /* end */,
309  const Vec4 & /* pdiff */, const Vec4 & /* pbeam */) const {
310  return vector<int>();
311  }
312 
313 protected:
314 
315  // Information set in the init() function.
316  // The PDG id of the projectile and target nuclei.
317  int idProjSave, idTargSave;
318 
319 };
320 
321 //==========================================================================
322 
323 } // end namespace Pythia8
324 
325 #endif // Pythia8_HIInfo_H
int nCollSDP() const
Definition: HIInfo.h:101
virtual void init(int idProjIn, int idTargIn)
Initialize this user hook.
Definition: HIInfo.h:259
bool canAddNucleonExcitation() const
Definition: HIInfo.h:295
virtual bool canFindRecoilers() const
Definition: HIInfo.h:306
long nAttempts() const
The number of attempted impact parameter points.
Definition: HIInfo.h:80
double weight() const
The weight for this collision.
Definition: HIInfo.h:150
int nElProj() const
Definition: HIInfo.h:131
int nFail() const
The number of failed nucleon excitations in the current event.
Definition: HIInfo.h:156
virtual bool canShiftEvent() const
A user-supplied method for shifting the event in impact parameter space.
Definition: HIInfo.h:290
int nCollND() const
Definition: HIInfo.h:94
int nCollEL() const
The number of separate elastic sub collisions.
Definition: HIInfo.h:116
Definition: Info.h:45
The Event class holds all info on the generated event.
Definition: Event.h:453
double sigmaTotErr() const
The estimated statistical error on sigmaTot().
Definition: HIInfo.h:58
double b() const
The impact-parameter distance in the current event.
Definition: HIInfo.h:43
Definition: HINucleusModel.h:28
double sigmaTot() const
The Monte Carlo integrated total cross section in the current run.
Definition: HIInfo.h:53
int nCollCD() const
Definition: HIInfo.h:113
int nElTarg() const
Definition: HIInfo.h:147
int nPartTarg() const
Definition: HIInfo.h:135
virtual ~HIUserHooks()
Virtual destructor.
Definition: HIInfo.h:256
The SubCollisionSet gives a set of subcollisions between two nuclei.
Definition: HISubCollisionModel.h:84
Definition: HIInfo.h:248
double weightSum() const
The sum of weights of the produced events.
Definition: HIInfo.h:153
virtual bool hasSubCollisionModel()
Definition: HIInfo.h:277
virtual bool hasImpactParameterGenerator() const
A user-supplied impact parameter generator.
Definition: HIInfo.h:265
void failedExcitation()
Register a failed nucleon excitation.
Definition: HIInfo.h:161
double sigmaND() const
Definition: HIInfo.h:64
const SubCollisionSet * subCollisionsPtr()
Access to subcollision to be extracted by the user.
Definition: HIInfo.h:227
int nPartProj() const
The number of interacting projectile nucleons in the current event.
Definition: HIInfo.h:119
HIInfo * hiInfo
Definition: Info.h:113
double sigmaNDErr() const
The estimated statistical error on sigmaND().
Definition: HIInfo.h:69
int nCollDD() const
Definition: HIInfo.h:109
Definition: HISubCollisionModel.h:30
virtual bool hasProjectileModel() const
A user-supplied NucleusModel for the projectile and target.
Definition: HIInfo.h:270
HIUserHooks()
The default constructor is empty.
Definition: HIInfo.h:253
Class for storing Events and Info objects.
Definition: HIBasics.h:47
int idProjSave
Definition: HIInfo.h:317
int nAbsTarg() const
Definition: HIInfo.h:139
int nAbsProj() const
Definition: HIInfo.h:123
HIInfo()
Constructor.
Definition: HIInfo.h:35
int nCollNDTot() const
The total number of non-diffractive sub collisions in the current event.
Definition: HIInfo.h:97
virtual bool canFixIsoSpin() const
Definition: HIInfo.h:286
Header for classes to set beam momentum and interaction vertex spread.
Definition: Analysis.h:20
The Pythia class contains the top-level routines to generate an event.
Definition: Pythia.h:71
int nCollSDT() const
Definition: HIInfo.h:105
int nDiffTarg() const
Definition: HIInfo.h:143
double avNDb() const
Definition: HIInfo.h:75
virtual bool canForceHadronLevel() const
A user supplied wrapper around the Pythia::forceHadronLevel()
Definition: HIInfo.h:300
virtual bool hasEventOrdering() const
A user-supplied ordering of events in (inverse) hardness.
Definition: HIInfo.h:281
int nDiffProj() const
Definition: HIInfo.h:127
double phi() const
The impact parameter angle.
Definition: HIInfo.h:48
Definition: HeavyIons.h:31
Definition: Basics.h:32
The default HeavyIon model in Pythia.
Definition: HeavyIons.h:162
Definition: HIInfo.h:27
long nAccepted() const
The number of produced events.
Definition: HIInfo.h:85
int nCollTot() const
The total number of separate sub-collisions.
Definition: HIInfo.h:90