00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef TableBuilder_HH
00018 #define TableBuilder_HH
00019
00020
00021 #include <iostream>
00022 #include <string>
00023 #include <map>
00024
00025 #include "HepPDT/ParticleDataTable.hh"
00026 #include "HepPDT/TempParticleData.hh"
00027 #include "HepPDT/DefTable.hh"
00028 #include "HepPDT/stringtodouble.hh"
00029
00030 namespace HepPDT {
00031
00033
00042 class TableBuilder {
00043 typedef std::map<ParticleID,TempParticleData> TempMap;
00044 typedef std::map<std::string,ParticleID> TempIDMap;
00045 typedef std::map<std::string,TempAliasData> TempAliasMap;
00046
00047 public:
00049 explicit TableBuilder( ParticleDataTable & table,
00050 std::ostream & str = std::cerr )
00051 : pdt(table), os(str) { reverseEngineer(); }
00053 ~TableBuilder() { pdt.convertTemporaryMap( tempPDT, os ); }
00054
00056 inline TempParticleData & getParticleData( ParticleID pid );
00058 inline TempParticleData & getParticleData( std::string const & name );
00060 inline TempParticleData & getAntiParticle( ParticleID pid,
00061 const std::string & aname );
00062
00063
00064
00066 inline void addParticle( TempParticleData const & pd );
00068 void removeParticle(ParticleID pid ) { tempPDT.erase(pid); }
00069
00071 inline void addAlias( TempAliasData const & ad );
00072
00073
00074
00076 inline bool hasParticleData( std::string const & name );
00078 inline bool hasAlias( std::string const & alias );
00080 bool hasDefinition( std::string const & def ) { return tempDefMap.hasDefinition( def ); }
00081
00082
00083
00085 int size() const { return tempPDT.size(); }
00087 int aliasSize() const { return tempAliases.size(); }
00089 DefTable & definitions() { return tempDefMap; }
00091 double definition( std::string const & def ) { return tempDefMap.definition( def ); }
00093 inline TempAliasData & aliasData( std::string const & alias );
00094
00095 private:
00096 ParticleDataTable & pdt;
00097 TempMap tempPDT;
00098 TempIDMap tempIDT;
00099 TempAliasMap tempAliases;
00100 DefTable tempDefMap;
00101 std::ostream & os;
00102
00103 inline void fillPDT();
00104
00105
00106 inline void reverseEngineer();
00107
00108
00109 TableBuilder & operator = ( TableBuilder const & );
00110 TableBuilder( TableBuilder const & );
00111
00112 };
00113
00114
00115
00116
00117
00119 bool addPDGParticles( std::istream & pdfile, TableBuilder & tb );
00120
00122 bool addPythiaParticles( std::istream & pdfile, TableBuilder & tb );
00123
00124 bool addHerwigParticles( std::istream & pdfile, TableBuilder & tb );
00125
00127 bool addIsajetParticles( std::istream & pdfile, TableBuilder & tb );
00129 bool addIsajetDecay( std::istream & pdfile, TableBuilder & tb );
00130
00132 bool addQQParticles( std::istream & pdfile, TableBuilder & tb );
00133
00135 bool addEvtGenParticles( std::istream & pdfile, TableBuilder & tb );
00136
00140 bool addParticleTable( std::istream & pdfile, TableBuilder & tb,
00141 bool validate = false );
00142
00143
00145
00150 namespace detail {
00151
00152 void getPDGpid( std::vector<int> & idlist, std::string & pdline );
00153 void getPDGnames( std::vector<std::string> & namelst, std::string & pdline );
00154 void parsePDGline( TempParticleData & tpd, std::string & pdline );
00155 bool CheckPDGEntry( TempParticleData & tpd, const std::string &, double, double );
00156
00157 bool getPythiaid( int & id, const std::string & pdline );
00158 void parsePythiaLine( TempParticleData & tpd, int & anti, std::string & aname,
00159 const std::string & pdline );
00160 void parsePythiaDecayLine( TempParticleData & tpd, const std::string & pdline );
00161 TempDecayData getPythiaDecay( const std::string & pdline );
00162
00163 bool getIsajetID( int & id, const std::string & pdline );
00164 void parseIsajetLine( TempParticleData & tpd, const std::string & pdline );
00165 void parseIsajetDecayLine( TempParticleData & tpd, const std::string & pdline,
00166 TableBuilder & tb );
00167
00168 bool getParticleID( int & id, const std::string & pdline );
00169 void parseParticleLine( TempParticleData & tpd, const std::string & pdline );
00170
00171 }
00172
00173
00174 }
00175
00176 #include "HepPDT/TableBuilder.icc"
00177
00178 #endif // TableBuilder_HH