HepMC event record
GenHeavyIon.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 GenHeavyIon.cc
8  * @brief Implementation of \b class GenHeavyIon
9  *
10  */
11 #include "HepMC/GenHeavyIon.h"
12 #include <cstring> // memcmp
13 #include <cstdlib> // atoi
14 #include <cstdio> // sprintf
15 
16 namespace HepMC {
17 
18 bool GenHeavyIon::from_string(const string &att) {
19  const char *cursor = att.data();
20 
21  Ncoll_hard = atoi(cursor);
22 
23  if( !(cursor = strchr(cursor+1,' ')) ) return false;
24  Npart_proj = atoi(cursor);
25 
26  if( !(cursor = strchr(cursor+1,' ')) ) return false;
27  Npart_targ = atoi(cursor);
28 
29  if( !(cursor = strchr(cursor+1,' ')) ) return false;
30  Ncoll = atoi(cursor);
31 
32  if( !(cursor = strchr(cursor+1,' ')) ) return false;
33  spectator_neutrons = atoi(cursor);
34 
35  if( !(cursor = strchr(cursor+1,' ')) ) return false;
36  spectator_protons = atoi(cursor);
37 
38  if( !(cursor = strchr(cursor+1,' ')) ) return false;
39  N_Nwounded_collisions = atoi(cursor);
40 
41  if( !(cursor = strchr(cursor+1,' ')) ) return false;
42  Nwounded_N_collisions = atoi(cursor);
43 
44  if( !(cursor = strchr(cursor+1,' ')) ) return false;
45  Nwounded_Nwounded_collisions = atoi(cursor);
46 
47  if( !(cursor = strchr(cursor+1,' ')) ) return false;
48  impact_parameter = atof(cursor);
49 
50  if( !(cursor = strchr(cursor+1,' ')) ) return false;
51  event_plane_angle = atof(cursor);
52 
53  if( !(cursor = strchr(cursor+1,' ')) ) return false;
54  eccentricity = atof(cursor);
55 
56  if( !(cursor = strchr(cursor+1,' ')) ) return false;
57  sigma_inel_NN = atof(cursor);
58 
59  if( !(cursor = strchr(cursor+1,' ')) ) return false;
60  centrality = atof(cursor);
61 
62  return true;
63 }
64 
65 bool GenHeavyIon::to_string(string &att) const {
66  char buf[255];
67 
68  sprintf(buf,"%i %i %i %i %i %i %i %i %i %.8e %.8e %.8e %.8e %.8e",
69  Ncoll_hard,
70  Npart_proj,
71  Npart_targ,
72  Ncoll,
82  centrality);
83 
84  att = buf;
85 
86  return true;
87 }
88 
89 void GenHeavyIon::set( int nh, int np, int nt, int nc, int ns, int nsp,
90  int nnw, int nwn, int nwnw,
91  float im, float pl, float ec, float s, float cent ) {
92  Ncoll_hard = nh;
93  Npart_proj = np;
94  Npart_targ = nt;
95  Ncoll = nc;
96  spectator_neutrons = ns;
97  spectator_protons = nsp;
101  impact_parameter = im;
102  event_plane_angle = pl;
103  eccentricity = ec;
104  sigma_inel_NN = s;
105  centrality = cent;
106 }
107 
108 bool GenHeavyIon::operator==( const GenHeavyIon& a ) const {
109  return ( memcmp( (void*) this, (void*) &a, sizeof(class GenHeavyIon) ) == 0 );
110 }
111 
112 bool GenHeavyIon::operator!=( const GenHeavyIon& a ) const {
113  return !( a == *this );
114 }
115 
116 bool GenHeavyIon::is_valid() const {
117  if( Ncoll_hard != 0 ) return true;
118  if( Npart_proj != 0 ) return true;
119  if( Npart_targ != 0 ) return true;
120  if( Ncoll != 0 ) return true;
121  if( spectator_neutrons != 0 ) return true;
122  if( spectator_protons != 0 ) return true;
123  if( N_Nwounded_collisions != 0 ) return true;
124  if( Nwounded_N_collisions != 0 ) return true;
125  if( Nwounded_Nwounded_collisions != 0 ) return true;
126  if( impact_parameter != 0 ) return true;
127  if( event_plane_angle != 0 ) return true;
128  if( eccentricity != 0 ) return true;
129  if( sigma_inel_NN != 0 ) return true;
130  if( centrality != 0 ) return true;
131  return false;
132 }
133 
134 } // namespace HepMC
Stores additional information about Heavy Ion generator.
int spectator_neutrons
Number of spectator neutrons.
bool is_valid() const
Verify that the instance contains non-zero information.
Definition: GenHeavyIon.cc:116
void set(int nh, int np, int nt, int nc, int ns, int nsp, int nnw=0, int nwn=0, int nwnw=0, float im=0., float pl=0., float ec=0., float s=0., float cent=0.)
Set all fields.
Definition: GenHeavyIon.cc:89
bool operator!=(const GenHeavyIon &) const
Operator !=.
Definition: GenHeavyIon.cc:112
double event_plane_angle
Event plane angle.
bool from_string(const string &att)
Implementation of Attribute::from_string.
Definition: GenHeavyIon.cc:18
bool operator==(const GenHeavyIon &) const
Operator ==.
Definition: GenHeavyIon.cc:108
int Ncoll_hard
Number of hard collisions.
int Npart_proj
Number of participating nucleons in the projectile.
bool to_string(string &att) const
Implementation of Attribute::to_string.
Definition: GenHeavyIon.cc:65
int spectator_protons
Number of spectator protons.
double sigma_inel_NN
Assumed nucleon-nucleon cross-section.
Definition of template class SmartPointer.
int Npart_targ
Number of participating nucleons in the target.