Gaudi Framework, version v23r9

Home   Generated: Thu Jul 18 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
Gaudi::ParticlePropertySvc Class Reference

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

#include <ParticlePropertySvc.h>

Inheritance diagram for Gaudi::ParticlePropertySvc:
Inheritance graph
[legend]
Collaboration diagram for Gaudi::ParticlePropertySvc:
Collaboration graph
[legend]

Public Types

typedef ParticlePropertymapped_type
 
typedef std::map< int,
mapped_type
MapID
 
typedef std::map< std::string,
mapped_type
MapName
 
typedef std::map< int,
mapped_type
MapStdHepID
 
typedef std::map< int,
mapped_type
MapPythiaID
 
typedef
IParticlePropertySvc::VectPP 
VectPP
 
typedef
IParticlePropertySvc::const_iterator 
const_iterator
 
typedef
IParticlePropertySvc::iterator 
iterator
 
typedef std::set
< ParticleProperty * > 
Set
 
- Public Types inherited from extends1< Service, IParticlePropertySvc >
typedef extends1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< IParticlePropertySvc
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Public Types inherited from extend_interfaces1< IParticlePropertySvc >
typedef
IParticlePropertySvc::iid::iids::type 
ext_iids
 MPL set of interfaces extended by this one.
 
- Public Types inherited from IParticlePropertySvc
typedef std::vector
< ParticleProperty * > 
VectPP
 
typedef VectPP::const_iterator const_iterator
 
typedef VectPP::iterator iterator
 

Public Member Functions

virtual StatusCode initialize ()
 Initialise the service.
 
virtual StatusCode finalize ()
 Finalise the service.
 
virtual 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)
 Create a new particle property.
 
virtual StatusCode push_back (ParticleProperty *pp)
 Add a new particle property.
 
virtual const_iterator begin () const
 Get a const reference to the beginning of the container.
 
virtual const_iterator end () const
 Get a const reference to the end of the container.
 
virtual int size () const
 Get the container size.
 
virtual ParticlePropertyfind (int geantId)
 Retrieve a property by geant3 id.
 
virtual ParticlePropertyfind (const std::string &name)
 Retrieve a property by particle name.
 
virtual ParticlePropertyfindByStdHepID (int stdHepId)
 Retrieve a property by StdHep id.
 
virtual ParticlePropertyfindByPythiaID (int pythiaID)
 Retrieve a property by Pythia id.
 
virtual StatusCode erase (int geantId)
 Erase a property by geant3 id.
 
virtual StatusCode erase (const std::string &name)
 Erase a property by particle name.
 
virtual StatusCode eraseByStdHepID (int stdHepId)
 Erase a property by StdHep id ???
 
 ParticlePropertySvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
 
virtual ~ParticlePropertySvc ()
 Destructor.
 
- Public Member Functions inherited from extends1< Service, IParticlePropertySvc >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends1 (A1 a1)
 Templated constructor with 1 argument.
 
 extends1 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends1 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::stringname () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
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.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, 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.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces1< IParticlePropertySvc >
virtual ~extend_interfaces1 ()
 Virtual destructor.
 
- Public Member Functions inherited from IParticlePropertySvc
 DeclareInterfaceID (IParticlePropertySvc, 3, 0)
 InterfaceID.
 
virtual ~IParticlePropertySvc ()
 virtual destructor
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID.
 
virtual StatusCode sysInitialize ()=0
 Initialize Service.
 
virtual StatusCode sysStart ()=0
 Start Service.
 
virtual StatusCode sysStop ()=0
 Stop Service.
 
virtual StatusCode sysFinalize ()=0
 Finalize Service.
 
virtual StatusCode sysReinitialize ()=0
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()=0
 Re-start the Service.
 
virtual StatusCode configure ()=0
 Configuration (from OFFLINE to CONFIGURED).
 
virtual StatusCode start ()=0
 Start (from INITIALIZED to RUNNING).
 
virtual StatusCode stop ()=0
 Stop (from RUNNING to INITIALIZED).
 
virtual StatusCode terminate ()=0
 Initialization (from CONFIGURED to OFFLINE).
 
virtual StatusCode reinitialize ()=0
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
 
virtual StatusCode restart ()=0
 Initialization (from RUNNING to RUNNING, via INITIALIZED).
 
virtual Gaudi::StateMachine::State FSMState () const =0
 Get the current state.
 
virtual Gaudi::StateMachine::State targetFSMState () const =0
 When we are in the middle of a transition, get the state where the transition is leading us.
 
virtual ~IService ()
 virtual destructor
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID.
 
virtual const std::stringname () const =0
 Retrieve the name of the instance.
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes).
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance.
 
virtual unsigned long release ()=0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual ~IInterface ()
 Virtual destructor.
 

Protected Member Functions

const ParticlePropertyanti (const ParticleProperty *pp) const
 helper (protected) function to find an antiparticle for the given particle ID (StdHepID)
 
StatusCode setAntiParticles ()
 helper (protected) function to set the valid particle<–>antiparticle relations
 
StatusCode rebuild ()
 rebuild "the linear container" from the map
 
StatusCode erase (const ParticleProperty *pp)
 remove particle property from all maps
 
StatusCode parse (const std::string &file)
 parse the file
 
StatusCode parse ()
 Parses the file and fill all the maps.
 
StatusCode addParticles ()
 
bool diff (const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
 

Private Types

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

Private Attributes

std::string m_filename
 Filename of the particle properties file.
 
Files m_other
 additional file names
 
Particles m_particles
 
VectPP m_vectpp
 Vector of all particle properties.
 
MapID m_idmap
 Map for geant IDs.
 
MapName m_namemap
 Map for particle names.
 
MapStdHepID m_stdhepidmap
 Map for StdHep Ids.
 
MapPythiaID m_pythiaidmap
 Map for Pythia Ids.
 
Set m_owned
 
std::set< std::stringm_replaced
 
IFileAccessm_fileAccess
 

Additional Inherited Members

- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level.
 
Gaudi::StateMachine::State m_state
 Service state.
 
Gaudi::StateMachine::State m_targetState
 Service state.
 

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 IParticlePropertySvc::const_iterator Gaudi::ParticlePropertySvc::const_iterator

Definition at line 82 of file ParticlePropertySvc.h.

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

Definition at line 183 of file ParticlePropertySvc.h.

typedef IParticlePropertySvc::iterator Gaudi::ParticlePropertySvc::iterator

Definition at line 83 of file ParticlePropertySvc.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 184 of file ParticlePropertySvc.h.

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

Definition at line 84 of file ParticlePropertySvc.h.

typedef IParticlePropertySvc::VectPP Gaudi::ParticlePropertySvc::VectPP

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

: base_class( name, svc )
// the default name of input data file
, m_filename ( "ParticleTable.txt" )
, m_other ()
// storages :
, m_vectpp ()
, m_idmap ()
, m_namemap ()
//
, m_owned ()
{
// Redefine the default name:
if( System::getEnv("PARAMFILESROOT", m_filename) )
{
m_filename += "/data/ParticleTable.txt";
}
//
declareProperty ( "ParticlePropertiesFile" , m_filename ) ;
declareProperty ( "OtherFiles" , m_other ) ;
declareProperty ( "Particles" , m_particles ) ;
}
Gaudi::ParticlePropertySvc::~ParticlePropertySvc ( )
virtual

Destructor.

destructor

Definition at line 77 of file ParticlePropertySvc.cpp.

{
for ( Set::iterator i = m_owned.begin(); i != m_owned.end() ; ++i )
{ if ( 0 != *i ) { delete *i ; } }
}

Member Function Documentation

StatusCode Gaudi::ParticlePropertySvc::addParticles ( )
protected

Definition at line 480 of file ParticlePropertySvc.cpp.

{
MsgStream log ( msgSvc() , name() ) ;
// loop over all "explicit" particles
for ( Particles::const_iterator ip = m_particles.begin() ;
m_particles.end() != ip ; ++ip )
{
const std::string item = *ip ;
std::istringstream input( item ) ;
// get the name
std::string p_name ;
int p_geant ;
int p_jetset ;
double p_charge ;
double p_mass ;
double p_ltime ;
std::string p_evtgen ;
int p_pythia ;
double p_maxwid ;
if ( input
>> p_name
>> p_geant
>> p_jetset
>> p_charge
>> p_mass
>> p_ltime
>> p_evtgen
>> p_pythia
>> p_maxwid )
{
<< " Add/Modify the particle: "
<< " name='" << p_name << "'"
<< " geant=" << p_geant
<< " jetset=" << p_jetset
<< " charge=" << p_charge
<< " mass=" << p_mass
<< " ltime=" << p_ltime
<< " evtgen='" << p_evtgen << "'"
<< " pythia=" << p_pythia
<< " maxwid=" << p_maxwid << endmsg ;
//
( p_name ,
p_geant ,
p_jetset ,
p_charge ,
p_mass * Gaudi::Units::GeV ,
p_ltime * Gaudi::Units::s ,
p_evtgen ,
p_pythia ,
p_maxwid * Gaudi::Units::GeV ) ;
if ( sc.isFailure() ) { return sc ; } // RETURN
}
else
{
<< " could not parse '" << item << "'" << endmsg ;
return StatusCode::FAILURE ; // RETURN
}
}
//
}
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 416 of file ParticlePropertySvc.cpp.

{
if ( 0 == pp ) { return 0 ; }
const int ID = pp->pdgID() ;
const int antiID = -1 * ID ;
for ( const_iterator it = m_vectpp.begin() ; m_vectpp.end() != it ; ++it )
{
const ParticleProperty* ap = *it ;
if ( 0 == ap ) { continue ; } // CONTINUE
if ( antiID == ap->pdgID() ) { return ap ; } // RETURN
};
//
return pp ; // RETURN
}
virtual const_iterator Gaudi::ParticlePropertySvc::begin ( ) const
inlinevirtual

Get a const reference to the beginning of the container.

Implements IParticlePropertySvc.

Definition at line 120 of file ParticlePropertySvc.h.

{ return m_vectpp.begin() ; }
bool Gaudi::ParticlePropertySvc::diff ( const ParticleProperty o,
const ParticleProperty n,
const MSG::Level  l = MSG::DEBUG 
) const
protected

Definition at line 553 of file ParticlePropertySvc.cpp.

{
//
if ( o == n ) { return false ; }
//
MsgStream log ( msgSvc() , name() ) ;
log << l ;
if ( 0 == o || 0 == n )
{
log << MSG::WARNING << " ParticleProperty* point to NULL" << endmsg ;
return true ; // RETURN
}
//
bool result = false ;
if ( o -> particle () != n -> particle () )
{
result = true ;
log << " Name:'" << o -> particle () << "'/'" << n -> particle () << "'" ;
}
if ( o -> geantID () != n -> geantID () )
{
result = true ;
log << " G3ID:" << o -> geantID () << "/" << n -> geantID () << "'" ;
}
if ( o -> pdgID () != n -> pdgID () )
{
result = true ;
log << " PDGID:" << o -> pdgID () << "/" << n -> pdgID () << "'" ;
}
if ( o -> pythiaID () != n -> pythiaID () )
{
result = true ;
log << " PYID:" << o -> pythiaID () << "/" << n -> pythiaID () << "'" ;
}
if ( o -> charge () != n -> charge () )
{
result = true ;
log << " Q:" << o -> charge () << "/" << n -> charge () << "'" ;
}
if ( o -> mass () != n -> mass () )
{
result = true ;
log << " M:" << o -> mass () << "/" << n -> mass () << "'" ;
}
if ( o -> lifetime () != n -> lifetime () )
{
result = true ;
log << " T:" << o -> lifetime () << "/" << n -> lifetime () << "'" ;
}
if ( o -> evtGenName () != n -> evtGenName () )
{
result = true ;
log << " EvtGen:" << o -> evtGenName () << "/" << n -> evtGenName () << "'" ;
}
if ( o -> maxWidth () != n -> maxWidth () )
{
result = true ;
log << " WMAX:" << o -> maxWidth () << "/" << n -> maxWidth () << "'" ;
}
if ( result ) { log << endmsg ; }
//
return result ;
}
virtual const_iterator Gaudi::ParticlePropertySvc::end ( ) const
inlinevirtual

Get a const reference to the end of the container.

Implements IParticlePropertySvc.

Definition at line 122 of file ParticlePropertySvc.h.

{ return m_vectpp.end() ; }
virtual StatusCode Gaudi::ParticlePropertySvc::erase ( int  geantId)
inlinevirtual

Erase a property by geant3 id.

Implements IParticlePropertySvc.

Definition at line 138 of file ParticlePropertySvc.h.

{ return erase ( find ( geantId ) ) ; }
virtual StatusCode Gaudi::ParticlePropertySvc::erase ( const std::string name)
inlinevirtual

Erase a property by particle name.

Implements IParticlePropertySvc.

Definition at line 141 of file ParticlePropertySvc.h.

{ return erase ( find ( name ) ) ; }
StatusCode Gaudi::ParticlePropertySvc::erase ( const ParticleProperty pp)
protected

remove particle property from all maps

Definition at line 286 of file ParticlePropertySvc.cpp.

{
if ( 0 == pp ) { return StatusCode::FAILURE ; }
_remove_ ( m_idmap , pp ) ;
_remove_ ( m_namemap , pp ) ;
_remove_ ( m_stdhepidmap , pp ) ;
_remove_ ( m_pythiaidmap , pp ) ;
//
return rebuild() ;
}
virtual StatusCode Gaudi::ParticlePropertySvc::eraseByStdHepID ( int  stdHepId)
inlinevirtual

Erase a property by StdHep id ???

Implements IParticlePropertySvc.

Definition at line 144 of file ParticlePropertySvc.h.

{ return erase( findByStdHepID ( stdHepId ) ) ; }
StatusCode Gaudi::ParticlePropertySvc::finalize ( )
virtual

Finalise the service.

finalize

finalize the base class

Reimplemented from Service.

Definition at line 151 of file ParticlePropertySvc.cpp.

{
if ( !m_other.empty() )
{
MsgStream log( msgSvc() , name() ) ;
<< "Additional Properties have been read from files: "
<< Gaudi::Utils::toString ( m_other )
<< endmsg ;
}
if ( !m_replaced.empty() )
{
MsgStream log( msgSvc() , name() ) ;
<< "Properties have been redefined for "
<< m_replaced.size() << " particles : "
<< Gaudi::Utils::toString( m_replaced )
<< endmsg ;
}
if (m_fileAccess) {
}
return Service::finalize () ;
}
virtual ParticleProperty* Gaudi::ParticlePropertySvc::find ( int  geantId)
inlinevirtual

Retrieve a property by geant3 id.

Implements IParticlePropertySvc.

Definition at line 126 of file ParticlePropertySvc.h.

{ return m_idmap[ geantId ] ; }
virtual ParticleProperty* Gaudi::ParticlePropertySvc::find ( const std::string name)
inlinevirtual

Retrieve a property by particle name.

Implements IParticlePropertySvc.

Definition at line 129 of file ParticlePropertySvc.h.

{ return m_namemap[ name ] ; }
virtual ParticleProperty* Gaudi::ParticlePropertySvc::findByPythiaID ( int  pythiaID)
inlinevirtual

Retrieve a property by Pythia id.

Implements IParticlePropertySvc.

Definition at line 135 of file ParticlePropertySvc.h.

{ return m_pythiaidmap[ pythiaID ]; }
virtual ParticleProperty* Gaudi::ParticlePropertySvc::findByStdHepID ( int  stdHepId)
inlinevirtual

Retrieve a property by StdHep id.

Implements IParticlePropertySvc.

Definition at line 132 of file ParticlePropertySvc.h.

{ return m_stdhepidmap[ stdHepId ] ; }
StatusCode Gaudi::ParticlePropertySvc::initialize ( )
virtual

Initialise the service.

initialize the service and setProperties

Reimplemented from Service.

Definition at line 85 of file ParticlePropertySvc.cpp.

{
if ( sc.isFailure() ) { return sc ; }
MsgStream log( msgSvc() , name() ) ;
sc = setProperties();
if ( sc.isFailure() )
{
log << MSG::ERROR << " Could not set the properties " << endmsg ;
return sc ;
}
sc = service("VFSSvc",m_fileAccess);
if ( sc.isFailure() )
{
log << MSG::ERROR << " Cannot retrieve the VFS service " << endmsg ;
return sc ;
}
sc = parse();
if ( sc.isFailure() )
{
log << MSG::ERROR << " Could not parse the file " << endmsg ;
return sc ;
}
if ( !m_particles.empty() )
{
sc = addParticles () ;
if ( sc.isFailure() )
{
log << MSG::ERROR << " Could not treat particles! " << endmsg ;
return sc ;
}
}
log << MSG::DEBUG << "ParticleProperties parsed successfully" << endmsg;
log << MSG::DEBUG << "Access properties" << endmsg;
// For debugging purposes print out the size of the internal maps
// particle name as key: all particles in database are present here
log << MSG::DEBUG << "NameMap size =" << m_namemap.size() << endmsg;
// Geant3 ID as key: all particles in database are present here
log << MSG::DEBUG << "GeantID Map size =" << m_idmap.size() << endmsg;
// StdHep ID as key: some particles have no valid StdHep ID
log << MSG::DEBUG << "StdHepID Map size =" << m_stdhepidmap.size()
<< endmsg;
// Pythia ID as key: some particles are not defined in Pythia
log << MSG::DEBUG << "PythiaID Map size =" << m_pythiaidmap.size()
<< endmsg;
if ( !m_replaced.empty() )
{
<< "Properties have been redefined for "
<< m_replaced.size() << " particles : "
<< Gaudi::Utils::toString( m_replaced )
<< endmsg ;
}
}
StatusCode Gaudi::ParticlePropertySvc::parse ( const std::string file)
protected

parse the file

Todo:
: This PPS should be removed from Gaudi, if not, the parser must be improved

Definition at line 329 of file ParticlePropertySvc.cpp.

{
char line[ 255 ];
if (m_fileAccess) infileptr = m_fileAccess->open(file);
if ( infileptr.get() == 0 )
{
log << MSG::ERROR << "Unable to open properties file : " << file
<< endmsg;
}
std::istream &infile = *infileptr;
<< "Opened particle properties file : " << file << endmsg;
while( infile )
{
// parse each line of the file (comment lines begin with # in the cdf
// file,
infile.getline( line, 255 );
if ( line[0] == '#' ) continue;
#ifdef WIN32
// Disable warning
// C4996: 'strtok': This function or variable may be unsafe.
#pragma warning(disable:4996)
#endif
std::string par, gid, jid, chg, mas, lif, evt, pyt, mwi ;
char* token = strtok( line, " " );
if ( token ) { par = token; token = strtok( NULL, " " );} else continue;
if ( token ) { gid = token; token = strtok( NULL, " " );} else continue;
if ( token ) { jid = token; token = strtok( NULL, " " );} else continue;
if ( token ) { chg = token; token = strtok( NULL, " " );} else continue;
if ( token ) { mas = token; token = strtok( NULL, " " );} else continue;
if ( token ) { lif = token; token = strtok( NULL, " " );} else continue;
if ( token ) { evt = token; token = strtok( NULL, " " );} else continue;
if ( token ) { pyt = token; token = strtok( NULL, " " );} else continue;
if ( token ) { mwi = token; token = strtok( NULL, " " );} else continue;
if ( token != NULL ) continue;
// In SICb cdf file mass and lifetime units are GeV and sec, specify it so
// that they are converted to Gaudi units (MeV and ns)
double mass = atof( mas.c_str() ) * Gaudi::Units::GeV;
double tlife = atof( lif.c_str() ) * Gaudi::Units::s;
long ljid = atoi( jid.c_str() );
long lgid = atoi( gid.c_str() );
long lpyt = atoi( pyt.c_str() ) ;
double mW = atof( mwi.c_str() ) * Gaudi::Units::GeV ;
// Change the particles that do not correspond to a pdg number
if ( ljid == 0 ) {
ljid = 10000000*lgid;
}
// add a particle property
sc = push_back( par, lgid, ljid,
atof( chg.c_str() ), mass, tlife, evt, lpyt, mW ) ;
if ( sc.isFailure() )
{
<< "Error from ParticlePropertySvc::push_back for particle='"
<< par << "'" << endmsg ;
}
}
//infile.close();
}
StatusCode Gaudi::ParticlePropertySvc::parse ( )
protected

Parses the file and fill all the maps.

Definition at line 300 of file ParticlePropertySvc.cpp.

{
// parse "the main" file
StatusCode sc = parse ( m_filename ) ;
if ( sc.isFailure() ) { return sc ; }
// parse "other" files
for ( Files::const_iterator file = m_other.begin() ;
m_other.end() != file ; ++file )
{
sc = parse ( *file ) ;
if ( sc.isFailure() ) { return sc ; }
}
// Now check that the file format was consistent with what parser
// expected
if ( m_namemap.size() == 0 )
{
<< "Format of input file inconsistent with what expected"
<< " - Check you are using ParticleData.txt" << endmsg;
}
return sc;
}
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 
)
virtual

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.

Implements IParticlePropertySvc.

Definition at line 184 of file ParticlePropertySvc.cpp.

{
( particle , geantId , jetsetId ,
charge , mass , tlife ,
evtName , pythiaId , maxWidth ) ;
//
m_owned.insert ( pp ) ;
//
return push_back( pp );
}
StatusCode Gaudi::ParticlePropertySvc::push_back ( ParticleProperty pp)
virtual

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.

Implements IParticlePropertySvc.

Definition at line 206 of file ParticlePropertySvc.cpp.

{
if ( 0 == pp ) { return StatusCode::FAILURE ; }
//
{ // try to add into Geant(3)ID map
const int ID = pp->geantID() ;
// is this already in the map?
MapID::const_iterator ifind = m_idmap.find( ID ) ;
if ( m_idmap.end() != ifind && 0 != m_idmap[ ID ])
{
diff ( ifind->second , pp ) ;
m_replaced.insert( m_idmap[ ID ]->particle() ) ;
}
// put it into the map
m_idmap[ ID ] = pp ;
}
//
{ // try to add into Name map
const std::string& particle = pp->particle() ;
// is this already in the map?
MapName::const_iterator ifind = m_namemap.find( particle ) ;
if ( m_namemap.end() != ifind && 0 != m_namemap[ particle ] )
{
diff ( ifind->second , pp ) ;
m_replaced.insert( m_namemap[ particle ]->particle() ) ;
}
// put it into the map
m_namemap[ particle ] = pp ;
}
//
// add to StdHep map only if StdHep ID different from zero and if
// not Cerenkov (StdHep ID = gamma)
if ( 0 != pp->jetsetID() && "Tcherenkov" != pp->particle() )
{ // try to add into StdHepID map
const int ID = pp->jetsetID() ;
// is this already in the map?
MapStdHepID::const_iterator ifind = m_stdhepidmap.find( ID ) ;
if ( m_stdhepidmap.end() != ifind && 0 != m_stdhepidmap[ ID ])
{
diff ( ifind->second , pp ) ;
m_replaced.insert( m_stdhepidmap[ ID ]->particle() ) ;
}
// put it into the map
m_stdhepidmap[ ID ] = pp ;
}
//
// add to Pythia map only if Pythia ID is different from
// zero ( StdHep id is always different from zero in this case )
if ( 0 != pp->pythiaID() &&
0 != pp->jetsetID() &&
"Tcherenkov" != pp->particle() )
{ // try to add into PythiaID map
const int ID = pp->pythiaID() ;
// is this already in the map?
MapPythiaID::const_iterator ifind = m_pythiaidmap.find( ID ) ;
if ( m_pythiaidmap.end() != ifind && 0 != m_pythiaidmap[ ID ])
{
diff ( ifind->second , pp ) ;
m_replaced.insert( m_pythiaidmap[ ID ]->particle() ) ;
}
// put it into the map
m_pythiaidmap[ ID ] = pp ;
}
//
return rebuild() ;
}
StatusCode Gaudi::ParticlePropertySvc::rebuild ( )
protected

rebuild "the linear container" from the map

Definition at line 462 of file ParticlePropertySvc.cpp.

{
Set local ;
m_vectpp.reserve ( m_idmap.size() + 100 ) ;
// load information from maps into the set
_load_ ( m_idmap , local ) ;
_load_ ( m_namemap , local ) ;
_load_ ( m_stdhepidmap , local ) ;
_load_ ( m_pythiaidmap , local ) ;
// load information from set to the linear container vector
for ( Set::iterator i = local.begin() ; local.end() != i ; ++i )
{ m_vectpp.push_back ( *i ) ; }
return setAntiParticles() ;
}
StatusCode Gaudi::ParticlePropertySvc::setAntiParticles ( )
protected

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

Returns
status code

Definition at line 436 of file ParticlePropertySvc.cpp.

{
// initialize particle<-->antiParticle relations
for ( iterator ip = m_vectpp.begin() ; m_vectpp.end() != ip ; ++ip )
{
if ( 0 == pp ) { continue ; } // CONTINUE
const ParticleProperty* ap = anti ( pp ) ;
if ( 0 != ap ) { pp->setAntiParticle( ap ) ; }
}
}
virtual int Gaudi::ParticlePropertySvc::size ( ) const
inlinevirtual

Get the container size.

Implements IParticlePropertySvc.

Definition at line 124 of file ParticlePropertySvc.h.

{ return m_vectpp.size() ; };

Member Data Documentation

IFileAccess* Gaudi::ParticlePropertySvc::m_fileAccess
private

Definition at line 201 of file ParticlePropertySvc.h.

std::string Gaudi::ParticlePropertySvc::m_filename
private

Filename of the particle properties file.

Definition at line 186 of file ParticlePropertySvc.h.

MapID Gaudi::ParticlePropertySvc::m_idmap
private

Map for geant IDs.

Definition at line 192 of file ParticlePropertySvc.h.

MapName Gaudi::ParticlePropertySvc::m_namemap
private

Map for particle names.

Definition at line 193 of file ParticlePropertySvc.h.

Files Gaudi::ParticlePropertySvc::m_other
private

additional file names

Definition at line 187 of file ParticlePropertySvc.h.

Set Gaudi::ParticlePropertySvc::m_owned
private

Definition at line 198 of file ParticlePropertySvc.h.

Particles Gaudi::ParticlePropertySvc::m_particles
private

Definition at line 189 of file ParticlePropertySvc.h.

MapPythiaID Gaudi::ParticlePropertySvc::m_pythiaidmap
private

Map for Pythia Ids.

Definition at line 195 of file ParticlePropertySvc.h.

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

Definition at line 199 of file ParticlePropertySvc.h.

MapStdHepID Gaudi::ParticlePropertySvc::m_stdhepidmap
private

Map for StdHep Ids.

Definition at line 194 of file ParticlePropertySvc.h.

VectPP Gaudi::ParticlePropertySvc::m_vectpp
private

Vector of all particle properties.

Definition at line 191 of file ParticlePropertySvc.h.


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

Generated at Thu Jul 18 2013 12:18:13 for Gaudi Framework, version v23r9 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004