The Gaudi Framework  master (37c0b60a)
Gaudi::ParticlePropertySvc Class Referencefinal

#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 More...
 
typedef GaudiUtils::VectorMap< std::string, const Gaudi::ParticleProperty * > NameMap
 the actual type of map: { "name" : "property" } More...
 
typedef GaudiUtils::VectorMap< Gaudi::ParticleID, const Gaudi::ParticleProperty * > PidMap
 the actual type of map: { "pid" : "property" } More...
 
typedef Gaudi::Interfaces::IParticlePropertySvc::ParticleProperties Vector
 
typedef std::vector< std::stringFiles
 the actual type for the list of files More...
 
typedef std::vector< std::stringParticles
 the actual type for the list of particle properties (strings) More...
 
typedef std::set< std::stringNameSet
 
typedef std::set< Gaudi::ParticleIDPidSet
 
- Public Types inherited from extends< Service, Gaudi::Interfaces::IParticlePropertySvc >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- 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 = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

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 More...
 
iterator end () const override
 get the end-iterator for the container of particle properties It is assumed that the container is properly ordered More...
 
size_t size () const override
 get the container size. More...
 
const Gaudi::ParticlePropertyfind (const std::string &name) const override
 Retrieve an object by name: More...
 
const Gaudi::ParticlePropertyfind (const Gaudi::ParticleID &pid) const override
 Retrieve an object by PID: More...
 
std::string cc (const std::string &decay) const override
 make the charge conjugation for the string/decay descriptor More...
 
StatusCode initialize () override
 Initialize the service. More...
 
 ParticlePropertySvc (const std::string &name, ISvcLocator *pSvc)
 Standard Constructor. More...
 
void updateHandler (Gaudi::Details::PropertyBase &p)
 the action in the case of interactive manipulation with properties: More...
 
void updateDump (Gaudi::Details::PropertyBase &p)
 the action in the case of interactive manipulation with properties: of the service More...
 
void updateCC (Gaudi::Details::PropertyBase &p)
 the action in the case of interactive manipulation with properties: of the service More...
 
void dump ()
 dump the table of particle properties More...
 
StatusCode rebuild ()
 rebuild the Particle Property Data More...
 
StatusCode parse (const std::string &file)
 parse the file More...
 
StatusCode parseLine (const std::string &line)
 parse the line More...
 
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) More...
 
StatusCode setAntiParticles ()
 set properly particle<-->antiparticle relations More...
 
bool diff (const Gaudi::ParticleProperty &n, const Gaudi::ParticleProperty &o)
 check the difference of two properties and fill corresponding sets More...
 
- Public Member Functions inherited from extends< Service, Gaudi::Interfaces::IParticlePropertySvc >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service
More...
 
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
More...
 
StatusCode sysStart () override
 Initialize Service
More...
 
StatusCode sysStop () override
 Initialize Service
More...
 
StatusCode sysFinalize () override
 Finalize Service
More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator
More...
 
template<class T >
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. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
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. More...
 
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. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
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. More...
 
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. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
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) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Public Attributes

Set m_set
 the actual storage of all particle properties More...
 
Vector m_vector
 "visible" data (the ordered container) More...
 
NameMap m_nameMap
 Map: { "name" : "property" }. More...
 
PidMap m_pidMap
 Map: { "pid" : "property" }. More...
 
Gaudi::Property< bool > m_dump
 dump the table? More...
 
Gaudi::Property< std::stringm_filename
 the main file with particle properties More...
 
Gaudi::Property< Filesm_other
 additional files More...
 
Gaudi::Property< Particlesm_particles
 properties to be redefined explicitly More...
 
Decays::CC::MapCC m_ccMap
 the CC-map More...
 
Gaudi::Property< std::map< std::string, std::string > > m_ccmap_
 CC-map for properties. More...
 
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
 Standard Destructor
More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditInit { this, "AuditServices", false, "[[deprecated]] unused" }
 
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
More...
 

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"
} ;

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

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

◆ 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

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 ) {}

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:
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 }

◆ 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 ) ;
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 }

◆ 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 }

◆ 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 }

◆ 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 ) ;
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:

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
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();
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 }

◆ 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 ) {
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 }

◆ 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 }

◆ 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
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 }

◆ 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 }

◆ 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 }

◆ 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" }

CC-map for properties.

Definition at line 272 of file ParticlePropertySvc.cpp.

◆ m_dump

Gaudi::Property<bool> Gaudi::ParticlePropertySvc::m_dump
Initial value:
"Dump all properties in a table format" }

dump the table?

Definition at line 245 of file ParticlePropertySvc.cpp.

◆ m_filename

Gaudi::Property<std::string> Gaudi::ParticlePropertySvc::m_filename
Initial value:
{ this, "ParticlePropertiesFile", defaultFilename(),
"The name of 'main' particle properties file" }

the main file with particle properties

Definition at line 253 of file ParticlePropertySvc.cpp.

◆ 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.

◆ 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.

◆ 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:
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
Gaudi::Units::hbar_Planck
constexpr double hbar_Planck
Definition: PhysicalConstants.h:75
Gaudi::ParticlePropertySvc::rebuild
StatusCode rebuild()
rebuild the Particle Property Data
Definition: ParticlePropertySvc.cpp:333
Gaudi::ParticlePropertySvc::m_by_tlife
NameSet m_by_tlife
Definition: ParticlePropertySvc.cpp:281
Gaudi::ParticleProperty::pythia
int pythia() const
Get the Pythia ID.
Definition: ParticleProperty.h:127
Gaudi::ParticlePropertySvc::addParticle
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)
Definition: ParticlePropertySvc.cpp:517
Write.stream
stream
Definition: Write.py:32
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
Gaudi::ParticlePropertySvc::dump
void dump()
dump the table of particle properties
Definition: ParticlePropertySvc.cpp:625
std::string
STL class.
Gaudi::ParticlePropertySvc::m_ccMap
Decays::CC::MapCC m_ccMap
the CC-map
Definition: ParticlePropertySvc.cpp:270
Gaudi.Configuration.log
log
Definition: Configuration.py:28
Gaudi::ParticlePropertySvc::m_particles
Gaudi::Property< Particles > m_particles
properties to be redefined explicitly
Definition: ParticlePropertySvc.cpp:263
MSG::INFO
@ INFO
Definition: IMessageSvc.h:25
Gaudi::ParticlePropertySvc::m_vector
Vector m_vector
"visible" data (the ordered container)
Definition: ParticlePropertySvc.cpp:239
Gaudi::ParticlePropertySvc::m_ccmap_
Gaudi::Property< std::map< std::string, std::string > > m_ccmap_
CC-map for properties.
Definition: ParticlePropertySvc.cpp:272
Gaudi::ParticleProperty::pid
const Gaudi::ParticleID & pid() const
get the particle ID
Definition: ParticleProperty.h:86
gaudirun.s
string s
Definition: gaudirun.py:346
std::find_if
T find_if(T... args)
std::vector::size
T size(T... args)
Gaudi::ParticleProperty::particle
const std::string & particle() const
Get the particle name.
Definition: ParticleProperty.h:78
Gaudi::Units::GeV
constexpr double GeV
Definition: SystemOfUnits.h:179
GaudiException
Definition: GaudiException.h:31
Gaudi::ParticlePropertySvc::m_by_evtgen
NameSet m_by_evtgen
Definition: ParticlePropertySvc.cpp:283
Gaudi::ParticlePropertySvc::m_dump
Gaudi::Property< bool > m_dump
dump the table?
Definition: ParticlePropertySvc.cpp:245
Gaudi::Interfaces::IParticlePropertySvc
Definition: IParticlePropertySvc.h:29
Gaudi::ParticlePropertySvc::parse
StatusCode parse(const std::string &file)
parse the file
Definition: ParticlePropertySvc.cpp:431
Gaudi::ParticlePropertySvc::updateHandler
void updateHandler(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties:
Definition: ParticlePropertySvc.cpp:406
Gaudi::ParticleProperty::name
const std::string & name() const
Get the particle name.
Definition: ParticleProperty.h:80
std::istringstream
STL class.
Gaudi::Decays::Symbols::instance
static Symbols & instance()
static accessor to teh singleton
Definition: Symbols.cpp:39
GaudiUtils::VectorMap::update
bool update(const key_type &key, const mapped_type &mapped)
forced insertion of the key/mapped pair The method acts like "insert" but it DOES overwrite the exist...
Definition: VectorMap.h:526
Gaudi::ParticlePropertySvc::ParticlePropertySvc
ParticlePropertySvc(const std::string &name, ISvcLocator *pSvc)
Standard Constructor.
Definition: ParticlePropertySvc.cpp:160
std::abs
Gaudi::ParticleID abs(const Gaudi::ParticleID &p)
Return the absolute value for a PID.
Definition: ParticleID.h:191
Gaudi::ParticlePropertySvc::cc
std::string cc(const std::string &decay) const override
make the charge conjugation for the string/decay descriptor
Definition: ParticlePropertySvc.cpp:647
Gaudi::ParticlePropertySvc::m_replaced_pids
PidSet m_replaced_pids
Definition: ParticlePropertySvc.cpp:287
Gaudi::ParticleProperty::maxWidth
double maxWidth() const
Get the max width deviation.
Definition: ParticleProperty.h:102
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
extends< Service, Gaudi::Interfaces::IParticlePropertySvc >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:24
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:62
std::set::clear
T clear(T... args)
Gaudi::ParticlePropertySvc::m_set
Set m_set
the actual storage of all particle properties
Definition: ParticlePropertySvc.cpp:237
AvalancheSchedulerErrorTest.msgSvc
msgSvc
Definition: AvalancheSchedulerErrorTest.py:80
GaudiUtils::VectorMap::clear
void clear()
clear the container
Definition: VectorMap.h:476
std::vector::push_back
T push_back(T... args)
Gaudi::ParticlePropertySvc::m_by_mass
NameSet m_by_mass
Definition: ParticlePropertySvc.cpp:280
Gaudi::ParticleProperties::printAsTable
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
Definition: ParticleProperty.cpp:319
Gaudi::ParticlePropertySvc::m_by_charge
NameSet m_by_charge
Definition: ParticlePropertySvc.cpp:279
Gaudi::ParticlePropertySvc::m_replaced_names
NameSet m_replaced_names
Definition: ParticlePropertySvc.cpp:286
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
Gaudi::ParticlePropertySvc::diff
bool diff(const Gaudi::ParticleProperty &n, const Gaudi::ParticleProperty &o)
check the difference of two properties and fill corresponding sets
Definition: ParticlePropertySvc.cpp:587
Gaudi::ParticlePropertySvc::m_filename
Gaudi::Property< std::string > m_filename
the main file with particle properties
Definition: ParticlePropertySvc.cpp:253
Gaudi::ParticleProperty::mass
double mass() const
Get the particle mass.
Definition: ParticleProperty.h:90
Gaudi::ParticlePropertySvc::m_by_width
NameSet m_by_width
Definition: ParticlePropertySvc.cpp:282
Gaudi::ParticlePropertySvc::m_nameMap
NameMap m_nameMap
Map: { "name" : "property" }.
Definition: ParticlePropertySvc.cpp:241
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:237
GaudiUtils::VectorMap::end
iterator end() const
"end" iterator for sequential access (const-only version!)
Definition: VectorMap.h:198
genconfuser.verbose
verbose
Definition: genconfuser.py:28
GaudiUtils::VectorMap::size
size_type size() const
number of elements
Definition: VectorMap.h:472
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::ParticleProperty
Definition: ParticleProperty.h:37
MsgStream
Definition: MsgStream.h:33
cpluginsvc.n
n
Definition: cpluginsvc.py:234
Gaudi::Decays::Symbols::cc
const CCMap & cc() const
get CC-map
Definition: Symbols.cpp:121
Gaudi::ParticlePropertySvc::m_by_pythia
NameSet m_by_pythia
Definition: ParticlePropertySvc.cpp:284
Gaudi::Units::s
constexpr double s
Definition: SystemOfUnits.h:153
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
Gaudi::Utils::toString
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:353
Gaudi::ParticlePropertySvc::updateCC
void updateCC(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service
Definition: ParticlePropertySvc.cpp:420
MSG::VERBOSE
@ VERBOSE
Definition: IMessageSvc.h:25
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
Gaudi::ParticlePropertySvc::setAntiParticles
StatusCode setAntiParticles()
set properly particle<-->antiparticle relations
Definition: ParticlePropertySvc.cpp:559
std::set::begin
T begin(T... args)
std::getline
T getline(T... args)
Gaudi::Decays::CC::cc
std::string cc(const std::string &decay, const MapCC &map_)
simple function to make charge conjugated inside the original string.
std::set::insert
T insert(T... args)
Gaudi::Utils::toStream
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:299
Gaudi::ParticleProperty::charge
double charge() const
Get the particle charge.
Definition: ParticleProperty.h:88
Gaudi::StateMachine::INITIALIZED
@ INITIALIZED
Definition: StateMachine.h:25
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
Gaudi::ParticleID
Definition: ParticleID.h:43
std::map::empty
T empty(T... args)
plotSpeedupsPyRoot.line
line
Definition: plotSpeedupsPyRoot.py:198
compareOutputFiles.pname
pname
Definition: compareOutputFiles.py:482
Gaudi::ParticleProperty::lifetime
double lifetime() const
Get the particle lifetime.
Definition: ParticleProperty.h:92
Gaudi::ParticleProperty::evtGen
const std::string & evtGen() const
Get the EvtGen name.
Definition: ParticleProperty.h:123
Gaudi::ParticleProperty::Compare
Definition: ParticleProperty.h:44
std::set::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Gaudi::ParticlePropertySvc::parseLine
StatusCode parseLine(const std::string &line)
parse the line
Definition: ParticlePropertySvc.cpp:482
Gaudi::ParticlePropertySvc::m_pidMap
PidMap m_pidMap
Map: { "pid" : "property" }.
Definition: ParticlePropertySvc.cpp:243
Gaudi::ParticlePropertySvc::m_modified
Vector m_modified
Definition: ParticlePropertySvc.cpp:290
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:507
std::stable_sort
T stable_sort(T... args)
Gaudi::ParticlePropertySvc::find
const Gaudi::ParticleProperty * find(const std::string &name) const override
Retrieve an object by name:
Definition: ParticlePropertySvc.cpp:119
Gaudi::ParticlePropertySvc::updateDump
void updateDump(Gaudi::Details::PropertyBase &p)
the action in the case of interactive manipulation with properties: of the service
Definition: ParticlePropertySvc.cpp:426
std::unique_ptr< Gaudi::ParticleProperty >
GaudiUtils::VectorMap::find
iterator find(const key_type &key) const
find the element by key
Definition: VectorMap.h:440
Gaudi::ParticlePropertySvc::m_other
Gaudi::Property< Files > m_other
additional files
Definition: ParticlePropertySvc.cpp:257
Gaudi::ParticlePropertySvc::m_no_anti
NameSet m_no_anti
Definition: ParticlePropertySvc.cpp:288