PIDDetails.cxx
Go to the documentation of this file.
1 #include "LEM/PIDDetails.h"
2 
3 #include <cfloat>
4 #include <iostream>
5 
6 namespace lem
7 {
8  //......................................................................
10  {
11  char buf[1024];
12  sprintf(buf, "pid=%.*e\n", DBL_DIG, fVal);
13 
14  // Don't bother to serialize the match list
15  return buf+vars.ToString();
16  }
17 
18  //......................................................................
20  {
22  ret.fPdg = 12;
23 
24  const size_t pos = s.find("pid=");
25  if(pos == std::string::npos){
26  std::cerr << "PIDExtraVars::FromString(): couldn't find pid"
27  << std::endl;
28  abort();
29  }
30  const size_t startpos = s.find("=", pos)+1;
31  const size_t endpos = s.find("\n", startpos);
32  if(endpos == std::string::npos){
33  std::cerr << "PIDExtraVars::FromString(): couldn't find "
34  << "newline after pid" << std::endl;
35  abort();
36  }
37 
38  errno = 0;
39  ret.fVal = strtod(s.substr(startpos, endpos-startpos).c_str(), 0);
40  if(errno != 0){
41  std::cerr << "PIDExtraVars::FromString(): failed to parse "
42  << "numerical value of pid" << std::endl;
43  abort();
44  }
45 
46  // Don't unserialize matchList as yet
48 
49  return ret;
50  }
51 }
int fPdg
pdg code
Definition: PID.h:27
OStream cerr
Definition: OStream.cxx:7
std::string ToString() const
PID
Definition: FillPIDs.h:14
const XML_Char * s
Definition: expat.h:262
double fVal
pid value
Definition: PID.h:28
static PIDDetails FromString(const std::string &s)
Definition: PIDDetails.cxx:19
PIDExtraVars vars
Definition: PIDDetails.h:32
std::string ToString() const
Definition: PIDDetails.cxx:9
Attach LEM-specific info to the base PID object.
Definition: PIDDetails.h:20
int errno
Definition: errno.cpp:12
static PIDExtraVars FromString(const std::string &s)
enum BeamMode string