ROOTPWA
particleProperties.h
Go to the documentation of this file.
1 
2 //
3 // Copyright 2010
4 //
5 // This file is part of rootpwa
6 //
7 // rootpwa is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // rootpwa is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
19 //
21 //-------------------------------------------------------------------------
22 // File and Version Information:
23 // $Rev:: $: revision of last commit
24 // $Author:: $: author of last commit
25 // $Date:: $: date of last commit
26 //
27 // Description:
28 // container class for particle properties
29 //
30 // !NOTE! all potentially half-integer quantum numbers (I, I_z, J)
31 // are in units of hbar / 2 so that they are always integer
32 //
33 //
34 // Author List:
35 // Boris Grube TUM (original author)
36 //
37 //
38 //-------------------------------------------------------------------------
39 
40 
41 #ifndef PARTICLEPROPERTIES_H
42 #define PARTICLEPROPERTIES_H
43 
44 
45 #include <string>
46 #include <map>
47 #include <set>
48 #include <vector>
49 #include <iostream>
50 #include <sstream>
51 
52 #include "mathUtils.hpp"
53 #include "reportingUtils.hpp"
54 
55 
56 namespace rpwa {
57 
58 
60 
61  public:
62 
63  // helper class that holds information about particle decay
64  struct decayMode {
65 
66  decayMode(const std::multiset<std::string>& daughters = std::multiset<std::string>(),
67  const int L = -1,
68  const int S = -1);
69  virtual ~decayMode();
70 
71  bool operator ==(const decayMode& rhsDecay) const;
72 
73  virtual std::ostream& print(std::ostream& out) const;
74 
75  std::multiset<std::string> _daughters;
76  int _L;
77  int _S;
78 
79  };
80 
82  particleProperties(const particleProperties& partProp);
83  particleProperties(const std::string& partName,
84  const int isospin,
85  const int G,
86  const int J,
87  const int P,
88  const int C);
89 
90  virtual ~particleProperties();
91 
93  // comparison operators that check equality of all fields
94  bool operator ==(const particleProperties& rhsProp) const { return this->isEqualTo(rhsProp); }
95  bool operator !=(const particleProperties& rhsProp) const { return not (*this == rhsProp); }
96  // comparison operators that check equality of fields selectable via string
97  friend bool operator ==(const particleProperties& lhsProp,
98  const std::pair<particleProperties, std::string>& rhsPropSel);
99  friend bool operator !=(const particleProperties& lhsProp,
100  const std::pair<particleProperties, std::string>& rhsPropSel)
101  { return not (lhsProp == rhsPropSel); }
102 
103  std::string name () const { return nameWithCharge(_name, _charge); }
104  std::string bareName () const { return _name; }
105  std::string antiPartName () const { return nameWithCharge(_antiPartName, -_charge); }
106  std::string antiPartBareName() const { return _antiPartName; }
107  int charge () const { return _charge; }
108  double mass () const { return _mass; }
109  double mass2 () const { return _mass2; }
110  double width () const { return _width; }
111  int baryonNmb () const { return _baryonNmb; }
112  int isospin () const { return _isospin; }
113  int isospinProj () const { return 2 * _charge - (baryonNmb() + strangeness() + charm() + beauty()); }
114  int strangeness () const { return _strangeness; }
115  int charm () const { return _charm; }
116  int beauty () const { return _beauty; }
117  int G () const { return _G; }
118  int J () const { return _J; }
119  int P () const { return _P; }
120  int C () const { return _C; }
121  unsigned int geantId () const;
122 
123  bool isXParticle() const;
124 
125  bool isMeson () const;
126  bool isBaryon() const;
127  bool isLepton() const;
128  bool isPhoton() const;
129 
130  bool isItsOwnAntiPart() const;
131 
132  bool isSpinExotic() const;
133 
134  const std::vector<decayMode>& decayModes() const { return _decayModes; }
135  unsigned int nmbDecays () const { return _decayModes.size(); }
136  bool hasDecay (const decayMode& decay) const;
137  void addDecayMode (const decayMode& decay) { _decayModes.push_back(decay); }
138  void deleteDecayModes() { _decayModes.clear(); }
139 
140  bool fillFromDataTable(const std::string& name,
141  const bool warnIfNotExistent = true);
142 
143  void setName (const std::string& name );
144  void setAntiPartName(const std::string& name ) { _antiPartName = stripChargeFromName(name); }
145  void setCharge (const int charge );
146  void setMass (const double mass );
147  void setWidth (const double width ) { _width = width; }
148  void setBaryonNmb (const int baryonNmb ) { _baryonNmb = baryonNmb; }
149  void setIsospin (const int isospin ) { _isospin = abs(isospin); }
150  void setIsospinProj (const int isospinProj) { _charge = (isospinProj + baryonNmb() + strangeness() + charm() + beauty()) / 2; }
152  void setCharm (const int charm ) { _charm = charm; }
153  void setBeauty (const int beauty ) { _beauty = beauty; }
154  void setG (const int G ) { _G = signum(G); }
155  void setJ (const int J ) { _J = abs(J); }
156  void setP (const int P ) { _P = signum(P); }
157  void setC (const int C ) { _C = signum(C); }
158 
159  void setSCB (const int strangeness,
160  const int charm,
161  const int beauty);
162  void setIGJPC(const int isospin,
163  const int G,
164  const int J,
165  const int P,
166  const int C);
167 
168  particleProperties antiPartProperties(const bool convertDecaysModes = false) const;
169 
170  virtual std::string qnSummary() const;
171 
172  // std::string nameLaTeX () const; ///< returns particle name including charge in LaTeX markup
173  std::string bareNameLaTeX () const;
174  // virtual std::string qnSummaryLaTeX() const; ///< returns particle's quantum number summary in form name[IG(JPC)] in LaTeX markup
175 
176  virtual std::ostream& print(std::ostream& out) const;
177  virtual std::ostream& dump (std::ostream& out) const;
178 
179  bool read(std::istringstream& line);
180 
181  static std::string nameWithCharge(const std::string& bareName,
182  const int charge);
183 
184  static std::string chargeFromName(const std::string& name,
185  int& charge);
186  static std::string stripChargeFromName(const std::string& name);
187 
188  static bool debug() { return _debug; }
189  static void setDebug(const bool debug = true) { _debug = debug; }
190 
191 
192  protected:
193 
194  virtual bool isEqualTo(const particleProperties& partProp) const;
195 
196 
197  private:
198 
199  std::string _name;
200  std::string _antiPartName;
201  int _charge;
202  double _mass;
203  double _mass2;
204  double _width;
206  int _isospin;
208  int _charm;
209  int _beauty;
210  int _G;
211  int _J;
212  int _P;
213  int _C;
214 
215  std::vector<decayMode> _decayModes;
216 
217  static bool _debug;
218 
219  }; // particleProperties
220 
221 
222  inline
223  std::ostream&
224  operator <<(std::ostream& out,
226  {
227  return mode.print(out);
228  }
229 
230 
231  inline
232  bool
234  {
235  return ((_name == "X") or (_name == "X-") or (_name == "X0") or (_name == "X+"));
236  }
237 
238 
239  inline
240  bool
242  {
243  return ( (abs(charge()) <= 1) and (baryonNmb() == 0)
244  and (isospin() <= 2) and (abs(strangeness()) <= 1) and (abs(charm()) <= 1)
245  and (abs(beauty()) <= 1) and isEven(J()) and (abs(P()) == 1) and (abs(C()) <= 1)
246  and ((abs(charge()) != 0) or (G() == powMinusOne(isospin() / 2) * C())));
247  }
248 
249 
250  inline
251  bool
253  {
254  return ( (abs(charge()) <= 2) and (baryonNmb() == 1)
255  and (isospin() <= 3) and (abs(strangeness()) <= 3) and (abs(charm()) <= 3)
256  and (abs(beauty()) <= 3) and isOdd(J()) and (abs(P()) == 1)
257  and (C() == 0) and (G() == 0));
258  }
259 
260 
261  inline
262  bool
264  {
265  return ( (abs(charge()) <= 1) and (baryonNmb() == 0) and (isospin() == 0)
266  and (strangeness() == 0) and (charm() == 0) and (beauty() == 0)
267  and (J() == 1) and (abs(P()) == 1) and (C() == 0) and (G() == 0));
268  }
269 
270 
271  inline
272  bool
274  {
275  return ( (charge() == 0) and (baryonNmb() == 0) and (isospin() == 0)
276  and (strangeness() == 0) and (charm() == 0) and (beauty() == 0)
277  and (J() == 2) and (P() == -1) and (C() == -1) and (G() == 0));
278  }
279 
280 
281  inline
282  bool
284  {
285  return ( (isMeson() or isPhoton()) and (name() == antiPartName())
286  and (charge() == 0) and (baryonNmb() == 0) and (isospinProj() == 0)
287  and (strangeness() == 0) and (charm() == 0) and (beauty() == 0));
288  }
289 
290 
291  inline
292  void
293  particleProperties::setName(const std::string& partName)
294  {
295  int charge;
296  _name = chargeFromName(partName, charge);
297  setCharge(charge);
298  }
299 
300 
301  inline
302  void
304  {
305  if (abs(charge) < 10)
306  _charge = charge;
307  else {
308  printErr << "absolute value of charge " << charge << " is larger than 9. "
309  << "aborting." << std::endl;
310  throw;
311  }
312  }
313 
314 
315  inline
316  void
318  {
319  _mass = mass;
320  _mass2 = mass * mass;
321  }
322 
323 
324  inline
325  std::ostream&
326  operator <<(std::ostream& out,
327  const particleProperties& partProp)
328  {
329  return partProp.print(out);
330  }
331 
332 
333  inline
334  std::istream&
335  operator >>(std::istream& in,
336  particleProperties& partProp)
337  {
338  std::string line;
339  if (getline(in, line)) {
340  // skip comments and empty lines
341  while ((line == "") or (line[0] == '#')) {
342  if (partProp.debug())
343  printDebug << "ignoring line '" << line << "'" << std::endl;
344  if (not getline(in, line)) {
345  printWarn << "could not find valid particle entry before end of file" << std::endl;
346  return in;
347  }
348  }
349  std::istringstream lineStream(line);
350  partProp.read(lineStream);
351  }
352  return in;
353  }
354 
355 
356 } // namespace rpwa
357 
358 
359 #endif // PARTICLEPROPERTIES_H