The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
Gaudi::ParticlePropertySvc Class Referencefinal

This service provides access to particle properties. More...

#include <ParticlePropertySvc.cpp>

Inheritance diagram for Gaudi::ParticlePropertySvc:
Collaboration diagram for Gaudi::ParticlePropertySvc:

Public Types

typedef std::set< std::unique_ptr< Gaudi::ParticleProperty > > Set
 the actual storage of all properties
 
typedef GaudiUtils::VectorMap< std::string, const Gaudi::ParticleProperty * > NameMap
 the actual type of map: { "name" : "property" }
 
typedef GaudiUtils::VectorMap< Gaudi::ParticleID, const Gaudi::ParticleProperty * > PidMap
 the actual type of map: { "pid" : "property" }
 
typedef Gaudi::Interfaces::IParticlePropertySvc::ParticleProperties Vector
 
typedef std::vector< std::string > Files
 the actual type for the list of files
 
typedef std::vector< std::string > Particles
 the actual type for the list of particle properties (strings)
 
typedef std::set< std::string > NameSet
 
typedef std::set< Gaudi::ParticleIDPidSet
 
- Public Types inherited from extends< Service, Gaudi::Interfaces::IParticlePropertySvc >
using base_class
 Typedef to this class.
 
using extend_interfaces_base
 Typedef to the base of this class.
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory<IService*( const std::string&, ISvcLocator* )>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl
 Typedef used to refer to this class from derived classes, as in.
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids
 take union of the ext_iids of all Interfaces...
 

Public Member Functions

iterator begin () const override
 get the begin-iterator for the container of particle properties It is assumed that the container is properly ordered
 
iterator end () const override
 get the end-iterator for the container of particle properties It is assumed that the container is properly ordered
 
size_t size () const override
 get the container size.
 
const Gaudi::ParticlePropertyfind (const std::string &name) const override
 Retrieve an object by name:
 
const Gaudi::ParticlePropertyfind (const Gaudi::ParticleID &pid) const override
 Retrieve an object by PID:
 
std::string cc (const std::string &decay) const override
 make the charge conjugation for the string/decay descriptor
 
StatusCode initialize () override
 Initialize the service.
 
 ParticlePropertySvc (const std::string &name, ISvcLocator *pSvc)
 Standard Constructor.
 
void updateHandler (Gaudi::Details::PropertyBase &p)
 the action in the case of interactive manipulation with properties:
 
void updateDump (Gaudi::Details::PropertyBase &p)
 the action in the case of interactive manipulation with properties: of the service
 
void updateCC (Gaudi::Details::PropertyBase &p)
 the action in the case of interactive manipulation with properties: of the service
 
void dump ()
 dump the table of particle properties
 
StatusCode rebuild ()
 rebuild the Particle Property Data
 
StatusCode parse (const std::string &file)
 parse the file
 
StatusCode parseLine (const std::string &line)
 parse the line
 
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 setAntiParticles ()
 set properly particle<-->antiparticle relations
 
bool diff (const Gaudi::ParticleProperty &n, const Gaudi::ParticleProperty &o)
 check the difference of two properties and fill corresponding sets
 
- Public Member Functions inherited from extends< Service, Gaudi::Interfaces::IParticlePropertySvc >
void const * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast.
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface.
 
std::vector< std::string > getInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames.
 
- Public Member Functions inherited from Service
const std::string & name () const override
 Retrieve name of the service.
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service.
 
StatusCode sysStart () override
 Initialize Service.
 
StatusCode sysStop () override
 Initialize Service.
 
StatusCode sysFinalize () override
 Finalize Service.
 
StatusCode sysReinitialize () override
 Re-initialize the Service.
 
StatusCode sysRestart () override
 Re-initialize the Service.
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator.
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T>
StatusCode declareTool (ToolHandle< T > &handle, const std::string &toolTypeAndName, bool createIf=true)
 Declare used tool.
 
template<class T>
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T>
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property.
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation.
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property.
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property.
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals.
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string.
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name.
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream)
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor.
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 

Public Attributes

Set m_set
 the actual storage of all particle properties
 
Vector m_vector
 "visible" data (the ordered container)
 
NameMap m_nameMap
 Map: { "name" : "property" }.
 
PidMap m_pidMap
 Map: { "pid" : "property" }.
 
Gaudi::Property< bool > m_dump
 dump the table?
 
Gaudi::Property< std::string > m_filename
 the main file with particle properties
 
Gaudi::Property< Filesm_other
 additional files
 
Gaudi::Property< Particlesm_particles
 properties to be redefined explicitly
 
Decays::CC::MapCC m_ccMap
 the CC-map
 
Gaudi::Property< std::map< std::string, std::string > > m_ccmap_
 CC-map for properties.
 
NameSet m_by_charge
 
NameSet m_by_mass
 
NameSet m_by_tlife
 
NameSet m_by_width
 
NameSet m_by_evtgen
 
NameSet m_by_pythia
 
NameSet m_replaced_names
 
PidSet m_replaced_pids
 
NameSet m_no_anti
 
Vector m_modified
 

Additional Inherited Members

- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 
int outputLevel () const
 get the Service's output level
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches.
 
MSG::Level resetMessaging ()
 Reinitialize internal states.
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream.
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state.
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools
 
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
 
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
 
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
 
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
 
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
 
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service.
 

Detailed Description

This service provides access to particle properties.

The settable property of this service is the ParticlePropertiesFile, an ASCII file containing the list of properties for the particles. The default file is: "$PARAMFILESROOT/data/ParticleTable.txt" or if $PARAMFILESROOT is not defined "ParticleTable.txt"

Author
Iain Last
Gloria Corti
Vanya BELYAEV
Date
2006-09-22

1) Modified to add possibility to redefine properties of existing particles and to read addiitonal files. New propeety "OtherFiles" (default is empty vector) is introduces. Service parsed additional files after the main one.

// read the additional files with particle properties
ParticlePropertySvc.OtherFiles += {
"$SOMELOCATION1/file1.txt" ,
"$SOMELOCATION2/file2.txt"
} ;
ParticlePropertySvc(const std::string &name, ISvcLocator *pSvc)
Standard Constructor.

2) Add possibility to modify only certain partiles through the new property "Particles" (default is enpty list), Each line is interpreted as a line in particle data table, e.g.

// redefine the properties of H_20 and H_30 particles:
ParticlePropertySvc.Particles = {
"H_20 88 35 0.0 120.0 9.4e-26 Higgs'0 35 0.0e+00" ,
"H_30 89 36 0.0 40.0 1.0e-12 A0 36 0.0e+00"
} ;

The replaces/modified particles are reported.

Definition at line 92 of file ParticlePropertySvc.cpp.

Member Typedef Documentation

◆ Files

typedef std::vector<std::string> Gaudi::ParticlePropertySvc::Files

the actual type for the list of files

Definition at line 249 of file ParticlePropertySvc.cpp.

◆ NameMap

the actual type of map: { "name" : "property" }

Definition at line 232 of file ParticlePropertySvc.cpp.

◆ NameSet

typedef std::set<std::string> Gaudi::ParticlePropertySvc::NameSet

Definition at line 276 of file ParticlePropertySvc.cpp.

◆ Particles

typedef std::vector<std::string> Gaudi::ParticlePropertySvc::Particles

the actual type for the list of particle properties (strings)

Definition at line 251 of file ParticlePropertySvc.cpp.

◆ PidMap

the actual type of map: { "pid" : "property" }

Definition at line 234 of file ParticlePropertySvc.cpp.

◆ PidSet

◆ Set

typedef std::set<std::unique_ptr<Gaudi::ParticleProperty> > Gaudi::ParticlePropertySvc::Set

the actual storage of all properties

Definition at line 230 of file ParticlePropertySvc.cpp.

◆ Vector

Constructor & Destructor Documentation

◆ ParticlePropertySvc()

Gaudi::ParticlePropertySvc::ParticlePropertySvc ( const std::string & name,
ISvcLocator * pSvc )
inline

Standard Constructor.

Parameters
nameservice instance name
pSvcpointer to service locator `

Definition at line 160 of file ParticlePropertySvc.cpp.

162 : base_class( name, pSvc ) {}
const std::string & name() const override
Retrieve name of the service.
Definition Service.cpp:333

Member Function Documentation

◆ addParticle()

StatusCode Gaudi::ParticlePropertySvc::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)

Parameters
pnamethe particle name
pidthe particle ID
chargethe particle charge
massthe particle mass
tlifethe particle tlife
maxWidththe particle max-width
evtgenthe name for EvtGen
pythiathe ID for pythia generator

Definition at line 517 of file ParticlePropertySvc.cpp.

520 {
521 // create the local object
522 const Gaudi::ParticleProperty pp( pname, pid, charge, mass, tlife, maxWidth, evtgen, pythia );
523
524 // 1) find the object with same name & pid in set:
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();
527 } );
528 // 2) object is found, redefine it!
529 Gaudi::ParticleProperty* newp = nullptr;
530 if ( m_set.end() != it ) { newp = it->get(); }
531 // new property ?
532 if ( !newp ) {
533 it = m_set.insert( std::make_unique<Gaudi::ParticleProperty>( pp ) ).first;
534 newp = it->get();
535 } else if ( diff( *newp, pp ) ) {
536 *newp = pp; // NB: redefine the properties
537 }
538
539 // insert into name map
540 {
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 );
544 }
545 // insert into PID map
546 {
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 );
550 }
551 // insert into vector
552 if ( m_vector.end() == std::find( m_vector.begin(), m_vector.end(), newp ) ) { m_vector.push_back( newp ); }
553
554 m_modified.push_back( newp );
555
556 return StatusCode::SUCCESS;
557}
const Gaudi::ParticleID & pid() const
get the particle ID
const std::string & name() const
Get the particle name.
constexpr static const auto SUCCESS
Definition StatusCode.h:99
bool diff(const Gaudi::ParticleProperty &n, const Gaudi::ParticleProperty &o)
check the difference of two properties and fill corresponding sets
Set m_set
the actual storage of all particle properties
PidMap m_pidMap
Map: { "pid" : "property" }.
NameMap m_nameMap
Map: { "name" : "property" }.
Vector m_vector
"visible" data (the ordered container)

◆ begin()

iterator Gaudi::ParticlePropertySvc::begin ( ) const
inlineoverride

get the begin-iterator for the container of particle properties It is assumed that the container is properly ordered

Returns
begin-iterator for the container of particle properties

Definition at line 97 of file ParticlePropertySvc.cpp.

97{ return m_vector.begin(); }

◆ cc()

std::string Gaudi::ParticlePropertySvc::cc ( const std::string & decay) const
override

make the charge conjugation for the string/decay descriptor

std::string decay = "B0 -> pi+ pi-" ;
Gaudi::IParticleProeprtySvc* svc = ... ;
std::string cc = svc -> cc ( decay ) ;
std::string cc(const std::string &decay) const override
make the charge conjugation for the string/decay descriptor
Parameters
decaythe decay descriptor
Returns
the charge conjugation for the decay descriptor

Definition at line 647 of file ParticlePropertySvc.cpp.

647 {
648 // build the map if not done yet
649 if ( m_ccMap.empty() ) {
650 // get the particles from the service
651 for ( const auto& pp : m_vector ) {
652 if ( !pp ) { continue; }
653 const Gaudi::ParticleProperty* anti = pp->antiParticle();
654 if ( !anti ) { continue; }
655 m_ccMap[pp->particle()] = anti->particle();
656 }
657 // get the particles from the options
658 for ( const auto& ic : m_ccmap_.value() ) {
659 m_ccMap[ic.first] = ic.second;
660 m_ccMap[ic.second] = ic.first;
661 }
662 if ( msgLevel( MSG::DEBUG ) ) {
663 Gaudi::Utils::toStream( m_ccMap, ( debug() << " CC-map is \n" ).stream() );
664 debug() << endmsg;
665 }
666 }
667 // use the map
668 return Decays::CC::cc( decay, m_ccMap );
669}
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
const std::string & particle() const
Get the particle name.
std::string cc(const std::string &decay, const MapCC &map_)
simple function to make charge conjugated inside the original string.
Definition CC.cpp:67
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
Definition ToStream.h:304
@ DEBUG
Definition IMessageSvc.h:22
stream
Definition Write.py:32
Gaudi::Property< std::map< std::string, std::string > > m_ccmap_
CC-map for properties.
Decays::CC::MapCC m_ccMap
the CC-map

◆ diff()

bool Gaudi::ParticlePropertySvc::diff ( const Gaudi::ParticleProperty & n,
const Gaudi::ParticleProperty & o )

check the difference of two properties and fill corresponding sets

Definition at line 587 of file ParticlePropertySvc.cpp.

587 {
588 bool d = false;
589
590 if ( different( n.charge(), o.charge() ) ) {
591 m_by_charge.insert( n.name() );
592 d = true;
593 }
594 if ( different( n.mass(), o.mass() ) ) {
595 m_by_mass.insert( n.name() );
596 d = true;
597 }
598 if ( different( n.lifetime(), o.lifetime() ) ) {
599 m_by_tlife.insert( n.name() );
600 d = true;
601 }
602 if ( different( n.maxWidth(), o.maxWidth() ) ) {
603 m_by_width.insert( n.name() );
604 d = true;
605 }
606 if ( different( n.evtGen(), o.evtGen() ) ) {
607 m_by_evtgen.insert( n.name() );
608 d = true;
609 }
610 if ( different( n.pythia(), o.pythia() ) ) {
611 m_by_pythia.insert( n.name() );
612 d = true;
613 }
614
615 if ( d ) {
616 MsgStream log( msgSvc(), name() );
617 if ( log.level() <= MSG::DEBUG )
618 log << MSG::DEBUG << " Change the properties of '" << n.name() << "'/" << n.pid().pid() << std::endl
619 << " New: " << n << std::endl
620 << " Old: " << o << endmsg;
621 }
622 return d;
623}
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
double charge() const
Get the particle charge.
double lifetime() const
Get the particle lifetime.
const std::string & evtGen() const
Get the EvtGen name.
double maxWidth() const
Get the max width deviation.
double mass() const
Get the particle mass.
int pythia() const
Get the Pythia ID.

◆ dump()

void Gaudi::ParticlePropertySvc::dump ( )

dump the table of particle properties

Definition at line 625 of file ParticlePropertySvc.cpp.

625 {
626 auto& log = always();
627 log << " The Table of Particle Properties " << std::endl;
629 log << endmsg;
630}
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
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

◆ end()

iterator Gaudi::ParticlePropertySvc::end ( ) const
inlineoverride

get the end-iterator for the container of particle properties It is assumed that the container is properly ordered

Returns
end-iterator for the container of particle properties

Definition at line 102 of file ParticlePropertySvc.cpp.

102{ return m_vector.end(); }

◆ find() [1/2]

const Gaudi::ParticleProperty * Gaudi::ParticlePropertySvc::find ( const Gaudi::ParticleID & pid) const
inlineoverride

Retrieve an object by PID:

const Gaudi::ParticleID& pid = ... ;
const Gaudi::ParticleProperty* pp = svc -> find ( pid ) ;
The abstract interface to Particle Property Service.
Holds PDG + LHCb extension particle code, following the PDG particle numbering scheme (pdg....
Definition ParticleID.h:43
A trivial class to hold information about a single particle properties.
const Gaudi::ParticleProperty * find(const std::string &name) const override
Retrieve an object by name:
Parameters
namethe particle name
Returns
pointer to particle property object

Definition at line 134 of file ParticlePropertySvc.cpp.

134{ return m_pidMap( pid ); }

◆ find() [2/2]

const Gaudi::ParticleProperty * Gaudi::ParticlePropertySvc::find ( const std::string & name) const
inlineoverride

Retrieve an object by name:

const std::string& name = ... ;
const Gaudi::ParticleProperty* pp = svc -> find ( name ) ;
Parameters
namethe particle name
Returns
pointer to particle property object

Definition at line 119 of file ParticlePropertySvc.cpp.

119{ return m_nameMap( name ); }

◆ initialize()

StatusCode Gaudi::ParticlePropertySvc::initialize ( )
override

Initialize the service.

Definition at line 294 of file ParticlePropertySvc.cpp.

294 {
295 // 1) initialize the base
296 StatusCode sc = Service::initialize();
297 if ( sc.isFailure() ) { return sc; }
298 // 2) create the log
299 MsgStream log( msgSvc(), name() );
300 // 3) rebuild everything
301 sc = rebuild();
302 log << MSG::INFO << "Initialising Gaudi ParticlePropertySvc" << endmsg;
303 if ( sc.isFailure() ) {
304 log << MSG::ERROR << " Unable to initialize the internal structures " << endmsg;
305 return sc;
306 }
307
308 m_by_charge.clear();
309 m_by_mass.clear();
310 m_by_tlife.clear();
311 m_by_width.clear();
312 m_by_evtgen.clear();
313 m_by_pythia.clear();
314 m_replaced_names.clear();
315 m_replaced_pids.clear();
316 m_no_anti.clear();
317
318 m_ccMap.clear();
319
320 if ( m_dump.value() || msgLevel( MSG::DEBUG ) ) { dump(); }
321
322 return StatusCode::SUCCESS;
323}
StatusCode initialize() override
Definition Service.cpp:118
bool isFailure() const
Definition StatusCode.h:129
@ ERROR
Definition IMessageSvc.h:22
@ INFO
Definition IMessageSvc.h:22
Gaudi::Property< bool > m_dump
dump the table?
StatusCode rebuild()
rebuild the Particle Property Data
void dump()
dump the table of particle properties

◆ parse()

StatusCode Gaudi::ParticlePropertySvc::parse ( const std::string & file)

parse the file

Parameters
filethe file name to be parsed
Returns
status code

Definition at line 431 of file ParticlePropertySvc.cpp.

431 {
432 auto fileAccess = service<IFileAccess>( "VFSSvc" );
433 if ( !fileAccess ) {
434 error() << "Unable to locate IFileAccess('VFSSvc') service" << endmsg;
435 return StatusCode::FAILURE;
436 }
437 // "open" the file
438 auto infile = fileAccess->open( file );
439 if ( !infile.get() ) {
440 error() << "Unable to open file '" << file << "'" << endmsg;
441 return StatusCode::FAILURE;
442 }
443 info() << "Opened particle properties file : " << file << endmsg;
444 bool active = false;
445 // read the file line-by-line
446 while ( *infile ) {
447 std::string line;
448 std::getline( *infile, line );
449 // skip empty lines:
450 if ( line.empty() ) { continue; }
451 // comment lines start with '#'
452 if ( line[0] == '#' ) { continue; }
453 //
454 if ( !active ) {
455 if ( "PARTICLE" == boost::to_upper_copy( boost::trim_copy( line ) ) ) {
456 active = true;
457 continue;
458 }
459 } else {
460 if ( "END PARTICLE" == boost::to_upper_copy( boost::trim_copy( line ) ) ) {
461 active = false;
462 continue;
463 }
464 }
465
466 if ( !active ) { continue; } // skip the lines if not active
467 // parse the line
468 if ( auto sc = parseLine( line ); sc.isFailure() ) {
469 error() << "Unable to parse the file '" << file << "'" << endmsg;
470 return sc;
471 }
472 }
473
474 return StatusCode::SUCCESS;
475}
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
Definition Service.h:79
constexpr static const auto FAILURE
Definition StatusCode.h:100
StatusCode parseLine(const std::string &line)
parse the line

◆ parseLine()

StatusCode Gaudi::ParticlePropertySvc::parseLine ( const std::string & line)

parse the line

Parameters
linethe line to be parsed
Returns
status code

Definition at line 482 of file ParticlePropertySvc.cpp.

482 {
483 // get the input stream from the line :
484 std::istringstream input( line );
485 // get the name
486 std::string p_name;
487 int p_geant; // obsolete, to be ignored
488 int p_pdg;
489 double p_charge;
490 double p_mass;
491 double p_ltime;
492 std::string p_evtgen;
493 int p_pythia;
494 double p_maxwid;
495 // parse the line
496 if ( input >> p_name >> p_geant >> p_pdg >> p_charge >> p_mass >> p_ltime >> p_evtgen >> p_pythia >> p_maxwid ) {
497 // Negative lifetime means the width in GeV-units
498 if ( 0 > p_ltime ) {
500 }
501
502 StatusCode sc = addParticle( p_name, Gaudi::ParticleID( p_pdg ), p_charge,
503 p_mass * Gaudi::Units::GeV, // rescale from CDF units
504 p_ltime * Gaudi::Units::s, // rescale from CDF units
505 p_maxwid * Gaudi::Units::GeV, // rescale from CDF units
506 p_evtgen, p_pythia );
507 if ( sc.isFailure() ) { return sc; }
508 } else {
509 MsgStream log( msgSvc(), name() );
510 log << MSG::ERROR << " could not parse the line: '" << line << "'" << endmsg;
511 return StatusCode::FAILURE;
512 }
513
514 return StatusCode::SUCCESS;
515}
constexpr double s
constexpr double GeV
constexpr double hbar_Planck
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition ParticleID.h:191
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)

◆ rebuild()

StatusCode Gaudi::ParticlePropertySvc::rebuild ( )

rebuild the Particle Property Data

  • clear existing containers
  • parse main file
  • parse additional files
  • parse the specific options
  • set particle<->antiparticle links
    Returns
    status code

Definition at line 333 of file ParticlePropertySvc.cpp.

333 {
334 // clear all existing containers
335 m_nameMap.clear();
336 m_pidMap.clear();
337 m_vector.clear();
338 m_ccMap.clear();
339
340 // parse the main file
341 StatusCode sc = parse( m_filename.value() );
342 if ( sc.isFailure() ) { return sc; }
343 // parse the additional files
344 for ( const auto& file : m_other.value() ) {
345 if ( sc = parse( file ); sc.isFailure() ) { return sc; }
346 }
347 // parse the options/lines
348 m_modified.clear();
349 for ( const auto& line : m_particles.value() ) {
350 if ( sc = parseLine( line ); sc.isFailure() ) { return sc; }
351 }
352 // sort the vector
353 std::stable_sort( m_vector.begin(), m_vector.end(), Gaudi::ParticleProperty::Compare() );
354 // set particle<-->antiparticle links
355 sc = setAntiParticles();
356 if ( sc.isFailure() ) { return sc; }
357 // some debug printout
358 if ( msgLevel( MSG::DEBUG ) ) {
359 debug() << " All: " << m_vector.size() << " By Name: " << m_nameMap.size() << " By PID: " << m_pidMap.size()
360 << " Total: " << m_set.size() << endmsg;
361 }
362
363 if ( !m_modified.empty() ) {
364 auto& log = always();
365 log << " New/updated particles (from \"Particles\" property)" << std::endl;
367 log << endmsg;
368 m_modified.clear();
369 }
370
371 if ( !m_by_charge.empty() ) {
372 info() << " Charge has beed redefined for " << Gaudi::Utils::toString( m_by_charge ) << endmsg;
373 }
374 if ( !m_by_mass.empty() ) {
375 info() << " Mass has beed redefined for " << Gaudi::Utils::toString( m_by_mass ) << endmsg;
376 }
377 if ( !m_by_tlife.empty() ) {
378 info() << " Lifetime has beed redefined for " << Gaudi::Utils::toString( m_by_tlife ) << endmsg;
379 }
380 if ( !m_by_width.empty() ) {
381 info() << " MaxWidth has beed redefined for " << Gaudi::Utils::toString( m_by_width ) << endmsg;
382 }
383 if ( !m_by_evtgen.empty() ) {
384 info() << " EvtGenID has beed redefined for " << Gaudi::Utils::toString( m_by_evtgen ) << endmsg;
385 }
386 if ( !m_by_pythia.empty() ) {
387 info() << " PythiaID has beed redefined for " << Gaudi::Utils::toString( m_by_pythia ) << endmsg;
388 }
389 if ( !m_replaced_names.empty() ) {
390 info() << " Replaced names : " << Gaudi::Utils::toString( m_replaced_names ) << endmsg;
391 }
392 if ( !m_replaced_pids.empty() ) {
393 info() << " Replaced PIDs : " << Gaudi::Utils::toString( m_replaced_pids ) << endmsg;
394 }
395 if ( !m_no_anti.empty() ) { info() << " No anti particle : " << Gaudi::Utils::toString( m_no_anti ) << endmsg; }
396
397 return StatusCode::SUCCESS;
398}
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition ToStream.h:326
Gaudi::Property< Particles > m_particles
properties to be redefined explicitly
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
Gaudi::Property< Files > m_other
additional files

◆ setAntiParticles()

StatusCode Gaudi::ParticlePropertySvc::setAntiParticles ( )

set properly particle<-->antiparticle relations

Returns
status code

Definition at line 559 of file ParticlePropertySvc.cpp.

559 {
560 for ( const Gaudi::ParticleProperty* _pp : m_vector ) {
561 Gaudi::ParticleProperty* pp = const_cast<Gaudi::ParticleProperty*>( _pp );
562 pp->setAntiParticle( nullptr );
563 // get the ID for antiParticle
564 Gaudi::ParticleID panti( -pp->particleID().pid() );
565 //
566 const Gaudi::ParticleProperty* anti = m_pidMap( panti );
567 //
568 if ( !anti && 0 < pp->particleID().pid() && !pp->particleID().isNucleus() ) { anti = _pp; }
569 //
570 pp->setAntiParticle( anti );
571 if ( pp->antiParticle() ) {
572 if ( msgLevel( MSG::VERBOSE ) )
573 verbose() << "Antiparticle for \n" << ( *pp ) << " is set to be \n" << ( *( pp->antiParticle() ) ) << endmsg;
574 }
575 if ( ( !pp->antiParticle() ) && ( 0 == pp->pid().extraBits() ) ) { m_no_anti.insert( pp->name() ); }
576 }
577 return StatusCode::SUCCESS;
578}
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
@ VERBOSE
Definition IMessageSvc.h:22

◆ size()

size_t Gaudi::ParticlePropertySvc::size ( ) const
inlineoverride

get the container size.

Definition at line 104 of file ParticlePropertySvc.cpp.

104{ return m_vector.size(); }

◆ updateCC()

void Gaudi::ParticlePropertySvc::updateCC ( Gaudi::Details::PropertyBase & p)

the action in the case of interactive manipulation with properties: of the service

Parameters
pthe updated property

Definition at line 420 of file ParticlePropertySvc.cpp.

420{ m_ccMap.clear(); }

◆ updateDump()

void Gaudi::ParticlePropertySvc::updateDump ( Gaudi::Details::PropertyBase & p)

the action in the case of interactive manipulation with properties: of the service

Parameters
pthe updated property

Definition at line 426 of file ParticlePropertySvc.cpp.

426 {
427 if ( FSMState() < Gaudi::StateMachine::INITIALIZED ) { return; }
428 dump();
429}
Gaudi::StateMachine::State FSMState() const override
Definition Service.h:55

◆ updateHandler()

void Gaudi::ParticlePropertySvc::updateHandler ( Gaudi::Details::PropertyBase & p)

the action in the case of interactive manipulation with properties:

  • no action if the internal data is not yet build
  • else rebuild the internal data Such action will allow more flexible interactive configuration of the service
    Parameters
    pthe updated property

Definition at line 406 of file ParticlePropertySvc.cpp.

406 {
407 if ( FSMState() < Gaudi::StateMachine::INITIALIZED ) { return; }
408
409 info() << "Property triggers the update of internal Particle Property Data : " << p << endmsg;
410 // rebuild the internal data
411 StatusCode sc = rebuild();
412 if ( sc.isFailure() ) {
413 throw GaudiException( "Can't rebuild Particle Properties Data", "*ParticlePropertySvc*", sc );
414 }
415 // clear CC-map
416 m_ccMap.clear();
417}

Member Data Documentation

◆ m_by_charge

NameSet Gaudi::ParticlePropertySvc::m_by_charge

Definition at line 279 of file ParticlePropertySvc.cpp.

◆ m_by_evtgen

NameSet Gaudi::ParticlePropertySvc::m_by_evtgen

Definition at line 283 of file ParticlePropertySvc.cpp.

◆ m_by_mass

NameSet Gaudi::ParticlePropertySvc::m_by_mass

Definition at line 280 of file ParticlePropertySvc.cpp.

◆ m_by_pythia

NameSet Gaudi::ParticlePropertySvc::m_by_pythia

Definition at line 284 of file ParticlePropertySvc.cpp.

◆ m_by_tlife

NameSet Gaudi::ParticlePropertySvc::m_by_tlife

Definition at line 281 of file ParticlePropertySvc.cpp.

◆ m_by_width

NameSet Gaudi::ParticlePropertySvc::m_by_width

Definition at line 282 of file ParticlePropertySvc.cpp.

◆ m_ccMap

Decays::CC::MapCC Gaudi::ParticlePropertySvc::m_ccMap
mutable

the CC-map

Definition at line 270 of file ParticlePropertySvc.cpp.

◆ m_ccmap_

Gaudi::Property<std::map<std::string, std::string> > Gaudi::ParticlePropertySvc::m_ccmap_
Initial value:
{
"The map of charge-conjugation & protected symbols" }
const CCMap & cc() const
get CC-map
Definition Symbols.cpp:121
static Symbols & instance()
static accessor to teh singleton
Definition Symbols.cpp:39
void updateCC(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service

CC-map for properties.

Definition at line 272 of file ParticlePropertySvc.cpp.

272 {
273 this, "ChargeConjugations", Decays::Symbols::instance().cc(), &Gaudi::ParticlePropertySvc::updateCC,
274 "The map of charge-conjugation & protected symbols" };

◆ m_dump

Gaudi::Property<bool> Gaudi::ParticlePropertySvc::m_dump
Initial value:
"Dump all properties in a table format" }
void updateDump(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service

dump the table?

Definition at line 245 of file ParticlePropertySvc.cpp.

245 { this, "Dump", false, &Gaudi::ParticlePropertySvc::updateDump,
246 "Dump all properties in a table format" };

◆ m_filename

Gaudi::Property<std::string> Gaudi::ParticlePropertySvc::m_filename
Initial value:
{ this, "ParticlePropertiesFile", defaultFilename(),
"The name of 'main' particle properties file" }
void updateHandler(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties:

the main file with particle properties

Definition at line 253 of file ParticlePropertySvc.cpp.

253 { this, "ParticlePropertiesFile", defaultFilename(),
255 "The name of 'main' particle properties file" };

◆ m_modified

Vector Gaudi::ParticlePropertySvc::m_modified

Definition at line 290 of file ParticlePropertySvc.cpp.

◆ m_nameMap

NameMap Gaudi::ParticlePropertySvc::m_nameMap

Map: { "name" : "property" }.

Definition at line 241 of file ParticlePropertySvc.cpp.

◆ m_no_anti

NameSet Gaudi::ParticlePropertySvc::m_no_anti

Definition at line 288 of file ParticlePropertySvc.cpp.

◆ m_other

Gaudi::Property<Files> Gaudi::ParticlePropertySvc::m_other
Initial value:
{ this,
"OtherFiles",
{},
"The (optional) list of additional files with the particle data" }

additional files

Definition at line 257 of file ParticlePropertySvc.cpp.

257 { this,
258 "OtherFiles",
259 {},
261 "The (optional) list of additional files with the particle data" };

◆ m_particles

Gaudi::Property<Particles> Gaudi::ParticlePropertySvc::m_particles
Initial value:
{ this,
"Particles",
{},
"The (optional) list of special particle properties" }

properties to be redefined explicitly

Definition at line 263 of file ParticlePropertySvc.cpp.

263 { this,
264 "Particles",
265 {},
267 "The (optional) list of special particle properties" };

◆ m_pidMap

PidMap Gaudi::ParticlePropertySvc::m_pidMap

Map: { "pid" : "property" }.

Definition at line 243 of file ParticlePropertySvc.cpp.

◆ m_replaced_names

NameSet Gaudi::ParticlePropertySvc::m_replaced_names

Definition at line 286 of file ParticlePropertySvc.cpp.

◆ m_replaced_pids

PidSet Gaudi::ParticlePropertySvc::m_replaced_pids

Definition at line 287 of file ParticlePropertySvc.cpp.

◆ m_set

Set Gaudi::ParticlePropertySvc::m_set

the actual storage of all particle properties

Definition at line 237 of file ParticlePropertySvc.cpp.

◆ m_vector

Vector Gaudi::ParticlePropertySvc::m_vector

"visible" data (the ordered container)

Definition at line 239 of file ParticlePropertySvc.cpp.


The documentation for this class was generated from the following file: