StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ParticleData.h
1 // ParticleData.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2018 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 the classes containing particle data.
7 // DecayChannel contains info on a single decay channel.
8 // ParticleDataEntry contains info on a single particle species.
9 // ParticleData collects info on all particles as a map.
10 
11 #ifndef Pythia8_ParticleData_H
12 #define Pythia8_ParticleData_H
13 
14 #include "Pythia8/Basics.h"
15 #include "Pythia8/Info.h"
16 #include "Pythia8/PythiaStdlib.h"
17 #include "Pythia8/Settings.h"
18 #include "Pythia8/StandardModel.h"
19 
20 namespace Pythia8 {
21 
22 //==========================================================================
23 
24 // Forward reference to some classes.
25 class ParticleData;
26 class ResonanceWidths;
27 class Couplings;
28 class CoupSUSY;
29 class SUSYResonanceWidths;
30 
31 //==========================================================================
32 
33 // This class holds info on a single decay channel.
34 
35 class DecayChannel {
36 
37 public:
38 
39  // Constructor.
40  DecayChannel(int onModeIn = 0, double bRatioIn = 0., int meModeIn = 0,
41  int prod0 = 0, int prod1 = 0, int prod2 = 0, int prod3 = 0,
42  int prod4 = 0, int prod5 = 0, int prod6 = 0, int prod7 = 0)
43  : onModeSave(onModeIn), bRatioSave(bRatioIn), currentBRSave(0.),
44  onShellWidthSave(0.), openSecPos(1.), openSecNeg(1.),
45  meModeSave(meModeIn), nProd(0), hasChangedSave(true) {
46  prod[0] = prod0; prod[1] = prod1; prod[2] = prod2; prod[3] = prod3;
47  prod[4] = prod4; prod[5] = prod5; prod[6] = prod6; prod[7] = prod7;
48  for (int j = 0; j < 8; ++j) if (prod[j] != 0 && j == nProd) ++nProd; }
49 
50  // Copy constructor.
51  DecayChannel& operator=( const DecayChannel& oldDC) { if (this != &oldDC) {
52  onModeSave = oldDC.onModeSave; bRatioSave = oldDC.bRatioSave;
53  currentBRSave = oldDC.currentBRSave;
54  onShellWidthSave = oldDC.onShellWidthSave; openSecPos = oldDC.openSecPos;
55  openSecNeg = oldDC.openSecNeg; meModeSave = oldDC.meModeSave;
56  nProd = oldDC.nProd; for (int j = 0; j < 8; ++j) prod[j] = oldDC.prod[j];
57  hasChangedSave = oldDC.hasChangedSave; } return *this; }
58 
59  // Member functions for input.
60  void onMode(int onModeIn) {onModeSave = onModeIn; hasChangedSave = true;}
61  void bRatio(double bRatioIn, bool countAsChanged = true) {
62  bRatioSave = bRatioIn; if (countAsChanged) hasChangedSave = true;}
63  void rescaleBR(double fac) {bRatioSave *= fac; hasChangedSave = true;}
64  void meMode(int meModeIn) {meModeSave = meModeIn; hasChangedSave = true;}
65  void multiplicity(int multIn) {nProd = multIn; hasChangedSave = true;}
66  void product(int i, int prodIn) {prod[i] = prodIn; nProd = 0;
67  for (int j = 0; j < 8; ++j) if (prod[j] != 0 && j == nProd) ++nProd;
68  hasChangedSave = true;}
69  void setHasChanged(bool hasChangedIn) {hasChangedSave = hasChangedIn;}
70 
71  // Member functions for output.
72  int onMode() const {return onModeSave;}
73  double bRatio() const {return bRatioSave;}
74  int meMode() const {return meModeSave;}
75  int multiplicity() const {return nProd;}
76  int product(int i) const {return (i >= 0 && i < nProd) ? prod[i] : 0;}
77  bool hasChanged() const { return hasChangedSave;}
78 
79  // Check for presence of particles anywhere in decay list.
80  bool contains(int id1) const;
81  bool contains(int id1, int id2) const;
82  bool contains(int id1, int id2, int id3) const;
83 
84  // Input/output for current selection of decay modes.
85  // Takes into account on/off switches and dynamic width for resonances.
86  void currentBR(double currentBRIn) {currentBRSave = currentBRIn;}
87  double currentBR() const {return currentBRSave;}
88 
89  // Input/output for nominal partial width; used by resonances.
90  void onShellWidth(double onShellWidthIn) {
91  onShellWidthSave = onShellWidthIn;}
92  double onShellWidth() const {return onShellWidthSave;}
93  void onShellWidthFactor(double factor) {onShellWidthSave *= factor;}
94 
95  // Input/output for fraction of secondary open widths; used by resonances.
96  void openSec(int idSgn, double openSecIn) {
97  if (idSgn > 0) openSecPos = openSecIn; else openSecNeg = openSecIn;}
98  double openSec(int idSgn) const {
99  return (idSgn > 0) ? openSecPos : openSecNeg;}
100 
101 private:
102 
103  // Decay channel info.
104  int onModeSave;
105  double bRatioSave, currentBRSave, onShellWidthSave, openSecPos,
106  openSecNeg;
107  int meModeSave, nProd, prod[8];
108  bool hasChangedSave;
109 
110 };
111 
112 //==========================================================================
113 
114 // This class holds info on a single particle species.
115 
116 class ParticleDataEntry {
117 
118 public:
119 
120  // Constructors: for antiparticle exists or not.
121  ParticleDataEntry(int idIn = 0, string nameIn = " ",
122  int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0,
123  double m0In = 0., double mWidthIn = 0., double mMinIn = 0.,
124  double mMaxIn = 0., double tau0In = 0.) : idSave(abs(idIn)),
125  nameSave(nameIn), antiNameSave("void"), spinTypeSave(spinTypeIn),
126  chargeTypeSave(chargeTypeIn), colTypeSave(colTypeIn), m0Save(m0In),
127  mWidthSave (mWidthIn), mMinSave(mMinIn), mMaxSave(mMaxIn),
128  tau0Save(tau0In), hasAntiSave(false), hasChangedSave(true),
129  resonancePtr(0) {setDefaults();}
130  ParticleDataEntry(int idIn, string nameIn, string antiNameIn,
131  int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0,
132  double m0In = 0., double mWidthIn = 0., double mMinIn = 0.,
133  double mMaxIn = 0., double tau0In = 0.) : idSave(abs(idIn)),
134  nameSave(nameIn), antiNameSave(antiNameIn), spinTypeSave(spinTypeIn),
135  chargeTypeSave(chargeTypeIn), colTypeSave(colTypeIn), m0Save(m0In),
136  mWidthSave (mWidthIn), mMinSave(mMinIn), mMaxSave(mMaxIn),
137  tau0Save(tau0In), hasAntiSave(true), hasChangedSave(true),
138  resonancePtr(0) {setDefaults();
139  if (toLower(antiNameIn) == "void") hasAntiSave = false;}
140 
141  // Copy constructor.
142  ParticleDataEntry& operator=( const ParticleDataEntry& oldPDE) {
143  if (this != &oldPDE) { idSave = oldPDE.idSave;
144  nameSave = oldPDE.nameSave; antiNameSave = oldPDE.antiNameSave;
145  spinTypeSave = oldPDE.spinTypeSave; chargeTypeSave = oldPDE.chargeTypeSave;
146  colTypeSave = oldPDE.colTypeSave; m0Save = oldPDE.m0Save;
147  mWidthSave = oldPDE.mWidthSave; mMinSave = oldPDE.mMinSave;
148  mMaxSave = oldPDE.mMaxSave; tau0Save = oldPDE.tau0Save;
149  constituentMassSave = oldPDE.constituentMassSave;
150  hasAntiSave = oldPDE.hasAntiSave; isResonanceSave = oldPDE.isResonanceSave;
151  mayDecaySave = oldPDE.mayDecaySave; doExternalDecaySave
152  = oldPDE.doExternalDecaySave; isVisibleSave = oldPDE.isVisibleSave;
153  doForceWidthSave = oldPDE.doForceWidthSave; hasChangedSave
154  = oldPDE.hasChangedSave; hasChangedMMinSave = oldPDE.hasChangedMMinSave;
155  hasChangedMMaxSave = oldPDE.hasChangedMMaxSave;
156  modeBWnow = oldPDE.modeBWnow; atanLow = oldPDE.atanLow;
157  atanDif = oldPDE.atanDif; mThr = oldPDE.mThr;
158  for (int i = 0; i < int(oldPDE.channels.size()); ++i) {
159  DecayChannel oldDC = oldPDE.channels[i]; channels.push_back(oldDC); }
160  currentBRSum = oldPDE.currentBRSum; resonancePtr = 0;
161  particleDataPtr = 0; } return *this; }
162 
163  // Destructor: delete any ResonanceWidths object.
164  ~ParticleDataEntry();
165 
166  // Initialization of some particle flags.
167  void setDefaults();
168 
169  // Store pointer to whole particle data table/database.
170  void initPtr( ParticleData* particleDataPtrIn) {
171  particleDataPtr = particleDataPtrIn;}
172 
173  // Reset all the properties of an existing particle.
174  void setAll(string nameIn, string antiNameIn, int spinTypeIn = 0,
175  int chargeTypeIn = 0, int colTypeIn = 0, double m0In = 0.,
176  double mWidthIn = 0., double mMinIn = 0., double mMaxIn = 0.,
177  double tau0In = 0.)
178  {nameSave = nameIn; antiNameSave = antiNameIn; hasAntiSave = true;
179  if (toLower(antiNameIn) == "void") hasAntiSave = false;
180  spinTypeSave = spinTypeIn; chargeTypeSave = chargeTypeIn;
181  colTypeSave = colTypeIn; m0Save = m0In; mWidthSave = mWidthIn;
182  setMMin(mMinIn); setMMax(mMaxIn); tau0Save = tau0In;
183  setDefaults(); hasChangedSave = true;}
184 
185  // Change current values one at a time (or set if not set before).
186  // (Must use set here since else name+signature clash with get methods.)
187  void setName(string nameIn) {nameSave = nameIn; hasChangedSave = true;}
188  void setAntiName(string antiNameIn) {antiNameSave = antiNameIn;
189  hasAntiSave = (toLower(antiNameIn) != "void"); hasChangedSave = true;}
190  void setNames(string nameIn, string antiNameIn) {nameSave = nameIn;
191  antiNameSave = antiNameIn; hasAntiSave = (toLower(antiNameIn) != "void");
192  hasChangedSave = true;}
193  void setSpinType(int spinTypeIn) {spinTypeSave = spinTypeIn;
194  hasChangedSave = true;}
195  void setChargeType(int chargeTypeIn) {chargeTypeSave = chargeTypeIn;
196  hasChangedSave = true;}
197  void setColType(int colTypeIn) {colTypeSave = colTypeIn;
198  hasChangedSave = true;}
199  void setM0(double m0In) {m0Save = m0In; setConstituentMass();
200  hasChangedSave = true;}
201  void setMWidth(double mWidthIn, bool countAsChanged = true) {
202  mWidthSave = mWidthIn; if (countAsChanged) hasChangedSave = true;}
203  void setMMin(double mMinIn) {mMinSave = mMinIn; hasChangedSave = true;
204  hasChangedMMinSave=true;}
205  void setMMax(double mMaxIn) {mMaxSave = mMaxIn; hasChangedSave = true;
206  hasChangedMMaxSave=true;}
207  // Special options specifically when cutting wings of Breit-Wigners.
208  void setMMinNoChange(double mMinIn) {mMinSave = mMinIn;}
209  void setMMaxNoChange(double mMaxIn) {mMaxSave = mMaxIn;}
210  void setTau0(double tau0In) {tau0Save = tau0In; hasChangedSave = true;}
211  void setIsResonance(bool isResonanceIn) {isResonanceSave = isResonanceIn;
212  hasChangedSave = true;}
213  void setMayDecay(bool mayDecayIn, bool countAsChanged = true) {
214  mayDecaySave = mayDecayIn; if (countAsChanged) hasChangedSave = true;}
215  void setDoExternalDecay(bool doExternalDecayIn)
216  {doExternalDecaySave = doExternalDecayIn; hasChangedSave = true;}
217  void setIsVisible(bool isVisibleIn) {isVisibleSave = isVisibleIn;
218  hasChangedSave = true;}
219  void setDoForceWidth(bool doForceWidthIn) {doForceWidthSave = doForceWidthIn;
220  hasChangedSave = true;}
221  void setHasChanged(bool hasChangedIn) {hasChangedSave = hasChangedIn;
222  for (int i = 0; i < int(channels.size()); ++i)
223  channels[i].setHasChanged(hasChangedIn);
224  if (!hasChangedIn) {hasChangedMMinSave=false; hasChangedMMaxSave=false;}}
225 
226  // Give back current values.
227  int id() const { return idSave; }
228  bool hasAnti() const { return hasAntiSave; }
229  string name(int idIn = 1) const {
230  return (idIn > 0) ? nameSave : antiNameSave; }
231  int spinType() const {return spinTypeSave; }
232  int chargeType(int idIn = 1) const {
233  return (idIn > 0) ? chargeTypeSave : -chargeTypeSave; }
234  double charge(int idIn = 1) const {
235  return (idIn > 0) ? chargeTypeSave / 3. : -chargeTypeSave / 3.; }
236  int colType(int idIn = 1) const {
237  if (colTypeSave == 2) return colTypeSave;
238  return (idIn > 0) ? colTypeSave : -colTypeSave; }
239  double m0() const { return m0Save; }
240  double mWidth() const { return mWidthSave; }
241  double mMin() const { return mMinSave; }
242  double mMax() const { return mMaxSave; }
243  double m0Min() const {
244  return (modeBWnow == 0) ? m0Save : mMinSave; }
245  double m0Max() const {
246  return (modeBWnow == 0) ? m0Save : mMaxSave; }
247  double tau0() const { return tau0Save; }
248  bool isResonance() const { return isResonanceSave; }
249  bool mayDecay() const { return mayDecaySave; }
250  bool doExternalDecay() const { return doExternalDecaySave; }
251  bool isVisible() const { return isVisibleSave; }
252  bool doForceWidth() const { return doForceWidthSave; }
253  bool hasChanged() const { if (hasChangedSave) return true;
254  for (int i = 0; i < int(channels.size()); ++i)
255  if (channels[i].hasChanged()) return true;
256  return false;}
257  bool hasChangedMMin() const { return hasChangedMMinSave; }
258  bool hasChangedMMax() const { return hasChangedMMaxSave; }
259 
260  // Set and give back several mass-related quantities.
261  void initBWmass();
262  double constituentMass() const { return constituentMassSave; }
263  double mSel();
264  double mRun(double mH);
265 
266  // Give back other quantities.
267  bool useBreitWigner() const { return (modeBWnow > 0); }
268  bool canDecay() const { return (channels.size() > 0);}
269  bool isLepton() const { return (idSave > 10 && idSave < 19);}
270  bool isQuark() const { return (idSave != 0 && idSave < 9);}
271  bool isGluon() const { return (idSave == 21);}
272  bool isDiquark() const { return (idSave > 1000 && idSave < 10000
273  && (idSave/10)%10 == 0);}
274  bool isParton() const { return ( idSave == 21
275  || (idSave != 0 && idSave < 6)
276  || (idSave > 1000 && idSave < 5510 && (idSave/10)%10 == 0) );}
277  bool isHadron() const;
278  bool isMeson() const;
279  bool isBaryon() const;
280 
281  // Intermediate octet ccbar or bbar states in colour-octet model.
282  bool isOctetHadron() const {return idSave >= 9940000
283  && idSave < 9960000; }
284  int heaviestQuark(int idIn = 1) const;
285  int baryonNumberType(int idIn = 1) const;
286  int nQuarksInCode(int idQIn) const;
287 
288  // Reset to empty decay table.
289  void clearChannels() {channels.resize(0);}
290 
291  // Add a decay channel to the decay table.
292  void addChannel(int onMode = 0, double bRatio = 0., int meMode = 0,
293  int prod0 = 0, int prod1 = 0, int prod2 = 0, int prod3 = 0,
294  int prod4 = 0, int prod5 = 0, int prod6 = 0, int prod7 = 0) {
295  channels.push_back( DecayChannel( onMode, bRatio, meMode, prod0,
296  prod1, prod2, prod3, prod4, prod5, prod6, prod7) ); }
297 
298  // Decay table size.
299  int sizeChannels() const {return channels.size();}
300 
301  // Gain access to a channel in the decay table.
302  DecayChannel& channel(int i){return channels[i];}
303  const DecayChannel& channel(int i) const {return channels[i];}
304 
305  // Rescale sum of branching ratios to unity.
306  void rescaleBR(double newSumBR = 1.);
307 
308  // Random choice of decay channel according to branching ratios.
309  bool preparePick(int idSgn, double mHat = 0., int idInFlav = 0);
310  DecayChannel& pickChannel();
311 
312  // Access methods stored in ResonanceWidths.
313  void setResonancePtr(ResonanceWidths* resonancePtrIn);
314  ResonanceWidths* getResonancePtr() {return resonancePtr;}
315  void resInit(Info* infoPtrIn, Settings* settingsPtrIn,
316  ParticleData* particleDataPtrIn, Couplings* couplingsPtrIn);
317  double resWidth(int idSgn, double mHat, int idIn = 0,
318  bool openOnly = false, bool setBR = false);
319  double resWidthOpen(int idSgn, double mHat, int idIn = 0);
320  double resWidthStore(int idSgn, double mHat, int idIn = 0);
321  double resOpenFrac(int idSgn);
322  double resWidthRescaleFactor();
323  double resWidthChan(double mHat, int idAbs1 = 0, int idAbs2 = 0);
324 
325 private:
326 
327  // Constants: could only be changed in the code itself.
328  static const int INVISIBLENUMBER, INVISIBLETABLE[80], KNOWNNOWIDTH[3];
329  static const double MAXTAU0FORDECAY,MINMASSRESONANCE, NARROWMASS,
330  CONSTITUENTMASSTABLE[10];
331 
332  // Particle data.
333  int idSave;
334  string nameSave, antiNameSave;
335  int spinTypeSave, chargeTypeSave, colTypeSave;
336  double m0Save, mWidthSave, mMinSave, mMaxSave, tau0Save,
337  constituentMassSave;
338  bool hasAntiSave, isResonanceSave, mayDecaySave, doExternalDecaySave,
339  isVisibleSave, doForceWidthSave, hasChangedSave, hasChangedMMinSave,
340  hasChangedMMaxSave;
341 
342  // Extra data for mass selection according to a Breit-Wigner and lifetime.
343  int modeBWnow, modeTau0now;
344  double atanLow, atanDif, mThr;
345 
346  // A vector containing all the decay channels of the particle.
347  vector<DecayChannel> channels;
348 
349  // Summed branching ratio of currently open channels.
350  double currentBRSum;
351 
352  // Pointer to ResonanceWidths object; only used for some particles.
353  ResonanceWidths* resonancePtr;
354 
355  // Pointer to the full particle data table.
356  ParticleData* particleDataPtr;
357 
358  // Set constituent mass.
359  void setConstituentMass();
360 
361 };
362 
363 //==========================================================================
364 
365 // This class holds a map of all ParticleDataEntries.
366 
367 class ParticleData {
368 
369 public:
370 
371  // Constructor.
372  ParticleData() : infoPtr(0), settingsPtr(0), rndmPtr(0), couplingsPtr(0),
373  particlePtr(0), isInit(false), readingFailedSave(false) {}
374 
375  // Copy constructors.
376  ParticleData& operator=( const ParticleData& oldPD) { if (this != &oldPD) {
377  modeBreitWigner = oldPD.modeBreitWigner; maxEnhanceBW = oldPD.maxEnhanceBW;
378  for (int i = 0; i < 7; ++i) mQRun[i] = oldPD.mQRun[i];
379  Lambda5Run = oldPD.Lambda5Run;
380  infoPtr = 0; settingsPtr = 0; rndmPtr = 0; couplingsPtr = 0;
381  for ( map<int, ParticleDataEntry>::const_iterator pde = oldPD.pdt.begin();
382  pde != oldPD.pdt.end(); pde++) { int idTmp = pde->first;
383  pdt[idTmp] = pde->second; pdt[idTmp].initPtr(this); }
384  particlePtr = 0; isInit = oldPD.isInit;
385  readingFailedSave = oldPD.readingFailedSave; } return *this; }
386 
387  // Initialize pointers.
388  void initPtr(Info* infoPtrIn, Settings* settingsPtrIn, Rndm* rndmPtrIn,
389  Couplings* couplingsPtrIn) {infoPtr = infoPtrIn;
390  settingsPtr = settingsPtrIn; rndmPtr = rndmPtrIn;
391  couplingsPtr = couplingsPtrIn;}
392 
393  // Read in database from specific file.
394  bool init(string startFile = "../share/Pythia8/xmldoc/ParticleData.xml") {
395  initCommon(); return readXML(startFile);}
396 
397  // Read in database from saved file stored in memory.
398  bool init(const ParticleData& particleDataIn) {
399  initCommon(); return copyXML(particleDataIn);}
400 
401  // Read in database from an istream.
402  bool init(istream& is) { initCommon(); return readXML(is);}
403 
404  // Overwrite existing database by reading from specific file.
405  bool reInit(string startFile, bool xmlFormat = true) { initCommon();
406  return (xmlFormat) ? readXML(startFile) : readFF(startFile);}
407 
408  // Initialize pointers, normal Breit-Wigners and special resonances.
409  void initWidths(vector<ResonanceWidths*> resonancePtrs);
410 
411  // Read and process or list whole (or part of) database from/to an XML file.
412  bool readXML(string inFile, bool reset = true) ;
413  void listXML(string outFile);
414  bool readXML(istream& is, bool reset=true);
415 
416  // Copy and process XML information from another particleData object.
417  bool copyXML(const ParticleData &particleDataIn);
418 
419  // Auxiliary functions to readXML() and copyXML().
420  bool loadXML(string inFile, bool reset = true) ;
421  bool loadXML(istream& is, bool reset=true);
422  bool processXML(bool reset = true) ;
423 
424  // Read or list whole (or part of) database from/to a free format file.
425  bool readFF(string inFile, bool reset = true) ;
426  bool readFF(istream& is, bool reset = true);
427  void listFF(string outFile);
428 
429  // Read in one update from a single line.
430  bool readString(string lineIn, bool warn = true) ;
431 
432  // Keep track whether any readings have failed, invalidating run setup.
433  bool readingFailed() {return readingFailedSave;}
434 
435  // Print out table of whole database, or of only part of it.
436  void listAll() {list(false, true);}
437  void listChanged(bool changedRes = false) {list(true, changedRes);}
438  void list(bool changedOnly = false, bool changedRes = true);
439 
440  // Print out specified particles.
441  void list(int idList) {vector<int> idListTemp;
442  idListTemp.push_back(idList); list( idListTemp);}
443  void list(vector<int> idList);
444 
445  // Retrieve readString history (e.g., for inspection). Everything
446  // (subrun=-999), up to first subrun (=-1), or subrun-specific (>=0).
447  vector<string> getReadHistory(int subrun=-999) {
448  if (subrun == -999) return readStringHistory;
449  else if (readStringSubrun.find(subrun) != readStringSubrun.end())
450  return readStringSubrun[subrun];
451  else return vector<string>();
452  }
453 
454  // Check that table makes sense, especially for decays.
455  void checkTable(int verbosity = 1) ;
456 
457  // Add new entry.
458  void addParticle(int idIn, string nameIn = " ", int spinTypeIn = 0,
459  int chargeTypeIn = 0, int colTypeIn = 0, double m0In = 0.,
460  double mWidthIn = 0., double mMinIn = 0., double mMaxIn = 0.,
461  double tau0In = 0.) { pdt[abs(idIn)] = ParticleDataEntry(idIn,
462  nameIn, spinTypeIn, chargeTypeIn, colTypeIn, m0In, mWidthIn,
463  mMinIn, mMaxIn, tau0In); pdt[abs(idIn)].initPtr(this); }
464  void addParticle(int idIn, string nameIn, string antiNameIn,
465  int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0,
466  double m0In = 0., double mWidthIn = 0., double mMinIn = 0.,
467  double mMaxIn = 0., double tau0In = 0.) { pdt[abs(idIn)]
468  = ParticleDataEntry(idIn, nameIn, antiNameIn, spinTypeIn,
469  chargeTypeIn, colTypeIn, m0In, mWidthIn, mMinIn, mMaxIn, tau0In);
470  pdt[abs(idIn)].initPtr(this); }
471 
472  // Reset all the properties of an entry in one go.
473  void setAll(int idIn, string nameIn, string antiNameIn,
474  int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0,
475  double m0In = 0., double mWidthIn = 0., double mMinIn = 0.,
476  double mMaxIn = 0.,double tau0In = 0.) {
477  ParticleDataEntry* ptr = findParticle(idIn);
478  if ( ptr ) ptr->setAll( nameIn, antiNameIn, spinTypeIn, chargeTypeIn,
479  colTypeIn, m0In, mWidthIn, mMinIn, mMaxIn, tau0In); }
480 
481  // Query existence of an entry.
482  bool isParticle(int idIn) const {
483  map<int,ParticleDataEntry>::const_iterator found = pdt.find( abs(idIn) );
484  if ( found == pdt.end() ) return false;
485  if ( idIn > 0 || found->second.hasAnti() ) return true;
486  return false;
487  }
488 
489  // Query existence of an entry and return an iterator.
490  ParticleDataEntry* findParticle(int idIn) {
491  map<int,ParticleDataEntry>::iterator found = pdt.find( abs(idIn) );
492  if( found == pdt.end() ) return NULL;
493  if ( idIn > 0 || found->second.hasAnti() ) return &((*found).second);
494  return NULL;
495  }
496 
497  // Query existence of an entry and return a const iterator.
498  const ParticleDataEntry* findParticle(int idIn) const {
499  map<int,ParticleDataEntry>::const_iterator found = pdt.find( abs(idIn) );
500  if( found == pdt.end() ) return NULL;
501  if ( idIn > 0 || found->second.hasAnti() ) return &((*found).second);
502  return NULL;
503  }
504 
505  // Return the id of the sequentially next particle stored in table.
506  int nextId(int idIn) ;
507 
508  // Change current values one at a time (or set if not set before).
509  void name(int idIn, string nameIn) {
510  ParticleDataEntry* ptr = findParticle(idIn);
511  if ( ptr ) ptr->setName(nameIn); }
512  void antiName(int idIn, string antiNameIn) {
513  ParticleDataEntry* ptr = findParticle(idIn);
514  if ( ptr ) ptr->setAntiName(antiNameIn); }
515  void names(int idIn, string nameIn, string antiNameIn) {
516  ParticleDataEntry* ptr = findParticle(idIn);
517  if ( ptr ) ptr->setNames(nameIn, antiNameIn); }
518  void spinType(int idIn, int spinTypeIn) {
519  ParticleDataEntry* ptr = findParticle(idIn);
520  if ( ptr ) ptr->setSpinType(spinTypeIn); }
521  void chargeType(int idIn, int chargeTypeIn) {
522  ParticleDataEntry* ptr = findParticle(idIn);
523  if ( ptr ) ptr->setChargeType(chargeTypeIn); }
524  void colType(int idIn, int colTypeIn) {
525  ParticleDataEntry* ptr = findParticle(idIn);
526  if ( ptr ) ptr->setColType(colTypeIn); }
527  void m0(int idIn, double m0In) {
528  ParticleDataEntry* ptr = findParticle(idIn);
529  if ( ptr ) ptr->setM0(m0In); }
530  void mWidth(int idIn, double mWidthIn) {
531  ParticleDataEntry* ptr = findParticle(idIn);
532  if ( ptr ) ptr->setMWidth(mWidthIn); }
533  void mMin(int idIn, double mMinIn) {
534  ParticleDataEntry* ptr = findParticle(idIn);
535  if ( ptr ) ptr->setMMin(mMinIn); }
536  void mMax(int idIn, double mMaxIn) {
537  ParticleDataEntry* ptr = findParticle(idIn);
538  if ( ptr ) ptr->setMMax(mMaxIn); }
539  void tau0(int idIn, double tau0In) {
540  ParticleDataEntry* ptr = findParticle(idIn);
541  if ( ptr ) ptr->setTau0(tau0In); }
542  void isResonance(int idIn, bool isResonanceIn) {
543  ParticleDataEntry* ptr = findParticle(idIn);
544  if ( ptr ) ptr->setIsResonance(isResonanceIn); }
545  void mayDecay(int idIn, bool mayDecayIn) {
546  ParticleDataEntry* ptr = findParticle(idIn);
547  if ( ptr ) ptr->setMayDecay(mayDecayIn); }
548  void doExternalDecay(int idIn, bool doExternalDecayIn) {
549  ParticleDataEntry* ptr = findParticle(idIn);
550  if ( ptr ) ptr->setDoExternalDecay(doExternalDecayIn); }
551  void isVisible(int idIn, bool isVisibleIn) {
552  ParticleDataEntry* ptr = findParticle(idIn);
553  if ( ptr ) ptr->setIsVisible(isVisibleIn); }
554  void doForceWidth(int idIn, bool doForceWidthIn) {
555  ParticleDataEntry* ptr = findParticle(idIn);
556  if ( ptr ) ptr->setDoForceWidth(doForceWidthIn); }
557  void hasChanged(int idIn, bool hasChangedIn) {
558  ParticleDataEntry* ptr = findParticle(idIn);
559  if ( ptr ) ptr->setHasChanged(hasChangedIn); }
560 
561  // Give back current values.
562  bool hasAnti(int idIn) const {
563  const ParticleDataEntry* ptr = findParticle(idIn);
564  return ( ptr ) ? ptr->hasAnti() : false; }
565  string name(int idIn) const {
566  const ParticleDataEntry* ptr = findParticle(idIn);
567  return ( ptr ) ? ptr->name(idIn) : " "; }
568  int spinType(int idIn) const {
569  const ParticleDataEntry* ptr = findParticle(idIn);
570  return ( ptr ) ? ptr->spinType() : 0; }
571  int chargeType(int idIn) {
572  const ParticleDataEntry* ptr = findParticle(idIn);
573  return ( ptr ) ? ptr->chargeType(idIn) : 0; }
574  double charge(int idIn) {
575  const ParticleDataEntry* ptr = findParticle(idIn);
576  return ( ptr ) ? ptr->charge(idIn) : 0; }
577  int colType(int idIn) {
578  const ParticleDataEntry* ptr = findParticle(idIn);
579  return ( ptr ) ? ptr->colType(idIn) : 0 ; }
580  double m0(int idIn) {
581  const ParticleDataEntry* ptr = findParticle(idIn);
582  return ( ptr ) ? ptr->m0() : 0. ; }
583  double mWidth(int idIn) {
584  const ParticleDataEntry* ptr = findParticle(idIn);
585  return ( ptr ) ? ptr->mWidth() : 0. ; }
586  double mMin(int idIn) {
587  const ParticleDataEntry* ptr = findParticle(idIn);
588  return ( ptr ) ? ptr->mMin() : 0. ; }
589  double m0Min(int idIn) {
590  const ParticleDataEntry* ptr = findParticle(idIn);
591  return ( ptr ) ? ptr->m0Min() : 0. ; }
592  double mMax(int idIn) {
593  const ParticleDataEntry* ptr = findParticle(idIn);
594  return ( ptr ) ? ptr->mMax() : 0. ; }
595  double m0Max(int idIn) {
596  const ParticleDataEntry* ptr = findParticle(idIn);
597  return ( ptr ) ? ptr->m0Max() : 0. ; }
598  double tau0(int idIn) {
599  const ParticleDataEntry* ptr = findParticle(idIn);
600  return ( ptr ) ? ptr->tau0() : 0. ; }
601  bool isResonance(int idIn) {
602  const ParticleDataEntry* ptr = findParticle(idIn);
603  return ( ptr ) ? ptr->isResonance() : false ; }
604  bool mayDecay(int idIn) {
605  const ParticleDataEntry* ptr = findParticle(idIn);
606  return ( ptr ) ? ptr->mayDecay() : false ; }
607  bool doExternalDecay(int idIn) {
608  const ParticleDataEntry* ptr = findParticle(idIn);
609  return ( ptr ) ? ptr->doExternalDecay() : false ; }
610  bool isVisible(int idIn) {
611  const ParticleDataEntry* ptr = findParticle(idIn);
612  return ( ptr ) ? ptr->isVisible() : false ; }
613  bool doForceWidth(int idIn) {
614  const ParticleDataEntry* ptr = findParticle(idIn);
615  return ( ptr ) ? ptr->doForceWidth() : false ; }
616  bool hasChanged(int idIn) {
617  const ParticleDataEntry* ptr = findParticle(idIn);
618  return ( ptr ) ? ptr->hasChanged() : false ; }
619  bool hasChangedMMin(int idIn) {
620  const ParticleDataEntry* ptr = findParticle(idIn);
621  return ( ptr ) ? ptr->hasChangedMMin() : false ; }
622  bool hasChangedMMax(int idIn) {
623  const ParticleDataEntry* ptr = findParticle(idIn);
624  return ( ptr ) ? ptr->hasChangedMMax() : false ; }
625 
626  // Give back special mass-related quantities.
627  bool useBreitWigner(int idIn) {
628  ParticleDataEntry* ptr = findParticle(idIn);
629  return ( ptr ) ? ptr->useBreitWigner() : false ; }
630  double constituentMass(int idIn) {
631  ParticleDataEntry* ptr = findParticle(idIn);
632  return ( ptr ) ? ptr->constituentMass() : 0. ; }
633  double mSel(int idIn) {
634  ParticleDataEntry* ptr = findParticle(idIn);
635  return ( ptr ) ? ptr->mSel() : 0. ; }
636  double mRun(int idIn, double mH) {
637  ParticleDataEntry* ptr = findParticle(idIn);
638  return ( ptr ) ? ptr->mRun(mH) : 0. ; }
639 
640  // Give back other quantities.
641  bool canDecay(int idIn) {
642  const ParticleDataEntry* ptr = findParticle(idIn);
643  return ( ptr ) ? ptr->canDecay() : false ; }
644  bool isLepton(int idIn) {
645  const ParticleDataEntry* ptr = findParticle(idIn);
646  return ( ptr ) ? ptr->isLepton() : false ; }
647  bool isQuark(int idIn) {
648  const ParticleDataEntry* ptr = findParticle(idIn);
649  return ( ptr ) ? ptr->isQuark() : false ; }
650  bool isGluon(int idIn) {
651  const ParticleDataEntry* ptr = findParticle(idIn);
652  return ( ptr ) ? ptr->isGluon() : false ; }
653  bool isDiquark(int idIn) {
654  const ParticleDataEntry* ptr = findParticle(idIn);
655  return ( ptr ) ? ptr->isDiquark() : false ; }
656  bool isParton(int idIn) {
657  const ParticleDataEntry* ptr = findParticle(idIn);
658  return ( ptr ) ? ptr->isParton() : false ; }
659  bool isHadron(int idIn) {
660  const ParticleDataEntry* ptr = findParticle(idIn);
661  return ( ptr ) ? ptr->isHadron() : false ; }
662  bool isMeson(int idIn) {
663  const ParticleDataEntry* ptr = findParticle(idIn);
664  return ( ptr ) ? ptr->isMeson() : false ; }
665  bool isBaryon(int idIn) {
666  const ParticleDataEntry* ptr = findParticle(idIn);
667  return ( ptr ) ? ptr->isBaryon() : false ; }
668  bool isOctetHadron(int idIn) {
669  const ParticleDataEntry* ptr = findParticle(idIn);
670  return ( ptr ) ? ptr->isOctetHadron() : false ; }
671  int heaviestQuark(int idIn) {
672  const ParticleDataEntry* ptr = findParticle(idIn);
673  return ( ptr ) ? ptr->heaviestQuark(idIn) : 0 ; }
674  int baryonNumberType(int idIn) {
675  const ParticleDataEntry* ptr = findParticle(idIn);
676  return ( ptr ) ? ptr->baryonNumberType(idIn) : 0 ; }
677  int nQuarksInCode(int idIn, int idQIn) {
678  const ParticleDataEntry* ptr = findParticle(idIn);
679  return ( ptr ) ? ptr->nQuarksInCode(idQIn) : 0 ; }
680 
681  // Change branching ratios.
682  void rescaleBR(int idIn, double newSumBR = 1.) {
683  ParticleDataEntry* ptr = findParticle(idIn);
684  if ( ptr ) ptr->rescaleBR(newSumBR); }
685 
686  // Access methods stored in ResonanceWidths.
687  void setResonancePtr(int idIn, ResonanceWidths* resonancePtrIn) {
688  ParticleDataEntry* ptr = findParticle(idIn);
689  if ( ptr ) ptr->setResonancePtr( resonancePtrIn);}
690  void resInit(int idIn) {
691  ParticleDataEntry* ptr = findParticle(idIn);
692  if ( ptr ) ptr->resInit(infoPtr, settingsPtr, this, couplingsPtr);}
693  double resWidth(int idIn, double mHat, int idInFlav = 0,
694  bool openOnly = false, bool setBR = false) {
695  ParticleDataEntry* ptr = findParticle(idIn);
696  return ( ptr ) ? ptr->resWidth(idIn, mHat,
697  idInFlav, openOnly, setBR) : 0.;}
698  double resWidthOpen(int idIn, double mHat, int idInFlav = 0) {
699  ParticleDataEntry* ptr = findParticle(idIn);
700  return ( ptr ) ? ptr->resWidthOpen(idIn, mHat, idInFlav) : 0.;}
701  double resWidthStore(int idIn, double mHat, int idInFlav = 0) {
702  ParticleDataEntry* ptr = findParticle(idIn);
703  return ( ptr ) ? ptr->resWidthStore(idIn, mHat, idInFlav) : 0.;}
704  double resOpenFrac(int id1In, int id2In = 0, int id3In = 0);
705  double resWidthRescaleFactor(int idIn) {
706  ParticleDataEntry* ptr = findParticle(idIn);
707  return ( ptr ) ? ptr->resWidthRescaleFactor() : 0.;}
708  double resWidthChan(int idIn, double mHat, int idAbs1 = 0,
709  int idAbs2 = 0) {
710  ParticleDataEntry* ptr = findParticle(idIn);
711  return ( ptr ) ? ptr->resWidthChan( mHat, idAbs1, idAbs2) : 0.;}
712 
713  // Return pointer to entry.
714  ParticleDataEntry* particleDataEntryPtr(int idIn) {
715  ParticleDataEntry* ptr = findParticle(idIn);
716  return ( ptr ) ? ptr : &pdt[0]; }
717 
718  // Check initialisation status.
719  bool getIsInit() {return isInit;}
720 
721 private:
722 
723  // Common data, accessible for the individual particles.
724  bool setRapidDecayVertex;
725  int modeBreitWigner;
726  double maxEnhanceBW, mQRun[7], Lambda5Run, intermediateTau0;
727 
728  // The individual particle need access to the full database.
729  friend class ParticleDataEntry;
730 
731  // Pointer to various information on the generation.
732  Info* infoPtr;
733 
734  // Pointer to the settings database.
735  Settings* settingsPtr;
736 
737  // Pointer to the random number generator.
738  Rndm* rndmPtr;
739 
740  // Pointer to Standard Model couplings.
741  Couplings* couplingsPtr;
742 
743  // All particle data stored in a map.
744  map<int, ParticleDataEntry> pdt;
745 
746  // Pointer to current particle (e.g. when reading decay channels).
747  ParticleDataEntry* particlePtr;
748 
749  // Flag that initialization has been performed; whether any failures.
750  bool isInit, readingFailedSave;
751 
752  // Method for common setting of particle-specific info.
753  void initCommon();
754 
755  // Useful functions for string handling.
756  bool boolString(string tag) { string tagLow = toLower(tag);
757  return ( tagLow == "true" || tagLow == "1" || tagLow == "on"
758  || tagLow == "yes" || tagLow == "ok" ); }
759 
760  // Extract XML value following XML attribute.
761  string attributeValue(string line, string attribute);
762  bool boolAttributeValue(string line, string attribute);
763  int intAttributeValue(string line, string attribute);
764  double doubleAttributeValue(string line, string attribute);
765 
766  // Vector of strings containing the readable lines of the XML file.
767  vector<string> xmlFileSav;
768 
769  // Stored history of readString statements (common and by subrun).
770  vector<string> readStringHistory;
771  map<int, vector<string> > readStringSubrun;
772 
773 };
774 
775 //==========================================================================
776 
777 } // end namespace Pythia8
778 
779 #endif // Pythia8_ParticleData_H