StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
HeavyIons.h
1 // HeavyIons.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 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 HeavyIons class which
7 // Provides Pythia with infrastructure to combine several nucleon
8 // collisions into a single heavy ion collision event. This file also
9 // includes the definition of the Angantyr class which implements the
10 // default model for heavy ion collisions in Pythia.
11 
12 #ifndef Pythia8_HeavyIons_H
13 #define Pythia8_HeavyIons_H
14 
15 #include "Pythia8/HIUserHooks.h"
16 #include "Pythia8/PhysicsBase.h"
17 
18 namespace Pythia8 {
19 
21 class Pythia;
22 
23 //==========================================================================
24 
30 
31 class HeavyIons : public PhysicsBase {
32 
33 public:
34 
38  HeavyIons(Pythia & mainPythiaIn)
39  : mainPythiaPtr(&mainPythiaIn), HIHooksPtr(0),
40  pythia(vector<Pythia*>(1, &mainPythiaIn)) {
41  }
42 
44  virtual ~HeavyIons() {}
45 
52  virtual bool init() = 0;
53 
58  virtual bool next() = 0;
59 
62  static void addSpecialSettings(Settings & settings);
63 
66  static bool isHeavyIon(Settings & settings);
67 
69  bool setHIUserHooksPtr(HIUserHooksPtr userHooksPtrIn) {
70  HIHooksPtr = userHooksPtrIn; return true;
71  }
72 
73 protected:
74 
78  void sumUpMessages(Info & in, string tag, const Info * other);
79 
82  void updateInfo();
83 
89  void clearProcessLevel(Pythia & pyt);
90 
92  static void setupSpecials(Settings & settings, string match);
93 
96  static void setupSpecials(Pythia & p, string match);
97 
101 
105 
108  HIUserHooksPtr HIHooksPtr;
109 
112  vector<Pythia *> pythia;
113 
115  vector<string> pythiaNames;
116 
119  vector<Info*> info;
120 
123  struct InfoGrabber : public UserHooks {
124 
126  Info * getInfo() {
127  return infoPtr;
128  }
129 
130  };
131 
132 public:
133 
138 
139  // Print out statistics.
140  virtual void stat();
141 
142 };
143 
144 //==========================================================================
145 
147 
148 class Angantyr: public HeavyIons {
149 
150 public:
151 
154  HADRON = 0,
155  MBIAS = 1,
156  SASD = 2,
157  SIGPP = 3,
158  SIGPN = 4,
159  SIGNP = 5,
160  SIGNN = 6,
161  ALL = 7
162  };
163 
164 public:
165 
169  Angantyr(Pythia & mainPythiaIn);
170 
171  virtual ~Angantyr();
172 
174  virtual bool init() override;
175 
177  virtual bool next() override;
178 
180  bool setUserHooksPtr(PythiaObject sel, UserHooksPtr userHooksPtrIn);
181 
183  vector<Nucleon>::iterator projBegin() {
184  return projectile.begin();
185  }
186  vector<Nucleon>::iterator targBegin() {
187  return target.begin();
188  }
189  vector<Nucleon>::iterator projEnd() {
190  return projectile.end();
191  }
192  vector<Nucleon>::iterator targEnd() {
193  return target.end();
194  }
195 
196 protected:
197 
198  virtual void onInitInfoPtr() override {
199  registerSubObject(sigtot); }
200 
203  bool init(PythiaObject sel, string name, int n = 0);
204 
206  EventInfo mkEventInfo(Pythia &, Info &, const SubCollision * coll = 0);
207 
209  EventInfo getSignal(const SubCollision & coll);
210  EventInfo getND() { return getMBIAS(0, 101); }
211  EventInfo getND(const SubCollision & coll) { return getMBIAS(&coll, 101); }
212  EventInfo getEl(const SubCollision & coll) { return getMBIAS(&coll, 102); }
213  EventInfo getSDP(const SubCollision & coll) { return getMBIAS(&coll, 103); }
214  EventInfo getSDT(const SubCollision & coll) { return getMBIAS(&coll, 104); }
215  EventInfo getDD(const SubCollision & coll) { return getMBIAS(&coll, 105); }
216  EventInfo getCD(const SubCollision & coll) { return getMBIAS(&coll, 106); }
217  EventInfo getSDabsP(const SubCollision & coll)
218  { return getSASD(&coll, 103); }
219  EventInfo getSDabsT(const SubCollision & coll)
220  { return getSASD(&coll, 104); }
221  EventInfo getMBIAS(const SubCollision * coll, int procid);
222  EventInfo getSASD(const SubCollision * coll, int procid);
223  bool genAbs(const multiset<SubCollision> & coll,
224  list<EventInfo> & subevents);
225  void addSASD(const multiset<SubCollision> & coll);
226  bool addDD(const multiset<SubCollision> & coll, list<EventInfo> & subevents);
227  bool addSD(const multiset<SubCollision> & coll, list<EventInfo> & subevents);
228  void addSDsecond(const multiset<SubCollision> & coll);
229  bool addCD(const multiset<SubCollision> & coll, list<EventInfo> & subevents);
230  void addCDsecond(const multiset<SubCollision> & coll);
231  bool addEL(const multiset<SubCollision> & coll, list<EventInfo> & subevents);
232  void addELsecond(const multiset<SubCollision> & coll);
233  bool buildEvent(list<EventInfo> & subevents,
234  const vector<Nucleon> & proj,
235  const vector<Nucleon> & targ);
236 
237  bool setupFullCollision(EventInfo & ei, const SubCollision & coll,
238  Nucleon::Status ptype, Nucleon::Status ttype);
239  bool isRemnant(const EventInfo & ei, int i, int past = 1 ) const {
240  int statNow = ei.event[i].status()*past;
241  if ( statNow == 63 ) return true;
242  if ( statNow > 70 && statNow < 80 )
243  return isRemnant(ei, ei.event[i].mother1(), -1);
244  return false;
245  }
246  bool fixIsoSpin(EventInfo & ei);
247  EventInfo & shiftEvent(EventInfo & ei);
248  static int getBeam(Event & ev, int i);
249 
251  bool nextSASD(int proc);
252 
255  bool addNucleonExcitation(EventInfo & orig, EventInfo & add,
256  bool colConnect = false);
257 
258  // Find the recoilers in the current event to conserve energy and
259  // momentum in addNucleonExcitation.
260  vector<int> findRecoilers(const Event & e, bool tside, int beam, int end,
261  const Vec4 & pdiff, const Vec4 & pbeam);
262 
264  void addSubEvent(Event & evnt, Event & sub);
265  static void addJunctions(Event & evnt, Event & sub, int coloff);
266 
269  bool addNucleusRemnants(const vector<Nucleon> & proj,
270  const vector<Nucleon> & targ);
271 
272 public:
273 
276  static bool
277  getTransforms(Vec4 p1, Vec4 p2, const Vec4 & p1p,
278  pair<RotBstMatrix,RotBstMatrix> & R12, int, int);
279  static double mT2(const Vec4 & p) { return p.pPos()*p.pNeg(); }
280  static double mT(const Vec4 & p) { return sqrt(max(mT2(p), 0.0)); }
281 
282 private:
283 
284  // Private UserHooks class to select a specific process.
285  struct ProcessSelectorHook: public UserHooks {
286 
287  ProcessSelectorHook(): proc(0), b(-1.0) {}
288 
289  // Yes we can veto event after process-level selection.
290  virtual bool canVetoProcessLevel() {
291  return true;
292  }
293 
294  // Veto any unwanted process.
295  virtual bool doVetoProcessLevel(Event&) {
296  return proc > 0 && infoPtr->code() != proc;
297  }
298 
299  // Can set the overall impact parameter for the MPI treatment.
300  virtual bool canSetImpactParameter() const {
301  return b >= 0.0;
302  }
303 
304  // Set the overall impact parameter for the MPI treatment.
305  virtual double doSetImpactParameter() {
306  return b;
307  }
308 
309  // The wanted process;
310  int proc;
311 
312  // The selected b-value.
313  double b;
314 
315  };
316 
317  // Holder class to temporarily select a specific process
318  struct HoldProcess {
319 
320  // Set the given process for the given hook object.
321  HoldProcess(shared_ptr<ProcessSelectorHook> hook, int proc,
322  double b = -1.0) : saveHook(hook), saveProc(hook->proc), saveB(hook->b) {
323  hook->proc = proc;
324  hook->b = b;
325  }
326 
327  // Reset the process of the hook object given in the constructor.
328  ~HoldProcess() {
329  if ( saveHook ) {
330  saveHook->proc = saveProc;
331  saveHook->b = saveB;
332  }
333  }
334 
335  // The hook object.
336  shared_ptr<ProcessSelectorHook> saveHook;
337 
338  // The previous process of the hook object.
339  int saveProc;
340 
341  // The previous b-value of the hook object.
342  double saveB;
343 
344  };
345 
346  // The process selector for standard minimum bias processes.
347  shared_ptr<ProcessSelectorHook> selectMB;
348 
349  // The process selector for the SASD object.
350  shared_ptr<ProcessSelectorHook> selectSASD;
351 
352 private:
353 
354  static const int MAXTRY = 999;
355  static const int MAXEVSAVE = 999;
356 
358  vector<Nucleon> projectile;
359  vector<Nucleon> target;
360 
362  multiset<SubCollision> subColls;
363 
366  bool hasSignal;
367 
369  ImpactParameterGenerator * bGenPtr;
370 
373  NucleusModel * projPtr;
374  NucleusModel * targPtr;
375 
378  SubCollisionModel * collPtr;
379 
382  int recoilerMode;
383 
385  int bMode;
386 
387 public:
388 
390  class Redirect {
391 
392  public:
393 
395  Redirect(ostream & os, ostream & ros)
396  : osSave(&os), bufferSave(os.rdbuf()) {
397  osSave->rdbuf(ros.rdbuf());
398  }
399 
400  ~Redirect() {
401  osSave->rdbuf(bufferSave);
402  }
403 
405  ostream * osSave;
406 
408  std::streambuf * bufferSave;
409 
410  };
411 
412 };
413 
414 //==========================================================================
415 
416 } // end namespace Pythia8
417 
418 #endif // Pythia8_HeavyIons_H
static bool getTransforms(Vec4 p1, Vec4 p2, const Vec4 &p1p, pair< RotBstMatrix, RotBstMatrix > &R12, int, int)
Definition: HeavyIons.cc:1293
HeavyIons(Pythia &mainPythiaIn)
Definition: HeavyIons.h:38
HIUserHooks * HIHooksPtr
Definition: HeavyIons.h:108
SigmaTotal sigtot
Definition: HeavyIons.h:104
ostream * osSave
The redirected ostream.
Definition: HeavyIons.h:364
Optional object for signal processes (nn).
Definition: HeavyIons.h:145
virtual bool next()
Produce a collision involving heavy ions.
Definition: HeavyIons.cc:1582
virtual ~HeavyIons()
Destructor.
Definition: HeavyIons.h:44
bool addNucleonExcitation(EventInfo &orig, EventInfo &add, bool colConnect=false)
Definition: HeavyIons.cc:1158
std::streambuf * bufferSave
The original buffer of the redirected ostream.
Definition: HeavyIons.h:367
static void addSpecialSettings(Settings &settings)
Definition: HeavyIons.cc:24
vector< Info * > info
Definition: HeavyIons.h:119
EventInfo getSignal(const SubCollision &coll)
Generate events from the internal Pythia oblects;.
Definition: HeavyIons.cc:594
bool nextSASD(int proc)
Generate a single diffractive.
Definition: HeavyIons.cc:1426
Optional object for signal processes (pp).
Definition: HeavyIons.h:142
PythiaObject
Enumerate the different internal Pythia objects.
Definition: HeavyIons.h:138
Minimum Bias processed.
Definition: HeavyIons.h:140
EventInfo mkEventInfo(Pythia &pyt, const SubCollision *coll=0)
Setup an EventInfo object from a Pythia instance.
Definition: HeavyIons.cc:319
Indicates all objects.
Definition: HeavyIons.h:146
Info * getInfo()
Only one function: return the info object.
Definition: HeavyIons.h:126
For hadronization only.
Definition: HeavyIons.h:139
vector< Pythia * > pythia
Definition: HeavyIons.h:112
void clearProcessLevel(Pythia &pyt)
Definition: HeavyIons.cc:126
bool setHIUserHooksPtr(HIUserHooksPtr userHooksPtrIn)
Possibility to pass in pointer for special heavy ion user hooks.
Definition: HeavyIons.h:69
Single diffractive as one side of non-diffractive.
Definition: HeavyIons.h:141
void sumUpMessages(Info &in, string tag, const Info &other)
Definition: HeavyIons.cc:115
vector< Nucleon >::iterator projBegin()
Iterate over nucleons.
Definition: HeavyIons.h:183
static void setupSpecials(Settings &settings, string match)
Duplicate setting on the form match: to settings on the form HImatch:
Definition: HeavyIons.cc:32
Optional object for signal processes (pn).
Definition: HeavyIons.h:143
virtual bool init()
Initialize Angantyr.
Definition: HeavyIons.cc:340
Pythia * mainPythiaPtr
Definition: HeavyIons.h:100
Optional object for signal processes (np).
Definition: HeavyIons.h:144
Angantyr(Pythia &mainPythiaIn)
Definition: HeavyIons.cc:272
Redirect(ostream &os, ostream &ros)
Redirect os to ros for the lifetime of this object.
Definition: HeavyIons.h:395
Definition: beam.h:43
Definition: AgUStep.h:26
bool setUserHooksPtr(PythiaObject sel, UserHooks *userHooksPtrIn)
Set UserHooks for specific (or ALL) internal Pythia objects.
Definition: HeavyIons.cc:307
HIUserHooksPtr HIHooksPtr
Definition: HeavyIons.h:108
bool addNucleusRemnants(const vector< Nucleon > &proj, const vector< Nucleon > &targ)
Definition: HeavyIons.cc:1497
virtual bool init()=0
Status
Enum for specifying the status of a nucleon.
Definition: HIUserHooks.h:69
virtual bool next()=0
vector< string > pythiaNames
The names associated with the secondary pythia objects.
Definition: HeavyIons.h:115
void addSubEvent(Event &evnt, Event &sub)
Add a sub-event to the final event record.
Definition: HeavyIons.cc:1372
internal class to redirect stdout
Definition: HeavyIons.h:349
The default HeavyIon model in Pythia.
Definition: HeavyIons.h:133
static bool isHeavyIon(Settings &settings)
Definition: HeavyIons.cc:258