Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:10

0001 //--------------------------------------------------------------------------
0002 #ifndef HEPMC_PDF_INFO_H
0003 #define HEPMC_PDF_INFO_H
0004 
0005 //////////////////////////////////////////////////////////////////////////
0006 // garren@fnal.gov, July 2006
0007 //
0008 // Additional PDF information
0009 //////////////////////////////////////////////////////////////////////////
0010 
0011 namespace HepMC {
0012 
0013 //! The PdfInfo class stores PDF information
0014 
0015 ///
0016 /// \class  PdfInfo
0017 /// HepMC::PdfInfo stores additional PDF information for a GenEvent.
0018 /// Creation and use of this information is optional. 
0019 ///
0020 ///   - int id1;    // flavour code of first parton
0021 ///   - int id2;    // flavour code of second parton 
0022 ///   - int pdf_id1;    // LHAPDF set id of first parton (zero by default)
0023 ///   - int pdf_id2;    // LHAPDF set id of second parton  (zero by default)
0024 ///   - double x1;      // fraction of beam momentum carried by first parton ("beam side") 
0025 ///   - double x2;      // fraction of beam momentum carried by second parton ("target side") 
0026 ///   - double scalePDF;  //  Q-scale used in evaluation of PDF's   (in GeV) 
0027 ///   - double pdf1;    // PDF (id1, x1, Q) 
0028 ///   - double pdf2;    // PDF (id2, x2, Q)   
0029 /// 
0030 /// Input parton flavour codes id1 & id2 are expected to obey the 
0031 /// PDG code conventions, especially g = 21.
0032 /// 
0033 /// The contents of pdf1 and pdf2 are expected to be x*f(x).
0034 /// The LHAPDF set ids are the entries in the first column of
0035 /// http:///projects.hepforge.org/lhapdf/PDFsets.index
0036 ///
0037 class PdfInfo {
0038 
0039 public:
0040   // ---  birth/death:
0041   //
0042   /// default constructor
0043   PdfInfo()
0044     : m_id1(0), 
0045       m_id2(0),
0046       m_pdf_id1(0),
0047       m_pdf_id2(0),
0048       m_x1(0),
0049       m_x2(0),
0050       m_scalePDF(0),
0051       m_pdf1(0),
0052       m_pdf2(0)
0053     {}
0054 
0055   /// all values EXCEPT pdf_id1 and pdf_id2 must be provided
0056   PdfInfo( int i1, int i2, double x1, double x2,
0057            double q, double p1, double p2,
0058        int pdf_id1 = 0, int pdf_id2 = 0 );
0059 
0060   ~PdfInfo() {}
0061     
0062   // ---  copying:
0063   //
0064   PdfInfo( PdfInfo const & orig );  //!< copy constructor
0065   PdfInfo &  operator = ( PdfInfo const & rhs ); //!< make a copy
0066   void swap( PdfInfo & other ); //!< swap two PdfInfo objects
0067 
0068   // ---  equivalence:
0069   //
0070   bool    operator==( const PdfInfo& ) const; //!< check for equality
0071   bool    operator!=( const PdfInfo& ) const; //!< check for inequality
0072 
0073   // ---  accessors:
0074     /// flavour code of first parton
0075     int   id1()                   const { return m_id1; }
0076     /// flavour code of second parton 
0077     int   id2()                   const { return m_id2; }
0078     /// LHAPDF set id of first parton
0079     int   pdf_id1()                   const { return m_pdf_id1; }
0080     /// LHAPDF set id of second parton
0081     int   pdf_id2()                   const { return m_pdf_id2; }
0082     /// fraction of beam momentum carried by first parton ("beam side") 
0083     double x1()                   const { return m_x1; } 
0084     /// fraction of beam momentum carried by second parton ("target side") 
0085     double x2()                   const { return m_x2; }
0086     ///  Q-scale used in evaluation of PDF's   (in GeV) 
0087     double scalePDF()             const { return m_scalePDF;  }
0088     /// PDF (id1, x1, Q) - x*f(x)
0089     double pdf1()                 const { return m_pdf1; }
0090     /// PDF (id2, x2, Q) - x*f(x)
0091     double pdf2()                 const { return m_pdf2; }
0092 
0093     /// verify that the instance contains non-zero information
0094     bool  is_valid()                     const;
0095 
0096   // ---  mutators:
0097     /// set flavour code of first parton
0098     void   set_id1(const int &i)              { m_id1=i; }
0099     /// set flavour code of second parton 
0100     void   set_id2(const int &i)              { m_id2=i; }
0101     /// set LHAPDF set id of first parton
0102     void   set_pdf_id1(const int &i)              { m_pdf_id1=i; }
0103     /// set LHAPDF set id of second parton 
0104     void   set_pdf_id2(const int &i)              { m_pdf_id2=i; }
0105     /// set fraction of beam momentum carried by first parton ("beam side") 
0106     void   set_x1(const double &f)            { m_x1=f; }
0107     /// set fraction of beam momentum carried by second parton ("target side") 
0108     void   set_x2(const double &f)            { m_x2=f; }
0109     /// set Q-scale used in evaluation of PDF's   (in GeV) 
0110     void   set_scalePDF(const double &f)      { m_scalePDF=f;  }
0111     /// set x*f(x) of first parton
0112     void   set_pdf1(const double &f)          { m_pdf1=f; }
0113     /// set x*f(x) of second parton
0114     void   set_pdf2(const double &f)          { m_pdf2=f; }
0115 
0116 private: // data members
0117     int   m_id1; 
0118     int   m_id2; 
0119     int   m_pdf_id1; 
0120     int   m_pdf_id2; 
0121     double m_x1;
0122     double m_x2;
0123     double m_scalePDF; 
0124     double m_pdf1;
0125     double m_pdf2;
0126 
0127 };
0128 
0129 // Free Functions
0130 
0131 // IO
0132 std::ostream & operator << (std::ostream &, PdfInfo const *);
0133 std::istream & operator >> (std::istream &, PdfInfo *);
0134 
0135 // inline operators
0136 inline PdfInfo::PdfInfo( int i1, int i2, double xin1, double xin2,
0137                  double q, double p1, double p2,
0138              int pid1, int pid2 )
0139     : m_id1(i1), 
0140       m_id2(i2),
0141       m_pdf_id1(pid1),
0142       m_pdf_id2(pid2),
0143       m_x1(xin1),
0144       m_x2(xin2),
0145       m_scalePDF(q),
0146       m_pdf1(p1),
0147       m_pdf2(p2)
0148    {}
0149 
0150 inline PdfInfo::PdfInfo( PdfInfo const & orig )
0151     : m_id1(orig.m_id1), 
0152       m_id2(orig.m_id2),
0153       m_pdf_id1(orig.m_pdf_id1), 
0154       m_pdf_id2(orig.m_pdf_id2),
0155       m_x1(orig.m_x1),
0156       m_x2(orig.m_x2),
0157       m_scalePDF(orig.m_scalePDF),
0158       m_pdf1(orig.m_pdf1),
0159       m_pdf2(orig.m_pdf2)
0160    {}
0161 
0162 inline PdfInfo &  PdfInfo::operator = ( PdfInfo const & rhs ) 
0163 {
0164   PdfInfo temp( rhs );
0165   swap( temp );
0166   return *this;
0167 }
0168 
0169 inline void PdfInfo::swap( PdfInfo & other ) 
0170 {
0171   std::swap(m_id1, other.m_id1); 
0172   std::swap(m_id2, other.m_id2);
0173   std::swap(m_pdf_id1, other.m_pdf_id1); 
0174   std::swap(m_pdf_id2, other.m_pdf_id2);
0175   std::swap(m_x1, other.m_x1);
0176   std::swap(m_x2, other.m_x2);
0177   std::swap(m_scalePDF, other.m_scalePDF);
0178   std::swap(m_pdf1, other.m_pdf1);
0179   std::swap(m_pdf2, other.m_pdf2);
0180 }
0181 
0182 inline bool    PdfInfo::operator==( const PdfInfo& a ) const
0183 {
0184     /// equality requires that each member match
0185     return (    a.id1() == this->id1() 
0186              && a.id2() == this->id2() 
0187              && a.pdf_id1() == this->pdf_id1() 
0188              && a.pdf_id2() == this->pdf_id2() 
0189          && a.x1() == this->x1() 
0190          && a.x2() == this->x2()
0191          && a.scalePDF() == this->scalePDF() 
0192          && a.pdf1() == this->pdf1()
0193          && a.pdf2() == this->pdf2() );
0194 }
0195 
0196 inline bool    PdfInfo::operator!=( const PdfInfo& a ) const
0197 {
0198     /// any nonmatching member generates inequality
0199     return !( a == *this );
0200 }
0201 
0202 inline bool  PdfInfo::is_valid() const
0203 {
0204     if( m_id1 != 0 ) return true;
0205     if( m_id2 != 0 ) return true;
0206     if( m_pdf_id1 != 0 ) return true;
0207     if( m_pdf_id2 != 0 ) return true;
0208     if( m_x1 != 0 ) return true;
0209     if( m_x2 != 0 ) return true;
0210     if( m_scalePDF != 0 ) return true;
0211     if( m_pdf1 != 0 ) return true;
0212     if( m_pdf2 != 0 ) return true;
0213     return false;
0214 }
0215 
0216 } // HepMC
0217 
0218 #endif  // HEPMC_PDF_INFO_H