StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StParticleTable.hh
1 /***************************************************************************
2  *
3  * $Id: StParticleTable.hh,v 1.5 2005/09/22 20:09:20 fisyak Exp $
4  *
5  * Author: Thomas Ullrich, May 99 (based on Geant4 code, see below)
6  ***************************************************************************
7  *
8  * The design of the StParticleDefinition class and all concrete
9  * classes derived from it is largely based on the design of the
10  * G4ParticleDefinition class from Geant4 (RD44).
11  * Although the code is in large parts different (modified or rewritten)
12  * and adapted to the STAR framework the basic idea stays the same.
13  *
14  ***************************************************************************
15  *
16  * $Log: StParticleTable.hh,v $
17  * Revision 1.5 2005/09/22 20:09:20 fisyak
18  * Make StLorentzVector persistent
19  *
20  * Revision 1.4 2003/09/02 17:59:35 perev
21  * gcc 3.2 updates + WarnOff
22  *
23  * Revision 1.3 2000/01/04 14:57:56 ullrich
24  * Added friend declaration to avoid warning messages
25  * under Linux.
26  *
27  * Revision 1.2 1999/12/21 15:14:26 ullrich
28  * Modified to cope with new compiler version on Sun (CC5.0).
29  *
30  * Revision 1.1 1999/05/14 18:50:00 ullrich
31  * Initial Revision
32  *
33  **************************************************************************/
34 #ifndef StParticleTable_hh
35 #define StParticleTable_hh
36 #ifdef __ROOT__
37 #include "Rtypes.h"
38 #endif
39 
40 #include <Stiostream.h>
41 #include <string>
42 #include <map>
43 #include <vector>
45 #if !defined(ST_NO_NAMESPACES)
46 using std::vector;
47 using std::map;
48 using std::string;
49 #endif
50 
51 #ifdef ST_NO_TEMPLATE_DEF_ARGS
52 typedef vector<StParticleDefinition*, allocator<StParticleDefinition*> > StVecPtrParticleDefinition;
53 #else
54 typedef vector<StParticleDefinition*> StVecPtrParticleDefinition;
55 #endif
56 
58 public:
59  virtual ~StParticleTable();
60 
61  static StParticleTable* particleTable();
62  static StParticleTable* instance();
63 
64  unsigned int entries() const;
65  unsigned int size() const;
66 
67  bool contains(const string &) const; // by name
68  bool contains(int) const; // by PDG encoding
69  bool containsGeantId(int) const; // by Geant3 id
70 
71  StParticleDefinition* findParticle(const string&) const; // by name
72  StParticleDefinition* findParticle(int) const; // by PDG encoding
73  StParticleDefinition* findParticleByGeantId(int) const; // by Geant3 id
74 
75  void insert(StParticleDefinition*);
76  void erase(StParticleDefinition*);
77 
78  void dump(ostream& = cout);
79 
80  StVecPtrParticleDefinition allParticles() const;
81 
82  friend class nobody;
83 
84 private:
86  StParticleTable(const StParticleTable &right);
87 
88  static StParticleTable *mParticleTable;
89 
90 #ifdef ST_NO_TEMPLATE_DEF_ARGS
91  // as soon as Sun CC4.2 is gone this goes as well
92  typedef map<int, int, less<int>,
93  allocator< pair<const int, int> > >
94  mGeantPdgMapType;
95  typedef map<int, StParticleDefinition*, less<int>,
96  allocator< pair<const int,StParticleDefinition*> > >
97  mPdgMapType;
98  typedef map<string, StParticleDefinition*, less<string>,
99  allocator< pair<const string,StParticleDefinition*> > >
100  mNameMapType;
101 #else
102  typedef map<int, int> mGeantPdgMapType;
103  typedef map<int, StParticleDefinition*> mPdgMapType;
104  typedef map<string, StParticleDefinition*> mNameMapType;
105 #endif
106 
107  mGeantPdgMapType mGeantPdgMap; // Geant3 IDs only
108  mPdgMapType mPdgMap; // PDG IDs only
109  mNameMapType mNameMap; // complete list
110 #ifdef __ROOT__
111  ClassDef(StParticleTable,1)
112 #endif
113 };
114 #endif
115 
116 
117 
118 
119 
120