]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PYTHIA8/pythia8175/include/ParticleData.h
Update to 8.175
[u/mrichter/AliRoot.git] / PYTHIA8 / pythia8175 / include / ParticleData.h
1 // ParticleData.h is a part of the PYTHIA event generator.
2 // Copyright (C) 2013 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 "Basics.h"
15 #include "Info.h"
16 #include "PythiaStdlib.h"
17 #include "Settings.h"
18 #include "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 mass(); 
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 == 9900441
245          || idSave == 9900443 || idSave == 9900551 || idSave == 9900553 
246          || idSave == 9910441 || idSave == 9910551); }
247   int    heaviestQuark(int idIn = 1)    const; 
248   int    baryonNumberType(int idIn = 1) const;
249
250   // Reset to empty decay table.
251   void clearChannels() {channels.resize(0);}
252
253   // Add a decay channel to the decay table.
254   void addChannel(int onMode = 0, double bRatio = 0., int meMode = 0, 
255     int prod0 = 0, int prod1 = 0, int prod2 = 0, int prod3 = 0, 
256     int prod4 = 0, int prod5 = 0, int prod6 = 0, int prod7 = 0) { 
257     channels.push_back( DecayChannel( onMode, bRatio, meMode, prod0, 
258     prod1, prod2, prod3, prod4, prod5, prod6, prod7) ); }
259
260   // Decay table size.
261   int sizeChannels() const {return channels.size();}
262
263   // Gain access to a channel in the decay table.
264   DecayChannel& channel(int i){return channels[i];}
265   const DecayChannel& channel(int i) const {return channels[i];}
266
267   // Rescale sum of branching ratios to unity.
268   void rescaleBR(double newSumBR = 1.);
269
270   // Random choice of decay channel according to branching ratios.
271   bool preparePick(int idSgn, double mHat = 0., int idInFlav = 0);
272   DecayChannel& pickChannel();
273
274   // Access methods stored in ResonanceWidths.
275   void   setResonancePtr(ResonanceWidths* resonancePtrIn); 
276   ResonanceWidths* getResonancePtr() {return resonancePtr;}
277   void   resInit(Info* infoPtrIn, Settings* settingsPtrIn, 
278     ParticleData* particleDataPtrIn, Couplings* couplingsPtrIn);
279   double resWidth(int idSgn, double mHat, int idIn = 0, 
280     bool openOnly = false, bool setBR = false);
281   double resWidthOpen(int idSgn, double mHat, int idIn = 0);
282   double resWidthStore(int idSgn, double mHat, int idIn = 0);
283   double resOpenFrac(int idSgn);
284   double resWidthRescaleFactor();
285   double resWidthChan(double mHat, int idAbs1 = 0, int idAbs2 = 0);
286
287 private:
288
289   // Constants: could only be changed in the code itself.
290   static const int    INVISIBLENUMBER, INVISIBLETABLE[50], KNOWNNOWIDTH[3];
291   static const double MAXTAU0FORDECAY,MINMASSRESONANCE, NARROWMASS,
292                       CONSTITUENTMASSTABLE[10];
293
294   // Particle data.
295   int    idSave;
296   string nameSave, antiNameSave;
297   int    spinTypeSave, chargeTypeSave, colTypeSave;
298   double m0Save, mWidthSave, mMinSave, mMaxSave, tau0Save, 
299          constituentMassSave;
300   bool   hasAntiSave, isResonanceSave, mayDecaySave, doExternalDecaySave, 
301          isVisibleSave, doForceWidthSave, hasChangedSave;
302
303   // Extra data for mass selection according to a Breit-Wigner.
304   int    modeBWnow;
305   double atanLow, atanDif, mThr;   
306
307   // A vector containing all the decay channels of the particle.
308   vector<DecayChannel> channels;
309
310   // Summed branching ratio of currently open channels.
311   double currentBRSum;
312
313   // Pointer to ResonanceWidths object; only used for some particles.
314   ResonanceWidths* resonancePtr;  
315
316   // Pointer to the full particle data table.
317   ParticleData* particleDataPtr;
318
319   // Set constituent mass. 
320   void setConstituentMass();
321
322   // Useful functions for string handling.
323   string toLower(const string& nameConv) { string temp(nameConv);
324     for (int i = 0; i < int(temp.length()); ++i) temp[i] = tolower(temp[i]); 
325     return temp; }
326
327 };
328
329 //==========================================================================
330
331 // This class holds a map of all ParticleDataEntries.
332
333 class ParticleData {
334
335 public:
336
337   // Constructor.
338   ParticleData() : infoPtr(0), settingsPtr(0), rndmPtr(0), couplingsPtr(0), 
339     particlePtr(0), isInit(false), readingFailedSave(false) {}
340
341   // Initialize pointers.
342   void initPtr(Info* infoPtrIn, Settings* settingsPtrIn, Rndm* rndmPtrIn, 
343     Couplings* couplingsPtrIn) {infoPtr = infoPtrIn; 
344     settingsPtr = settingsPtrIn; rndmPtr = rndmPtrIn; 
345     couplingsPtr = couplingsPtrIn;}
346  
347   // Read in database from specific file.
348   bool init(string startFile = "../xmldoc/ParticleData.xml") {
349     initCommon(); return readXML(startFile);}
350
351   // Overwrite existing database by reading from specific file.
352   bool reInit(string startFile, bool xmlFormat = true) { initCommon();
353     return (xmlFormat) ? readXML(startFile) : readFF(startFile);}
354
355   // Initialize pointers, normal Breit-Wigners and special resonances.
356   void initWidths(vector<ResonanceWidths*> resonancePtrs);
357
358   // Read or list whole (or part of) database from/to an XML file.
359   bool readXML(string inFile, bool reset = true) ; 
360   void listXML(string outFile); 
361
362   // Read or list whole (or part of) database from/to a free format file.
363   bool readFF(string inFile, bool reset = true) ; 
364   void listFF(string outFile); 
365
366   // Read in one update from a single line.
367   bool readString(string lineIn, bool warn = true, ostream& os = cout) ; 
368
369   // Keep track whether any readings have failed, invalidating run setup.
370   bool readingFailed() {return readingFailedSave;} 
371
372   // Print out table of whole database, or of only part of it.
373   void listAll(ostream& os = cout) {list(false, true, os);} 
374   void listChanged(ostream& os = cout) {list(true, false, os);} 
375   void listChanged(bool changedRes, ostream& os = cout) {
376     list(true, changedRes, os);} 
377   void list(bool changedOnly = false, bool changedRes = true, 
378     ostream& os = cout); 
379
380   // Print out specified particles.
381   void list(int idList, ostream& os = cout) {vector<int> idListTemp; 
382     idListTemp.push_back(idList); list( idListTemp, os);} 
383   void list(vector<int> idList, ostream& os = cout); 
384
385   // Check that table makes sense, especially for decays.
386   void checkTable(ostream& os = cout) {checkTable(1, os);};
387   void checkTable(int verbosity, ostream& os = cout) ;
388  
389   // Add new entry.
390   void addParticle(int idIn, string nameIn = " ", int spinTypeIn = 0, 
391     int chargeTypeIn = 0, int colTypeIn = 0, double m0In = 0., 
392     double mWidthIn = 0., double mMinIn = 0., double mMaxIn = 0., 
393     double tau0In = 0.) { pdt[abs(idIn)] = ParticleDataEntry(idIn, 
394     nameIn, spinTypeIn, chargeTypeIn, colTypeIn, m0In, mWidthIn, 
395     mMinIn, mMaxIn, tau0In); }  
396   void addParticle(int idIn, string nameIn, string antiNameIn, 
397     int spinTypeIn = 0, int chargeTypeIn = 0, int colTypeIn = 0, 
398     double m0In = 0., double mWidthIn = 0., double mMinIn = 0., 
399     double mMaxIn = 0., double tau0In = 0.) { pdt[abs(idIn)] 
400     = ParticleDataEntry(idIn, nameIn, antiNameIn, spinTypeIn, 
401     chargeTypeIn, colTypeIn, m0In, mWidthIn, mMinIn, mMaxIn, tau0In); }  
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 mass(int idIn) {
503     return isParticle(idIn) ? pdt[abs(idIn)].mass() : 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