CLHEP/HepPDT/TableBuilderT.hh

00001 // $Id: TableBuilderT.hh,v 1.3 2002/04/12 15:02:43 evc Exp $
00002 // ----------------------------------------------------------------------
00003 //
00004 // TableBuilderT.hh
00005 // Author: Marc Paterno, Walter Brown, Lynn Garren
00006 //
00007 // ----------------------------------------------------------------------
00008 // User code:
00009 //    ParticleDataTable pdt;
00010 //    {
00011 //       TableBuilderT      tb(pdt);
00012 //       addPythiaParticles( istream1, tb );
00013 //       addPythiaParticles( istream2, tb );
00014 //       tb.addParticle( myTempParticleData );
00015 //       // ...
00016 //    }  // triggers tb's destruction, filling pdt!
00017 // ----------------------------------------------------------------------
00018 #ifndef TABLEBUILDERT_HH
00019 #define TABLEBUILDERT_HH
00020 
00021 
00022 #include "CLHEP/config/CLHEP.h"
00023 #include "CLHEP/config/iostream.h"
00024 #include <string>
00025 #include <map>
00026 
00027 #include "CLHEP/HepPDT/ParticleDataTableT.hh"
00028 #include "CLHEP/HepPDT/TempParticleData.hh"
00029 #include "CLHEP/HepPDT/DefTable.hh"
00030 #include "CLHEP/HepPDT/QQDecayTable.hh"
00031 #include "CLHEP/HepPDT/stringtodouble.hh"
00032 
00033 namespace HepPDT {
00034 
00035 
00040 template< class Config >
00041 class TableBuilderT  {
00042   typedef  std::map<ParticleID,TempParticleData>   TempMap;
00043   typedef  std::map<std::string,ParticleID>        TempIDMap;
00044   typedef  std::map<std::string,TempAliasData>     TempAliasMap;
00045 
00046 public:
00047   explicit TableBuilderT( ParticleDataTableT<Config> & table,
00048                           std::ostream & str = std::cerr )
00049   : pdt(table), os(str)   { reverseEngineer(); }
00050   ~TableBuilderT()  { pdt.convertTemporaryMap( tempPDT, os ); }
00051 
00052   inline TempParticleData &  getParticleData( ParticleID pid );
00053   inline TempParticleData &  getParticleData( std::string const & name );
00054   inline TempParticleData &  getAntiParticle( ParticleID pid, 
00055                                               const std::string & aname );
00056 
00057   // --- mutators
00058   //
00059   inline void addParticle( TempParticleData const & pd );
00060          void removeParticle(ParticleID pid )  { tempPDT.remove(pid); }
00061   
00062   inline void addAlias( TempAliasData const & ad );
00063 
00064   // --- booleans
00065   //
00066   inline bool hasParticleData( std::string const & name );
00067   inline bool hasAlias( std::string const & alias );
00068          bool hasDefinition( std::string const & def ) { return tempDefMap.hasDefinition( def ); }
00069 
00070   // --- accessors
00071   //
00072          int             size()       const { return tempPDT.size(); }
00073          int             aliasSize()  const { return tempAliases.size(); }
00074          DefTable      & definitions()      { return tempDefMap; }
00075          double          definition( std::string const & def ) { return tempDefMap.definition( def ); }
00076   inline TempAliasData & aliasData( std::string const & alias );
00077 
00078 private:
00079   ParticleDataTableT<Config> &  pdt;
00080   TempMap                       tempPDT;
00081   TempIDMap                     tempIDT;
00082   TempAliasMap                  tempAliases;    // hold EvtGen alias information
00083   DefTable                      tempDefMap;     // hold EvtGen "Define" info
00084   std::ostream &                os;             // for diagnostics
00085 
00086   inline void fillPDT();                // ????
00087   // unpack existing PDT so its contents can be modified and added to
00088   inline void reverseEngineer();
00089 
00090   // forbidden copy:
00091   TableBuilderT &  operator = ( TableBuilderT const & );
00092   TableBuilderT( TableBuilderT const & );
00093 
00094 };  // TableBuilderT<>
00095 
00096 
00097 // --- free functions
00098 //
00099 
00100 template< class Config >
00101 inline
00102 bool  addPDGParticles( std::istream & pdfile, TableBuilderT<Config> & tb );
00103 
00104 template< class Config >
00105 inline
00106 bool  addPythiaParticles( std::istream & pdfile, TableBuilderT<Config> & tb );
00107 
00108 template< class Config >
00109 inline
00110 bool  addHerwigParticles( std::istream & pdfile, TableBuilderT<Config> & tb );
00111 
00112 template< class Config >
00113 inline
00114 bool  addIsajetParticles( std::istream & pdfile, TableBuilderT<Config> & tb );
00115 
00116 template< class Config >
00117 inline
00118 bool  addQQParticles( QQDecayTable & qd, TableBuilderT<Config> & tb );
00119 
00120 template< class Config >
00121 inline
00122 bool  addEvtGenParticles( std::istream & pdfile, TableBuilderT<Config> & tb );
00123 
00124 }  // namespace HepPDT
00125 
00126 #include "CLHEP/HepPDT/TableBuilderT.icc"
00127 #include "CLHEP/HepPDT/TableBuilderPythiaT.icc"
00128 #include "CLHEP/HepPDT/TableBuilderHerwigT.icc"
00129 #include "CLHEP/HepPDT/TableBuilderIsajetT.icc"
00130 #include "CLHEP/HepPDT/TableBuilderTEvtGen.icc"
00131 #include "CLHEP/HepPDT/TableBuilderTQQ.icc"
00132 
00133 #endif // TABLEBUILDERT_HH

Class Library for High Energy Physics (version 1.8)