The Gaudi Framework  v30r3 (a5ef0a68)
Gaudi::ParticlePropertySvc Class Reference

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

#include <src/ParticlePropertySvc.h>

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

Public Types

typedef ParticlePropertymapped_type
 
typedef std::map< int, mapped_typeMapID
 
typedef std::map< std::string, mapped_typeMapName
 
typedef std::map< int, mapped_typeMapStdHepID
 
typedef std::map< int, mapped_typeMapPythiaID
 
typedef std::vector< ParticleProperty * > VectPP
 
typedef VectPP::const_iterator const_iterator
 
typedef VectPP::iterator iterator
 
- Public Types inherited from extends< Service, 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

StatusCode initialize () override
 Initialise the service. More...
 
StatusCode finalize () override
 Finalise the service. More...
 
StatusCode push_back (const std::string &particle, int geantId, int jetsetId, double charge, double mass, double tlife, const std::string &evtName, int pythiaId, double maxWidth) override
 Create a new particle property. More...
 
StatusCode push_back (ParticleProperty *pp) override
 Add a new particle property. More...
 
const_iterator begin () const override
 Get a const reference to the beginning of the container. More...
 
const_iterator end () const override
 Get a const reference to the end of the container. More...
 
int size () const override
 Get the container size. More...
 
ParticlePropertyfind (int geantId) override
 Retrieve a property by geant3 id. More...
 
ParticlePropertyfind (const std::string &name) override
 Retrieve a property by particle name. More...
 
ParticlePropertyfindByStdHepID (int stdHepId) override
 Retrieve a property by StdHep id. More...
 
ParticlePropertyfindByPythiaID (int pythiaID) override
 Retrieve a property by Pythia id. More...
 
StatusCode erase (int geantId) override
 Erase a property by geant3 id. More...
 
StatusCode erase (const std::string &name) override
 Erase a property by particle name. More...
 
StatusCode eraseByStdHepID (int stdHepId) override
 Erase a property by StdHep id ??? More...
 
 ParticlePropertySvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
- Public Member Functions inherited from extends< Service, 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...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. 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 >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
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 Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &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 (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 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...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Protected Member Functions

const ParticlePropertyanti (const ParticleProperty *pp) const
 helper (protected) function to find an antiparticle for the given particle ID (StdHepID) More...
 
StatusCode setAntiParticles ()
 helper (protected) function to set the valid particle<–>antiparticle relations More...
 
StatusCode rebuild ()
 rebuild "the linear container" from the map More...
 
StatusCode erase (const ParticleProperty *pp)
 remove particle property from all maps More...
 
StatusCode parse (const std::string &file)
 parse the file More...
 
StatusCode parse ()
 Parses the file and fill all the maps. More...
 
StatusCode addParticles ()
 
bool diff (const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- 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...
 

Private Attributes

Gaudi::Property< std::stringm_filename
 
Gaudi::Property< std::vector< std::string > > m_other {this, "OtherFiles", {}, "additional file names"}
 
Gaudi::Property< std::vector< std::string > > m_particles
 
VectPP m_vectpp
 Vector of all particle properties. More...
 
MapID m_idmap
 Map for geant IDs. More...
 
MapName m_namemap
 Map for particle names. More...
 
MapStdHepID m_stdhepidmap
 Map for StdHep Ids. More...
 
MapPythiaID m_pythiaidmap
 Map for Pythia Ids. More...
 
std::set< std::unique_ptr< ParticleProperty > > m_owned
 
std::set< std::stringm_replaced
 
SmartIF< IFileAccessm_fileAccess
 

Additional Inherited Members

- 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"}
 
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()"}
 
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 8/11/1999 change default file from $CDF/particle.cdf to $LHCBDBASE/cdf/particle.cdf on Unix and use environment variable also on WinNT Also introduce finding of particle by StdHepID
Vanya BELYAEV
Date
2006-09-22 1) Modified to add possibility to redefine properties of existing particles and to read additional files. New property "OtherFiles" (default is empty vector) is introduces. Service parsed additional files after the main one.
// read additional properties
ParticlePropertySvc.OtherFiles = {
"$SOMELOCATION1/file1.txt" ,
"$SOMELOCATION2/file2.txt"
} ;

2) Add possibility to modify only certain particles through the new property "Particles" (default is empty 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 72 of file ParticlePropertySvc.h.

Member Typedef Documentation

typedef VectPP::const_iterator IParticlePropertySvc::const_iterator

Definition at line 27 of file IParticlePropertySvc.h.

typedef VectPP::iterator IParticlePropertySvc::iterator

Definition at line 28 of file IParticlePropertySvc.h.

typedef std::map<int, mapped_type> Gaudi::ParticlePropertySvc::MapID

Definition at line 77 of file ParticlePropertySvc.h.

typedef std::map<std::string, mapped_type> Gaudi::ParticlePropertySvc::MapName

Definition at line 78 of file ParticlePropertySvc.h.

typedef ParticleProperty* Gaudi::ParticlePropertySvc::mapped_type

Definition at line 76 of file ParticlePropertySvc.h.

typedef std::map<int, mapped_type> Gaudi::ParticlePropertySvc::MapPythiaID

Definition at line 80 of file ParticlePropertySvc.h.

typedef std::map<int, mapped_type> Gaudi::ParticlePropertySvc::MapStdHepID

Definition at line 79 of file ParticlePropertySvc.h.

Constructor & Destructor Documentation

Gaudi::ParticlePropertySvc::ParticlePropertySvc ( const std::string name,
ISvcLocator svc 
)

Standard Constructor.

Parameters
nameString with service name
svcPointer to service locator interface
Todo:
: remove reference to LHCb-specific environment variable

Definition at line 47 of file ParticlePropertySvc.cpp.

47  : base_class( name, svc )
48  {
50  // Redefine the default name:
51  if ( System::getEnv( "PARAMFILESROOT", m_filename.value() ) ) {
52  m_filename.value() += "/data/ParticleTable.txt";
53  }
54  }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:411
extends base_class
Typedef to this class.
Definition: extends.h:15
Gaudi::Property< std::string > m_filename

Member Function Documentation

StatusCode Gaudi::ParticlePropertySvc::addParticles ( )
protected

Definition at line 378 of file ParticlePropertySvc.cpp.

379  {
380  // loop over all "explicit" particles
381  for ( const auto& item : m_particles ) {
382  std::istringstream input( item );
383  // get the name
384  std::string p_name;
385  int p_geant;
386  int p_jetset;
387  double p_charge;
388  double p_mass;
389  double p_ltime;
390  std::string p_evtgen;
391  int p_pythia;
392  double p_maxwid;
393  if ( input >> p_name >> p_geant >> p_jetset >> p_charge >> p_mass >> p_ltime >> p_evtgen >> p_pythia >>
394  p_maxwid ) {
395  always() << " Add/Modify the particle: "
396  << " name='" << p_name << "'"
397  << " geant=" << p_geant << " jetset=" << p_jetset << " charge=" << p_charge << " mass=" << p_mass
398  << " ltime=" << p_ltime << " evtgen='" << p_evtgen << "'"
399  << " pythia=" << p_pythia << " maxwid=" << p_maxwid << endmsg;
400  //
401  StatusCode sc = push_back( p_name, p_geant, p_jetset, p_charge, p_mass * Gaudi::Units::GeV,
402  p_ltime * Gaudi::Units::s, p_evtgen, p_pythia, p_maxwid * Gaudi::Units::GeV );
403  if ( sc.isFailure() ) {
404  return sc;
405  } // RETURN
406  } else {
407  error() << " could not parse '" << item << "'" << endmsg;
408  return StatusCode::FAILURE; // RETURN
409  }
410  }
411  //
412  return StatusCode::SUCCESS;
413  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
constexpr double s
bool isFailure() const
Definition: StatusCode.h:139
StatusCode push_back(const std::string &particle, int geantId, int jetsetId, double charge, double mass, double tlife, const std::string &evtName, int pythiaId, double maxWidth) override
Create a new particle property.
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
Gaudi::Property< std::vector< std::string > > m_particles
constexpr double GeV
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
const ParticleProperty * Gaudi::ParticlePropertySvc::anti ( const ParticleProperty pp) const
protected

helper (protected) function to find an antiparticle for the given particle ID (StdHepID)

Helper (protected) function to find an antiparticle for the given particle ID (StdHepID)

Parameters
pppointer to particle property
Returns
pointer to antiparticle

Definition at line 311 of file ParticlePropertySvc.cpp.

312  {
313  if ( !pp ) {
314  return nullptr;
315  }
316  const int ID = pp->pdgID();
317  const int antiID = -1 * ID;
318  for ( const auto& ap : m_vectpp ) {
319  if ( ap && antiID == ap->pdgID() ) {
320  return ap;
321  } // RETURN
322  };
323  //
324  return pp; // RETURN
325  }
int pdgID() const
Get the PDG (= JETSET) ID.
VectPP m_vectpp
Vector of all particle properties.
const_iterator Gaudi::ParticlePropertySvc::begin ( ) const
inlineoverride

Get a const reference to the beginning of the container.

Definition at line 111 of file ParticlePropertySvc.h.

111 { return m_vectpp.begin(); }
T begin(T...args)
VectPP m_vectpp
Vector of all particle properties.
bool Gaudi::ParticlePropertySvc::diff ( const ParticleProperty o,
const ParticleProperty n,
const MSG::Level  l = MSG::DEBUG 
) const
protected

Definition at line 421 of file ParticlePropertySvc.cpp.

422  {
423  //
424  if ( o == n ) {
425  return false;
426  }
427  //
428  auto& log = msgStream();
429  log << l;
430  if ( !o || !n ) {
431  log << MSG::WARNING << " ParticleProperty* point to NULL" << endmsg;
432  return true; // RETURN
433  }
434  //
435  bool result = false;
436  if ( o->particle() != n->particle() ) {
437  result = true;
438  log << " Name:'" << o->particle() << "'/'" << n->particle() << "'";
439  }
440  if ( o->geantID() != n->geantID() ) {
441  result = true;
442  log << " G3ID:" << o->geantID() << "/" << n->geantID() << "'";
443  }
444  if ( o->pdgID() != n->pdgID() ) {
445  result = true;
446  log << " PDGID:" << o->pdgID() << "/" << n->pdgID() << "'";
447  }
448  if ( o->pythiaID() != n->pythiaID() ) {
449  result = true;
450  log << " PYID:" << o->pythiaID() << "/" << n->pythiaID() << "'";
451  }
452  if ( o->charge() != n->charge() ) {
453  result = true;
454  log << " Q:" << o->charge() << "/" << n->charge() << "'";
455  }
456  if ( o->mass() != n->mass() ) {
457  result = true;
458  log << " M:" << o->mass() << "/" << n->mass() << "'";
459  }
460  if ( o->lifetime() != n->lifetime() ) {
461  result = true;
462  log << " T:" << o->lifetime() << "/" << n->lifetime() << "'";
463  }
464  if ( o->evtGenName() != n->evtGenName() ) {
465  result = true;
466  log << " EvtGen:" << o->evtGenName() << "/" << n->evtGenName() << "'";
467  }
468  if ( o->maxWidth() != n->maxWidth() ) {
469  result = true;
470  log << " WMAX:" << o->maxWidth() << "/" << n->maxWidth() << "'";
471  }
472  if ( result ) {
473  log << endmsg;
474  }
475  //
476  return result;
477  }
int pdgID() const
Get the PDG (= JETSET) ID.
int geantID() const
Get the GEANT3 ID.
double maxWidth() const
Get the max width deviation.
double lifetime() const
Get the particle lifetime.
dictionary l
Definition: gaudirun.py:440
double charge() const
Get the particle charge.
MsgStream & msgStream() const
Return an uninitialized MsgStream.
const std::string & particle() const
Get the particle name.
double mass() const
Get the particle mass.
int pythiaID() const
Get the Pythia ID.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
const std::string & evtGenName() const
Get the EvtGen name.
const_iterator Gaudi::ParticlePropertySvc::end ( ) const
inlineoverride

Get a const reference to the end of the container.

Definition at line 113 of file ParticlePropertySvc.h.

113 { return m_vectpp.end(); }
T end(T...args)
VectPP m_vectpp
Vector of all particle properties.
StatusCode Gaudi::ParticlePropertySvc::erase ( int  geantId)
inlineoverride

Erase a property by geant3 id.

Definition at line 125 of file ParticlePropertySvc.h.

125 { return erase( find( geantId ) ); }
StatusCode erase(int geantId) override
Erase a property by geant3 id.
ParticleProperty * find(int geantId) override
Retrieve a property by geant3 id.
StatusCode Gaudi::ParticlePropertySvc::erase ( const std::string name)
inlineoverride

Erase a property by particle name.

Definition at line 127 of file ParticlePropertySvc.h.

127 { return erase( find( name ) ); }
StatusCode erase(int geantId) override
Erase a property by geant3 id.
ParticleProperty * find(int geantId) override
Retrieve a property by geant3 id.
StatusCode Gaudi::ParticlePropertySvc::erase ( const ParticleProperty pp)
protected

remove particle property from all maps

Definition at line 220 of file ParticlePropertySvc.cpp.

221  {
222  if ( !pp ) {
223  return StatusCode::FAILURE;
224  }
225 
226  _remove_( m_idmap, pp );
227  _remove_( m_namemap, pp );
228  _remove_( m_stdhepidmap, pp );
229  _remove_( m_pythiaidmap, pp );
230  //
231  return rebuild();
232  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
StatusCode rebuild()
rebuild "the linear container" from the map
MapName m_namemap
Map for particle names.
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
MapID m_idmap
Map for geant IDs.
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
StatusCode Gaudi::ParticlePropertySvc::eraseByStdHepID ( int  stdHepId)
inlineoverride

Erase a property by StdHep id ???

Definition at line 129 of file ParticlePropertySvc.h.

129 { return erase( findByStdHepID( stdHepId ) ); }
StatusCode erase(int geantId) override
Erase a property by geant3 id.
ParticleProperty * findByStdHepID(int stdHepId) override
Retrieve a property by StdHep id.
StatusCode Gaudi::ParticlePropertySvc::finalize ( )
override

Finalise the service.

finalize

finalize the base class

Definition at line 112 of file ParticlePropertySvc.cpp.

113  {
114  if ( !m_other.empty() ) {
115  info() << "Additional Properties have been read from files: " << Gaudi::Utils::toString( m_other ) << endmsg;
116  }
117 
118  if ( !m_replaced.empty() ) {
119  always() << "Properties have been redefined for " << m_replaced.size()
120  << " particles : " << Gaudi::Utils::toString( m_replaced ) << endmsg;
121  }
122 
124 
126  return Service::finalize();
127  }
T empty(T...args)
StatusCode finalize() override
Definition: Service.cpp:173
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:356
SmartIF< IFileAccess > m_fileAccess
std::set< std::string > m_replaced
T size(T...args)
Gaudi::Property< std::vector< std::string > > m_other
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
ParticleProperty* Gaudi::ParticlePropertySvc::find ( int  geantId)
inlineoverride

Retrieve a property by geant3 id.

Definition at line 117 of file ParticlePropertySvc.h.

117 { return m_idmap[geantId]; }
MapID m_idmap
Map for geant IDs.
ParticleProperty* Gaudi::ParticlePropertySvc::find ( const std::string name)
inlineoverride

Retrieve a property by particle name.

Definition at line 119 of file ParticlePropertySvc.h.

119 { return m_namemap[name]; }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
MapName m_namemap
Map for particle names.
ParticleProperty* Gaudi::ParticlePropertySvc::findByPythiaID ( int  pythiaID)
inlineoverride

Retrieve a property by Pythia id.

Definition at line 123 of file ParticlePropertySvc.h.

123 { return m_pythiaidmap[pythiaID]; }
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
ParticleProperty* Gaudi::ParticlePropertySvc::findByStdHepID ( int  stdHepId)
inlineoverride

Retrieve a property by StdHep id.

Definition at line 121 of file ParticlePropertySvc.h.

121 { return m_stdhepidmap[stdHepId]; }
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
StatusCode Gaudi::ParticlePropertySvc::initialize ( )
override

Initialise the service.

initialize the service and setProperties

Definition at line 58 of file ParticlePropertySvc.cpp.

59  {
61  if ( sc.isFailure() ) {
62  return sc;
63  }
64 
65  sc = setProperties();
66  if ( sc.isFailure() ) {
67  error() << " Could not set the properties " << endmsg;
68  return sc;
69  }
70 
71  m_fileAccess = service( "VFSSvc" );
72  if ( !m_fileAccess ) {
73  error() << " Cannot retrieve the VFS service " << endmsg;
74  return StatusCode::FAILURE;
75  }
76 
77  sc = parse();
78  if ( sc.isFailure() ) {
79  error() << " Could not parse the file " << endmsg;
80  return sc;
81  }
82  if ( !m_particles.empty() ) {
83  sc = addParticles();
84  if ( sc.isFailure() ) {
85  error() << " Could not treat particles! " << endmsg;
86  return sc;
87  }
88  }
89  debug() << "ParticleProperties parsed successfully" << endmsg;
90 
91  debug() << "Access properties" << endmsg;
92  // For debugging purposes print out the size of the internal maps
93  // particle name as key: all particles in database are present here
94  debug() << "NameMap size =" << m_namemap.size() << endmsg;
95  // Geant3 ID as key: all particles in database are present here
96  debug() << "GeantID Map size =" << m_idmap.size() << endmsg;
97  // StdHep ID as key: some particles have no valid StdHep ID
98  debug() << "StdHepID Map size =" << m_stdhepidmap.size() << endmsg;
99  // Pythia ID as key: some particles are not defined in Pythia
100  debug() << "PythiaID Map size =" << m_pythiaidmap.size() << endmsg;
101 
102  if ( !m_replaced.empty() ) {
103  info() << "Properties have been redefined for " << m_replaced.size()
104  << " particles : " << Gaudi::Utils::toString( m_replaced ) << endmsg;
105  }
106 
107  return StatusCode::SUCCESS;
108  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
StatusCode initialize() override
Definition: Service.cpp:63
T empty(T...args)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
Definition: ToStream.h:356
MapName m_namemap
Map for particle names.
StatusCode parse()
Parses the file and fill all the maps.
SmartIF< IFileAccess > m_fileAccess
bool isFailure() const
Definition: StatusCode.h:139
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::set< std::string > m_replaced
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:294
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
T size(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MapID m_idmap
Map for geant IDs.
Gaudi::Property< std::vector< std::string > > m_particles
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:84
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
StatusCode Gaudi::ParticlePropertySvc::parse ( const std::string file)
protected

parse the file

Definition at line 264 of file ParticlePropertySvc.cpp.

265  {
266  auto infile = ( m_fileAccess ? m_fileAccess->open( file ) : nullptr );
267  if ( !infile ) {
268  error() << "Unable to open properties file : " << file << endmsg;
269  return StatusCode::FAILURE;
270  }
271 
273  info() << "Opened particle properties file : " << file << endmsg;
274 
276  tokens.reserve( 9 );
278  while ( std::getline( *infile, line ) ) {
279  // parse each line of the file (comment lines begin with # in the cdf
280  // file,
281  if ( line.front() == '#' ) continue;
282 
283  tokens.clear();
284  ba::trim_left_if( line, ba::is_space() );
285  ba::split( tokens, line, ba::is_space(), boost::token_compress_on );
286  if ( tokens.size() != 9 ) continue;
287 
288  auto gid = std::stoi( tokens[1] );
289  auto jid = std::stoi( tokens[2] );
290  // Change the particles that do not correspond to a pdg number
291  if ( jid == 0 ) jid = 10000000 * gid;
292 
293  // add a particle property
294  sc = push_back( tokens[0], gid, jid, std::stod( tokens[3] ), std::stod( tokens[4] ) * Gaudi::Units::GeV,
295  std::stod( tokens[5] ) * Gaudi::Units::s, tokens[6], std::stoi( tokens[7] ),
296  std::stod( tokens[8] ) * Gaudi::Units::GeV );
297 
298  if ( sc.isFailure() ) {
299  error() << "Error from ParticlePropertySvc::push_back for particle='" << tokens[0] << "'" << endmsg;
300  }
301  }
302  return StatusCode::SUCCESS;
303  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
constexpr double s
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
T front(T...args)
T stod(T...args)
T getline(T...args)
SmartIF< IFileAccess > m_fileAccess
bool isFailure() const
Definition: StatusCode.h:139
StatusCode push_back(const std::string &particle, int geantId, int jetsetId, double charge, double mass, double tlife, const std::string &evtName, int pythiaId, double maxWidth) override
Create a new particle property.
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
T clear(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
T size(T...args)
constexpr double GeV
T stoi(T...args)
virtual std::unique_ptr< std::istream > open(const std::string &url)=0
Find the URL and returns a unique_ptr to an input stream interface of an object that can be used to r...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
T reserve(T...args)
StatusCode Gaudi::ParticlePropertySvc::parse ( )
protected

Parses the file and fill all the maps.

Definition at line 236 of file ParticlePropertySvc.cpp.

237  {
238 
239  // parse "the main" file
240  StatusCode sc = parse( m_filename );
241  if ( sc.isFailure() ) {
242  return sc;
243  }
244 
245  // parse "other" files
246  for ( auto& file : m_other ) {
247  sc = parse( file );
248  if ( sc.isFailure() ) {
249  return sc;
250  }
251  }
252 
253  // Now check that the file format was consistent with what parser
254  // expected
255  if ( m_namemap.empty() ) {
256  error() << "Format of input file inconsistent with what expected"
257  << " - Check you are using ParticleData.txt" << endmsg;
258  return StatusCode::FAILURE;
259  }
260 
261  return sc;
262  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
T empty(T...args)
MapName m_namemap
Map for particle names.
StatusCode parse()
Parses the file and fill all the maps.
bool isFailure() const
Definition: StatusCode.h:139
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Gaudi::Property< std::vector< std::string > > m_other
Gaudi::Property< std::string > m_filename
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode Gaudi::ParticlePropertySvc::push_back ( const std::string particle,
int  geantId,
int  jetsetId,
double  charge,
double  mass,
double  tlife,
const std::string evtName,
int  pythiaId,
double  maxWidth 
)
override

Create a new particle property.

Create a particle property and insert it in the maps.

Attention
ParticlePropertySvc IS the owner if this property! String name of the particle.
Parameters
geantIdGeant3 ID of the particle.
jetsetIdJetset ID of the particle.
chargeParticle charge (/e).
massParticle mass (GeV).
tlifeParticle lifetime (s).
evtNameString name of the particle in EvtGen.
pythiaIdPythia ID of the particle.
Returns
StatusCode - SUCCESS if the particle property was added.

Definition at line 131 of file ParticlePropertySvc.cpp.

134  {
135  //
136  auto i = m_owned.insert( std::make_unique<ParticleProperty>( particle, geantId, jetsetId, charge, mass, tlife,
137  evtName, pythiaId, maxWidth ) );
138  //
139  return i.second ? push_back( i.first->get() ) : StatusCode::FAILURE;
140  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
StatusCode push_back(const std::string &particle, int geantId, int jetsetId, double charge, double mass, double tlife, const std::string &evtName, int pythiaId, double maxWidth) override
Create a new particle property.
T insert(T...args)
std::set< std::unique_ptr< ParticleProperty > > m_owned
StatusCode Gaudi::ParticlePropertySvc::push_back ( ParticleProperty pp)
override

Add a new particle property.

Add a particle property.

Attention
ParticlePropertySvc is not the owner of this property!
Parameters
pp,aparticle property class.
Returns
StatusCode - SUCCESS if the particle property was added.

Definition at line 144 of file ParticlePropertySvc.cpp.

145  {
146  if ( !pp ) {
147  return StatusCode::FAILURE;
148  }
149  //
150  { // try to add into Geant(3)ID map
151  const int ID = pp->geantID();
152  // is this already in the map?
153  auto ifind = m_idmap.find( ID );
154  if ( m_idmap.end() != ifind && 0 != m_idmap[ID] ) {
155  diff( ifind->second, pp );
156  m_replaced.insert( m_idmap[ID]->particle() );
157  }
158  // put it into the map
159  m_idmap[ID] = pp;
160  }
161  //
162  { // try to add into Name map
163  const std::string& particle = pp->particle();
164  // is this already in the map?
165  auto ifind = m_namemap.find( particle );
166  if ( ifind != m_namemap.end() && ifind->second ) {
167  diff( ifind->second, pp );
168  m_replaced.insert( ifind->second->particle() );
169  }
170  // put it into the map
171  m_namemap[particle] = pp;
172  }
173  //
174  // add to StdHep map only if StdHep ID different from zero and if
175  // not Cerenkov (StdHep ID = gamma)
176  if ( 0 != pp->jetsetID() && "Tcherenkov" != pp->particle() ) { // try to add into StdHepID map
177  const int ID = pp->jetsetID();
178  // is this already in the map?
179  auto ifind = m_stdhepidmap.find( ID );
180  if ( m_stdhepidmap.end() != ifind && ifind->second ) {
181  diff( ifind->second, pp );
182  m_replaced.insert( ifind->second->particle() );
183  }
184  // put it into the map
185  m_stdhepidmap[ID] = pp;
186  }
187  //
188  // add to Pythia map only if Pythia ID is different from
189  // zero ( StdHep id is always different from zero in this case )
190  if ( 0 != pp->pythiaID() && 0 != pp->jetsetID() &&
191  "Tcherenkov" != pp->particle() ) { // try to add into PythiaID map
192  const int ID = pp->pythiaID();
193  // is this already in the map?
194  auto ifind = m_pythiaidmap.find( ID );
195  if ( m_pythiaidmap.end() != ifind && ifind->second ) {
196  diff( ifind->second, pp );
197  m_replaced.insert( ifind->second->particle() );
198  }
199  // put it into the map
200  m_pythiaidmap[ID] = pp;
201  }
202  //
203  return rebuild();
204  }
constexpr static const auto FAILURE
Definition: StatusCode.h:88
StatusCode rebuild()
rebuild "the linear container" from the map
int geantID() const
Get the GEANT3 ID.
MapName m_namemap
Map for particle names.
T end(T...args)
STL class.
std::set< std::string > m_replaced
int jetsetID() const
Get the JETSET(StdHep) ID.
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
T insert(T...args)
T find(T...args)
bool diff(const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
MapID m_idmap
Map for geant IDs.
const std::string & particle() const
Get the particle name.
int pythiaID() const
Get the Pythia ID.
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
StatusCode Gaudi::ParticlePropertySvc::rebuild ( )
protected

rebuild "the linear container" from the map

Definition at line 361 of file ParticlePropertySvc.cpp.

362  {
363  std::set<mapped_type> local;
364  m_vectpp.clear();
365  m_vectpp.reserve( m_idmap.size() + 100 );
366  // load information from maps into the set
367  _load_( m_idmap, local );
368  _load_( m_namemap, local );
369  _load_( m_stdhepidmap, local );
370  _load_( m_pythiaidmap, local );
371  // load information from set to the linear container vector
372  std::copy( std::begin( local ), std::end( local ), std::back_inserter( m_vectpp ) );
373  return setAntiParticles();
374  }
T copy(T...args)
MapName m_namemap
Map for particle names.
T end(T...args)
T clear(T...args)
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
T size(T...args)
STL class.
T begin(T...args)
T back_inserter(T...args)
MapID m_idmap
Map for geant IDs.
StatusCode setAntiParticles()
helper (protected) function to set the valid particle<–>antiparticle relations
VectPP m_vectpp
Vector of all particle properties.
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
T reserve(T...args)
StatusCode Gaudi::ParticlePropertySvc::setAntiParticles ( )
protected

helper (protected) function to set the valid particle<–>antiparticle relations

Returns
status code

Definition at line 332 of file ParticlePropertySvc.cpp.

333  {
334  // initialize particle<-->antiParticle relations
335  for ( auto& pp : m_vectpp ) {
336  if ( !pp ) {
337  continue;
338  } // CONTINUE
339  const ParticleProperty* ap = anti( pp );
340  if ( ap ) {
341  pp->setAntiParticle( ap );
342  }
343  }
344  return StatusCode::SUCCESS;
345  }
A trivial class to hold information about a single particle properties.
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID) ...
VectPP m_vectpp
Vector of all particle properties.
int Gaudi::ParticlePropertySvc::size ( ) const
inlineoverride

Get the container size.

Definition at line 115 of file ParticlePropertySvc.h.

115 { return m_vectpp.size(); };
T size(T...args)
VectPP m_vectpp
Vector of all particle properties.

Member Data Documentation

SmartIF<IFileAccess> Gaudi::ParticlePropertySvc::m_fileAccess
private

Definition at line 178 of file ParticlePropertySvc.h.

Gaudi::Property<std::string> Gaudi::ParticlePropertySvc::m_filename
private
Initial value:
{this, "ParticlePropertiesFile", "ParticleTable.txt",
"Filename of the particle properties file"}

Definition at line 162 of file ParticlePropertySvc.h.

MapID Gaudi::ParticlePropertySvc::m_idmap
private

Map for geant IDs.

Definition at line 169 of file ParticlePropertySvc.h.

MapName Gaudi::ParticlePropertySvc::m_namemap
private

Map for particle names.

Definition at line 170 of file ParticlePropertySvc.h.

Gaudi::Property<std::vector<std::string> > Gaudi::ParticlePropertySvc::m_other {this, "OtherFiles", {}, "additional file names"}
private

Definition at line 164 of file ParticlePropertySvc.h.

std::set<std::unique_ptr<ParticleProperty> > Gaudi::ParticlePropertySvc::m_owned
private

Definition at line 175 of file ParticlePropertySvc.h.

Gaudi::Property<std::vector<std::string> > Gaudi::ParticlePropertySvc::m_particles
private
Initial value:
{
this, "Particles", {}, "properties to be redefined explicitly"}

Definition at line 165 of file ParticlePropertySvc.h.

MapPythiaID Gaudi::ParticlePropertySvc::m_pythiaidmap
private

Map for Pythia Ids.

Definition at line 172 of file ParticlePropertySvc.h.

std::set<std::string> Gaudi::ParticlePropertySvc::m_replaced
private

Definition at line 176 of file ParticlePropertySvc.h.

MapStdHepID Gaudi::ParticlePropertySvc::m_stdhepidmap
private

Map for StdHep Ids.

Definition at line 171 of file ParticlePropertySvc.h.

VectPP Gaudi::ParticlePropertySvc::m_vectpp
private

Vector of all particle properties.

Definition at line 168 of file ParticlePropertySvc.h.


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