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
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- 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...
 
 ~ParticlePropertySvc () override=default
 Destructor. 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...
 
 ~extends () override=default
 Virtual destructor. 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...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value 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 >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public 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 CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
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...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. 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 CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Private Types

typedef std::vector< std::stringFiles
 
typedef std::vector< std::stringParticles
 

Private Attributes

std::string m_filename = "ParticleTable.txt"
 Filename of the particle properties file. More...
 
Files m_other
 additional file names More...
 
Particles 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
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. 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 71 of file ParticlePropertySvc.h.

Member Typedef Documentation

typedef VectPP::const_iterator IParticlePropertySvc::const_iterator

Definition at line 26 of file IParticlePropertySvc.h.

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

Definition at line 181 of file ParticlePropertySvc.h.

typedef VectPP::iterator IParticlePropertySvc::iterator

Definition at line 27 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.

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

Definition at line 182 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 54 of file ParticlePropertySvc.cpp.

56  : base_class( name, svc )
57 {
59  // Redefine the default name:
60  if( System::getEnv("PARAMFILESROOT", m_filename) )
61  {
62  m_filename += "/data/ParticleTable.txt";
63  }
64  //
65  declareProperty ( "ParticlePropertiesFile" , m_filename ) ;
66  declareProperty ( "OtherFiles" , m_other ) ;
67  declareProperty ( "Particles" , m_particles ) ;
68 }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:617
extends base_class
Typedef to this class.
Definition: extends.h:14
Files m_other
additional file names
std::string m_filename
Filename of the particle properties file.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
Gaudi::ParticlePropertySvc::~ParticlePropertySvc ( )
overridedefault

Destructor.

Member Function Documentation

StatusCode Gaudi::ParticlePropertySvc::addParticles ( )
protected

Definition at line 422 of file ParticlePropertySvc.cpp.

423 {
424  // loop over all "explicit" particles
425  for ( const auto& item : m_particles )
426  {
427  std::istringstream input( item ) ;
428  // get the name
429  std::string p_name ;
430  int p_geant ;
431  int p_jetset ;
432  double p_charge ;
433  double p_mass ;
434  double p_ltime ;
435  std::string p_evtgen ;
436  int p_pythia ;
437  double p_maxwid ;
438  if ( input
439  >> p_name
440  >> p_geant
441  >> p_jetset
442  >> p_charge
443  >> p_mass
444  >> p_ltime
445  >> p_evtgen
446  >> p_pythia
447  >> p_maxwid )
448  {
449  always()
450  << " Add/Modify the particle: "
451  << " name='" << p_name << "'"
452  << " geant=" << p_geant
453  << " jetset=" << p_jetset
454  << " charge=" << p_charge
455  << " mass=" << p_mass
456  << " ltime=" << p_ltime
457  << " evtgen='" << p_evtgen << "'"
458  << " pythia=" << p_pythia
459  << " maxwid=" << p_maxwid << endmsg ;
460  //
462  ( p_name ,
463  p_geant ,
464  p_jetset ,
465  p_charge ,
466  p_mass * Gaudi::Units::GeV ,
467  p_ltime * Gaudi::Units::s ,
468  p_evtgen ,
469  p_pythia ,
470  p_maxwid * Gaudi::Units::GeV ) ;
471  if ( sc.isFailure() ) { return sc ; } // RETURN
472  }
473  else
474  {
475  error()
476  << " could not parse '" << item << "'" << endmsg ;
477  return StatusCode::FAILURE ; // RETURN
478  }
479  }
480  //
481  return StatusCode::SUCCESS ;
482 }
constexpr double s
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
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:26
tuple item
print s1,s2
Definition: ana.py:146
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:244
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 362 of file ParticlePropertySvc.cpp.

363 {
364  if ( !pp ) { return nullptr ; }
365  const int ID = pp->pdgID() ;
366  const int antiID = -1 * ID ;
367  for ( const auto& ap : m_vectpp )
368  {
369  if ( ap && antiID == ap->pdgID() ) { return ap ; } // RETURN
370  };
371  //
372  return pp ; // RETURN
373 }
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 119 of file ParticlePropertySvc.h.

119 { 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 491 of file ParticlePropertySvc.cpp.

494 {
495  //
496  if ( o == n ) { return false ; }
497  //
498  auto& log = msgStream();
499  log << l ;
500  if ( !o || !n )
501  {
502  log << MSG::WARNING << " ParticleProperty* point to NULL" << endmsg ;
503  return true ; // RETURN
504  }
505  //
506  bool result = false ;
507  if ( o -> particle () != n -> particle () )
508  {
509  result = true ;
510  log << " Name:'" << o -> particle () << "'/'" << n -> particle () << "'" ;
511  }
512  if ( o -> geantID () != n -> geantID () )
513  {
514  result = true ;
515  log << " G3ID:" << o -> geantID () << "/" << n -> geantID () << "'" ;
516  }
517  if ( o -> pdgID () != n -> pdgID () )
518  {
519  result = true ;
520  log << " PDGID:" << o -> pdgID () << "/" << n -> pdgID () << "'" ;
521  }
522  if ( o -> pythiaID () != n -> pythiaID () )
523  {
524  result = true ;
525  log << " PYID:" << o -> pythiaID () << "/" << n -> pythiaID () << "'" ;
526  }
527  if ( o -> charge () != n -> charge () )
528  {
529  result = true ;
530  log << " Q:" << o -> charge () << "/" << n -> charge () << "'" ;
531  }
532  if ( o -> mass () != n -> mass () )
533  {
534  result = true ;
535  log << " M:" << o -> mass () << "/" << n -> mass () << "'" ;
536  }
537  if ( o -> lifetime () != n -> lifetime () )
538  {
539  result = true ;
540  log << " T:" << o -> lifetime () << "/" << n -> lifetime () << "'" ;
541  }
542  if ( o -> evtGenName () != n -> evtGenName () )
543  {
544  result = true ;
545  log << " EvtGen:" << o -> evtGenName () << "/" << n -> evtGenName () << "'" ;
546  }
547  if ( o -> maxWidth () != n -> maxWidth () )
548  {
549  result = true ;
550  log << " WMAX:" << o -> maxWidth () << "/" << n -> maxWidth () << "'" ;
551  }
552  if ( result ) { log << endmsg ; }
553  //
554  return result ;
555 }
dictionary l
Definition: gaudirun.py:421
MsgStream & msgStream() const
Return an uninitialized MsgStream.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
const_iterator Gaudi::ParticlePropertySvc::end ( ) const
inlineoverride

Get a const reference to the end of the container.

Definition at line 121 of file ParticlePropertySvc.h.

121 { 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 137 of file ParticlePropertySvc.h.

138  { 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 140 of file ParticlePropertySvc.h.

141  { 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 264 of file ParticlePropertySvc.cpp.

265 {
266  if ( !pp ) { return StatusCode::FAILURE ; }
267 
268  _remove_ ( m_idmap , pp ) ;
269  _remove_ ( m_namemap , pp ) ;
270  _remove_ ( m_stdhepidmap , pp ) ;
271  _remove_ ( m_pythiaidmap , pp ) ;
272  //
273  return rebuild() ;
274 }
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 143 of file ParticlePropertySvc.h.

144  { 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 136 of file ParticlePropertySvc.cpp.

137 {
138  if ( !m_other.empty() )
139  {
140  info() << "Additional Properties have been read from files: "
142  << endmsg ;
143  }
144 
145  if ( !m_replaced.empty() )
146  {
147  always() << "Properties have been redefined for "
148  << m_replaced.size() << " particles : "
150  << endmsg ;
151  }
152 
154 
156  return Service::finalize () ;
157 }
T empty(T...args)
StatusCode finalize() override
Definition: Service.cpp:193
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:371
Files m_other
additional file names
SmartIF< IFileAccess > m_fileAccess
std::set< std::string > m_replaced
T size(T...args)
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
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:244
ParticleProperty* Gaudi::ParticlePropertySvc::find ( int  geantId)
inlineoverride

Retrieve a property by geant3 id.

Definition at line 125 of file ParticlePropertySvc.h.

126  { 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 128 of file ParticlePropertySvc.h.

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

Retrieve a property by Pythia id.

Definition at line 134 of file ParticlePropertySvc.h.

135  { 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 131 of file ParticlePropertySvc.h.

132  { 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 72 of file ParticlePropertySvc.cpp.

73 {
75  if ( sc.isFailure() ) { return sc ; }
76 
77 
78  sc = setProperties();
79  if ( sc.isFailure() )
80  {
81  error() << " Could not set the properties " << endmsg ;
82  return sc ;
83  }
84 
85  m_fileAccess = service("VFSSvc");
86  if ( !m_fileAccess )
87  {
88  error() << " Cannot retrieve the VFS service " << endmsg ;
89  return StatusCode::FAILURE ;
90  }
91 
92  sc = parse();
93  if ( sc.isFailure() )
94  {
95  error() << " Could not parse the file " << endmsg ;
96  return sc ;
97  }
98  if ( !m_particles.empty() )
99  {
100  sc = addParticles () ;
101  if ( sc.isFailure() )
102  {
103  error() << " Could not treat particles! " << endmsg ;
104  return sc ;
105  }
106  }
107  debug() << "ParticleProperties parsed successfully" << endmsg;
108 
109  debug() << "Access properties" << endmsg;
110  // For debugging purposes print out the size of the internal maps
111  // particle name as key: all particles in database are present here
112  debug() << "NameMap size =" << m_namemap.size() << endmsg;
113  // Geant3 ID as key: all particles in database are present here
114  debug() << "GeantID Map size =" << m_idmap.size() << endmsg;
115  // StdHep ID as key: some particles have no valid StdHep ID
116  debug() << "StdHepID Map size =" << m_stdhepidmap.size()
117  << endmsg;
118  // Pythia ID as key: some particles are not defined in Pythia
119  debug() << "PythiaID Map size =" << m_pythiaidmap.size()
120  << endmsg;
121 
122  if ( !m_replaced.empty() )
123  {
124  info()
125  << "Properties have been redefined for "
126  << m_replaced.size() << " particles : "
128  << endmsg ;
129  }
130 
131  return StatusCode::SUCCESS ;
132 }
StatusCode initialize() override
Definition: Service.cpp:68
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:371
MapName m_namemap
Map for particle names.
StatusCode parse()
Parses the file and fill all the maps.
SmartIF< IFileAccess > m_fileAccess
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
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:26
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:363
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.
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.
Definition: Service.h:144
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
StatusCode Gaudi::ParticlePropertySvc::parse ( const std::string file)
protected

parse the file

Definition at line 305 of file ParticlePropertySvc.cpp.

306 {
307  auto infile = ( m_fileAccess ? m_fileAccess->open(file) : nullptr );
308  if ( !infile )
309  {
310  error() << "Unable to open properties file : " << file
311  << endmsg;
312  return StatusCode::FAILURE ;
313  }
314 
316  info() << "Opened particle properties file : " << file << endmsg;
317 
318  std::vector<std::string> tokens; tokens.reserve(9);
320  while( std::getline( *infile, line ) )
321  {
322  // parse each line of the file (comment lines begin with # in the cdf
323  // file,
324  if ( line.front() == '#' ) continue;
325 
326  tokens.clear();
327  ba::trim_left_if( line, ba::is_space() );
328  ba::split( tokens, line, ba::is_space() , boost::token_compress_on );
329  if (tokens.size()!=9) continue;
330 
331  auto gid = std::stoi( tokens[1] );
332  auto jid = std::stoi( tokens[2] );
333  // Change the particles that do not correspond to a pdg number
334  if ( jid == 0 ) jid = 10000000*gid;
335 
336  // add a particle property
337  sc = push_back( tokens[0], gid, jid,
338  std::stod( tokens[3] ),
339  std::stod( tokens[4] ) * Gaudi::Units::GeV,
340  std::stod( tokens[5] ) * Gaudi::Units::s,
341  tokens[6],
342  std::stoi( tokens[7] ),
343  std::stod( tokens[8] ) * Gaudi::Units::GeV ) ;
344 
345  if ( sc.isFailure() )
346  {
347  error()
348  << "Error from ParticlePropertySvc::push_back for particle='"
349  << tokens[0] << "'" << endmsg ;
350  }
351  }
352  return StatusCode::SUCCESS ;
353 }
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
Test for a status code of FAILURE.
Definition: StatusCode.h:86
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:26
T clear(T...args)
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:244
T reserve(T...args)
StatusCode Gaudi::ParticlePropertySvc::parse ( )
protected

Parses the file and fill all the maps.

Definition at line 278 of file ParticlePropertySvc.cpp.

279 {
280 
281  // parse "the main" file
282  StatusCode sc = parse ( m_filename ) ;
283  if ( sc.isFailure() ) { return sc ; }
284 
285  // parse "other" files
286  for ( auto& file : m_other )
287  {
288  sc = parse ( file ) ;
289  if ( sc.isFailure() ) { return sc ; }
290  }
291 
292  // Now check that the file format was consistent with what parser
293  // expected
294  if ( m_namemap.empty() )
295  {
296  error()
297  << "Format of input file inconsistent with what expected"
298  << " - Check you are using ParticleData.txt" << endmsg;
299  return StatusCode::FAILURE;
300  }
301 
302  return sc;
303 }
T empty(T...args)
MapName m_namemap
Map for particle names.
StatusCode parse()
Parses the file and fill all the maps.
Files m_other
additional file names
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::string m_filename
Filename of the particle properties file.
list file
Definition: ana.py:160
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
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 162 of file ParticlePropertySvc.cpp.

171 {
172  //
173  auto i = m_owned.insert(
174  make_unique_<ParticleProperty>( particle , geantId , jetsetId ,
175  charge , mass , tlife ,
176  evtName , pythiaId , maxWidth )
177  ) ;
178  //
179  return i.second ? push_back( i.first->get() ) : StatusCode::FAILURE;
180 }
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
list i
Definition: ana.py:128
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 184 of file ParticlePropertySvc.cpp.

185 {
186  if ( !pp ) { return StatusCode::FAILURE ; }
187  //
188  { // try to add into Geant(3)ID map
189  const int ID = pp->geantID() ;
190  // is this already in the map?
191  auto ifind = m_idmap.find( ID ) ;
192  if ( m_idmap.end() != ifind && 0 != m_idmap[ ID ])
193  {
194  diff ( ifind->second , pp ) ;
195  m_replaced.insert( m_idmap[ ID ]->particle() ) ;
196  }
197  // put it into the map
198  m_idmap[ ID ] = pp ;
199  }
200  //
201  { // try to add into Name map
202  const std::string& particle = pp->particle() ;
203  // is this already in the map?
204  auto ifind = m_namemap.find( particle ) ;
205  if ( ifind != m_namemap.end() && ifind->second )
206  {
207  diff ( ifind->second , pp ) ;
208  m_replaced.insert( ifind->second->particle() ) ;
209  }
210  // put it into the map
211  m_namemap[ particle ] = pp ;
212  }
213  //
214  // add to StdHep map only if StdHep ID different from zero and if
215  // not Cerenkov (StdHep ID = gamma)
216  if ( 0 != pp->jetsetID() && "Tcherenkov" != pp->particle() )
217  { // try to add into StdHepID map
218  const int ID = pp->jetsetID() ;
219  // is this already in the map?
220  auto ifind = m_stdhepidmap.find( ID ) ;
221  if ( m_stdhepidmap.end() != ifind && ifind->second )
222  {
223  diff ( ifind->second , pp ) ;
224  m_replaced.insert( ifind->second->particle() ) ;
225  }
226  // put it into the map
227  m_stdhepidmap[ ID ] = pp ;
228  }
229  //
230  // add to Pythia map only if Pythia ID is different from
231  // zero ( StdHep id is always different from zero in this case )
232  if ( 0 != pp->pythiaID() &&
233  0 != pp->jetsetID() &&
234  "Tcherenkov" != pp->particle() )
235  { // try to add into PythiaID map
236  const int ID = pp->pythiaID() ;
237  // is this already in the map?
238  auto ifind = m_pythiaidmap.find( ID ) ;
239  if ( m_pythiaidmap.end() != ifind && ifind->second )
240  {
241  diff ( ifind->second , pp ) ;
242  m_replaced.insert( ifind->second ->particle() ) ;
243  }
244  // put it into the map
245  m_pythiaidmap[ ID ] = pp ;
246  }
247  //
248  return rebuild() ;
249 }
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 405 of file ParticlePropertySvc.cpp.

406 {
407  std::set<mapped_type> local ;
408  m_vectpp.clear() ;
409  m_vectpp.reserve ( m_idmap.size() + 100 ) ;
410  // load information from maps into the set
411  _load_ ( m_idmap , local ) ;
412  _load_ ( m_namemap , local ) ;
413  _load_ ( m_stdhepidmap , local ) ;
414  _load_ ( m_pythiaidmap , local ) ;
415  // load information from set to the linear container vector
417  return setAntiParticles() ;
418 }
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 380 of file ParticlePropertySvc.cpp.

381 {
382  // initialize particle<-->antiParticle relations
383  for ( auto& pp : m_vectpp )
384  {
385  if ( !pp ) { continue ; } // CONTINUE
386  const ParticleProperty* ap = anti ( pp ) ;
387  if ( ap ) { pp->setAntiParticle( ap ) ; }
388  }
389  return StatusCode::SUCCESS ;
390 }
A trivial class to hold information about a single particle properties.
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 123 of file ParticlePropertySvc.h.

123 { 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 199 of file ParticlePropertySvc.h.

std::string Gaudi::ParticlePropertySvc::m_filename = "ParticleTable.txt"
private

Filename of the particle properties file.

Definition at line 184 of file ParticlePropertySvc.h.

MapID Gaudi::ParticlePropertySvc::m_idmap
private

Map for geant IDs.

Definition at line 190 of file ParticlePropertySvc.h.

MapName Gaudi::ParticlePropertySvc::m_namemap
private

Map for particle names.

Definition at line 191 of file ParticlePropertySvc.h.

Files Gaudi::ParticlePropertySvc::m_other
private

additional file names

Definition at line 185 of file ParticlePropertySvc.h.

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

Definition at line 196 of file ParticlePropertySvc.h.

Particles Gaudi::ParticlePropertySvc::m_particles
private

Definition at line 187 of file ParticlePropertySvc.h.

MapPythiaID Gaudi::ParticlePropertySvc::m_pythiaidmap
private

Map for Pythia Ids.

Definition at line 193 of file ParticlePropertySvc.h.

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

Definition at line 197 of file ParticlePropertySvc.h.

MapStdHepID Gaudi::ParticlePropertySvc::m_stdhepidmap
private

Map for StdHep Ids.

Definition at line 192 of file ParticlePropertySvc.h.

VectPP Gaudi::ParticlePropertySvc::m_vectpp
private

Vector of all particle properties.

Definition at line 189 of file ParticlePropertySvc.h.


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