ROOTPWA
particleDataTable.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 // singleton class that manages all particle data
29 //
30 //
31 // Author List:
32 // Boris Grube TUM (original author)
33 //
34 //
35 //-------------------------------------------------------------------------
36 
37 
38 #ifndef PARTICLEDATATABLE_H
39 #define PARTICLEDATATABLE_H
40 
41 
42 #include <string>
43 #include <vector>
44 #include <map>
45 #include <set>
46 
47 #include <boost/bimap.hpp>
48 
49 #include "particleProperties.h"
50 
51 
52 namespace rpwa {
53 
54 
56 
57  public:
58 
59  static particleDataTable& instance() { return _instance; }
60 
61  static bool isInTable(const std::string& partName);
62 
63  static const particleProperties* entry(const std::string& partName,
64  const bool warnIfNotExistent = true);
65 
66  static bool addEntry(const particleProperties& partProp);
67 
68  static std::vector<const particleProperties*>
69  entriesMatching(const particleProperties& prototype,
70  const std::string& sel,
71  const double minMass = 0,
72  const double minMassWidthFactor = 0,
73  const std::vector<std::string>& whiteList = std::vector<std::string>(),
74  const std::vector<std::string>& blackList = std::vector<std::string>(),
76  const bool& forceDecayCheck = true);
77 
78  static unsigned int nmbEntries() { return _dataTable.size(); }
79 
80  typedef std::map<std::string, particleProperties>::const_iterator iterator;
81  static iterator begin() { return _dataTable.begin(); }
82  static iterator end() { return _dataTable.end(); }
83 
84  static std::ostream& print(std::ostream& out);
85  static std::ostream& dump (std::ostream& out);
86 
87  static bool readFile(const std::string& fileName = "./particleDataTable.txt");
88  static bool read(std::istream& in);
89 
90  static bool readDecayModeFile(const std::string& fileName);
91 
92  static std::string particleNameFromGeantId(const int id);
93  static void geantIdAndChargeFromParticleName(const std::string& name,
94  int& id,
95  int& charge);
96  static unsigned int geantIdFromParticleName(const std::string& name);
97 
98  static void clear() { _dataTable.clear(); }
99 
100  static bool debug() { return _debug; }
101  static void setDebug(const bool debug = true) { _debug = debug; }
102 
103 
104  private:
105 
110 
112  static std::map<std::string, particleProperties> _dataTable;
113 
114  static boost::bimap<std::string, unsigned int> _nameGeantIdMap;
115 
116  static bool _debug;
117 
118  };
119 
120 
121  inline
122  std::ostream&
123  operator <<(std::ostream& out,
124  const particleDataTable& dataTable)
125  {
126  return dataTable.print(out);
127  }
128 
129 
130  inline
131  std::istream&
132  operator >>(std::istream& in,
133  particleDataTable& dataTable)
134  {
135  dataTable.read(in);
136  return in;
137  }
138 
139 
140 } // namespace rpwa
141 
142 
143 #endif // PARTICLEDATATABLE_H