18 #include <HepPDT/HeavyIonUnknownID.hh>
22 #include <boost/algorithm/string/case_conv.hpp>
23 #include <boost/tokenizer.hpp>
31 error() <<
"Could not initialize main svc" <<
endmsg;
37 typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
38 boost::char_separator<char> sep(
", " );
39 boost::char_separator<char> sep_eq(
"=" );
41 tokenizer tokens(
key, sep );
42 for (
auto it = tokens.begin(); it != tokens.end(); ++it ) {
44 tokenizer tok2( *it, sep_eq );
45 int nToks( std::distance( tok2.begin(), tok2.end() ) );
47 auto it2 = tok2.begin();
48 const std::string fname = *it2;
51 info() <<
"No table format type specified for \"" << fname <<
"\". Assuming PDG" <<
endmsg;
60 if ( rfile.empty() ) {
61 error() <<
"Could not find PDT file: \"" << fname <<
"\" in $DATAPATH" <<
endmsg;
66 std::ifstream pdfile{ rfile };
68 error() <<
"Could not open PDT file: \"" << rfile <<
"\"" <<
endmsg;
72 std::string FMT = boost::algorithm::to_upper_copy(
fmt );
78 error() <<
"Could not determine Particle Property table type: \"" << FMT <<
"\" for file \"" << fname <<
"\""
83 debug() <<
"Adding PDT file \"" << rfile <<
"\" type " << FMT <<
endmsg;
106 if ( status.
isSuccess() ) { debug() <<
"Service finalised successfully" <<
endmsg; }
114 static const auto table = {
115 std::make_pair(
"PDG", &HepPDT::addPDGParticles ), std::make_pair(
"PYTHIA", &HepPDT::addPythiaParticles ),
116 std::make_pair(
"EVTGEN", &HepPDT::addEvtGenParticles ), std::make_pair(
"HERWIG", &HepPDT::addHerwigParticles ),
117 std::make_pair(
"ISAJET", &HepPDT::addIsajetParticles ), std::make_pair(
"QQ", &HepPDT::addQQParticles ) };
119 [&](
const std::pair<const char*, inputFunPtr>& p ) {
return typ == p.first; } );
121 error() <<
"Unknown Particle Data file type: \"" << typ <<
"\"" <<
endmsg;
122 throw std::runtime_error(
"error parsing particle table type" );
139 HepPDT::TableBuilder tb( *
m_pdt );
141 for (
const auto& itr :
m_inputs ) {
142 const auto& f = itr.first;
143 const auto& pF = itr.second;
145 debug() <<
"Reading PDT file \"" << f <<
"\"" <<
endmsg;
147 std::ifstream pdfile{ f };
149 if ( !pF( pdfile, tb ) ) {
150 error() <<
"Error reading PDT file: \"" << f <<
"\"" <<
endmsg;
163 debug() <<
"creating ParticleDataTable" <<
endmsg;
165 fatal() <<
"Could not create ParticleDataTable" <<
endmsg;
177 error() <<
"not setting Unknown Particle Handler \"" <<
n <<
"\" as ParticleDataTable already instantiated"
182 debug() <<
"setting Unknown Particle Handler \"" <<
n <<
"\" at " << puid <<
endmsg;
185 warning() <<
"overriding previously selected Unknown Particle Handler \"" <<
m_upid_name <<
"\" with \"" <<
n