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