Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // ----------------------------------------------------------------------
0002 //
0003 // ParticleDataTable.hh
0004 // Author: Lynn Garren, Walter Brown
0005 //
0006 // ----------------------------------------------------------------------
0007 #ifndef ParticleDataTable_HH
0008 #define ParticleDataTable_HH
0009 
0010 #include <iostream>
0011 #include <string>
0012 #include <map>
0013 #include <list>
0014 
0015 #include "HepPDT/ParticleID.hh"
0016 #include "HepPDT/DecayData.hh"
0017 #include "HepPDT/DecayChannel.hh"
0018 #include "HepPDT/ParticleData.hh"
0019 #include "HepPDT/ParticleDataTableComparison.hh"
0020 #include "HepPDT/ProcessUnknownID.hh"
0021 #include "HepPDT/SimpleProcessUnknownID.hh"
0022 #include "HepPDT/Version.hh"
0023 
0024 //! HepPDT is a Particle Data Table namespace 
0025 
0026 ///
0027 /// \namespace HepPDT
0028 /// The HepPDT classes are used to create a Particle Data Table.
0029 ///
0030 namespace HepPDT {
0031   
0032 //! The ParticleDataTable class is the core of HepPDT.
0033 
0034 ///
0035 /// \class ParticleDataTable
0036 /// \author Lynn Garren, Walter Brown
0037 ///
0038 /// This is the table of particle data information.
0039 /// This table is created once at the beginning of a job and referenced
0040 /// as needed.  
0041 /// We expect that the table will be saved as part of the standard job output.
0042 /// Methods exist to fill the table from a variety of input formats.
0043 /// The user may fill the table from as many differernt input streams 
0044 /// as desired.
0045 /// See the examples.
0046 ///
0047 class ParticleDataTable  {
0048   
0049 public:
0050   typedef  CommonParticleData                     CPD;
0051 
0052   typedef  std::list<CommonParticleData>          CPDlist;
0053   typedef  std::list<DecayData>                   DDlist;
0054 
0055   typedef  CPDlist::const_iterator                CPDID;
0056   typedef  DDlist::const_iterator                 DDID;
0057 
0058   typedef  std::map<ParticleID,TempParticleData>  TempMap;
0059   typedef  std::map<ParticleID,ParticleData,ParticleDataTableComparison> PDTMap;
0060   typedef  std::map<std::string,ParticleID>       PDTNameMap;
0061 
0062   typedef PDTMap::const_iterator                  const_iterator;
0063   typedef PDTNameMap::const_iterator              const_iteratorByName;
0064 
0065   // ---  birth/death:
0066   //
0067   /// Construct a particle data table with an identifying name.
0068   /// Require a method to deal with unknown PID's.
0069   ParticleDataTable( std::string name = " ", ProcessUnknownID* = new SimpleProcessUnknownID );
0070   ~ParticleDataTable();
0071 
0072   // ---  accessors:
0073   //
0074   /// size of the particle data table
0075   int             size()  const { return itsMap.size(); }
0076   /// begin iterating over the particle data table
0077   const_iterator  begin() const { return itsMap.begin(); }
0078   /// end iterating over the particle data table
0079   const_iterator  end()   const { return itsMap.end(); }
0080   /// size of the map of particle names
0081   int                   sizeNameMap()  const { return itsNameMap.size(); }
0082   /// begin iterating over the map of particle names
0083   const_iteratorByName  beginNameMap() const { return itsNameMap.begin(); }
0084   /// end iterating over the map of particle names
0085   const_iteratorByName  endNameMap()   const { return itsNameMap.end(); }
0086   /// return the name of this particle data table
0087   std::string     tableName() const { return itsTableName; }
0088 
0089   /// access particle information via ParticleID
0090   ParticleData const * particle( ParticleID ) const;
0091   /// access particle information via ParticleID
0092   ParticleData       * particle( ParticleID );
0093   /// access particle information via a particle name
0094   ParticleData const * particle( std::string ) const;
0095   /// access particle information via a particle name
0096   ParticleData       * particle( std::string );
0097 
0098   /// access particle information via ParticleID
0099   ParticleData       * operator [] ( ParticleID );
0100   /// access particle information via ParticleID
0101   ParticleData const * operator [] ( ParticleID ) const;
0102   /// access particle information via a particle name
0103   ParticleData       * operator [] ( std::string );
0104   /// access particle information via a particle name
0105   ParticleData const * operator [] ( std::string ) const;
0106 
0107   /// output all information in the PDT
0108   void writeParticleData( std::ostream & outstr );
0109   /// output all information about a particle EXCEPT its decays
0110   void writeParticleInfo( std::ostream & outstr );
0111   /// output a list of original IDs and their translations
0112   void writeParticleTranslation( std::ostream & outstr );
0113   /// primarily useful for testing
0114   void writeParticleStatus( std::ostream & );
0115   
0116   /// used by the TableBuilder destructor to fill the PDT 
0117   void convertTemporaryMap( TempMap & tempPDT, std::ostream & err );
0118 
0119   /// add decay data information
0120   DDID addDecayData( DecayData const d );
0121 
0122 private:
0123   // --- local data:
0124   CPDlist    mutable  itsCPDlist;
0125   DDlist              itsDDlist;
0126   PDTMap     mutable  itsMap;
0127   PDTNameMap mutable  itsNameMap;
0128   std::string itsTableName;
0129   ProcessUnknownID * itsProcessUnknownID;
0130 
0131   // ---  copying; forbidden:
0132   ParticleDataTable( const ParticleDataTable & orig );
0133   ParticleDataTable& operator=( const ParticleDataTable & );
0134   
0135   // --- add methods are private
0136   void addParticle( ParticleData const & p ) const;
0137   CPDID addParticleData( CPD const cpd ) const;
0138   // private interface to ProcessUnknownID
0139   ParticleData * DealWithUnknownID( ParticleID & ) const;
0140   // private non const iterators
0141   typedef PDTMap::iterator        iterator;
0142   typedef PDTNameMap::iterator    nameIterator;
0143 
0144 };  // ParticleDataTable
0145 
0146 // --- free functions
0147 //
0148 
0149 bool writePDGStream (std::ostream & os, const ParticleDataTable & table);
0150 
0151 bool writePythiaStream (std::ostream & os, const ParticleDataTable & table);
0152 
0153 bool writeHerwigStream (std::ostream & os, const ParticleDataTable & table);
0154 
0155 bool writeIsajetStream (std::ostream & os, const ParticleDataTable & table);
0156 
0157 bool writeQQStream (std::ostream & os, const ParticleDataTable & table);
0158 
0159 bool writeEvtGenStream (std::ostream & os, const ParticleDataTable & table);
0160 
0161 
0162 }   // HepPDT
0163 
0164 #include "HepPDT/ParticleDataTable.icc"
0165 
0166 #endif // ParticleDataTable_HH