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 +=
"/data/ParticleTable.txt";
65 declareProperty (
"ParticlePropertiesFile" , m_filename ) ;
66 declareProperty (
"OtherFiles" , m_other ) ;
67 declareProperty (
"Particles" , m_particles ) ;
81 error() <<
" Could not set the properties " <<
endmsg ;
88 error() <<
" Cannot retrieve the VFS service " <<
endmsg ;
103 error() <<
" Could not treat particles! " <<
endmsg ;
107 debug() <<
"ParticleProperties parsed successfully" <<
endmsg;
125 <<
"Properties have been redefined for "
140 info() <<
"Additional Properties have been read from files: "
147 always() <<
"Properties have been redefined for "
173 auto i = m_owned.insert(
174 make_unique_<ParticleProperty>( particle , geantId , jetsetId ,
175 charge , mass , tlife ,
176 evtName , pythiaId , maxWidth )
194 diff ( ifind->second , pp ) ;
207 diff ( ifind->second , pp ) ;
223 diff ( ifind->second , pp ) ;
241 diff ( ifind->second , pp ) ;
259 [&](
typename MAP::const_reference
i) {
return i.second ==
pp; } );
260 if (
i != m.end() ) { m.erase (
i ) ; }
297 <<
"Format of input file inconsistent with what expected"
298 <<
" - Check you are using ParticleData.txt" <<
endmsg;
310 error() <<
"Unable to open properties file : " << file
316 info() <<
"Opened particle properties file : " << file <<
endmsg;
324 if ( line.
front() ==
'#' )
continue;
327 ba::trim_left_if( line, ba::is_space() );
328 ba::split( tokens, line, ba::is_space() , boost::token_compress_on );
329 if (tokens.
size()!=9)
continue;
334 if ( jid == 0 ) jid = 10000000*gid;
343 std::stod( tokens[8] ) * Gaudi::Units::GeV ) ;
348 <<
"Error from ParticlePropertySvc::push_back for particle='"
349 << tokens[0] <<
"'" <<
endmsg ;
364 if ( !pp ) {
return nullptr ; }
365 const int ID = pp->
pdgID() ;
366 const int antiID = -1 * ID ;
369 if ( ap && antiID == ap->pdgID() ) {
return ap ; }
385 if ( !pp ) { continue ; }
397 template <
typename MAP,
typename SET>
398 void _load_ ( MAP& m ,
SET& result )
400 for (
auto i = m.begin() ; m.end() !=
i ; ++
i )
401 { result.insert (
i->second ); }
450 <<
" Add/Modify the particle: "
451 <<
" name='" << p_name <<
"'"
452 <<
" geant=" << p_geant
453 <<
" jetset=" << p_jetset
454 <<
" charge=" << p_charge
455 <<
" mass=" << p_mass
456 <<
" ltime=" << p_ltime
457 <<
" evtgen='" << p_evtgen <<
"'"
458 <<
" pythia=" << p_pythia
459 <<
" maxwid=" << p_maxwid <<
endmsg ;
470 p_maxwid * Gaudi::Units::GeV ) ;
476 <<
" could not parse '" <<
item <<
"'" <<
endmsg ;
487 #pragma warning(push)
488 #pragma warning(disable:1572)
496 if ( o == n ) {
return false ; }
498 auto&
log = msgStream();
506 bool result = false ;
507 if ( o -> particle () != n -> particle () )
510 log <<
" Name:'" << o -> particle () <<
"'/'" << n -> particle () <<
"'" ;
512 if ( o -> geantID () != n -> geantID () )
515 log <<
" G3ID:" << o -> geantID () <<
"/" << n -> geantID () <<
"'" ;
517 if ( o -> pdgID () != n -> pdgID () )
520 log <<
" PDGID:" << o -> pdgID () <<
"/" << n -> pdgID () <<
"'" ;
522 if ( o -> pythiaID () != n -> pythiaID () )
525 log <<
" PYID:" << o -> pythiaID () <<
"/" << n -> pythiaID () <<
"'" ;
527 if ( o -> charge () != n -> charge () )
530 log <<
" Q:" << o -> charge () <<
"/" << n -> charge () <<
"'" ;
532 if ( o -> mass () != n -> mass () )
535 log <<
" M:" << o -> mass () <<
"/" << n -> mass () <<
"'" ;
537 if ( o -> lifetime () != n -> lifetime () )
540 log <<
" T:" << o -> lifetime () <<
"/" << n -> lifetime () <<
"'" ;
542 if ( o -> evtGenName () != n -> evtGenName () )
545 log <<
" EvtGen:" << o -> evtGenName () <<
"/" << n -> evtGenName () <<
"'" ;
547 if ( o -> maxWidth () != n -> maxWidth () )
550 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 rebuild()
rebuild "the linear container" from the map
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
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
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 erase(int geantId) override
Erase a property by geant3 id.
StatusCode finalize() override
Finalise the service.
StatusCode initialize() override
Initialise the service.
MapName m_namemap
Map for particle names.
StatusCode parse()
Parses the file and fill all the maps.
Files m_other
additional file names
SmartIF< IFileAccess > m_fileAccess
bool isFailure() const
Test for a status code of FAILURE.
#define DECLARE_COMPONENT(type)
StatusCode push_back(const std::string &particle, int geantId, int jetsetId, double charge, double mass, double tlife, const std::string &evtName, int pythiaId, double maxWidth) override
Create a new particle property.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::set< std::string > m_replaced
int jetsetID() const
Get the JETSET(StdHep) ID.
This class is used for returning status codes from appropriate routines.
std::string m_filename
Filename of the particle properties file.
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID) ...
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
bool diff(const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
T back_inserter(T...args)
StatusCode addParticles()
MapID m_idmap
Map for geant IDs.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
void setAntiParticle(const ParticleProperty *p)
set the pointer to the antiparticle
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
StatusCode setAntiParticles()
helper (protected) function to set the valid particle<–>antiparticle relations
VectPP m_vectpp
Vector of all particle properties.
const std::string & particle() const
Get the particle name.
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
int pythiaID() const
Get the Pythia ID.
virtual std::unique_ptr< std::istream > open(const std::string &url)=0
Find the URL and returns a unique_ptr to an input stream interface of an object that can be used to r...
Helper functions to set/get the application return code.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
MapPythiaID m_pythiaidmap
Map for Pythia Ids.