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

          Line data    Source code
       1             : //--------------------------------------------------------------------------
       2             : //
       3             : // HeavyIon.cc
       4             : // Author:  Lynn Garren
       5             : //
       6             : // Implement operator >> and operator <<
       7             : //
       8             : // ----------------------------------------------------------------------
       9             : 
      10             : #include <iostream>
      11             : #include <ostream>
      12             : #include <istream>
      13             : #include <sstream>
      14             : 
      15             : #include "HepMC/HeavyIon.h"
      16             : #include "HepMC/StreamHelpers.h"
      17             : #include "HepMC/IO_Exception.h"
      18             : 
      19             : namespace HepMC {
      20             : 
      21             : /// Write the contents of HeavyIon to an output stream.
      22             : /// GenEvent stores a pointer to a HeavyIon.
      23             : std::ostream & operator << (std::ostream & os, HeavyIon const * ion)
      24             : {
      25           0 :     if ( !os ) {
      26           0 :         std::cerr << "HeavyIon output stream !os, "
      27           0 :                   << " setting badbit" << std::endl;
      28           0 :         os.clear(std::ios::badbit); 
      29           0 :         return os;
      30             :     }
      31           0 :     os << 'H';
      32             :     // HeavyIon* is set to 0 by default
      33           0 :     if ( !ion  ) {
      34           0 :         detail::output( os, 0 );
      35           0 :         detail::output( os, 0 );
      36           0 :         detail::output( os, 0 );
      37           0 :         detail::output( os, 0 );
      38           0 :         detail::output( os, 0 );
      39           0 :         detail::output( os, 0 );
      40           0 :         detail::output( os, 0 );
      41           0 :         detail::output( os, 0 );
      42           0 :         detail::output( os, 0 );
      43           0 :         detail::output( os, 0. );
      44           0 :         detail::output( os, 0. );
      45           0 :         detail::output( os, 0. );
      46           0 :         detail::output( os, 0. );
      47           0 :         detail::output( os,'\n');
      48           0 :         return os;
      49             :     }
      50             :     //
      51           0 :     detail::output( os, ion->Ncoll_hard() );
      52           0 :     detail::output( os, ion->Npart_proj() );
      53           0 :     detail::output( os, ion->Npart_targ() );
      54           0 :     detail::output( os, ion->Ncoll() );
      55           0 :     detail::output( os, ion->spectator_neutrons() );
      56           0 :     detail::output( os, ion->spectator_protons() );
      57           0 :     detail::output( os, ion->N_Nwounded_collisions() );
      58           0 :     detail::output( os, ion->Nwounded_N_collisions() );
      59           0 :     detail::output( os, ion->Nwounded_Nwounded_collisions() );
      60           0 :     detail::output( os, ion->impact_parameter() );
      61           0 :     detail::output( os, ion->event_plane_angle() );
      62           0 :     detail::output( os, ion->eccentricity() );
      63           0 :     detail::output( os, ion->sigma_inel_NN() );
      64           0 :     detail::output( os,'\n');
      65             : 
      66           0 :     return os;
      67           0 : }
      68             : 
      69             : /// Read the contents of HeavyIon from an input stream.
      70             : /// GenEvent stores a pointer to a HeavyIon.
      71             : std::istream & operator >> (std::istream & is, HeavyIon * ion)
      72             : {
      73             :     // make sure the stream is valid
      74           0 :     if ( !is ) { 
      75           0 :       std::cerr << "HeavyIon input stream setting badbit." << std::endl;
      76           0 :       is.clear(std::ios::badbit); 
      77           0 :       return is; 
      78             :     }
      79             :     // get the HeavyIon line
      80           0 :     std::string line;
      81           0 :     std::getline(is,line);
      82           0 :     std::istringstream iline(line);
      83           0 :     std::string firstc;
      84           0 :     iline >> firstc;
      85             :     // test to be sure the next entry is of type "H" 
      86           0 :     if( firstc != "H" ) { 
      87           0 :         std::cerr << "HeavyIon input stream invalid line type: " 
      88           0 :                   << firstc << std::endl;
      89             :         // The most likely problem is that we have found a HepMC block line
      90           0 :         throw IO_Exception("HeavyIon input stream encounterd invalid data");
      91             :     } 
      92             :     // read values into temp variables, then create a new HeavyIon object
      93           0 :     int nh =0, np =0, nt =0, nc =0, 
      94           0 :         neut = 0, prot = 0, nw =0, nwn =0, nwnw =0;
      95           0 :     float impact = 0., plane = 0., xcen = 0., inel = 0.; 
      96           0 :     iline >> nh ;
      97           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
      98           0 :     iline >> np ;
      99           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     100           0 :     iline >> nt ;
     101           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     102           0 :     iline >> nc ;
     103           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     104           0 :     iline >> neut ;
     105           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     106           0 :     iline >> prot;
     107           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     108           0 :     iline >> nw ;
     109           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     110           0 :     iline >> nwn ;
     111           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     112           0 :     iline >> nwnw ;
     113           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     114           0 :     iline >> impact ;
     115           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     116           0 :     iline >> plane ;
     117           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     118           0 :     iline >> xcen ;
     119           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     120           0 :     iline >> inel;
     121           0 :     if(!iline) throw IO_Exception("HeavyIon input stream encounterd invalid data");
     122             : //    if( nh == 0 ) {
     123             : //        return is;
     124             : //    }
     125             :     
     126           0 :     ion->set_Ncoll_hard(nh);
     127           0 :     ion->set_Npart_proj(np);
     128           0 :     ion->set_Npart_targ(nt);
     129           0 :     ion->set_Ncoll(nc);
     130           0 :     ion->set_spectator_neutrons(neut);
     131           0 :     ion->set_spectator_protons(prot);
     132           0 :     ion->set_N_Nwounded_collisions(nw);
     133           0 :     ion->set_Nwounded_N_collisions(nwn);
     134           0 :     ion->set_Nwounded_Nwounded_collisions(nwnw);
     135           0 :     ion->set_impact_parameter(impact);
     136           0 :     ion->set_event_plane_angle(plane);
     137           0 :     ion->set_eccentricity(xcen);
     138           0 :     ion->set_sigma_inel_NN(inel);
     139             : 
     140             :     return is;
     141           0 : }
     142             : 
     143             : 
     144             : } // HepMC

Generated by: LCOV version 1.11