LCOV - code coverage report
Current view: top level - TEvtGen/HepMC - GenCrossSection.cc (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 48 0.0 %
Date: 2016-06-14 17:26:59 Functions: 0 9 0.0 %

          Line data    Source code
       1             : //--------------------------------------------------------------------------
       2             : //////////////////////////////////////////////////////////////////////////
       3             : // garren@fnal.gov, January 2009
       4             : //
       5             : // The singleton GenCrossSection class holds run level information, 
       6             : // such as the cross section.
       7             : // 
       8             : //////////////////////////////////////////////////////////////////////////
       9             : //--------------------------------------------------------------------------
      10             : 
      11             : #include <iostream>
      12             : #include <sstream>
      13             : 
      14             : #include "HepMC/GenCrossSection.h"
      15             : #include "HepMC/IO_Exception.h"
      16             : 
      17             : namespace HepMC {
      18             : 
      19             : GenCrossSection::GenCrossSection( GenCrossSection const & orig )
      20           0 :     : m_cross_section( orig.cross_section() ),
      21           0 :       m_cross_section_error( orig.cross_section_error() ),
      22           0 :       m_is_set( orig.is_set() )
      23           0 : {}
      24             : 
      25             : void GenCrossSection::swap( GenCrossSection & other)
      26             : {
      27           0 :     std::swap( m_cross_section, other.m_cross_section );
      28           0 :     std::swap( m_cross_section_error, other.m_cross_section_error );
      29           0 :     std::swap( m_is_set, other.m_is_set );
      30           0 : }
      31             : 
      32             : GenCrossSection &  GenCrossSection::operator = ( GenCrossSection const & rhs )
      33             : {
      34           0 :     GenCrossSection tmp( rhs );
      35           0 :     swap( tmp );
      36             :     return *this;
      37           0 : }
      38             : 
      39             : bool GenCrossSection::operator==( const GenCrossSection& rhs ) const
      40             : {
      41           0 :     if( rhs.cross_section() != this->cross_section() ) return false;
      42           0 :     if( rhs.cross_section_error() != this->cross_section_error() ) return false;
      43           0 :     return true;
      44           0 : }
      45             : 
      46             : bool GenCrossSection::operator!=( const GenCrossSection& rhs ) const
      47             : {
      48           0 :         return !( rhs == *this );
      49             : }
      50             : 
      51             : 
      52             : void GenCrossSection::clear() 
      53             : {
      54           0 :     m_cross_section       = 0.0;
      55           0 :     m_cross_section_error = 0.0;
      56           0 :     m_is_set              = false;
      57           0 : }
      58             : 
      59             : std::ostream & GenCrossSection::write( std::ostream & os ) const
      60             : {
      61             :     // make sure the stream is valid
      62           0 :     if ( !os ) {
      63           0 :         std::cerr << "GenCrossSection::print !os, setting badbit" << std::endl;
      64           0 :         os.clear(std::ios::badbit); 
      65           0 :         return os;
      66             :     }
      67             :     // write the GenCrossSection information if the cross section was set
      68           0 :     if( is_set() ) {
      69           0 :         os << "C " << m_cross_section 
      70           0 :            << " " << m_cross_section_error 
      71           0 :            << "\n";
      72           0 :     }
      73           0 :     return os;
      74           0 : }
      75             : 
      76             : std::istream & GenCrossSection::read( std::istream & is )
      77             : {
      78             :     // make sure the stream is valid
      79           0 :     if ( !is ) { 
      80           0 :       std::cerr << "GenCrossSection stream input setting badbit." << std::endl;
      81           0 :       is.clear(std::ios::badbit); 
      82           0 :       return is; 
      83             :     }
      84             :     // check to see if we have a GenCrossSection line
      85             :     // This line is optional and may not exist
      86           0 :     if ( is.peek()!='C' ) { 
      87           0 :       return is; 
      88             :     }
      89             :     // get the GenCrossSection line
      90           0 :     std::string line, firstc;
      91           0 :     std::getline(is,line);
      92           0 :     std::istringstream iline(line);
      93             :     // Get first character and throw it away
      94           0 :     iline >> firstc;
      95             :     // Now get the numbers
      96           0 :     double xs = 0., xserr = 0.;
      97           0 :     iline >> xs ;
      98           0 :     if(!iline) throw IO_Exception("GenCrossSection::read encounterd invalid data");
      99           0 :     iline >> xserr ;
     100           0 :     if(!iline) throw IO_Exception("GenCrossSection::read encounterd invalid data");
     101             :     // set the data members
     102           0 :     set_cross_section( xs, xserr );
     103             :     return  is;
     104           0 : }
     105             : 
     106             : } // HepMC

Generated by: LCOV version 1.11