Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/HepMC/GenCrossSection.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #ifndef HEPMC_GEN_CROSS_SECTION_H
0002 #define HEPMC_GEN_CROSS_SECTION_H
0003 
0004 //--------------------------------------------------------------------------
0005 //////////////////////////////////////////////////////////////////////////
0006 // garren@fnal.gov, May 2009
0007 // 
0008 //////////////////////////////////////////////////////////////////////////
0009 //--------------------------------------------------------------------------
0010 
0011 #include <iostream>
0012 
0013 namespace HepMC {
0014 
0015 //! The GenCrossSection class stores the generated cross section
0016 
0017 ///
0018 /// \class  GenCrossSection
0019 /// HepMC::GenCrossSection is used to store the generated cross section.
0020 /// This class is meant to be used to pass, on an event by event basis,
0021 /// the current best guess of the total cross section. 
0022 /// It is expected that the final cross section will be stored elsewhere.
0023 ///
0024 ///   - double cross_section;       // cross section in pb
0025 ///   - double cross_section_error;     // error associated with this cross section   
0026 /// 
0027 /// The units of cross_section and cross_section_error are expected to be pb.
0028 /// 
0029 /// GenCrossSection information will be written if GenEvent contains a pointer 
0030 /// to a valid GenCrossSection object.
0031 ///
0032 class GenCrossSection {
0033 
0034 public:
0035   GenCrossSection()
0036     : m_cross_section(0),
0037       m_cross_section_error(0),
0038       m_is_set(false)
0039     {}
0040   ~GenCrossSection() {}
0041 
0042   GenCrossSection( GenCrossSection const & orig ); //!< copy
0043 
0044   void swap( GenCrossSection & other); //!< swap
0045   GenCrossSection &  operator = ( GenCrossSection const & rhs ); //!< shallow
0046   /// check for equality
0047   bool         operator==( const GenCrossSection& ) const;
0048   /// check for inequality
0049   bool         operator!=( const GenCrossSection& ) const;
0050 
0051 
0052   // ---  accessors:
0053 
0054   /// cross section in pb
0055   double cross_section()          const { return m_cross_section; }
0056   /// error associated with this cross section in pb
0057   double cross_section_error()    const { return m_cross_section_error; }
0058 
0059   /// True if the cross section has been set.  False by default.
0060   bool   is_set()                 const { return m_is_set; }
0061 
0062   // ---  mutators:
0063   /// Set cross section and error in pb
0064   void   set_cross_section( double xs, double xs_err );
0065   /// set cross section in pb
0066   void   set_cross_section( double );
0067   /// set error associated with this cross section in pb
0068   void   set_cross_section_error( double );
0069   /// Clear all GenCrossSection info 
0070   /// (disables output of GenCrossSection until the cross section is set again)
0071   void   clear();
0072  
0073   // ---  I/O:
0074   /// write to an output stream
0075   std::ostream &  write( std::ostream & ) const;
0076   /// read from an input stream
0077   std::istream &  read( std::istream & );
0078 
0079 private: // data members
0080     double m_cross_section;
0081     double m_cross_section_error;
0082     bool   m_is_set;
0083 
0084 };
0085 
0086 //
0087 // streaming I/O
0088 
0089 inline std::ostream & operator << ( std::ostream & os, GenCrossSection & xs )
0090 { return xs.write(os); }
0091 
0092 inline std::istream & operator >> ( std::istream & is, GenCrossSection & xs )
0093 { return xs.read(is); }
0094 
0095 //
0096 // inline methods
0097 
0098 inline void GenCrossSection::set_cross_section( double xs, double xserr ) { 
0099   set_cross_section(xs);
0100   set_cross_section_error(xserr); 
0101 }
0102 
0103 inline void GenCrossSection::set_cross_section( double xs )        
0104 {
0105   m_cross_section = xs;
0106   m_is_set = true;
0107 }
0108 
0109 inline void GenCrossSection::set_cross_section_error( double xserr )  
0110 {
0111   m_cross_section_error = xserr;
0112 }
0113 
0114 } // HepMC
0115 
0116 #endif  // HEPMC_GEN_CROSS_SECTION_H