Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:11:35

0001 // ----------------------------------------------------------------------
0002 //
0003 // TableBuilder.hh
0004 // Author: Marc Paterno, Walter Brown, Lynn Garren
0005 //
0006 // ----------------------------------------------------------------------
0007 // User code:
0008 //    ParticleDataTable pdt;
0009 //    {
0010 //       TableBuilder      tb(pdt);
0011 //       addPythiaParticles( istream1, tb );
0012 //       addPythiaParticles( istream2, tb );
0013 //       tb.addParticle( myTempParticleData );
0014 //       // ...
0015 //    }  // triggers tb's destruction, filling pdt!
0016 // ----------------------------------------------------------------------
0017 #ifndef TableBuilder_HH
0018 #define TableBuilder_HH
0019 
0020 
0021 #include <iostream>
0022 #include <string>
0023 #include <map>
0024 
0025 #include "HepPDT/ParticleDataTable.hh"
0026 #include "HepPDT/TempParticleData.hh"
0027 #include "HepPDT/DefTable.hh"
0028 #include "HepPDT/stringtodouble.hh"
0029 
0030 namespace HepPDT {
0031 
0032 //! The TableBuilder class is used to construct a ParticleDataTable.
0033 
0034 ///
0035 /// \class TableBuilder
0036 /// \author Marc Paterno, Walter Brown, Lynn Garren
0037 ///
0038 /// Define this class and use the add methods to define a ParticleDataTable.
0039 /// The destructor fills ParticleDataTable from the information in TableBuilder.
0040 /// See the examples for user code.
0041 ///
0042 class TableBuilder  {
0043   typedef  std::map<ParticleID,TempParticleData>   TempMap;
0044   typedef  std::map<std::string,ParticleID>        TempIDMap;
0045   typedef  std::map<std::string,TempAliasData>     TempAliasMap;
0046 
0047 public:
0048   /// create TableBuilder from a ParticleDataTable
0049   explicit TableBuilder( ParticleDataTable & table,
0050                           std::ostream & str = std::cerr )
0051   : pdt(table), os(str)   { reverseEngineer(); }
0052   /// call the ParticleDataTable conversion method upon destruction
0053   ~TableBuilder()  { pdt.convertTemporaryMap( tempPDT, os ); }
0054 
0055   /// create a TempParticleData from a ParticleID
0056   inline TempParticleData &  getParticleData( ParticleID pid );
0057   /// create a TempParticleData from a particle name
0058   inline TempParticleData &  getParticleData( std::string const & name );
0059   /// create an antiparicle TempParticleData from a ParticleID
0060   inline TempParticleData &  getAntiParticle( ParticleID pid, 
0061                                               const std::string & aname );
0062 
0063   // --- mutators
0064   //
0065   /// add a TempParticleData to the map
0066   inline void addParticle( TempParticleData const & pd );
0067   /// remove a TempParticleData from the map
0068          void removeParticle(ParticleID pid )  { tempPDT.erase(pid); }
0069   
0070   /// add alias information to the alias map
0071   inline void addAlias( TempAliasData const & ad );
0072 
0073   // --- booleans
0074   //
0075   /// check to see if this particle is already defined
0076   inline bool hasParticleData( std::string const & name );
0077   /// check to see if this alias is already defined
0078   inline bool hasAlias( std::string const & alias );
0079   /// check to see if this particle name is already defined
0080          bool hasDefinition( std::string const & def ) { return tempDefMap.hasDefinition( def ); }
0081 
0082   // --- accessors
0083   //
0084   /// get size of particle data map
0085          int             size()       const { return tempPDT.size(); }
0086   /// get size of alias map
0087          int             aliasSize()  const { return tempAliases.size(); }
0088   /// get the list of definitions (for EvtGen)
0089          DefTable      & definitions()      { return tempDefMap; }
0090   /// return a parameter definition (for EvtGen)
0091      double          definition( std::string const & def ) { return tempDefMap.definition( def ); }
0092   /// find an entry in the alias map
0093   inline TempAliasData & aliasData( std::string const & alias );
0094 
0095 private:
0096   ParticleDataTable &  pdt;
0097   TempMap                       tempPDT;
0098   TempIDMap                     tempIDT;
0099   TempAliasMap                  tempAliases;    // hold EvtGen alias information
0100   DefTable                      tempDefMap; // hold EvtGen "Define" info
0101   std::ostream &                os;         // for diagnostics
0102 
0103   inline void fillPDT();        //!< unused
0104   /// unpack existing PDT so its contents can be modified and added to a new PDT
0105   /// not implemented
0106   inline void reverseEngineer();
0107 
0108   // forbidden copy:
0109   TableBuilder &  operator = ( TableBuilder const & );
0110   TableBuilder( TableBuilder const & );
0111 
0112 };  // TableBuilder<>
0113 
0114 
0115 // --- free functions
0116 //
0117 
0118 /// read PDG input and add particles to the table
0119 bool  addPDGParticles( std::istream &, TableBuilder & );
0120 
0121 /// read Pythia input and add particles to the table
0122 bool  addPythiaParticles( std::istream &, TableBuilder & );
0123 
0124 bool  addHerwigParticles( std::istream &, TableBuilder & );
0125 
0126 /// read Isajet particle input and add particles to the table
0127 bool  addIsajetParticles( std::istream &, TableBuilder & );
0128 /// read Isajet decay input and add decay information to the table
0129 bool  addIsajetDecay( std::istream &, TableBuilder & );
0130 
0131 /// read QQ input and add particles to the table
0132 bool  addQQParticles( std::istream &, TableBuilder & );
0133 
0134 /// read EvtGen input and add particles to the table
0135 bool  addEvtGenParticles( std::istream &, TableBuilder & );
0136 
0137 /// read particle.tbl (or something similar) and add particles to the table
0138 bool  addParticleTable( std::istream &, TableBuilder & );
0139 
0140 
0141 //! HepPDT::detail is for internal use
0142 
0143 ///
0144 /// \namespace HepPDT::detail
0145 /// This namespace encapsulates free functions used when parsing various input streams.
0146 /// These functions are intended for internal use.
0147 ///
0148 namespace detail {
0149 
0150 void getPDGpid( std::vector<int> &,  std::string & ); //!< for internal use
0151 void getPDGnames( std::vector<std::string> &,  std::string & ); //!< for internal use
0152 void parsePDGline( TempParticleData &,  std::string & ); //!< for internal use
0153 bool CheckPDGEntry( TempParticleData &, const std::string &, double, double ); //!< for internal use
0154 
0155 bool getPythiaid( int &, const std::string & ); //!< for internal use
0156 void parsePythiaLine( TempParticleData &, int &, std::string &, 
0157                       const std::string & ); //!< for internal use
0158 void parsePythiaDecayLine( TempParticleData &, const std::string & ); //!< for internal use
0159 TempDecayData getPythiaDecay( const std::string & ); //!< for internal use
0160 
0161 bool getIsajetID( int &, const std::string & ); //!< for internal use
0162 void parseIsajetLine( TempParticleData &, const std::string & ); //!< for internal use
0163 void parseIsajetDecayLine( TempParticleData &, const std::string &,
0164                            TableBuilder & ); //!< for internal use
0165 
0166 bool getParticleID( int & id, const std::string & ); //!< for internal use
0167 void parseParticleLine( TempParticleData &, const std::string & ); //!< for internal use
0168 
0169 }  // namespace detail
0170 
0171 
0172 }  // namespace HepPDT
0173 
0174 #include "HepPDT/TableBuilder.icc"
0175 
0176 #endif // TableBuilder_HH