HepMC event record
GenPdfInfo.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 GenPdfInfo.cc
8  * @brief Implementation of \b class GenPdfInfo
9  *
10  */
11 #include "HepMC/GenPdfInfo.h"
12 #include <cstring> // memcmp
13 #include <cstdlib> // atoi
14 #include <cstdio> // sprintf
15 
16 namespace HepMC {
17 
18 bool GenPdfInfo::from_string(const string &att) {
19  const char *cursor = att.data();
20 
21  parton_id[0] = atoi(cursor);
22 
23  if( !(cursor = strchr(cursor+1,' ')) ) return false;
24  parton_id[1] = atoi(cursor);
25 
26  if( !(cursor = strchr(cursor+1,' ')) ) return false;
27  x[0] = atof(cursor);
28 
29  if( !(cursor = strchr(cursor+1,' ')) ) return false;
30  x[1] = atof(cursor);
31 
32  if( !(cursor = strchr(cursor+1,' ')) ) return false;
33  scale = atof(cursor);
34 
35  if( !(cursor = strchr(cursor+1,' ')) ) return false;
36  xf[0] = atof(cursor);
37 
38  if( !(cursor = strchr(cursor+1,' ')) ) return false;
39  xf[1] = atof(cursor);
40 
41  if( !(cursor = strchr(cursor+1,' ')) ) return false;
42  pdf_id[0] = atoi(cursor);
43 
44  if( !(cursor = strchr(cursor+1,' ')) ) return false;
45  pdf_id[1] = atoi(cursor);
46 
47  return true;
48 }
49 
50 bool GenPdfInfo::to_string(string &att) const {
51  char buf[255];
52 
53  sprintf(buf,"%i %i %.8e %.8e %.8e %.8e %.8e %i %i",
54  parton_id[0],
55  parton_id[1],
56  x[0],
57  x[1],
58  scale,
59  xf[0],
60  xf[1],
61  pdf_id[0],
62  pdf_id[1]);
63 
64  att = buf;
65 
66  return true;
67 }
68 
69 void GenPdfInfo::set( int parton_id1, int parton_id2, double x1, double x2,
70  double scale_in, double xf1, double xf2,
71  int pdf_id1, int pdf_id2) {
72  parton_id[0] = parton_id1;
73  parton_id[1] = parton_id2;
74  x[0] = x1;
75  x[1] = x2;
76  scale = scale_in;
77  xf[0] = xf1;
78  xf[1] = xf2;
79  pdf_id[0] = pdf_id1;
80  pdf_id[1] = pdf_id2;
81 }
82 
83 bool GenPdfInfo::operator==( const GenPdfInfo& a ) const {
84  return ( memcmp( (void*)this, (void*)&a, sizeof(class GenPdfInfo) ) == 0 );
85 }
86 
87 bool GenPdfInfo::operator!=( const GenPdfInfo& a ) const {
88  return !( a == *this );
89 }
90 
92 {
93  if( parton_id[0] != 0 ) return true;
94  if( parton_id[1] != 0 ) return true;
95  if( x[0] != 0 ) return true;
96  if( x[1] != 0 ) return true;
97  if( scale != 0 ) return true;
98  if( xf[0] != 0 ) return true;
99  if( xf[1] != 0 ) return true;
100  if( pdf_id[0] != 0 ) return true;
101  if( pdf_id[1] != 0 ) return true;
102 
103  return false;
104 }
105 
106 } // namespace HepMC
Stores additional information about PDFs.
bool to_string(string &att) const
Implementation of Attribute::to_string.
Definition: GenPdfInfo.cc:50
bool from_string(const string &att)
Implementation of Attribute::from_string.
Definition: GenPdfInfo.cc:18
bool operator!=(const GenPdfInfo &) const
Operator !=.
Definition: GenPdfInfo.cc:87
void set(int parton_id1, int parton_id2, double x1, double x2, double scale_in, double xf1, double xf2, int pdf_id1=0, int pdf_id2=0)
Set all fields.
Definition: GenPdfInfo.cc:69
double scale
Factorisation scale (in GEV)
bool is_valid() const
Verify that the instance contains non-zero information.
Definition: GenPdfInfo.cc:91
double x[2]
Parton momentum fraction.
bool operator==(const GenPdfInfo &) const
Operator ==.
Definition: GenPdfInfo.cc:83
Definition of template class SmartPointer.