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;
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 ) };
118 auto i = std::find_if( std::begin( table ), std::end( table ),
119 [&](
const std::pair<const char*, inputFunPtr>& p ) {
return typ == p.first; } );
120 if ( i == std::end( table ) ) {
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;
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
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Gaudi::Property< std::string > m_pdtFiles
inputFunPtr parseTableType(const std::string &)
StatusCode finalize() override
HepPDT::ProcessUnknownID * m_upid
std::vector< std::pair< std::string, inputFunPtr > > m_inputs
bool(*)(std::istream &, HepPDT::TableBuilder &) inputFunPtr
StatusCode initialize() override
std::optional< HepPDT::ParticleDataTable > m_pdt
HepPDT::ParticleDataTable * PDT() override
void setUnknownParticleHandler(HepPDT::ProcessUnknownID *, const std::string &) override
StatusCode finalize() override
StatusCode initialize() override
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)