8 #include "boost/algorithm/string/split.hpp" 9 #include "boost/algorithm/string/trim.hpp" 10 #include "boost/algorithm/string/classification.hpp" 11 namespace ba = boost::algorithm;
30 template <
typename T,
class... Args>
53 ParticlePropertySvc::ParticlePropertySvc
62 m_filename.value() +=
"/data/ParticleTable.txt";
77 error() <<
" Could not set the properties " <<
endmsg ;
81 m_fileAccess = service(
"VFSSvc");
84 error() <<
" Cannot retrieve the VFS service " <<
endmsg ;
91 error() <<
" Could not parse the file " <<
endmsg ;
94 if ( !m_particles.empty() )
96 sc = addParticles () ;
99 error() <<
" Could not treat particles! " <<
endmsg ;
103 debug() <<
"ParticleProperties parsed successfully" <<
endmsg;
105 debug() <<
"Access properties" <<
endmsg;
108 debug() <<
"NameMap size =" << m_namemap.size() <<
endmsg;
110 debug() <<
"GeantID Map size =" << m_idmap.size() <<
endmsg;
112 debug() <<
"StdHepID Map size =" << m_stdhepidmap.size()
115 debug() <<
"PythiaID Map size =" << m_pythiaidmap.size()
118 if ( !m_replaced.empty() )
121 <<
"Properties have been redefined for " 122 << m_replaced.size() <<
" particles : " 134 if ( !m_other.empty() )
136 info() <<
"Additional Properties have been read from files: " 141 if ( !m_replaced.empty() )
143 always() <<
"Properties have been redefined for " 144 << m_replaced.size() <<
" particles : " 149 m_fileAccess.reset();
169 auto i = m_owned.insert(
170 make_unique_<ParticleProperty>( particle , geantId , jetsetId ,
171 charge , mass , tlife ,
172 evtName , pythiaId , maxWidth )
187 auto ifind = m_idmap.find( ID ) ;
188 if ( m_idmap.end() != ifind && 0 != m_idmap[ ID ])
190 diff ( ifind->second , pp ) ;
191 m_replaced.insert( m_idmap[ ID ]->particle() ) ;
200 auto ifind = m_namemap.
find( particle ) ;
201 if ( ifind != m_namemap.end() && ifind->second )
203 diff ( ifind->second , pp ) ;
204 m_replaced.insert( ifind->second->particle() ) ;
207 m_namemap[ particle ] =
pp ;
216 auto ifind = m_stdhepidmap.find( ID ) ;
217 if ( m_stdhepidmap.end() != ifind && ifind->second )
219 diff ( ifind->second , pp ) ;
220 m_replaced.insert( ifind->second->particle() ) ;
223 m_stdhepidmap[ ID ] =
pp ;
234 auto ifind = m_pythiaidmap.find( ID ) ;
235 if ( m_pythiaidmap.end() != ifind && ifind->second )
237 diff ( ifind->second , pp ) ;
238 m_replaced.insert( ifind->second ->particle() ) ;
241 m_pythiaidmap[ ID ] =
pp ;
255 [&](
typename MAP::const_reference i) {
return i.second ==
pp; } );
256 if ( i != m.end() ) { m.erase ( i ) ; }
264 _remove_ ( m_idmap , pp ) ;
265 _remove_ ( m_namemap , pp ) ;
266 _remove_ ( m_stdhepidmap , pp ) ;
267 _remove_ ( m_pythiaidmap , pp ) ;
282 for (
auto& file : m_other )
284 sc =
parse ( file ) ;
290 if ( m_namemap.empty() )
293 <<
"Format of input file inconsistent with what expected" 294 <<
" - Check you are using ParticleData.txt" <<
endmsg;
303 auto infile = ( m_fileAccess ? m_fileAccess->open(file) : nullptr );
306 error() <<
"Unable to open properties file : " << file
312 info() <<
"Opened particle properties file : " << file <<
endmsg;
320 if ( line.
front() ==
'#' )
continue;
323 ba::trim_left_if( line, ba::is_space() );
324 ba::split( tokens, line, ba::is_space() , boost::token_compress_on );
325 if (tokens.
size()!=9)
continue;
330 if ( jid == 0 ) jid = 10000000*gid;
339 std::stod( tokens[8] ) * Gaudi::Units::GeV ) ;
344 <<
"Error from ParticlePropertySvc::push_back for particle='" 345 << tokens[0] <<
"'" <<
endmsg ;
360 if ( !pp ) {
return nullptr ; }
361 const int ID = pp->
pdgID() ;
362 const int antiID = -1 * ID ;
363 for (
const auto& ap : m_vectpp )
365 if ( ap && antiID == ap->pdgID() ) {
return ap ; }
379 for (
auto&
pp : m_vectpp )
381 if ( !
pp ) { continue ; }
383 if ( ap ) {
pp->setAntiParticle( ap ) ; }
393 template <
typename MAP,
typename SET>
394 void _load_ ( MAP&
m ,
SET& result )
396 for (
auto i = m.begin() ; m.end() != i ; ++i )
397 { result.insert ( i->second ); }
405 m_vectpp.reserve ( m_idmap.size() + 100 ) ;
407 _load_ ( m_idmap , local ) ;
408 _load_ ( m_namemap , local ) ;
409 _load_ ( m_stdhepidmap , local ) ;
410 _load_ ( m_pythiaidmap , local ) ;
413 return setAntiParticles() ;
421 for (
const auto& item : m_particles )
446 <<
" Add/Modify the particle: " 447 <<
" name='" << p_name <<
"'" 448 <<
" geant=" << p_geant
449 <<
" jetset=" << p_jetset
450 <<
" charge=" << p_charge
451 <<
" mass=" << p_mass
452 <<
" ltime=" << p_ltime
453 <<
" evtgen='" << p_evtgen <<
"'" 454 <<
" pythia=" << p_pythia
455 <<
" maxwid=" << p_maxwid <<
endmsg ;
466 p_maxwid * Gaudi::Units::GeV ) ;
472 <<
" could not parse '" << item <<
"'" <<
endmsg ;
483 #pragma warning(push) 484 #pragma warning(disable:1572) 486 bool ParticlePropertySvc::diff
492 if ( o == n ) {
return false ; }
494 auto&
log = msgStream();
502 bool result = false ;
503 if ( o -> particle () != n -> particle () )
506 log <<
" Name:'" << o -> particle () <<
"'/'" << n -> particle () <<
"'" ;
508 if ( o -> geantID () != n -> geantID () )
511 log <<
" G3ID:" << o -> geantID () <<
"/" << n -> geantID () <<
"'" ;
513 if ( o -> pdgID () != n -> pdgID () )
516 log <<
" PDGID:" << o -> pdgID () <<
"/" << n -> pdgID () <<
"'" ;
518 if ( o -> pythiaID () != n -> pythiaID () )
521 log <<
" PYID:" << o -> pythiaID () <<
"/" << n -> pythiaID () <<
"'" ;
523 if ( o -> charge () != n -> charge () )
526 log <<
" Q:" << o -> charge () <<
"/" << n -> charge () <<
"'" ;
528 if ( o -> mass () != n -> mass () )
531 log <<
" M:" << o -> mass () <<
"/" << n -> mass () <<
"'" ;
533 if ( o -> lifetime () != n -> lifetime () )
536 log <<
" T:" << o -> lifetime () <<
"/" << n -> lifetime () <<
"'" ;
538 if ( o -> evtGenName () != n -> evtGenName () )
541 log <<
" EvtGen:" << o -> evtGenName () <<
"/" << n -> evtGenName () <<
"'" ;
543 if ( o -> maxWidth () != n -> maxWidth () )
546 log <<
" WMAX:" << o -> maxWidth () <<
"/" << n -> maxWidth () <<
"'" ;
int pdgID() const
Get the PDG (= JETSET) ID.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
StatusCode initialize() override
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
int geantID() const
Get the GEANT3 ID.
StatusCode finalize() override
A trivial class to hold information about a single particle properties.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
StatusCode parse(GaudiUtils::HashMap< K, V > &result, const std::string &input)
Basic parser for the types of HashMap used in DODBasicMapper.
void push_back(Container &c, const Value &v, std::true_type)
bool isFailure() const
Test for a status code of FAILURE.
#define DECLARE_COMPONENT(type)
int jetsetID() const
Get the JETSET(StdHep) ID.
This class is used for returning status codes from appropriate routines.
T back_inserter(T...args)
const std::string & particle() const
Get the particle name.
int pythiaID() const
Get the Pythia ID.
Helper functions to set/get the application return code.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.