Go to the documentation of this file.
23 #include <boost/algorithm/string.hpp>
218 const double mass,
const double tlife,
const double maxWidth,
const std::string& evtgen,
246 "Dump all properties in a table format" };
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" };
344 for (
const auto& file : m_other.value() ) {
349 for (
const auto&
line : m_particles.value() ) {
355 sc = setAntiParticles();
359 debug() <<
" All: " << m_vector.size() <<
" By Name: " << m_nameMap.size() <<
" By PID: " << m_pidMap.size()
360 <<
" Total: " << m_set.size() <<
endmsg;
363 if ( !m_modified.empty() ) {
364 auto&
log = always();
365 log <<
" New/updated particles (from \"Particles\" property)" <<
std::endl;
371 if ( !m_by_charge.empty() ) {
374 if ( !m_by_mass.empty() ) {
377 if ( !m_by_tlife.empty() ) {
380 if ( !m_by_width.empty() ) {
383 if ( !m_by_evtgen.empty() ) {
386 if ( !m_by_pythia.empty() ) {
389 if ( !m_replaced_names.empty() ) {
392 if ( !m_replaced_pids.empty() ) {
409 info() <<
"Property triggers the update of internal Particle Property Data : " << p <<
endmsg;
413 throw GaudiException(
"Can't rebuild Particle Properties Data",
"*ParticlePropertySvc*", sc );
432 auto fileAccess = service<IFileAccess>(
"VFSSvc" );
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;
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;
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 );
518 const double charge,
const double mass,
const double tlife,
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() );
542 if ( m_nameMap.end() != i1 && i1->second != newp ) { m_replaced_names.insert( 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 ); }
554 m_modified.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 ) {
590 if ( different(
n.charge(), o.
charge() ) ) {
591 m_by_charge.insert(
n.name() );
594 if ( different(
n.mass(), o.
mass() ) ) {
595 m_by_mass.insert(
n.name() );
598 if ( different(
n.lifetime(), o.
lifetime() ) ) {
599 m_by_tlife.insert(
n.name() );
602 if ( different(
n.maxWidth(), o.
maxWidth() ) ) {
603 m_by_width.insert(
n.name() );
606 if ( different(
n.evtGen(), o.
evtGen() ) ) {
607 m_by_evtgen.insert(
n.name() );
610 if ( different(
n.pythia(), o.
pythia() ) ) {
611 m_by_pythia.insert(
n.name() );
620 <<
" Old: " << o <<
endmsg;
626 auto&
log = always();
627 log <<
" The Table of Particle Properties " <<
std::endl;
649 if ( m_ccMap.empty() ) {
651 for (
const auto&
pp : m_vector ) {
652 if ( !
pp ) {
continue; }
654 if ( !anti ) {
continue; }
658 for (
const auto& ic : m_ccmap_.value() ) {
659 m_ccMap[ic.first] = ic.second;
660 m_ccMap[ic.second] = ic.first;
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
constexpr double hbar_Planck
StatusCode rebuild()
rebuild the Particle Property Data
GaudiUtils::VectorMap< std::string, const Gaudi::ParticleProperty * > NameMap
the actual type of map: { "name" : "property" }
int pythia() const
Get the Pythia ID.
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)
StatusCode initialize() override
void dump()
dump the table of particle properties
Decays::CC::MapCC m_ccMap
the CC-map
Gaudi::Property< Particles > m_particles
properties to be redefined explicitly
iterator begin() const override
get the begin-iterator for the container of particle properties It is assumed that the container is p...
Vector m_vector
"visible" data (the ordered container)
Gaudi::Property< std::map< std::string, std::string > > m_ccmap_
CC-map for properties.
const Gaudi::ParticleID & pid() const
get the particle ID
size_t size() const override
get the container size.
const std::string & particle() const
Get the particle name.
Gaudi::Property< bool > m_dump
dump the table?
StatusCode parse(const std::string &file)
parse the file
void updateHandler(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties:
const std::string & name() const
Get the particle name.
static Symbols & instance()
static accessor to teh singleton
ParticlePropertySvc(const std::string &name, ISvcLocator *pSvc)
Standard Constructor.
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
std::set< std::string > NameSet
std::string cc(const std::string &decay) const override
make the charge conjugation for the string/decay descriptor
Gaudi::Interfaces::IParticlePropertySvc::ParticleProperties Vector
double maxWidth() const
Get the max width deviation.
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Set m_set
the actual storage of all particle properties
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
const std::string & name() const override
Retrieve name of the service
std::vector< std::string > Files
the actual type for the list of files
bool diff(const Gaudi::ParticleProperty &n, const Gaudi::ParticleProperty &o)
check the difference of two properties and fill corresponding sets
Gaudi::Property< std::string > m_filename
the main file with particle properties
double mass() const
Get the particle mass.
const Gaudi::ParticleProperty * find(const Gaudi::ParticleID &pid) const override
Retrieve an object by PID:
NameMap m_nameMap
Map: { "name" : "property" }.
const ValueType & value() const
void clear(STATE_TYPE _i=std::ios_base::failbit)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Base class used to extend a class implementing other interfaces.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
const CCMap & cc() const
get CC-map
iterator end() const override
get the end-iterator for the container of particle properties It is assumed that the container is pro...
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
std::set< Gaudi::ParticleID > PidSet
void updateCC(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service
constexpr static const auto SUCCESS
StatusCode parse(DataObjID &dest, std::string_view src)
std::set< std::unique_ptr< Gaudi::ParticleProperty > > Set
the actual storage of all properties
StatusCode setAntiParticles()
set properly particle<-->antiparticle relations
std::string cc(const std::string &decay, const MapCC &map_)
simple function to make charge conjugated inside the original string.
#define DECLARE_COMPONENT(type)
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
double charge() const
Get the particle charge.
double lifetime() const
Get the particle lifetime.
GaudiUtils::VectorMap< Gaudi::ParticleID, const Gaudi::ParticleProperty * > PidMap
the actual type of map: { "pid" : "property" }
const std::string & evtGen() const
Get the EvtGen name.
constexpr static const auto FAILURE
std::vector< std::string > Particles
the actual type for the list of particle properties (strings)
StatusCode parseLine(const std::string &line)
parse the line
PidMap m_pidMap
Map: { "pid" : "property" }.
StatusCode initialize() override
Initialize the service.
const Gaudi::ParticleProperty * find(const std::string &name) const override
Retrieve an object by name:
void updateDump(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service
Gaudi::Property< Files > m_other
additional files