23#include <boost/algorithm/string.hpp>
39 std::string defaultFilename() {
40 auto*
root = getenv(
"PARAMFILESROOT" );
41 return root ? std::string{
root } +
"/data/ParticleTable.txt" : std::string{
"./ParticleTable.txt" };
151 std::string
cc(
const std::string& decay )
const override;
218 const double mass,
const double tlife,
const double maxWidth,
const std::string& evtgen,
230 typedef std::set<std::unique_ptr<Gaudi::ParticleProperty>>
Set;
246 "Dump all properties in a table format" };
249 typedef std::vector<std::string>
Files;
255 "The name of 'main' particle properties file" };
261 "The (optional) list of additional files with the particle data" };
267 "The (optional) list of special particle properties" };
274 "The map of charge-conjugation & protected symbols" };
277 typedef std::set<Gaudi::ParticleID>
PidSet;
302 log <<
MSG::INFO <<
"Initialising Gaudi ParticlePropertySvc" <<
endmsg;
304 log <<
MSG::ERROR <<
" Unable to initialize the internal structures " <<
endmsg;
344 for (
const auto& file :
m_other.value() ) {
365 log <<
" New/updated particles (from \"Particles\" property)" << std::endl;
409 info() <<
"Property triggers the update of internal Particle Property Data : " << p <<
endmsg;
413 throw GaudiException(
"Can't rebuild Particle Properties Data",
"*ParticlePropertySvc*", sc );
434 error() <<
"Unable to locate IFileAccess('VFSSvc') service" <<
endmsg;
438 auto infile = fileAccess->open( file );
439 if ( !infile.get() ) {
440 error() <<
"Unable to open file '" << file <<
"'" <<
endmsg;
443 info() <<
"Opened particle properties file : " << file <<
endmsg;
448 std::getline( *infile, line );
450 if ( line.empty() ) {
continue; }
452 if ( line[0] ==
'#' ) {
continue; }
455 if (
"PARTICLE" == boost::to_upper_copy( boost::trim_copy( line ) ) ) {
460 if (
"END PARTICLE" == boost::to_upper_copy( boost::trim_copy( line ) ) ) {
466 if ( !active ) {
continue; }
468 if (
auto sc =
parseLine( line ); sc.isFailure() ) {
469 error() <<
"Unable to parse the file '" << file <<
"'" <<
endmsg;
484 std::istringstream input( line );
492 std::string p_evtgen;
496 if ( input >> p_name >> p_geant >> p_pdg >> p_charge >> p_mass >> p_ltime >> p_evtgen >> p_pythia >> p_maxwid ) {
506 p_evtgen, p_pythia );
510 log <<
MSG::ERROR <<
" could not parse the line: '" << line <<
"'" <<
endmsg;
518 const double charge,
const double mass,
const double tlife,
519 const double maxWidth,
const std::string& evtgen,
525 auto it = std::find_if(
m_set.begin(),
m_set.end(), [&](
const std::unique_ptr<Gaudi::ParticleProperty>& s ) {
526 return s->name() == pp.name() && s->pid() == pp.pid();
530 if (
m_set.end() != it ) { newp = it->get(); }
533 it =
m_set.insert( std::make_unique<Gaudi::ParticleProperty>( pp ) ).first;
535 }
else if (
diff( *newp, pp ) ) {
562 pp->setAntiParticle(
nullptr );
568 if ( !anti && 0 < pp->particleID().pid() && !pp->particleID().isNucleus() ) { anti = _pp; }
570 pp->setAntiParticle( anti );
571 if ( pp->antiParticle() ) {
573 verbose() <<
"Antiparticle for \n" << ( *pp ) <<
" is set to be \n" << ( *( pp->antiParticle() ) ) <<
endmsg;
575 if ( ( !pp->antiParticle() ) && ( 0 == pp->pid().extraBits() ) ) {
m_no_anti.insert( pp->name() ); }
581 inline bool different(
const double a,
const double b,
const double p = 1.e-8 ) {
584 inline bool different(
const std::string& a,
const std::string& b ) {
return a != b; }
590 if ( different( n.charge(), o.
charge() ) ) {
594 if ( different( n.mass(), o.
mass() ) ) {
598 if ( different( n.lifetime(), o.
lifetime() ) ) {
602 if ( different( n.maxWidth(), o.
maxWidth() ) ) {
606 if ( different( n.evtGen(), o.
evtGen() ) ) {
610 if ( different( n.pythia(), o.
pythia() ) ) {
618 log <<
MSG::DEBUG <<
" Change the properties of '" << n.name() <<
"'/" << n.pid().pid() << std::endl
619 <<
" New: " << n << std::endl
620 <<
" Old: " << o <<
endmsg;
627 log <<
" The Table of Particle Properties " << std::endl;
652 if ( !pp ) {
continue; }
654 if ( !anti ) {
continue; }
658 for (
const auto& ic :
m_ccmap_.value() ) {
StatusCode parse(DataObjID &dest, std::string_view src)
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 & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
MSG::Level msgLevel() const
const CCMap & cc() const
get CC-map
static Symbols & instance()
static accessor to teh singleton
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
std::vector< const Gaudi::ParticleProperty * > ParticleProperties
the actual type of (ordered) container of particle properties
Holds PDG + LHCb extension particle code, following the PDG particle numbering scheme (pdg....
A trivial class to hold information about a single particle properties.
double charge() const
Get the particle charge.
double lifetime() const
Get the particle lifetime.
const std::string & evtGen() const
Get the EvtGen name.
const std::string & particle() const
Get the particle name.
double maxWidth() const
Get the max width deviation.
double mass() const
Get the particle mass.
const Gaudi::ParticleID & pid() const
get the particle ID
const std::string & name() const
Get the particle name.
int pythia() const
Get the Pythia ID.
Implementation of property with value of concrete type.
Define general base for Gaudi exception.
A bit modified version of 'Loki::AssocVector' associative vector from Loki library by Andrei Alexandr...
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition of the MsgStream class used to transmit messages.
Gaudi::StateMachine::State FSMState() const override
const std::string & name() const override
Retrieve name of the service.
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
StatusCode initialize() override
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
Base class used to extend a class implementing other interfaces.
std::map< std::string, std::string, CmpCC > MapCC
the actual type of CC-map
std::string cc(const std::string &decay, const MapCC &map_)
simple function to make charge conjugated inside the original string.
GAUDI_API std::string printAsTable(const std::vector< const Gaudi::ParticleProperty * > &particles, const Gaudi::Interfaces::IParticlePropertySvc *service=0)
print a list of properties in a form of the table
constexpr double hbar_Planck
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
The comparison criteria for particle properties.
This service provides access to particle properties.
std::vector< std::string > Files
the actual type for the list of files
Gaudi::Property< bool > m_dump
dump the table?
iterator end() const override
get the end-iterator for the container of particle properties It is assumed that the container is pro...
StatusCode initialize() override
Initialize the service.
const Gaudi::ParticleProperty * find(const Gaudi::ParticleID &pid) const override
Retrieve an object by PID:
Gaudi::Property< Particles > m_particles
properties to be redefined explicitly
StatusCode rebuild()
rebuild the Particle Property Data
Gaudi::Property< std::map< std::string, std::string > > m_ccmap_
CC-map for properties.
std::set< std::unique_ptr< Gaudi::ParticleProperty > > Set
the actual storage of all properties
bool diff(const Gaudi::ParticleProperty &n, const Gaudi::ParticleProperty &o)
check the difference of two properties and fill corresponding sets
std::set< Gaudi::ParticleID > PidSet
std::set< std::string > NameSet
Gaudi::Property< std::string > m_filename
the main file with particle properties
StatusCode setAntiParticles()
set properly particle<-->antiparticle relations
StatusCode parse(const std::string &file)
parse the file
StatusCode addParticle(const std::string &pname, const Gaudi::ParticleID &pid, const double charge, const double mass, const double tlife, const double maxWidth, const std::string &evtgen, const int pythia)
add new particle (or redefine the existing one)
ParticlePropertySvc(const std::string &name, ISvcLocator *pSvc)
Standard Constructor.
Set m_set
the actual storage of all particle properties
size_t size() const override
get the container size.
const Gaudi::ParticleProperty * find(const std::string &name) const override
Retrieve an object by name:
PidMap m_pidMap
Map: { "pid" : "property" }.
iterator begin() const override
get the begin-iterator for the container of particle properties It is assumed that the container is p...
Gaudi::Property< Files > m_other
additional files
NameMap m_nameMap
Map: { "name" : "property" }.
StatusCode parseLine(const std::string &line)
parse the line
void updateDump(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service
GaudiUtils::VectorMap< Gaudi::ParticleID, const Gaudi::ParticleProperty * > PidMap
the actual type of map: { "pid" : "property" }
Vector m_vector
"visible" data (the ordered container)
Gaudi::Interfaces::IParticlePropertySvc::ParticleProperties Vector
std::string cc(const std::string &decay) const override
make the charge conjugation for the string/decay descriptor
void dump()
dump the table of particle properties
GaudiUtils::VectorMap< std::string, const Gaudi::ParticleProperty * > NameMap
the actual type of map: { "name" : "property" }
Decays::CC::MapCC m_ccMap
the CC-map
void updateCC(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service
std::vector< std::string > Particles
the actual type for the list of particle properties (strings)
void updateHandler(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: