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) 2014 Torbjorn Sjostrand.
3 // PYTHIA is licenced under the GNU GPL version 2, 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  // Constructor.
39  DecayChannel(int onModeIn = 0, double bRatioIn = 0., int meModeIn = 0,
40  int prod0 = 0, int prod1 = 0, int prod2 = 0, int prod3 = 0,
41  int prod4 = 0, int prod5 = 0, int prod6 = 0, int prod7 = 0)
42  : onModeSave(onModeIn), bRatioSave(bRatioIn), currentBRSave(0.),
43  onShellWidthSave(0.), openSecPos(1.), openSecNeg(1.),
44  meModeSave(meModeIn), nProd(0), hasChangedSave(true) {
45  prod[0] = prod0; prod[1] = prod1; prod[2] = prod2; prod[3] = prod3;
46  prod[4] = prod4; prod[5] = prod5; prod[6] = prod6; prod[7] = prod7;
47  for (int j = 0; j < 8; ++j) if (prod[j] != 0 && j == nProd) ++nProd; }
48 
49  // Member functions for input.
50  void onMode(int onModeIn) {onModeSave = onModeIn; hasChangedSave = true;}
51  void bRatio(double bRatioIn, bool countAsChanged = true) {
52  bRatioSave = bRatioIn; if (countAsChanged) hasChangedSave = true;}
53  void rescaleBR(double fac) {bRatioSave *= fac; hasChangedSave = true;}
54  void meMode(int meModeIn) {meModeSave = meModeIn; hasChangedSave = true;}
55  void multiplicity(int multIn) {nProd = multIn; hasChangedSave = true;}
56  void product(int i, int prodIn) {prod[i] = prodIn; nProd = 0;
57  for (int j = 0; j < 8; ++j) if (prod[j] != 0 && j == nProd) ++nProd;
58  hasChangedSave = true;}
59  void setHasChanged(bool hasChangedIn) {hasChangedSave = hasChangedIn;}
60 
61  // Member functions for output.
62  int onMode() const {return onModeSave;}
63  double bRatio() const {return bRatioSave;}
64  int meMode() const {return meModeSave;}
65  int multiplicity() const {return nProd;}
66  int product(int i) const {return (i >= 0 && i < nProd) ? prod[i] : 0;}
67  bool hasChanged() const { return hasChangedSave;}
68 
69  // Check for presence of particles anywhere in decay list.
70  bool contains(int id1) const;
71  bool contains(int id1, int id2) const;
72  bool contains(int id1, int id2, int id3) const;
73 
74  // Input/output for current selection of decay modes.
75  // Takes into account on/off switches and dynamic width for resonances.
76  void currentBR(double currentBRIn) {currentBRSave = currentBRIn;}
77  double currentBR() const {return currentBRSave;}
78 
79  // Input/output for nominal partial width; used by resonances.
80  void onShellWidth(double onShellWidthIn) {
81  onShellWidthSave = onShellWidthIn;}
82  double onShellWidth() const {return onShellWidthSave;}
83  void onShellWidthFactor(double factor) {onShellWidthSave *= factor;}
84 
85  // Input/output for fraction of secondary open widths; used by resonances.
86  void openSec(int idSgn, double openSecIn) {
87  if (idSgn > 0) openSecPos = openSecIn; else openSecNeg = openSecIn;}
88  double openSec(int idSgn) const {
89  return (idSgn > 0) ? openSecPos : openSecNeg;}
90 
91 private:
92 
93  // Decay channel info.
94  int onModeSave;
95  double bRatioSave, currentBRSave, onShellWidthSave, openSecPos,
96  openSecNeg;
97  int meModeSave, nProd, prod[8];
98  bool hasChangedSave;
99 
100 };
101 
102 //==========================================================================
103 
104 // This class holds info on a single particle species.
105 
106 class ParticleDataEntry {
107 
108 public:
109 
110  // Constructors: for antiparticle exists or not.
111  ParticleDataEntry(int idIn = 0, string nameIn = " ",
112  int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0,
113  double m0In = 0., double mWidthIn = 0., double mMinIn = 0.,
114  double mMaxIn = 0., double tau0In = 0.) : idSave(abs(idIn)),
115  nameSave(nameIn), antiNameSave("void"), spinTypeSave(spinTypeIn),
116  chargeTypeSave(chargeTypeIn), colTypeSave(colTypeIn), m0Save(m0In),
117  mWidthSave (mWidthIn), mMinSave(mMinIn), mMaxSave(mMaxIn),
118  tau0Save(tau0In), hasAntiSave(false), hasChangedSave(true),
119  resonancePtr(0) {setDefaults();}
120  ParticleDataEntry(int idIn, string nameIn, string antiNameIn,
121  int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0,
122  double m0In = 0., double mWidthIn = 0., double mMinIn = 0.,
123  double mMaxIn = 0., double tau0In = 0.) : idSave(abs(idIn)),
124  nameSave(nameIn), antiNameSave(antiNameIn), spinTypeSave(spinTypeIn),
125  chargeTypeSave(chargeTypeIn), colTypeSave(colTypeIn), m0Save(m0In),
126  mWidthSave (mWidthIn), mMinSave(mMinIn), mMaxSave(mMaxIn),
127  tau0Save(tau0In), hasAntiSave(true), hasChangedSave(true),
128  resonancePtr(0) {setDefaults();
129  if (toLower(antiNameIn) == "void") hasAntiSave = false;}
130 
131  // Destructor: delete any ResonanceWidths object.
132  ~ParticleDataEntry();
133 
134  // Initialization of some particle flags.
135  void setDefaults();
136 
137  // Store pointer to whole particle data table/database.
138  void initPtr( ParticleData* particleDataPtrIn) {
139  particleDataPtr = particleDataPtrIn;}
140 
141  // Reset all the properties of an existing particle.
142  void setAll(string nameIn, string antiNameIn, int spinTypeIn = 0,
143  int chargeTypeIn = 0, int colTypeIn = 0, double m0In = 0.,
144  double mWidthIn = 0., double mMinIn = 0., double mMaxIn = 0.,
145  double tau0In = 0.)
146  {nameSave = nameIn; antiNameSave = antiNameIn; hasAntiSave = true;
147  if (toLower(antiNameIn) == "void") hasAntiSave = false;
148  spinTypeSave = spinTypeIn; chargeTypeSave = chargeTypeIn;
149  colTypeSave = colTypeIn; m0Save = m0In; mWidthSave = mWidthIn;
150  mMinSave = mMinIn; mMaxSave = mMaxIn; tau0Save = tau0In;
151  setDefaults(); hasChangedSave = true;}
152 
153  // Change current values one at a time (or set if not set before).
154  // (Must use set here since else name+signature clash with get methods.)
155  void setName(string nameIn) {nameSave = nameIn; hasChangedSave = true;}
156  void setAntiName(string antiNameIn) {antiNameSave = antiNameIn;
157  hasChangedSave = true;}
158  void setNames(string nameIn, string antiNameIn) {nameSave = nameIn;
159  antiNameSave = antiNameIn; hasAntiSave = true; if (toLower(antiNameIn)
160  == "void") hasAntiSave = false; hasChangedSave = true;}
161  void setSpinType(int spinTypeIn) {spinTypeSave = spinTypeIn;
162  hasChangedSave = true;}
163  void setChargeType(int chargeTypeIn) {chargeTypeSave = chargeTypeIn;
164  hasChangedSave = true;}
165  void setColType(int colTypeIn) {colTypeSave = colTypeIn;
166  hasChangedSave = true;}
167  void setM0(double m0In) {m0Save = m0In; setConstituentMass();
168  hasChangedSave = true;}
169  void setMWidth(double mWidthIn, bool countAsChanged = true) {
170  mWidthSave = mWidthIn; if (countAsChanged) hasChangedSave = true;}
171  void setMMin(double mMinIn) {mMinSave = mMinIn; hasChangedSave = true;}
172  void setMMax(double mMaxIn) {mMaxSave = mMaxIn; hasChangedSave = true;}
173  // Special options specifically when cutting wings of Breit-Wigners.
174  void setMMinNoChange(double mMinIn) {mMinSave = mMinIn;}
175  void setMMaxNoChange(double mMaxIn) {mMaxSave = mMaxIn;}
176  void setTau0(double tau0In) {tau0Save = tau0In; hasChangedSave = true;}
177  void setIsResonance(bool isResonanceIn) {isResonanceSave = isResonanceIn;
178  hasChangedSave = true;}
179  void setMayDecay(bool mayDecayIn, bool countAsChanged = true) {
180  mayDecaySave = mayDecayIn; if (countAsChanged) hasChangedSave = true;}
181  void setDoExternalDecay(bool doExternalDecayIn)
182  {doExternalDecaySave = doExternalDecayIn; hasChangedSave = true;}
183  void setIsVisible(bool isVisibleIn) {isVisibleSave = isVisibleIn;
184  hasChangedSave = true;}
185  void setDoForceWidth(bool doForceWidthIn) {doForceWidthSave = doForceWidthIn;
186  hasChangedSave = true;}
187  void setHasChanged(bool hasChangedIn) {hasChangedSave = hasChangedIn;
188  for (int i = 0; i < int(channels.size()); ++i)
189  channels[i].setHasChanged(hasChangedIn);}
190 
191  // Give back current values.
192  int id() const { return idSave; }
193  bool hasAnti() const { return hasAntiSave; }
194  string name(int idIn = 1) const {
195  return (idIn > 0) ? nameSave : antiNameSave; }
196  int spinType() const {return spinTypeSave; }
197  int chargeType(int idIn = 1) const {
198  return (idIn > 0) ? chargeTypeSave : -chargeTypeSave; }
199  double charge(int idIn = 1) const {
200  return (idIn > 0) ? chargeTypeSave / 3. : -chargeTypeSave / 3.; }
201  int colType(int idIn = 1) const {
202  if (colTypeSave == 2) return colTypeSave;
203  return (idIn > 0) ? colTypeSave : -colTypeSave; }
204  double m0() const { return m0Save; }
205  double mWidth() const { return mWidthSave; }
206  double mMin() const { return mMinSave; }
207  double mMax() const { return mMaxSave; }
208  double m0Min() const {
209  return (modeBWnow == 0) ? m0Save : mMinSave; }
210  double m0Max() const {
211  return (modeBWnow == 0) ? m0Save : mMaxSave; }
212  double tau0() const { return tau0Save; }
213  bool isResonance() const { return isResonanceSave; }
214  bool mayDecay() const { return mayDecaySave; }
215  bool doExternalDecay() const { return doExternalDecaySave; }
216  bool isVisible() const { return isVisibleSave; }
217  bool doForceWidth() const { return doForceWidthSave; }
218  bool hasChanged() const { if (hasChangedSave) return true;
219  for (int i = 0; i < int(channels.size()); ++i)
220  if (channels[i].hasChanged()) return true; return false;}
221 
222  // Set and give back several mass-related quantities.
223  void initBWmass();
224  double constituentMass() const { return constituentMassSave; }
225  double mSel();
226  double mRun(double mH);
227 
228  // Give back other quantities.
229  bool useBreitWigner() const { return (modeBWnow > 0); }
230  bool canDecay() const { return (channels.size() > 0);}
231  bool isLepton() const { return (idSave > 10 && idSave < 19);}
232  bool isQuark() const { return (idSave != 0 && idSave < 9);}
233  bool isGluon() const { return (idSave == 21);}
234  bool isDiquark() const { return (idSave > 1000 && idSave < 10000
235  && (idSave/10)%10 == 0);}
236  bool isParton() const { return ( idSave == 21
237  || (idSave != 0 && idSave < 6)
238  || (idSave > 1000 && idSave < 5510 && (idSave/10)%10 == 0) );}
239  bool isHadron() const;
240  bool isMeson() const;
241  bool isBaryon() const;
242 
243  // Intermediate octet ccbar or bbar states in colour-octet model.
244  bool isOctetHadron() const {return idSave >= 9940000
245  && idSave < 9960000; }
246  int heaviestQuark(int idIn = 1) const;
247  int baryonNumberType(int idIn = 1) const;
248 
249  // Reset to empty decay table.
250  void clearChannels() {channels.resize(0);}
251 
252  // Add a decay channel to the decay table.
253  void addChannel(int onMode = 0, double bRatio = 0., int meMode = 0,
254  int prod0 = 0, int prod1 = 0, int prod2 = 0, int prod3 = 0,
255  int prod4 = 0, int prod5 = 0, int prod6 = 0, int prod7 = 0) {
256  channels.push_back( DecayChannel( onMode, bRatio, meMode, prod0,
257  prod1, prod2, prod3, prod4, prod5, prod6, prod7) ); }
258 
259  // Decay table size.
260  int sizeChannels() const {return channels.size();}
261 
262  // Gain access to a channel in the decay table.
263  DecayChannel& channel(int i){return channels[i];}
264  const DecayChannel& channel(int i) const {return channels[i];}
265 
266  // Rescale sum of branching ratios to unity.
267  void rescaleBR(double newSumBR = 1.);
268 
269  // Random choice of decay channel according to branching ratios.
270  bool preparePick(int idSgn, double mHat = 0., int idInFlav = 0);
271  DecayChannel& pickChannel();
272 
273  // Access methods stored in ResonanceWidths.
274  void setResonancePtr(ResonanceWidths* resonancePtrIn);
275  ResonanceWidths* getResonancePtr() {return resonancePtr;}
276  void resInit(Info* infoPtrIn, Settings* settingsPtrIn,
277  ParticleData* particleDataPtrIn, Couplings* couplingsPtrIn);
278  double resWidth(int idSgn, double mHat, int idIn = 0,
279  bool openOnly = false, bool setBR = false);
280  double resWidthOpen(int idSgn, double mHat, int idIn = 0);
281  double resWidthStore(int idSgn, double mHat, int idIn = 0);
282  double resOpenFrac(int idSgn);
283  double resWidthRescaleFactor();
284  double resWidthChan(double mHat, int idAbs1 = 0, int idAbs2 = 0);
285 
286 private:
287 
288  // Constants: could only be changed in the code itself.
289  static const int INVISIBLENUMBER, INVISIBLETABLE[50], KNOWNNOWIDTH[3];
290  static const double MAXTAU0FORDECAY,MINMASSRESONANCE, NARROWMASS,
291  CONSTITUENTMASSTABLE[10];
292 
293  // Particle data.
294  int idSave;
295  string nameSave, antiNameSave;
296  int spinTypeSave, chargeTypeSave, colTypeSave;
297  double m0Save, mWidthSave, mMinSave, mMaxSave, tau0Save,
298  constituentMassSave;
299  bool hasAntiSave, isResonanceSave, mayDecaySave, doExternalDecaySave,
300  isVisibleSave, doForceWidthSave, hasChangedSave;
301 
302  // Extra data for mass selection according to a Breit-Wigner.
303  int modeBWnow;
304  double atanLow, atanDif, mThr;
305 
306  // A vector containing all the decay channels of the particle.
307  vector<DecayChannel> channels;
308 
309  // Summed branching ratio of currently open channels.
310  double currentBRSum;
311 
312  // Pointer to ResonanceWidths object; only used for some particles.
313  ResonanceWidths* resonancePtr;
314 
315  // Pointer to the full particle data table.
316  ParticleData* particleDataPtr;
317 
318  // Set constituent mass.
319  void setConstituentMass();
320 
321  // Useful functions for string handling.
322  string toLower(const string& nameConv) { string temp(nameConv);
323  for (int i = 0; i < int(temp.length()); ++i) temp[i] = tolower(temp[i]);
324  return temp; }
325 
326 };
327 
328 //==========================================================================
329 
330 // This class holds a map of all ParticleDataEntries.
331 
332 class ParticleData {
333 
334 public:
335 
336  // Constructor.
337  ParticleData() : infoPtr(0), settingsPtr(0), rndmPtr(0), couplingsPtr(0),
338  particlePtr(0), isInit(false), readingFailedSave(false) {}
339 
340  // Initialize pointers.
341  void initPtr(Info* infoPtrIn, Settings* settingsPtrIn, Rndm* rndmPtrIn,
342  Couplings* couplingsPtrIn) {infoPtr = infoPtrIn;
343  settingsPtr = settingsPtrIn; rndmPtr = rndmPtrIn;
344  couplingsPtr = couplingsPtrIn;}
345 
346  // Read in database from specific file.
347  bool init(string startFile = "../xmldoc/ParticleData.xml") {
348  initCommon(); return readXML(startFile);}
349 
350  // Overwrite existing database by reading from specific file.
351  bool reInit(string startFile, bool xmlFormat = true) { initCommon();
352  return (xmlFormat) ? readXML(startFile) : readFF(startFile);}
353 
354  // Initialize pointers, normal Breit-Wigners and special resonances.
355  void initWidths(vector<ResonanceWidths*> resonancePtrs);
356 
357  // Read or list whole (or part of) database from/to an XML file.
358  bool readXML(string inFile, bool reset = true) ;
359  void listXML(string outFile);
360 
361  // Read or list whole (or part of) database from/to a free format file.
362  bool readFF(string inFile, bool reset = true) ;
363  void listFF(string outFile);
364 
365  // Read in one update from a single line.
366  bool readString(string lineIn, bool warn = true, ostream& os = cout) ;
367 
368  // Keep track whether any readings have failed, invalidating run setup.
369  bool readingFailed() {return readingFailedSave;}
370 
371  // Print out table of whole database, or of only part of it.
372  void listAll(ostream& os = cout) {list(false, true, os);}
373  void listChanged(ostream& os = cout) {list(true, false, os);}
374  void listChanged(bool changedRes, ostream& os = cout) {
375  list(true, changedRes, os);}
376  void list(bool changedOnly = false, bool changedRes = true,
377  ostream& os = cout);
378 
379  // Print out specified particles.
380  void list(int idList, ostream& os = cout) {vector<int> idListTemp;
381  idListTemp.push_back(idList); list( idListTemp, os);}
382  void list(vector<int> idList, ostream& os = cout);
383 
384  // Check that table makes sense, especially for decays.
385  void checkTable(ostream& os = cout) {checkTable(1, os);};
386  void checkTable(int verbosity, ostream& os = cout) ;
387 
388  // Add new entry.
389  void addParticle(int idIn, string nameIn = " ", int spinTypeIn = 0,
390  int chargeTypeIn = 0, int colTypeIn = 0, double m0In = 0.,
391  double mWidthIn = 0., double mMinIn = 0., double mMaxIn = 0.,
392  double tau0In = 0.) { pdt[abs(idIn)] = ParticleDataEntry(idIn,
393  nameIn, spinTypeIn, chargeTypeIn, colTypeIn, m0In, mWidthIn,
394  mMinIn, mMaxIn, tau0In); pdt[abs(idIn)].initPtr(this); }
395  void addParticle(int idIn, string nameIn, string antiNameIn,
396  int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0,
397  double m0In = 0., double mWidthIn = 0., double mMinIn = 0.,
398  double mMaxIn = 0., double tau0In = 0.) { pdt[abs(idIn)]
399  = ParticleDataEntry(idIn, nameIn, antiNameIn, spinTypeIn,
400  chargeTypeIn, colTypeIn, m0In, mWidthIn, mMinIn, mMaxIn, tau0In);
401  pdt[abs(idIn)].initPtr(this); }
402 
403  // Reset all the properties of an entry in one go.
404  void setAll(int idIn, string nameIn, string antiNameIn,
405  int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0,
406  double m0In = 0., double mWidthIn = 0., double mMinIn = 0.,
407  double mMaxIn = 0.,double tau0In = 0.) { if (isParticle(idIn))
408  pdt[abs(idIn)].setAll( nameIn, antiNameIn, spinTypeIn, chargeTypeIn,
409  colTypeIn, m0In, mWidthIn, mMinIn, mMaxIn, tau0In); }
410 
411  // Query existence of an entry.
412  bool isParticle(int idIn) {
413  if (pdt.find(abs(idIn)) == pdt.end()) return false;
414  if (idIn > 0 || pdt[abs(idIn)].hasAnti()) return true;
415  return false; }
416 
417  // Return the id of the sequentially next particle stored in table.
418  int nextId(int idIn) ;
419 
420  // Change current values one at a time (or set if not set before).
421  void name(int idIn, string nameIn) {
422  if (isParticle(idIn)) pdt[abs(idIn)].setName(nameIn); }
423  void antiName(int idIn, string antiNameIn) {
424  if (isParticle(idIn)) pdt[abs(idIn)].setAntiName(antiNameIn); }
425  void names(int idIn, string nameIn, string antiNameIn) {
426  if (isParticle(idIn)) pdt[abs(idIn)].setNames(nameIn, antiNameIn); }
427  void spinType(int idIn, int spinTypeIn) {
428  if (isParticle(idIn)) pdt[abs(idIn)].setSpinType(spinTypeIn); }
429  void chargeType(int idIn, int chargeTypeIn) {
430  if (isParticle(idIn)) pdt[abs(idIn)].setChargeType(chargeTypeIn); }
431  void colType(int idIn, int colTypeIn) {
432  if (isParticle(idIn)) pdt[abs(idIn)].setColType(colTypeIn); }
433  void m0(int idIn, double m0In) {
434  if (isParticle(idIn)) pdt[abs(idIn)].setM0(m0In); }
435  void mWidth(int idIn, double mWidthIn) {
436  if (isParticle(idIn)) pdt[abs(idIn)].setMWidth(mWidthIn); }
437  void mMin(int idIn, double mMinIn) {
438  if (isParticle(idIn)) pdt[abs(idIn)].setMMin(mMinIn); }
439  void mMax(int idIn, double mMaxIn) {
440  if (isParticle(idIn)) pdt[abs(idIn)].setMMax(mMaxIn); }
441  void tau0(int idIn, double tau0In) {
442  if (isParticle(idIn)) pdt[abs(idIn)].setTau0(tau0In); }
443  void isResonance(int idIn, bool isResonanceIn) {
444  if (isParticle(idIn)) pdt[abs(idIn)].setIsResonance(isResonanceIn); }
445  void mayDecay(int idIn, bool mayDecayIn) {
446  if (isParticle(idIn)) pdt[abs(idIn)].setMayDecay(mayDecayIn); }
447  void doExternalDecay(int idIn, bool doExternalDecayIn) {
448  if (isParticle(idIn))
449  pdt[abs(idIn)].setDoExternalDecay(doExternalDecayIn); }
450  void isVisible(int idIn, bool isVisibleIn) {
451  if (isParticle(idIn)) pdt[abs(idIn)].setIsVisible(isVisibleIn); }
452  void doForceWidth(int idIn, bool doForceWidthIn) {
453  if (isParticle(idIn)) pdt[abs(idIn)].setDoForceWidth(doForceWidthIn); }
454  void hasChanged(int idIn, bool hasChangedIn) {
455  if (isParticle(idIn)) pdt[abs(idIn)].setHasChanged(hasChangedIn); }
456 
457  // Give back current values.
458  bool hasAnti(int idIn) {
459  return isParticle(idIn) ? pdt[abs(idIn)].hasAnti() : false ; }
460  string name(int idIn) {
461  return (isParticle(abs(idIn))) ? pdt[abs(idIn)].name(idIn) : " "; }
462  int spinType(int idIn) {
463  return isParticle(idIn) ? pdt[abs(idIn)].spinType() : 0 ; }
464  int chargeType(int idIn) {
465  return isParticle(idIn) ? pdt[abs(idIn)].chargeType(idIn) : 0 ; }
466  double charge(int idIn) {
467  return isParticle(idIn) ? pdt[abs(idIn)].charge(idIn) : 0 ; }
468  int colType(int idIn) {
469  return isParticle(idIn) ? pdt[abs(idIn)].colType(idIn) : 0 ; }
470  double m0(int idIn) {
471  return isParticle(idIn) ? pdt[abs(idIn)].m0() : 0. ; }
472  double mWidth(int idIn) {
473  return isParticle(idIn) ? pdt[abs(idIn)].mWidth() : 0. ; }
474  double mMin(int idIn) {
475  return isParticle(idIn) ? pdt[abs(idIn)].mMin() : 0. ; }
476  double m0Min(int idIn) {
477  return isParticle(idIn) ? pdt[abs(idIn)].m0Min() : 0. ; }
478  double mMax(int idIn) {
479  return isParticle(idIn) ? pdt[abs(idIn)].mMax() : 0. ; }
480  double m0Max(int idIn) {
481  return isParticle(idIn) ? pdt[abs(idIn)].m0Max() : 0. ; }
482  double tau0(int idIn) {
483  return isParticle(idIn) ? pdt[abs(idIn)].tau0() : 0. ; }
484  bool isResonance(int idIn) {
485  return isParticle(idIn) ? pdt[abs(idIn)].isResonance() : false ; }
486  bool mayDecay(int idIn) {
487  return isParticle(idIn) ? pdt[abs(idIn)].mayDecay() : false ; }
488  bool doExternalDecay(int idIn) {
489  return isParticle(idIn) ? pdt[abs(idIn)].doExternalDecay() : false ; }
490  bool isVisible(int idIn) {
491  return isParticle(idIn) ? pdt[abs(idIn)].isVisible() : false ; }
492  bool doForceWidth(int idIn) {
493  return isParticle(idIn) ? pdt[abs(idIn)].doForceWidth() : false ; }
494  bool hasChanged(int idIn) {
495  return isParticle(idIn) ? pdt[abs(idIn)].hasChanged() : false ; }
496 
497  // Give back special mass-related quantities.
498  bool useBreitWigner(int idIn) {
499  return isParticle(idIn) ? pdt[abs(idIn)].useBreitWigner() : false ; }
500  double constituentMass(int idIn) {
501  return isParticle(idIn) ? pdt[abs(idIn)].constituentMass() : 0. ; }
502  double mSel(int idIn) {
503  return isParticle(idIn) ? pdt[abs(idIn)].mSel() : 0. ; }
504  double mRun(int idIn, double mH) {
505  return isParticle(idIn) ? pdt[abs(idIn)].mRun(mH) : 0. ; }
506 
507  // Give back other quantities.
508  bool canDecay(int idIn) {
509  return isParticle(idIn) ? pdt[abs(idIn)].canDecay() : false ; }
510  bool isLepton(int idIn) {
511  return isParticle(idIn) ? pdt[abs(idIn)].isLepton() : false ; }
512  bool isQuark(int idIn) {
513  return isParticle(idIn) ? pdt[abs(idIn)].isQuark() : false ; }
514  bool isGluon(int idIn) {
515  return isParticle(idIn) ? pdt[abs(idIn)].isGluon() : false ; }
516  bool isDiquark(int idIn) {
517  return isParticle(idIn) ? pdt[abs(idIn)].isDiquark() : false ; }
518  bool isParton(int idIn) {
519  return isParticle(idIn) ? pdt[abs(idIn)].isParton() : false ; }
520  bool isHadron(int idIn) {
521  return isParticle(idIn) ? pdt[abs(idIn)].isHadron() : false ; }
522  bool isMeson(int idIn) {
523  return isParticle(idIn) ? pdt[abs(idIn)].isMeson() : false ; }
524  bool isBaryon(int idIn) {
525  return isParticle(idIn) ? pdt[abs(idIn)].isBaryon() : false ; }
526  bool isOctetHadron(int idIn) {
527  return isParticle(idIn) ? pdt[abs(idIn)].isOctetHadron() : false ; }
528  int heaviestQuark(int idIn) {
529  return isParticle(idIn) ? pdt[abs(idIn)].heaviestQuark(idIn) : 0 ; }
530  int baryonNumberType(int idIn) {
531  return isParticle(idIn) ? pdt[abs(idIn)].baryonNumberType(idIn) : 0 ; }
532 
533  // Change branching ratios.
534  void rescaleBR(int idIn, double newSumBR = 1.) {
535  if (isParticle(idIn)) pdt[abs(idIn)].rescaleBR(newSumBR); }
536 
537  // Access methods stored in ResonanceWidths.
538  void setResonancePtr(int idIn, ResonanceWidths* resonancePtrIn) {
539  if (isParticle(idIn)) pdt[abs(idIn)].setResonancePtr( resonancePtrIn);}
540  void resInit(int idIn) { if (isParticle(idIn))
541  pdt[abs(idIn)].resInit(infoPtr, settingsPtr, this, couplingsPtr);}
542  double resWidth(int idIn, double mHat, int idInFlav = 0,
543  bool openOnly = false, bool setBR = false) {
544  return isParticle(idIn) ? pdt[abs(idIn)].resWidth(idIn, mHat,
545  idInFlav, openOnly, setBR) : 0.;}
546  double resWidthOpen(int idIn, double mHat, int idInFlav = 0) {
547  return isParticle(idIn) ? pdt[abs(idIn)].resWidthOpen(idIn, mHat,
548  idInFlav) : 0.;}
549  double resWidthStore(int idIn, double mHat, int idInFlav = 0) {
550  return isParticle(idIn) ? pdt[abs(idIn)].resWidthStore(idIn, mHat,
551  idInFlav) : 0.;}
552  double resOpenFrac(int id1In, int id2In = 0, int id3In = 0);
553  double resWidthRescaleFactor(int idIn) { return isParticle(idIn)
554  ? pdt[abs(idIn)].resWidthRescaleFactor() : 0.;}
555  double resWidthChan(int idIn, double mHat, int idAbs1 = 0,
556  int idAbs2 = 0) { return isParticle(idIn)
557  ? pdt[abs(idIn)].resWidthChan( mHat, idAbs1, idAbs2) : 0.;}
558 
559  // Return pointer to entry.
560  ParticleDataEntry* particleDataEntryPtr(int idIn) {
561  return (isParticle(idIn)) ? &pdt[abs(idIn)] : &pdt[0]; }
562 
563 private:
564 
565  // Common data, accessible for the individual particles.
566  int modeBreitWigner;
567  double maxEnhanceBW, mQRun[7], Lambda5Run;
568 
569  // The individual particle need access to the full database.
570  friend class ParticleDataEntry;
571 
572  // Pointer to various information on the generation.
573  Info* infoPtr;
574 
575  // Pointer to the settings database.
576  Settings* settingsPtr;
577 
578  // Pointer to the random number generator.
579  Rndm* rndmPtr;
580 
581  // Pointer to Standard Model couplings.
582  Couplings* couplingsPtr;
583 
584  // All particle data stored in a map.
585  map<int, ParticleDataEntry> pdt;
586 
587  // Pointer to current particle (e.g. when reading decay channels).
588  ParticleDataEntry* particlePtr;
589 
590  // Flag that initialization has been performed; whether any failures.
591  bool isInit, readingFailedSave;
592 
593  // Method for common setting of particle-specific info.
594  void initCommon();
595 
596  // Useful functions for string handling.
597  string toLower(const string& nameConv) { string temp(nameConv);
598  for (int i = 0; i < int(temp.length()); ++i) temp[i] = tolower(temp[i]);
599  return temp; }
600  bool boolString(string tag) { string tagLow = toLower(tag);
601  return ( tagLow == "true" || tagLow == "1" || tagLow == "on"
602  || tagLow == "yes" || tagLow == "ok" ); }
603 
604  // Extract XML value following XML attribute.
605  string attributeValue(string line, string attribute);
606  bool boolAttributeValue(string line, string attribute);
607  int intAttributeValue(string line, string attribute);
608  double doubleAttributeValue(string line, string attribute);
609 
610 };
611 
612 //==========================================================================
613 
614 } // end namespace Pythia8
615 
616 #endif // Pythia8_ParticleData_H