MINT2
ParticlePropertiesList.h
Go to the documentation of this file.
1 #ifndef PARTICLEPROPERTIESLIST_HH
2 #define PARTICLEPROPERTIESLIST_HH
3 // author: Jonas Rademacker (Jonas.Rademacker@bristol.ac.uk)
4 // status: Mon 9 Feb 2009 19:18:04 GMT
5 
6 #include <string>
7 #include <list>
8 #include <vector>
9 #include <map>
10 #include <iostream>
11 
13 
14 class ParticlePropertiesList{ // a singleton - ensures everyone
15  // uses the same particle properties, which is initialised
16  // only once. Saves space and time
17  // and (maybe) increases consistency.
18  // To get access do:
19  // ParticlePropertiesList* PPL = ParticlePropertiesList::getMe();
20  // and then:
21  // ParticleProperties* pionProps = PPL->get("pion");
22  // ParticleProperties* pionProps = PPL->get(221);
23  //
24 
26 
27 
28  ParticlePropertiesList(std::string fname_in="mass_width.cvs");
29  static std::string _MintDalitzSpecialParticles;
30  protected:
31  static std::vector<std::string> _dirList;
32  static const std::vector<std::string>& dirList();
33  static void fillDirList();
34 
35  static void printCannotFindWarning(const std::string& where
36  , const std::string& what);
37  static void printCannotFindWarning(const std::string& where
38  , int what);
39 
40  std::string _fname;
41  FILE* findFiles();
42  static FILE* findThisFile(const std::string& fname);
43  bool readFiles();
44  std::list<ParticleProperties> theList;
45  std::map<std::string, std::list<ParticleProperties>::iterator > byName;
46  std::map<int, std::list<ParticleProperties>::iterator > byID;
47 
48  public:
49  static const ParticlePropertiesList* getMe();
50 
51  const ParticleProperties* get(const std::string& name) const;
52  const ParticleProperties* get(int pdg_id) const;
53 
54  void print(std::ostream& out=std::cout) const;
55 
56 
57  // fast fuss-free access:
58  static double mass(const std::string& name);
59  static double mass(int PDG);
60  static double width(const std::string& name);
61  static double width(int PDG);
62 
63 };
64 
65 
66 std::ostream& operator<<(std::ostream& out, const ParticlePropertiesList& ppl);
67 
68 #endif
69 //
static FILE * findThisFile(const std::string &fname)
ParticlePropertiesList(std::string fname_in="mass_width.cvs")
void print(std::ostream &out=std::cout) const
static double width(const std::string &name)
std::ostream & operator<<(std::ostream &out, const ParticlePropertiesList &ppl)
static const std::vector< std::string > & dirList()
std::map< int, std::list< ParticleProperties >::iterator > byID
std::list< ParticleProperties > theList
const ParticleProperties * get(const std::string &name) const
static ParticlePropertiesList * ptr
static std::vector< std::string > _dirList
static void printCannotFindWarning(const std::string &where, const std::string &what)
static const ParticlePropertiesList * getMe()
static std::string _MintDalitzSpecialParticles
std::map< std::string, std::list< ParticleProperties >::iterator > byName
static double mass(const std::string &name)