MINT2
ParticleProperties.cpp
Go to the documentation of this file.
1 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
2 // status: Mon 9 Feb 2009 19:18:04 GMT
6 #include "Mint/NamedParameter.h"
7 #include "Mint/Utils.h"
8 
9 
10 #include <cstdio>
11 #include <cstring>
12 #include <algorithm>
13 
14 using namespace std;
15 using namespace MINT;
16 
17 const char* ParticleProperties::pionString = "1.3957018E+02 ,3.5E-04,3.5E-04,2.5284E-14 ,5.0E-18,5.0E-18,1 ,-,0 ,-, ,B, 211, +, ,R,pi ,uD ";
18 
21 
22 void ParticleProperties::print(ostream& out) const{
23  out << "Mass " << mass() << " +" << mErrPlus() << " -" << mErrMinus()
24  << "\nWidth " << width() << " +" << wErrPlus() << " -" << wErrMinus()
25  << "\n I=" << I() << ", G=" << G()
26  << "\n J=" << J() << ", C=" << C() << ", P=" << P()
27  << "\n Q = " << charge()
28  << "\n pdg_id " << pdg_id()
29  << "\n name " << name()
30  << "\n quark content: " << quarks()
31  << "\n net-quark-content " << netQuarkContent()
32  << "\n is its own antiparticle? " << (isItsOwnAnti() ? "yes" : "no")
33  << "\n lifetime " << lifetime_in_ps() << " ps"
34  << "\n radius " << radius()*GeV << " /GeV"
35  << endl;
36 }
37 
38 /*
39 
40  0 1 2 3 4 5 6 7 8 91011 12 13 1415 16 17
41 *MASS(MeV) ,Err+ ,Err- ,WIDTH(MeV) ,Err+ ,Err- ,I ,G,J ,P,C,A,PDG-MC ,Chrg,R,S,Name ,Quarks
42 0.0E+00 ,0.0E+00,0.0E+00,0.0E+00 ,0.0E+00,0.0E+00,<2 , ,1 ,-,-, , 22, 0, ,R,gamma ,
43 8.0403E+04 ,2.9E+01,2.9E+01,2.14E+03 ,4.0E+01,4.0E+01, , ,1 , , ,B, 24, +, ,R,W ,
44 */
45 
47  : _netQuarkContent()
48 {
49  bool debugThis=false;
50 
51  _isValid=false;
52  if(pdg_string.empty()) return;
53  if(pdg_string[0] == '*') return;
54 
55  replace(pdg_string.begin(), pdg_string.end(), '\n', ','); // add a ',' to the end
56  remove(pdg_string.begin(), pdg_string.end(), ' '); // remove white space
57 
58  static const unsigned int nFields=18;
59  std::string s[nFields];
60  unsigned int first= 0;
61  unsigned int counter=0;
62  unsigned int charCounter=0;
63  while(counter < nFields){
64  if(pdg_string[charCounter] == ','){
65  int n=charCounter-first;
66  if(n<0)n=0;
67 
68  std::string tempString = " ";
69  if(n >= 1) tempString = pdg_string.substr(first, n);
70  if(debugThis){
71  cout << " tempString for charCounter = " << charCounter
72  << ", and counter = " << counter
73  << " is: " << tempString << endl;
74  }
75  if(tempString.empty()){
76  s[counter] = " ";
77  }else{
78  s[counter] = tempString;
79  }
80 
81  ++counter;
82  first = charCounter+1;
83  }
84  if(charCounter < pdg_string.size()-1) charCounter++;
85  }
86  if(counter != nFields) return; // sth wrong
87 
88  if(debugThis){
89  cout << "the strings : ";
90  for(unsigned int i=0; i<nFields; i++) cout << s[i] << "\n";
91  cout << endl;
92  }
93 
94  _mass = atof(s[0].c_str());
95  _mErrPlus = atof(s[1].c_str());
96  _mErrMinus = atof(s[2].c_str());
97  _width = atof(s[3].c_str());
98  _wErrPlus = atof(s[4].c_str());
99  _wErrMinus = atof(s[5].c_str());
100 
101  _Isospin = s[6];
102  char Gchar = s[7][0];
103  _JtotalSpin = s[8];
104  char Pchar = s[9][0];
105  char Cchar = s[10][0];
106  _Aformat = s[11][0];
107  _pdg_id = atoi(s[12].c_str());
108  _charge = s[13];
109  _Rexist = atoi(s[14].c_str());
110  _Status = s[15][0];
111  _name = s[16];
112  _quarks = s[17];
113 
115 
116  if(Gchar == '+') _Gparity= 1;
117  if(Gchar == '-') _Gparity= -1;
118  if(Gchar == ' ') _Gparity= 0;
119  if(Gchar == '0') _Gparity= 0;
120 
121  if(Cchar == '+') _Cqm= 1;
122  if(Cchar == '-') _Cqm= -1;
123  if(Cchar == ' ') _Cqm= 0;
124  if(Cchar == '0') _Cqm= 0;
125 
126  if(Pchar == '+') _Parity= 1;
127  if(Pchar == '-') _Parity= -1;
128  if(Pchar == ' ') _Parity= 0;
129  if(Pchar == '0') _Parity= 0;
130 
131  setRadius();
132 
133  if(debugThis){
134  cout << "ParticleProperties constructor: "
135  << "This is how I parsed the string: ";
136  this->print();
137  }
138 
139  _isValid=true;
140 }
141 
143  // set radius (not part of mass_width.csv):
144  if (abs(pdg_id()) == 421
145  || abs(pdg_id()) == 411
146  || abs(pdg_id()) == 431){
148  }else{
150  }
151 
152  string pdg_id_string = anythingToString(abs(pdg_id()));
153  string parName = pdg_id_string + "_Radius_invGeV";
154  NamedParameter<double> specificR( parName
155  , (double) -9999.0
156  , (const char*) 0
157  , NamedParameterBase::QUIET
158  );
159  if(specificR > -9998){
160  _Radius = specificR/GeV;
161  }else{
162  NamedParameter<double> genericR("Default_Radius_invGeV"
163  , (double) -9999.0
164  , (const char*) 0
165  , NamedParameterBase::QUIET);
166  if(genericR > -9998){
167  _Radius = genericR/GeV;
168  }
169  }
170 
171  return;
172 }
173 
174 void ParticleProperties::setMass(double m) const{
175  _mass = m;
176 }
177 
179  if(_quarks.empty()) return;
180 
181  replace(_quarks.begin(), _quarks.end(), 'U', 'h');
182  replace(_quarks.begin(), _quarks.end(), 'D', 'l');
183  replace(_quarks.begin(), _quarks.end(), 'C', 'i');
184  replace(_quarks.begin(), _quarks.end(), 'S', 'm');
185  replace(_quarks.begin(), _quarks.end(), 'T', 'j');
186  replace(_quarks.begin(), _quarks.end(), 'B', 'n');
187 
188  replace(_quarks.begin(), _quarks.end(), 'u', 'U');
189  replace(_quarks.begin(), _quarks.end(), 'd', 'D');
190  replace(_quarks.begin(), _quarks.end(), 'c', 'C');
191  replace(_quarks.begin(), _quarks.end(), 's', 'S');
192  replace(_quarks.begin(), _quarks.end(), 't', 'T');
193  replace(_quarks.begin(), _quarks.end(), 'b', 'B');
194 
195  replace(_quarks.begin(), _quarks.end(), 'h', 'u');
196  replace(_quarks.begin(), _quarks.end(), 'l', 'd');
197  replace(_quarks.begin(), _quarks.end(), 'i', 'c');
198  replace(_quarks.begin(), _quarks.end(), 'm', 's');
199  replace(_quarks.begin(), _quarks.end(), 'j', 't');
200  replace(_quarks.begin(), _quarks.end(), 'n', 'b');
201 
202  // since this also changes sqrt to sqrT, fix that:
203  unsigned int pos = _quarks.find("SqrT");
204  if(pos < _quarks.size()){
205  _quarks.replace(pos, 4, "sqrt");
206  }
207 }
208 
211 }
212 
214  replace(_charge.begin(), _charge.end(), '+', 'f');
215  replace(_charge.begin(), _charge.end(), '-', '+');
216  replace(_charge.begin(), _charge.end(), 'f', '-');
217 }
219  return ! (_Aformat == ' ');
220 }
222  if(! hasDistinctAnti()) return false;
223  antiCharge();
224  antiQuarks();
226  _pdg_id *= -1;
227  return true;
228 }
229 
231  ParticleProperties PP(*this);
232  PP.antiThis();
233  return PP;
234 }
235 
236 std::string ParticleProperties::name() const{
237  std::string fullName = _name;
238  if(_pdg_id < 0 && _Aformat == 'F') fullName += "bar";
239  fullName += _charge;
240  return fullName;
241 }
242 
244  if(width()<0) return -9999.0;
245  if(width() == 0) return 9.9999e109;
246  return hbar_Planck/width();
247 }
249  return lifetime()/ns;
250 }
252  return lifetime()/picosecond;
253 }
255  return lifetime()*c_light;
256 }
258  return ctau()/micrometer;
259 }
260 
262  return _Radius;
263  // not set in mass_width.csv, but in normal options file
264  // has default: 5/GeV for D0, 1.5/GeV otherwise
265  // Set in your usual options file like this (units: inverse GeV)
266  // <pdg_id>_Radius_invGeV <number in inverse GeV>
267  // for example:
268  // 421_Radius_invGeV 1.24
269  //
270 
271 }
272 
274 
275  if(J()=="0" && P() == -1) return "P";
276  else if(J()=="1" && P() == -1) return "V";
277  else if(J()=="0" && P() == 1) return "S";
278  else if(J()=="1" && P() == 1) return "A";
279  else if(J()=="2" && P() == 1) return "T";
280  else if(J()=="2" && P() == -1) return "PT";
281  else return "?";
282 }
283 
285 return ( 9981 == abs(pdg_id())
286  || 9991 == abs(pdg_id())
287  || 9983 == abs(pdg_id())
288  || 9993 == abs(pdg_id())
289  || 9985 == abs(pdg_id())
290  || 9975 == abs(pdg_id())
291  || 99981 == abs(pdg_id())
292  || 99991 == abs(pdg_id())
293  || 99983 == abs(pdg_id())
294  || 99993 == abs(pdg_id())
295  || 99985 == abs(pdg_id())
296  || 99975 == abs(pdg_id())
297  || 999981 == abs(pdg_id())
298  || 999991 == abs(pdg_id())
299  || 999983 == abs(pdg_id())
300  || 999993 == abs(pdg_id())
301  || 999985 == abs(pdg_id())
302  || 999975 == abs(pdg_id())
303  );
304 }
305 
306 std::ostream& operator<<(std::ostream& out, const ParticleProperties& pp){
307  pp.print(out);
308  return out;
309 }
310 
311 
312 //
double lifetime_in_ps() const
MultiQuarkContent _netQuarkContent
static const char * pionString
bool initFromString(const std::string &str)
std::ostream & operator<<(std::ostream &out, const ParticleProperties &pp)
static const double s
static const double picosecond
static const double ns
std::string J() const
static double _defaultCharmRadius
static const double hbar_Planck
void print(std::ostream &out=std::cout) const
ParticleProperties(std::string pdg_string="")
void setMass(double m) const
double lifetime_in_ns() const
MultiQuarkContent netQuarkContent(const DecayTree &dt_in)
Definition: DecayTree.cpp:33
static const double m
static const double c_light
double ctau_in_microns() const
static const double GeV
std::string anythingToString(const T &anything)
Definition: Utils.h:62
std::string name() const
ParticleProperties anti() const
double width() const
static const double micrometer
std::string ScalarVectorPseudoAxialVectorTensor() const
static double _defaultRadius