StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
DireSplitInfo.h
1 // DireSplitInfo.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2020 Stefan Prestel, 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 // Header file for splitting information storage containers.
7 // DireSplitParticle: Quantum numbers and other information of one of the
8 // particles participating in current branching.
9 // DireSplitKinematics: Kinematical variables from which to construct a
10 // branching.
11 // DireSplitInfo: Particles participating in the current branching.
12 
13 #ifndef Pythia8_DireSplitInfo_H
14 #define Pythia8_DireSplitInfo_H
15 
16 #define DIRE_SPLITINFO_VERSION "2.002"
17 
18 #include "Pythia8/Event.h"
19 #include "Pythia8/PartonSystems.h"
20 #include "Pythia8/DireBasics.h"
21 
22 namespace Pythia8 {
23 
24 //==========================================================================
25 
26 // Definition of color chains.
27 
29 
30 public:
31 
33  DireSingleColChain(const DireSingleColChain& chainIn) : chain(chainIn.chain),
34  original_chain(chainIn.original_chain) {}
35  DireSingleColChain & operator=(const DireSingleColChain& c) { if (this != &c)
36  { chain = c.chain; original_chain = c.original_chain;} return *this; }
37  DireSingleColChain(int iPos, const Event& state,
38  PartonSystems* partonSysPtr);
39 
40  void addToChain(const int iPos, const Event& state);
41 
42  int iPosEnd() { return chain.back().first; }
43  int colEnd () { return chain.back().second.first; }
44  int acolEnd() { return chain.back().second.second; }
45  int size() const { return chain.size(); }
46  bool isInChain ( int iPos);
47  int posInChain ( int iPos);
48  bool colInChain ( int col);
49 
50  DireSingleColChain chainFromCol(int iPos, int col, int nSteps,
51  const Event& state);
52 
53  string listPos() const;
54 
55  // List functions by N. Fischer.
56  void print() const;
57  void list () const;
58  string list2 () const;
59 
60  void clear() { chain.resize(0); original_chain.resize(0); }
61 
62  vector<pair<int,pair<int,int> > > chain;
63  vector<pair<int,pair<int,int> > > original_chain;
64 
65  // Overload index operator to access element of event record.
66  pair<int,pair<int,int> >& operator[](int i) {return chain[i];}
67  const pair<int,pair<int,int> >& operator[](int i) const {return chain[i];}
68 
69 };
70 
71 //==========================================================================
72 
73 // Container for multiple color chains.
74 
76 
77 public:
78 
79  DireColChains() {}
80 
81  void addChain(DireSingleColChain chain) { chains.push_back( chain); }
82 
83  int size() const { return chains.size(); }
84 
85  DireSingleColChain chainOf (int iPos);
86 
87  DireSingleColChain chainFromCol (int iPos, int col, int nSteps,
88  const Event& state);
89 
90  int check(int iSys, const Event& state, PartonSystems* partonSysPtr);
91 
92  void list();
93 
94  vector<DireSingleColChain> chains;
95 
96 };
97 
98 //==========================================================================
99 
101 
102 public:
103 
104  DireSplitParticle() : id(0), col(-1), acol(-1), charge(0), spin(-9), m2(-1.),
105  isFinal(false) {}
106  DireSplitParticle( int idIn, int colIn, int acolIn, int chargeIn, int spinIn,
107  double m2In, bool isFinalIn) : id(idIn), col(colIn),
108  acol(acolIn), charge(chargeIn), spin(spinIn), m2(m2In), isFinal(isFinalIn)
109  {}
110  DireSplitParticle ( const Particle& in) : id(in.id()),
111  col(in.col()), acol(in.acol()), charge(in.charge()), spin(in.pol()),
112  m2(pow2(in.m())), isFinal(in.isFinal()) {}
113 
114  void store( int idIn, int colIn, int acolIn, int chargeIn, int spinIn,
115  double m2In, bool isFinalIn) { id = idIn; col = colIn;
116  acol = acolIn; charge = chargeIn; spin = spinIn; m2 = m2In;
117  isFinal = isFinalIn; }
118  void store( const Particle in) { id = in.id(); col = in.col();
119  acol = in.acol(); charge = in.charge(); spin = in.pol();
120  m2 = pow2(in.m()); isFinal = in.isFinal(); }
121 
122  void clear() { col = acol = -1; id = charge = 0; spin = -9; m2 = -1.;
123  isFinal = false; }
124 
125  // Quantum numbers.
126  int id, col, acol, charge, spin;
127 
128  // Mass.
129  double m2;
130 
131  // Incoming/final
132  bool isFinal;
133 
134 };
135 
136 //==========================================================================
137 
139 
140 public:
141 
142  DireSplitKinematics() : m2Dip(-1.), pT2(-1.), pT2Old(-1.), z(-1.), phi(-9.),
143  sai(0.), xa(-1), phi2(-9.), m2RadBef(-1.), m2Rec(-1.), m2RadAft(-1.),
144  m2EmtAft(-1.), m2EmtAft2(-1.), xBef(-1.), xAft(-1.) {}
145 
146  DireSplitKinematics( double m2DipIn, double pT2In, double zIn, double phiIn,
147  double saiIn, double xaIn, double phi2In, double m2RadBefIn,
148  double m2RecIn, double m2RadAftIn, double m2EmtAftIn, double m2EmtAft2In,
149  double xBefIn, double xAftIn )
150  : m2Dip(m2DipIn), pT2(pT2In), pT2Old(-1.), z(zIn), phi(phiIn),
151  sai(saiIn), xa(xaIn), phi2(phi2In), m2RadBef(m2RadBefIn), m2Rec(m2RecIn),
152  m2RadAft(m2RadAftIn), m2EmtAft(m2EmtAftIn), m2EmtAft2(m2EmtAft2In),
153  xBef(xBefIn), xAft(xAftIn) {}
154 
155  void store2to3kine( double m2DipIn, double pT2In, double zIn, double phiIn,
156  double xAftIn = -1.) {
157  m2Dip = m2DipIn; pT2 = pT2In; z = zIn; phi = phiIn; xAft = xAftIn; }
158  void store2to3mass( double m2RadBefIn, double m2RecIn, double m2RadAftIn,
159  double m2EmtAftIn) { m2RadBef = m2RadBefIn; m2Rec = m2RecIn;
160  m2RadAft = m2RadAftIn; m2EmtAft = m2EmtAftIn; }
161 
162  void store2to4kine( double m2DipIn, double pT2In, double zIn, double phiIn,
163  double saiIn, double xaIn, double phi2In, double xAftIn = -1.) {
164  m2Dip = m2DipIn;
165  pT2 = pT2In; z = zIn; phi = phiIn; sai = saiIn; xa = xaIn; phi2 = phi2In;
166  xAft = xAftIn;}
167  void store2to4mass( double m2RadBefIn, double m2RecIn, double m2RadAftIn,
168  double m2EmtAftIn, double m2EmtAft2In) {
169  m2RadBef = m2RadBefIn; m2Rec = m2RecIn; m2RadAft = m2RadAftIn;
170  m2EmtAft = m2EmtAftIn; m2EmtAft2 = m2EmtAft2In; }
171 
172  void set_m2Dip ( double in) {m2Dip=(in);}
173  void set_pT2 ( double in) {pT2=(in);}
174  void set_pT2Old ( double in) {pT2Old=(in);}
175  void set_z ( double in) {z=(in);}
176  void set_phi ( double in) {phi=(in);}
177  void set_sai ( double in) {sai=(in);}
178  void set_xa ( double in) {xa=(in);}
179  void set_phi2 ( double in) {phi2=(in);}
180  void set_m2RadBef ( double in) {m2RadBef=(in);}
181  void set_m2Rec ( double in) {m2Rec=(in);}
182  void set_m2RadAft ( double in) {m2RadAft=(in);}
183  void set_m2EmtAft ( double in) {m2EmtAft=(in);}
184  void set_m2EmtAft2 ( double in) {m2EmtAft2=(in);}
185  void set_xBef ( double in) {xBef=(in);}
186  void set_xAft ( double in) {xAft=(in);}
187 
188  void clear() { m2Dip = pT2 = pT2Old = z = xa = m2RadBef = m2Rec = m2RadAft
189  = m2EmtAft = m2EmtAft2 = xBef = xAft = -1.; sai = 0.; phi = phi2 = -9.; }
190 
191  void store ( const DireSplitKinematics& k);
192 
193  void list();
194 
195  unordered_map<string,double> getKinInfo() {
196  return create_unordered_map<string,double> ("m2Dip",m2Dip)("pT2",pT2)
197  ("pT2Old",pT2Old)
198  ("z",z)("phi",phi)("sai",sai)("xa",xa)("phi2",phi2)("m2RadBef",m2RadBef)
199  ("m2Rec",m2Rec)("m2RadAft",m2RadAft)("m2EmtAft",m2EmtAft)
200  ("m2EmtAft2",m2EmtAft2)("xBef",xBef) ("xAft",xAft);
201  }
202 
203  // Kinematic variable to enable branching.
204  double m2Dip, pT2, pT2Old, z, phi, sai, xa, phi2,
205  m2RadBef, m2Rec, m2RadAft, m2EmtAft, m2EmtAft2;
206  double xBef, xAft;
207 
208 };
209 
210 //==========================================================================
211 
213 
214 public:
215 
216  DireSplitInfo() : iRadBef(0), iRecBef(0), iRadAft(0), iRecAft(0), iEmtAft(0),
217  iEmtAft2(0), side(0), type(0), system(0), systemRec(0),
218  splittingSelName(""), useForBranching(false), terminateEvolution(false),
219  iRadBefStore(-1), iRecBefStore(-1), iRadAftStore(-1), iRecAftStore(-1),
220  iEmtAftStore(-1), iEmtAft2Store(-1), sideStore(-1), typeStore(-1),
221  systemStore(-1), systemRecStore(-1), splittingSelNameStore(""),
222  useForBranchingStore(false), terminateEvolutionStore(false) {
223  init(); }
224  DireSplitInfo ( const Event& state, int iRadBefIn, int iRecBefIn,
225  int iRadAftIn, int iRecAftIn, int iEmtAftIn,
226  double m2DipIn = -1., double pT2In = -1., double zIn = -1.,
227  double phiIn = -9., double saiIn = 0., double xaIn = -1.,
228  double phi2In = -9., double m2RadBefIn = -1., double m2RecIn = -1.,
229  double m2RadAftIn = -1., double m2EmtAftIn = -1., double m2EmtAft2In = -1.,
230  double xBefIn = -1., double xAftIn = -1.,
231  int sideIn = 0, int typeIn = 0, int systemIn = 0, int systemRecIn = 0,
232  string splittingSelNameIn = "", bool useForBranchingIn = false,
233  DireSingleColChain iSiblingsIn = DireSingleColChain() ) :
234  iRadBef(iRadBefIn), iRecBef(iRecBefIn),
235  iRadAft(iRadAftIn), iRecAft(iRecAftIn), iEmtAft(iEmtAftIn),
236  kinSave(m2DipIn, pT2In, zIn, phiIn, saiIn, xaIn, phi2In, m2RadBefIn,
237  m2RecIn, m2RadAftIn, m2EmtAftIn, m2EmtAft2In, xBefIn, xAftIn),
238  side(sideIn), type(typeIn), system(systemIn), systemRec(systemRecIn),
239  splittingSelName(splittingSelNameIn), useForBranching(useForBranchingIn),
240  terminateEvolution(false), iSiblings(iSiblingsIn)
241  { init(state); }
242 
243  DireSplitInfo ( const Event& state, int iRadBefIn, int iRecBefIn,
244  string splittingSelNameIn) : iRadBef(iRadBefIn), iRecBef(iRecBefIn),
245  splittingSelName(splittingSelNameIn),
246  iRadBefStore(-1), iRecBefStore(-1), iRadAftStore(-1), iRecAftStore(-1),
247  iEmtAftStore(-1), iEmtAft2Store(-1), sideStore(-1), typeStore(-1),
248  systemStore(-1), systemRecStore(-1), splittingSelNameStore(""),
249  useForBranchingStore(false), terminateEvolutionStore(false) {
250  iRadAft = iRecAft = iEmtAft = side = type = system = systemRec = 0;
251  useForBranching = terminateEvolution = false; init(state); }
252 
253  DireSplitInfo ( const Event& state, int iRadAftIn, int iRecAftIn,
254  int iEmtAftIn, string splittingSelNameIn) :
255  iRadAft(iRadAftIn), iRecAft(iRecAftIn),
256  iEmtAft(iEmtAftIn), splittingSelName(splittingSelNameIn),
257  iRadBefStore(-1), iRecBefStore(-1), iRadAftStore(-1), iRecAftStore(-1),
258  iEmtAftStore(-1), iEmtAft2Store(-1), sideStore(-1), typeStore(-1),
259  systemStore(-1), systemRecStore(-1), splittingSelNameStore(""),
260  useForBranchingStore(false), terminateEvolutionStore(false) {
261  splittingSelName = ""; iRadBef = iRecBef = side = type = system
262  = systemRec = 0;
263  useForBranching = terminateEvolution = false; init(state); }
264 
265  DireSplitInfo ( const DireSplitInfo& s) : iRadBefStore(-1), iRecBefStore(-1),
266  iRadAftStore(-1), iRecAftStore(-1), iEmtAftStore(-1), iEmtAft2Store(-1),
267  sideStore(-1), typeStore(-1), systemStore(-1), systemRecStore(-1),
268  particleSaveStore(), kinSaveStore(), splittingSelNameStore(),
269  extrasStore(), useForBranchingStore(false), terminateEvolutionStore(false),
270  iSiblingsStore() {
271  iRadBef = s.iRadBef;
272  iRecBef = s.iRecBef;
273  iRadAft = s.iRadAft;
274  iRecAft = s.iRecAft;
275  iEmtAft = s.iEmtAft;
276  iEmtAft2 = s.iEmtAft2;
277  for (int i=0; i < int(s.particleSave.size()); ++i)
278  particleSave.push_back(s.particleSave[i]);
279  kinSave.store(s.kinSave);
280  side = s.side;
281  type = s.type;
282  system = s.system;
283  systemRec = s.systemRec;
284  splittingSelName = s.splittingSelName;
285  for ( unordered_map<string,double>::const_iterator it = s.extras.begin();
286  it != s.extras.end(); ++it )
287  extras.insert(make_pair(it->first,it->second));
288  useForBranching = s.useForBranching;
289  terminateEvolution = s.terminateEvolution;
290  iSiblings = s.iSiblings;
291  }
292 
293  void init(const Event& state = Event() );
294 
295  void store (const DireSplitInfo& s);
296 
297  void save ();
298 
299  void restore ();
300 
301  const DireSplitParticle* radBef() const { return &particleSave[0]; }
302  const DireSplitParticle* recBef() const { return &particleSave[1]; }
303  const DireSplitParticle* radAft() const { return &particleSave[2]; }
304  const DireSplitParticle* recAft() const { return &particleSave[3]; }
305  const DireSplitParticle* emtAft() const { return &particleSave[4]; }
306  const DireSplitParticle* emtAft2() const { return &particleSave[5]; }
307 
308  const DireSplitKinematics* kinematics() const { return &kinSave; }
309 
310  void set2to3kin( double m2DipIn, double pT2In, double zIn, double phiIn,
311  double m2RadBefIn, double m2RecIn, double m2RadAftIn, double m2EmtAftIn) {
312  kinSave.store2to3kine(m2DipIn, pT2In, zIn, phiIn);
313  kinSave.store2to3mass(m2RadBefIn, m2RecIn, m2RadAftIn, m2EmtAftIn); }
314 
315  void set2to4kin( double m2DipIn, double pT2In, double zIn, double phiIn,
316  double saiIn, double xaIn, double phi2In, double m2RadBefIn,
317  double m2RecIn, double m2RadAftIn, double m2EmtAftIn, double m2EmtAft2In) {
318  kinSave.store2to4kine(m2DipIn, pT2In, zIn, phiIn, saiIn, xaIn, phi2In);
319  kinSave.store2to4mass(m2RadBefIn, m2RecIn, m2RadAftIn, m2EmtAftIn,
320  m2EmtAft2In); }
321 
322  void set_m2Dip ( double in) {kinSave.set_m2Dip(in);}
323  void set_pT2 ( double in) {kinSave.set_pT2(in);}
324  void set_pT2Old ( double in) {kinSave.set_pT2Old(in);}
325  void set_z ( double in) {kinSave.set_z(in);}
326  void set_phi ( double in) {kinSave.set_phi(in);}
327  void set_sai ( double in) {kinSave.set_sai(in);}
328  void set_xa ( double in) {kinSave.set_xa(in);}
329  void set_phi2 ( double in) {kinSave.set_phi2(in);}
330  void set_m2RadBef ( double in) {kinSave.set_m2RadBef(in);}
331  void set_m2Rec ( double in) {kinSave.set_m2Rec(in);}
332  void set_m2RadAft ( double in) {kinSave.set_m2RadAft(in);}
333  void set_m2EmtAft ( double in) {kinSave.set_m2EmtAft(in);}
334  void set_m2EmtAft2 ( double in) {kinSave.set_m2EmtAft2(in);}
335  void set_xBef ( double in) {kinSave.set_xBef(in);}
336  void set_xAft ( double in) {kinSave.set_xAft(in);}
337 
338  void storeRadBef(const Particle& in)
339  { particleSave[0].store(in); }
340  void storeRecBef(const Particle& in)
341  { particleSave[1].store(in); }
342  void storeRadAft(const Particle& in)
343  { particleSave[2].store(in); }
344  void storeRecAft(const Particle& in)
345  { particleSave[3].store(in); }
346  void storeEmtAft(const Particle& in)
347  { particleSave[4].store(in); }
348  void storeEmtAft2(const Particle& in)
349  { particleSave[5].store(in); }
350 
351  void setRadBef( int idIn = 0, int colIn = -1, int acolIn = -1,
352  int chargeIn = 0, int spinIn = -9, double m2In = -1.0,
353  bool isFinalIn = false) { setParticle(0, idIn, colIn,
354  acolIn, chargeIn, spinIn, m2In, isFinalIn); }
355  void setRecBef( int idIn = 0, int colIn = -1, int acolIn = -1,
356  int chargeIn = 0, int spinIn = -9, double m2In = -1.0,
357  bool isFinalIn = false) { setParticle(1, idIn, colIn,
358  acolIn, chargeIn, spinIn, m2In, isFinalIn); }
359  void setRadAft( int idIn = 0, int colIn = -1, int acolIn = -1,
360  int chargeIn = 0, int spinIn = -9, double m2In = -1.0,
361  bool isFinalIn = false) { setParticle(2, idIn, colIn,
362  acolIn, chargeIn, spinIn, m2In, isFinalIn); }
363  void setRecAft( int idIn = 0, int colIn = -1, int acolIn = -1,
364  int chargeIn = 0, int spinIn = -9, double m2In = -1.0,
365  bool isFinalIn = false) { setParticle(3, idIn, colIn,
366  acolIn, chargeIn, spinIn, m2In, isFinalIn); }
367  void setEmtAft( int idIn = 0, int colIn = -1, int acolIn = -1,
368  int chargeIn = 0, int spinIn = -9, double m2In = -1.0,
369  bool isFinalIn = false) { setParticle(4, idIn, colIn,
370  acolIn, chargeIn, spinIn, m2In, isFinalIn); }
371  void setEmtAft2( int idIn = 0, int colIn = -1, int acolIn = -1,
372  int chargeIn = 0, int spinIn = -9, double m2In = -1.0,
373  bool isFinalIn = false) { setParticle(5, idIn, colIn,
374  acolIn, chargeIn, spinIn, m2In, isFinalIn); }
375  void clearRadBef() { setParticle(0, 0, -1, -1, 0, -9, -1.0, false); }
376  void clearRecBef() { setParticle(1, 0, -1, -1, 0, -9, -1.0, false); }
377  void clearRadAft() { setParticle(2, 0, -1, -1, 0, -9, -1.0, false); }
378  void clearRecAft() { setParticle(3, 0, -1, -1, 0, -9, -1.0, false); }
379  void clearEmtAft() { setParticle(4, 0, -1, -1, 0, -9, -1.0, false); }
380  void clearEmtAft2() { setParticle(5, 0, -1, -1, 0, -9, -1.0, false); }
381  void setParticle( int iPos, int idIn = 0, int colIn = -1, int acolIn = -1,
382  int chargeIn = 0, int spinIn = -9, double m2In = -1.0,
383  bool isFinalIn = false) { particleSave[iPos].store(
384  idIn, colIn, acolIn, chargeIn, spinIn, m2In, isFinalIn); }
385 
386  void storeName (string name) { splittingSelName = name; }
387  void storeType ( int in) { type = in; }
388  void storeSystem ( int in) { system = in; }
389  void storeSystemRec ( int in) { systemRec = in; }
390  void storeSide ( int in) { side = in; }
391  void storeExtras ( unordered_map<string,double> in) { extras = in; }
392  void storeRadRecBefPos (int rad, int rec) { iRadBef = rad; iRecBef = rec; }
393  void canUseForBranching (bool in) { useForBranching = in;}
394 
395  void addExtra(string key, double value) {
396  unordered_map<string, double>::iterator it = extras.find(key);
397  if (it == extras.end()) extras.insert(make_pair(key,value));
398  else it->second = value;
399  }
400 
401  void storeInfo(string name, int typeIn, int systemIn, int systemRecIn,
402  int sideIn, int iPosRadBef, int iPosRecBef,
403  const Event& state, int idEmtAft,
404  int idRadAft, int nEmissions, double m2Dip, double pT2, double pT2Old,
405  double z, double phi, double m2Bef, double m2s, double m2r, double m2i,
406  double sa1, double xa, double phia1, double m2j, double xBef, double xAft);
407 
408  unordered_map<string,double> getKinInfo() { return kinSave.getKinInfo();}
409 
410  void storePosAfter( int iRadAftIn, int iRecAftIn, int iEmtAftIn,
411  int iEmtAft2In);
412 
413  void clear();
414 
415  void list();
416 
417  // Information to enable branching.
418  int iRadBef, iRecBef;
419 
420  // Information to enable clustering.
421  int iRadAft, iRecAft, iEmtAft, iEmtAft2;
422 
423  vector<DireSplitParticle> particleSave;
424  DireSplitKinematics kinSave;
425 
426  // Auxiliary information.
427  int side, type, system, systemRec;
428  string splittingSelName;
429  unordered_map<string,double> extras;
430 
431  bool useForBranching, terminateEvolution;
432 
433  // Information to enable branching.
434  int iRadBefStore, iRecBefStore, iRadAftStore, iRecAftStore, iEmtAftStore,
435  iEmtAft2Store, sideStore, typeStore, systemStore, systemRecStore;
436  vector<DireSplitParticle> particleSaveStore;
437  DireSplitKinematics kinSaveStore;
438  string splittingSelNameStore;
439  unordered_map<string,double> extrasStore;
440  bool useForBranchingStore, terminateEvolutionStore;
441 
442  DireSingleColChain iSiblings, iSiblingsStore;
443  void setSiblings(DireSingleColChain s) { clearSiblings(); iSiblings = s; }
444  void clearSiblings() { iSiblings.clear(); }
445 
446 };
447 
448 //==========================================================================
449 
450 } // end namespace Pythia8
451 
452 #endif // end Pythia8_DireSplitInfo_H
Sparse class to hold track kinematics.