CLHEP/HepPDT/PDGtoQQTable.hh

00001 // $Id: PDGtoQQTable.hh,v 1.5 2002/04/18 20:15:23 garren Exp $
00002 // ----------------------------------------------------------------------
00003 //
00004 // PDGtoQQTable.hh
00005 // Author: Lynn Garren
00006 //
00007 // There should never be more than one translation table, therefore
00008 // this class is a singleton.
00009 // ----------------------------------------------------------------------
00010 #ifndef PDGTOQQTABLE_HH
00011 #define PDGTOQQTABLE_HH
00012 
00013 #include "CLHEP/config/CLHEP.h"
00014 #include <assert.h>
00015 #include <vector>
00016 #include <map>
00017 
00018 #include "CLHEP/config/sstream.h"
00019 #include "CLHEP/HepPDT/QQDecayTable.hh"
00020 
00021 #define QQTOPDTARRAYSIZE 520
00022 
00023 namespace HepPDT {
00024 
00029 class PDGtoQQTable  {
00030   typedef  std::map<int,int>            PDTtoQQMap;
00031 
00032 public:
00033   typedef  PDTtoQQMap::const_iterator  const_iterator;
00034   typedef  PDTtoQQMap::iterator        iterator;
00035 
00036   // The singleton instance
00037   static PDGtoQQTable* instance();
00038 
00039   // --- mutators
00040   //
00041   void addPDTDefinition( int const & def, int val );
00042   void addQQDefinition( int const & def, int val );
00043   void buildTable( QQDecayTable & qd );
00044 
00045   // --- boolean
00046   //
00047   bool hasDefinition( int const & def ) const;
00048 
00049   // --- accessors
00050   //
00051   int   QQnumber( int const & def ) const;
00052   int   PDTnumber( int const & def ) const;
00053   void  writeTranslations( std::ostream & os ) const;   // intended for diagnostic use
00054 
00055   int             size()  const { return itsPDTtoQQmap.size(); }
00056   iterator        begin()       { return itsPDTtoQQmap.begin(); }
00057   const_iterator  begin() const { return itsPDTtoQQmap.begin(); }
00058   iterator        end()         { return itsPDTtoQQmap.end(); }
00059   const_iterator  end()   const { return itsPDTtoQQmap.end(); }
00060 
00061 private:
00062   PDTtoQQMap        itsPDTtoQQmap;      // map of PDT numbers to QQ numbers
00063   std::vector<int>  itsQQtoPDTarray;    // QQ numbers range from -13 to 498
00064 
00065   // Singleton stuff
00066   PDGtoQQTable(): itsPDTtoQQmap(), itsQQtoPDTarray(QQTOPDTARRAYSIZE,0) { ; }
00067   ~PDGtoQQTable();
00068 
00069   PDGtoQQTable(const PDGtoQQTable&);            // not implemented
00070   PDGtoQQTable& operator=(const PDGtoQQTable&); // not implemented
00071 
00072   static PDGtoQQTable* _inst;
00073   static void destroy_and_clear();
00074 
00075   struct Cleaner;
00076   friend struct Cleaner;
00077   struct Cleaner { ~Cleaner() { PDGtoQQTable::destroy_and_clear(); } };
00078 
00079 };  // PDGtoQQTable
00080 
00081 }  // namespace HepPDT
00082 
00083 #endif // PDGTOQQTABLE_HH

Class Library for High Energy Physics (version 1.8)