HepMC event record
GenCrossSection.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // This file is part of HepMC
4 // Copyright (C) 2014-2015 The HepMC collaboration (see AUTHORS for details)
5 //
6 /**
7  * @file GenCrossSection.cc
8  * @brief Implementation of \b class GenCrossSection
9  *
10  */
11 #include "HepMC/GenCrossSection.h"
12 #include <cstring> // memcmp
13 #include <cstdlib> // atoi
14 #include <cstdio> // sprintf
15 
16 namespace HepMC {
17 
18 bool GenCrossSection::from_string(const string &att) {
19  const char *cursor = att.data();
20 
21  cross_section = atof(cursor);
22 
23  if( !(cursor = strchr(cursor+1,' ')) ) return false;
24  cross_section_error = atof(cursor);
25 
26  if( !(cursor = strchr(cursor+1,' ')) ) accepted_events = -1;
27  else accepted_events = atof(cursor);
28 
29  if( !(cursor = strchr(cursor+1,' ')) ) attempted_events = -1;
30  else attempted_events = atof(cursor);
31 
32  return true;
33 }
34 
35 bool GenCrossSection::to_string(string &att) const {
36  char buf[128];
37 
38  sprintf(buf,"%.8e %.8e %li %li",
43 
44  att = buf;
45 
46  return true;
47 }
48 
50  return ( memcmp( (void*)this, (void*) &a, sizeof(class GenCrossSection) ) == 0 );
51 }
52 
54  return !( a == *this );
55 }
56 
58  if( cross_section != 0 ) return true;
59  if( cross_section_error != 0 ) return true;
60  return false;
61 }
62 
63 } // namespace HepMC
double cross_section_error
Generated cross-section error.
bool to_string(string &att) const
Implementation of Attribute::to_string.
Stores additional information about cross-section.
long accepted_events
The number of events generated so far.
bool from_string(const string &att)
Implementation of Attribute::from_string.
long attempted_events
The number of events attempted so far.
double cross_section
Generated cross-section.
bool operator!=(const GenCrossSection &) const
Operator !=.
bool operator==(const GenCrossSection &) const
Operator ==.
Definition of template class SmartPointer.
bool is_valid() const
Verify that the instance contains non-zero information.