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" };
97 iterator
begin()
const override {
return m_vector.begin(); }
102 iterator
end()
const override {
return m_vector.end(); }
104 size_t size()
const override {
return m_vector.size(); }
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;
251 typedef std::vector<std::string> Particles;
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() ) {
359 debug() <<
" All: " << m_vector.size() <<
" By Name: " << m_nameMap.size() <<
" By PID: " << m_pidMap.size()
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 ) ) {
541 auto i1 = m_nameMap.find( newp->
name() );
543 m_nameMap.update( newp->
name(), newp );
547 auto i2 = m_pidMap.find( newp->
pid() );
548 if ( m_pidMap.end() != i2 && i2->second != newp ) {
m_replaced_pids.insert( newp->
pid() ); }
549 m_pidMap.update( newp->
pid(), newp );
552 if ( m_vector.end() == std::find( m_vector.begin(), m_vector.end(), newp ) ) { m_vector.push_back( newp ); }
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;
651 for (
const auto& pp : m_vector ) {
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
get the cached level (originally extracted from the embedded MsgStream)
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.
*properties to be redefined explicitly Gaudi::Property< Particles > m_particles
*the actual storage of all properties typedef std::set< std::unique_ptr< Gaudi::ParticleProperty > > Set
*additional files Gaudi::Property< Files > m_other
*CC map for properties Gaudi::Property< std::map< std::string, std::string > > m_ccmap_
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:
StatusCode rebuild()
rebuild the Particle Property Data
*check the difference of two properties and fill corresponding sets bool diff(const Gaudi::ParticleProperty &n, const Gaudi::ParticleProperty &o)
std::set< Gaudi::ParticleID > PidSet
std::set< std::string > NameSet
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)
size_t size() const override
get the container size.
const Gaudi::ParticleProperty * find(const std::string &name) const override
Retrieve an object by name:
*dump the table Gaudi::Property< bool > m_dump
iterator begin() const override
get the begin-iterator for the container of particle properties It is assumed that the container is p...
*the actual type for the list of files typedef std::vector< std::string > Files
*the CC map Decays::CC::MapCC m_ccMap
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
*the actual type of const Gaudi::ParticleProperty * PidMap
Gaudi::Interfaces::IParticlePropertySvc::ParticleProperties Vector
std::string cc(const std::string &decay) const override
make the charge conjugation for the string/decay descriptor
*dump the table of particle properties void dump()
*the actual storage of all particle properties Set m_set
void updateCC(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service
*the actual type of const Gaudi::ParticleProperty * NameMap
*the actual type for the list of particle properties *(strings) typedef std the main file with particle properties Gaudi::Property< std::string > m_filename
void updateHandler(Gaudi::Details::PropertyBase &p)
Standard Constructor.