The Gaudi Framework  v36r9p1 (5c15b2bb)
Gaudi::ParticlePropertySvc Class Reference

#include </builds/gaudi/Gaudi/GaudiPartProp/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 VectPP::const_iterator const_iterator
 
typedef VectPP::iterator iterator
 
typedef std::vector< ParticleProperty * > VectPP
 
- 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...
 
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, 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...
 

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

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::deque< ParticlePropertym_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" }
 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 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 82 of file ParticlePropertySvc.h.

Member Typedef Documentation

◆ const_iterator

typedef VectPP::const_iterator IParticlePropertySvc::const_iterator

Definition at line 36 of file IParticlePropertySvc.h.

◆ iterator

typedef VectPP::iterator IParticlePropertySvc::iterator

Definition at line 37 of file IParticlePropertySvc.h.

◆ MapID

◆ MapName

◆ mapped_type

◆ MapPythiaID

◆ MapStdHepID

◆ VectPP

Constructor & Destructor Documentation

◆ ParticlePropertySvc()

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 56 of file ParticlePropertySvc.cpp.

56  : base_class( name, svc ) {
58  // Redefine the default name:
59  if ( System::getEnv( "PARAMFILESROOT", m_filename.value() ) ) { m_filename.value() += "/data/ParticleTable.txt"; }
60  }

Member Function Documentation

◆ addParticles()

StatusCode Gaudi::ParticlePropertySvc::addParticles ( )
protected

Definition at line 340 of file ParticlePropertySvc.cpp.

340  {
341  // loop over all "explicit" particles
342  for ( const auto& item : m_particles ) {
343  std::istringstream input( item );
344  // get the name
345  std::string p_name;
346  int p_geant;
347  int p_jetset;
348  double p_charge;
349  double p_mass;
350  double p_ltime;
351  std::string p_evtgen;
352  int p_pythia;
353  double p_maxwid;
354  if ( input >> p_name >> p_geant >> p_jetset >> p_charge >> p_mass >> p_ltime >> p_evtgen >> p_pythia >>
355  p_maxwid ) {
356  always() << " Add/Modify the particle: "
357  << " name='" << p_name << "'"
358  << " geant=" << p_geant << " jetset=" << p_jetset << " charge=" << p_charge << " mass=" << p_mass
359  << " ltime=" << p_ltime << " evtgen='" << p_evtgen << "'"
360  << " pythia=" << p_pythia << " maxwid=" << p_maxwid << endmsg;
361  //
362  StatusCode sc = push_back( p_name, p_geant, p_jetset, p_charge, p_mass * Gaudi::Units::GeV,
363  p_ltime * Gaudi::Units::s, p_evtgen, p_pythia, p_maxwid * Gaudi::Units::GeV );
364  if ( sc.isFailure() ) { return sc; } // RETURN
365  } else {
366  error() << " could not parse '" << item << "'" << endmsg;
367  return StatusCode::FAILURE; // RETURN
368  }
369  }
370  //
371  return StatusCode::SUCCESS;
372  }

◆ anti()

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 288 of file ParticlePropertySvc.cpp.

288  {
289  if ( !pp ) { return nullptr; }
290  const int ID = pp->pdgID();
291  const int antiID = -1 * ID;
292  for ( const auto& ap : m_vectpp ) {
293  if ( ap && antiID == ap->pdgID() ) { return ap; } // RETURN
294  };
295  //
296  return pp; // RETURN
297  }

◆ begin()

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

Get a const reference to the beginning of the container.

Definition at line 120 of file ParticlePropertySvc.h.

120 { return m_vectpp.begin(); }

◆ diff()

bool Gaudi::ParticlePropertySvc::diff ( const ParticleProperty o,
const ParticleProperty n,
const MSG::Level  l = MSG::DEBUG 
) const
protected

Definition at line 380 of file ParticlePropertySvc.cpp.

380  {
381  //
382  if ( o == n ) { return false; }
383  //
384  auto& log = msgStream();
385  log << l;
386  if ( !o || !n ) {
387  log << MSG::WARNING << " ParticleProperty* point to NULL" << endmsg;
388  return true; // RETURN
389  }
390  //
391  bool result = false;
392  if ( o->particle() != n->particle() ) {
393  result = true;
394  log << " Name:'" << o->particle() << "'/'" << n->particle() << "'";
395  }
396  if ( o->geantID() != n->geantID() ) {
397  result = true;
398  log << " G3ID:" << o->geantID() << "/" << n->geantID() << "'";
399  }
400  if ( o->pdgID() != n->pdgID() ) {
401  result = true;
402  log << " PDGID:" << o->pdgID() << "/" << n->pdgID() << "'";
403  }
404  if ( o->pythiaID() != n->pythiaID() ) {
405  result = true;
406  log << " PYID:" << o->pythiaID() << "/" << n->pythiaID() << "'";
407  }
408  if ( o->charge() != n->charge() ) {
409  result = true;
410  log << " Q:" << o->charge() << "/" << n->charge() << "'";
411  }
412  if ( o->mass() != n->mass() ) {
413  result = true;
414  log << " M:" << o->mass() << "/" << n->mass() << "'";
415  }
416  if ( o->lifetime() != n->lifetime() ) {
417  result = true;
418  log << " T:" << o->lifetime() << "/" << n->lifetime() << "'";
419  }
420  if ( o->evtGenName() != n->evtGenName() ) {
421  result = true;
422  log << " EvtGen:" << o->evtGenName() << "/" << n->evtGenName() << "'";
423  }
424  if ( o->maxWidth() != n->maxWidth() ) {
425  result = true;
426  log << " WMAX:" << o->maxWidth() << "/" << n->maxWidth() << "'";
427  }
428  if ( result ) { log << endmsg; }
429  //
430  return result;
431  }

◆ end()

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

Get a const reference to the end of the container.

Definition at line 122 of file ParticlePropertySvc.h.

122 { return m_vectpp.end(); }

◆ erase() [1/3]

StatusCode Gaudi::ParticlePropertySvc::erase ( const ParticleProperty pp)
protected

remove particle property from all maps

Definition at line 206 of file ParticlePropertySvc.cpp.

206  {
207  if ( !pp ) { return StatusCode::FAILURE; }
208 
209  _remove_( m_idmap, pp );
210  _remove_( m_namemap, pp );
211  _remove_( m_stdhepidmap, pp );
212  _remove_( m_pythiaidmap, pp );
213  //
214  return rebuild();
215  }

◆ erase() [2/3]

StatusCode Gaudi::ParticlePropertySvc::erase ( const std::string name)
inlineoverride

Erase a property by particle name.

Definition at line 136 of file ParticlePropertySvc.h.

136 { return erase( find( name ) ); }

◆ erase() [3/3]

StatusCode Gaudi::ParticlePropertySvc::erase ( int  geantId)
inlineoverride

Erase a property by geant3 id.

Definition at line 134 of file ParticlePropertySvc.h.

134 { return erase( find( geantId ) ); }

◆ eraseByStdHepID()

StatusCode Gaudi::ParticlePropertySvc::eraseByStdHepID ( int  stdHepId)
inlineoverride

Erase a property by StdHep id ???

Definition at line 138 of file ParticlePropertySvc.h.

138 { return erase( findByStdHepID( stdHepId ) ); }

◆ finalize()

StatusCode Gaudi::ParticlePropertySvc::finalize ( )
override

Finalise the service.

finalize

finalize the base class

Definition at line 109 of file ParticlePropertySvc.cpp.

109  {
110  if ( !m_other.empty() ) {
111  info() << "Additional Properties have been read from files: " << Gaudi::Utils::toString( m_other ) << endmsg;
112  }
113 
114  if ( !m_replaced.empty() ) {
115  always() << "Properties have been redefined for " << m_replaced.size()
116  << " particles : " << Gaudi::Utils::toString( m_replaced ) << endmsg;
117  }
118 
120 
122  return Service::finalize();
123  }

◆ find() [1/2]

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

Retrieve a property by particle name.

Definition at line 128 of file ParticlePropertySvc.h.

128 { return m_namemap[name]; }

◆ find() [2/2]

ParticleProperty* Gaudi::ParticlePropertySvc::find ( int  geantId)
inlineoverride

Retrieve a property by geant3 id.

Definition at line 126 of file ParticlePropertySvc.h.

126 { return m_idmap[geantId]; }

◆ findByPythiaID()

ParticleProperty* Gaudi::ParticlePropertySvc::findByPythiaID ( int  pythiaID)
inlineoverride

Retrieve a property by Pythia id.

Definition at line 132 of file ParticlePropertySvc.h.

132 { return m_pythiaidmap[pythiaID]; }

◆ findByStdHepID()

ParticleProperty* Gaudi::ParticlePropertySvc::findByStdHepID ( int  stdHepId)
inlineoverride

Retrieve a property by StdHep id.

Definition at line 130 of file ParticlePropertySvc.h.

130 { return m_stdhepidmap[stdHepId]; }

◆ initialize()

StatusCode Gaudi::ParticlePropertySvc::initialize ( )
override

Initialise the service.

initialize the service and setProperties

Definition at line 64 of file ParticlePropertySvc.cpp.

64  {
66  if ( sc.isFailure() ) { return sc; }
67 
68  m_fileAccess = service( "VFSSvc" );
69  if ( !m_fileAccess ) {
70  error() << " Cannot retrieve the VFS service " << endmsg;
71  return StatusCode::FAILURE;
72  }
73 
74  sc = parse();
75  if ( sc.isFailure() ) {
76  error() << " Could not parse the file " << endmsg;
77  return sc;
78  }
79  if ( !m_particles.empty() ) {
80  sc = addParticles();
81  if ( sc.isFailure() ) {
82  error() << " Could not treat particles! " << endmsg;
83  return sc;
84  }
85  }
86  debug() << "ParticleProperties parsed successfully" << endmsg;
87 
88  debug() << "Access properties" << endmsg;
89  // For debugging purposes print out the size of the internal maps
90  // particle name as key: all particles in database are present here
91  debug() << "NameMap size =" << m_namemap.size() << endmsg;
92  // Geant3 ID as key: all particles in database are present here
93  debug() << "GeantID Map size =" << m_idmap.size() << endmsg;
94  // StdHep ID as key: some particles have no valid StdHep ID
95  debug() << "StdHepID Map size =" << m_stdhepidmap.size() << endmsg;
96  // Pythia ID as key: some particles are not defined in Pythia
97  debug() << "PythiaID Map size =" << m_pythiaidmap.size() << endmsg;
98 
99  if ( !m_replaced.empty() ) {
100  info() << "Properties have been redefined for " << m_replaced.size()
101  << " particles : " << Gaudi::Utils::toString( m_replaced ) << endmsg;
102  }
103 
104  return StatusCode::SUCCESS;
105  }

◆ parse() [1/2]

StatusCode Gaudi::ParticlePropertySvc::parse ( )
protected

Parses the file and fill all the maps.

Definition at line 219 of file ParticlePropertySvc.cpp.

219  {
220 
221  // parse "the main" file
222  StatusCode sc = parse( m_filename );
223  if ( sc.isFailure() ) { return sc; }
224 
225  // parse "other" files
226  for ( auto& file : m_other ) {
227  sc = parse( file );
228  if ( sc.isFailure() ) { return sc; }
229  }
230 
231  // Now check that the file format was consistent with what parser
232  // expected
233  if ( m_namemap.empty() ) {
234  error() << "Format of input file inconsistent with what expected"
235  << " - Check you are using ParticleData.txt" << endmsg;
236  return StatusCode::FAILURE;
237  }
238 
239  return sc;
240  }

◆ parse() [2/2]

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

parse the file

Definition at line 242 of file ParticlePropertySvc.cpp.

242  {
243  auto infile = ( m_fileAccess ? m_fileAccess->open( file ) : nullptr );
244  if ( !infile ) {
245  error() << "Unable to open properties file : " << file << endmsg;
246  return StatusCode::FAILURE;
247  }
248 
250  info() << "Opened particle properties file : " << file << endmsg;
251 
253  tokens.reserve( 9 );
255  while ( std::getline( *infile, line ) ) {
256  // parse each line of the file (comment lines begin with # in the cdf
257  // file,
258  if ( line.front() == '#' ) continue;
259 
260  tokens.clear();
261  ba::trim_left_if( line, ba::is_space() );
262  ba::split( tokens, line, ba::is_space(), boost::token_compress_on );
263  if ( tokens.size() != 9 ) continue;
264 
265  auto gid = std::stoi( tokens[1] );
266  auto jid = std::stoi( tokens[2] );
267  // Change the particles that do not correspond to a pdg number
268  if ( jid == 0 ) jid = 10000000 * gid;
269 
270  // add a particle property
271  sc = push_back( tokens[0], gid, jid, std::stod( tokens[3] ), std::stod( tokens[4] ) * Gaudi::Units::GeV,
272  std::stod( tokens[5] ) * Gaudi::Units::s, tokens[6], std::stoi( tokens[7] ),
273  std::stod( tokens[8] ) * Gaudi::Units::GeV );
274 
275  if ( sc.isFailure() ) {
276  error() << "Error from ParticlePropertySvc::push_back for particle='" << tokens[0] << "'" << endmsg;
277  }
278  }
279  return StatusCode::SUCCESS;
280  }

◆ push_back() [1/2]

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! @paramparticle 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 127 of file ParticlePropertySvc.cpp.

129  {
130  //
131  auto& pp = m_owned.emplace_back( particle, geantId, jetsetId, charge, mass, tlife, evtName, pythiaId, maxWidth );
132  return push_back( &pp );
133  }

◆ push_back() [2/2]

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 137 of file ParticlePropertySvc.cpp.

137  {
138  if ( !pp ) { return StatusCode::FAILURE; }
139  //
140  { // try to add into Geant(3)ID map
141  const int ID = pp->geantID();
142  // is this already in the map?
143  auto ifind = m_idmap.find( ID );
144  if ( m_idmap.end() != ifind && 0 != m_idmap[ID] ) {
145  diff( ifind->second, pp );
146  m_replaced.insert( m_idmap[ID]->particle() );
147  }
148  // put it into the map
149  m_idmap[ID] = pp;
150  }
151  //
152  { // try to add into Name map
153  const std::string& particle = pp->particle();
154  // is this already in the map?
155  auto ifind = m_namemap.find( particle );
156  if ( ifind != m_namemap.end() && ifind->second ) {
157  diff( ifind->second, pp );
158  m_replaced.insert( ifind->second->particle() );
159  }
160  // put it into the map
161  m_namemap[particle] = pp;
162  }
163  //
164  // add to StdHep map only if StdHep ID different from zero and if
165  // not Cerenkov (StdHep ID = gamma)
166  if ( 0 != pp->jetsetID() && "Tcherenkov" != pp->particle() ) { // try to add into StdHepID map
167  const int ID = pp->jetsetID();
168  // is this already in the map?
169  auto ifind = m_stdhepidmap.find( ID );
170  if ( m_stdhepidmap.end() != ifind && ifind->second ) {
171  diff( ifind->second, pp );
172  m_replaced.insert( ifind->second->particle() );
173  }
174  // put it into the map
175  m_stdhepidmap[ID] = pp;
176  }
177  //
178  // add to Pythia map only if Pythia ID is different from
179  // zero ( StdHep id is always different from zero in this case )
180  if ( 0 != pp->pythiaID() && 0 != pp->jetsetID() && "Tcherenkov" != pp->particle() ) { // try to add into PythiaID
181  // map
182  const int ID = pp->pythiaID();
183  // is this already in the map?
184  auto ifind = m_pythiaidmap.find( ID );
185  if ( m_pythiaidmap.end() != ifind && ifind->second ) {
186  diff( ifind->second, pp );
187  m_replaced.insert( ifind->second->particle() );
188  }
189  // put it into the map
190  m_pythiaidmap[ID] = pp;
191  }
192  //
193  return rebuild();
194  }

◆ rebuild()

StatusCode Gaudi::ParticlePropertySvc::rebuild ( )
protected

rebuild "the linear container" from the map

Definition at line 324 of file ParticlePropertySvc.cpp.

324  {
325  std::set<mapped_type> local;
326  m_vectpp.clear();
327  m_vectpp.reserve( m_idmap.size() + 100 );
328  // load information from maps into the set
329  _load_( m_idmap, local );
330  _load_( m_namemap, local );
331  _load_( m_stdhepidmap, local );
332  _load_( m_pythiaidmap, local );
333  // load information from set to the linear container vector
334  std::copy( std::begin( local ), std::end( local ), std::back_inserter( m_vectpp ) );
335  return setAntiParticles();
336  }

◆ setAntiParticles()

StatusCode Gaudi::ParticlePropertySvc::setAntiParticles ( )
protected

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

Returns
status code

Definition at line 304 of file ParticlePropertySvc.cpp.

304  {
305  // initialize particle<-->antiParticle relations
306  for ( auto& pp : m_vectpp ) {
307  if ( !pp ) { continue; } // CONTINUE
308  const ParticleProperty* ap = anti( pp );
309  if ( ap ) { pp->setAntiParticle( ap ); }
310  }
311  return StatusCode::SUCCESS;
312  }

◆ size()

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

Get the container size.

Definition at line 124 of file ParticlePropertySvc.h.

124 { return m_vectpp.size(); };

Member Data Documentation

◆ m_fileAccess

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

Definition at line 187 of file ParticlePropertySvc.h.

◆ m_filename

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

Definition at line 171 of file ParticlePropertySvc.h.

◆ m_idmap

MapID Gaudi::ParticlePropertySvc::m_idmap
private

Map for geant IDs.

Definition at line 178 of file ParticlePropertySvc.h.

◆ m_namemap

MapName Gaudi::ParticlePropertySvc::m_namemap
private

Map for particle names.

Definition at line 179 of file ParticlePropertySvc.h.

◆ m_other

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

Definition at line 173 of file ParticlePropertySvc.h.

◆ m_owned

std::deque<ParticleProperty> Gaudi::ParticlePropertySvc::m_owned
private

Definition at line 184 of file ParticlePropertySvc.h.

◆ m_particles

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

Definition at line 174 of file ParticlePropertySvc.h.

◆ m_pythiaidmap

MapPythiaID Gaudi::ParticlePropertySvc::m_pythiaidmap
private

Map for Pythia Ids.

Definition at line 181 of file ParticlePropertySvc.h.

◆ m_replaced

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

Definition at line 185 of file ParticlePropertySvc.h.

◆ m_stdhepidmap

MapStdHepID Gaudi::ParticlePropertySvc::m_stdhepidmap
private

Map for StdHep Ids.

Definition at line 180 of file ParticlePropertySvc.h.

◆ m_vectpp

VectPP Gaudi::ParticlePropertySvc::m_vectpp
private

Vector of all particle properties.

Definition at line 177 of file ParticlePropertySvc.h.


The documentation for this class was generated from the following files:
ParticleProperty::charge
double charge() const
Get the particle charge.
Definition: ParticleProperty.h:73
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
Gaudi::ParticlePropertySvc::setAntiParticles
StatusCode setAntiParticles()
helper (protected) function to set the valid particle<-->antiparticle relations
Definition: ParticlePropertySvc.cpp:304
std::string
STL class.
Gaudi.Configuration.log
log
Definition: Configuration.py:28
Gaudi::ParticlePropertySvc::m_fileAccess
SmartIF< IFileAccess > m_fileAccess
Definition: ParticlePropertySvc.h:187
Gaudi::ParticlePropertySvc::m_idmap
MapID m_idmap
Map for geant IDs.
Definition: ParticlePropertySvc.h:178
Gaudi::ParticlePropertySvc::m_stdhepidmap
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
Definition: ParticlePropertySvc.h:180
std::vector::reserve
T reserve(T... args)
Gaudi::ParticlePropertySvc::erase
StatusCode erase(int geantId) override
Erase a property by geant3 id.
Definition: ParticlePropertySvc.h:134
ParticleProperty::evtGenName
const std::string & evtGenName() const
Get the EvtGen name.
Definition: ParticleProperty.h:91
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:385
std::vector< std::string >
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
std::map::find
T find(T... args)
std::set::size
T size(T... args)
Gaudi::ParticlePropertySvc::parse
StatusCode parse()
Parses the file and fill all the maps.
Definition: ParticlePropertySvc.cpp:219
Gaudi::Units::GeV
constexpr double GeV
Definition: SystemOfUnits.h:179
std::back_inserter
T back_inserter(T... args)
Gaudi::ParticlePropertySvc::m_namemap
MapName m_namemap
Map for particle names.
Definition: ParticlePropertySvc.h:179
std::istringstream
STL class.
MSG::WARNING
@ WARNING
Definition: IMessageSvc.h:25
Gaudi::ParticlePropertySvc::m_filename
Gaudi::Property< std::string > m_filename
Definition: ParticlePropertySvc.h:171
ParticleProperty::pythiaID
int pythiaID() const
Get the Pythia ID.
Definition: ParticleProperty.h:97
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
ParticleProperty::particle
const std::string & particle() const
Get the particle name.
Definition: ParticleProperty.h:49
extends< Service, IParticlePropertySvc >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:24
std::vector::clear
T clear(T... args)
Gaudi::ParticlePropertySvc::m_pythiaidmap
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
Definition: ParticlePropertySvc.h:181
Gaudi::ParticlePropertySvc::anti
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID)
Definition: ParticlePropertySvc.cpp:288
std::stoi
T stoi(T... args)
Gaudi::ParticlePropertySvc::rebuild
StatusCode rebuild()
rebuild "the linear container" from the map
Definition: ParticlePropertySvc.cpp:324
ParticleProperty::pdgID
int pdgID() const
Get the PDG (= JETSET) ID.
Definition: ParticleProperty.h:61
ParticleProperty
Definition: ParticleProperty.h:28
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 ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
Definition: ParticlePropertySvc.cpp:380
ParticleProperty::mass
double mass() const
Get the particle mass.
Definition: ParticleProperty.h:79
Gaudi::ParticlePropertySvc::m_particles
Gaudi::Property< std::vector< std::string > > m_particles
Definition: ParticlePropertySvc.h:174
ParticleProperty::maxWidth
double maxWidth() const
Get the max width deviation.
Definition: ParticleProperty.h:103
Gaudi::Property::value
const ValueType & value() const
Backward compatibility (.
Definition: Property.h:240
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:93
std::copy
T copy(T... args)
ParticleProperty::lifetime
double lifetime() const
Get the particle lifetime.
Definition: ParticleProperty.h:85
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
ParticleProperty::geantID
int geantID() const
Get the GEANT3 ID.
Definition: ParticleProperty.h:55
Gaudi::ParticlePropertySvc::addParticles
StatusCode addParticles()
Definition: ParticlePropertySvc.cpp:340
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:235
Gaudi::ParticlePropertySvc::push_back
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.
Definition: ParticlePropertySvc.cpp:127
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::m_owned
std::deque< ParticleProperty > m_owned
Definition: ParticlePropertySvc.h:184
std::deque::emplace_back
T emplace_back(T... args)
Gaudi::ParticlePropertySvc::findByStdHepID
ParticleProperty * findByStdHepID(int stdHepId) override
Retrieve a property by StdHep id.
Definition: ParticlePropertySvc.h:130
std::stod
T stod(T... args)
Gaudi::ParticlePropertySvc::m_other
Gaudi::Property< std::vector< std::string > > m_other
Definition: ParticlePropertySvc.h:173
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
gaudirun.l
dictionary l
Definition: gaudirun.py:580
Gaudi::ParticlePropertySvc::ParticlePropertySvc
ParticlePropertySvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: ParticlePropertySvc.cpp:56
std::vector::begin
T begin(T... args)
std::getline
T getline(T... args)
std::set::insert
T insert(T... args)
Gaudi::ParticlePropertySvc::find
ParticleProperty * find(int geantId) override
Retrieve a property by geant3 id.
Definition: ParticlePropertySvc.h:126
std::set::empty
T empty(T... args)
plotSpeedupsPyRoot.line
line
Definition: plotSpeedupsPyRoot.py:193
Gaudi::ParticlePropertySvc::m_replaced
std::set< std::string > m_replaced
Definition: ParticlePropertySvc.h:185
Gaudi::ParticlePropertySvc::m_vectpp
VectPP m_vectpp
Vector of all particle properties.
Definition: ParticlePropertySvc.h:177
std::vector::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
compareOutputFiles.pp
pp
Definition: compareOutputFiles.py:513
Service::service
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:88
std::set
STL class.