6 #include "boost/algorithm/string/classification.hpp" 7 #include "boost/algorithm/string/split.hpp" 8 #include "boost/algorithm/string/trim.hpp" 11 namespace ba = boost::algorithm;
31 template <
typename T,
class... Args>
61 m_filename.value() +=
"/data/ParticleTable.txt";
76 error() <<
" Could not set the properties " <<
endmsg;
82 error() <<
" Cannot retrieve the VFS service " <<
endmsg;
94 error() <<
" Could not treat particles! " <<
endmsg;
98 debug() <<
"ParticleProperties parsed successfully" <<
endmsg;
141 double mass,
double tlife,
const std::string& evtName,
int pythiaId,
145 auto i =
m_owned.
insert( make_unique_<ParticleProperty>( particle, geantId, jetsetId, charge, mass, tlife, evtName,
146 pythiaId, maxWidth ) );
164 diff( ifind->second, pp );
176 diff( ifind->second, pp );
190 diff( ifind->second, pp );
205 diff( ifind->second, pp );
222 auto i =
std::find_if( m.begin(), m.end(), [&](
typename MAP::const_reference i ) {
return i.second ==
pp; } );
223 if ( i != m.end() ) {
265 error() <<
"Format of input file inconsistent with what expected" 266 <<
" - Check you are using ParticleData.txt" <<
endmsg;
277 error() <<
"Unable to open properties file : " << file <<
endmsg;
282 info() <<
"Opened particle properties file : " << file <<
endmsg;
290 if ( line.
front() ==
'#' )
continue;
293 ba::trim_left_if( line, ba::is_space() );
294 ba::split( tokens, line, ba::is_space(), boost::token_compress_on );
295 if ( tokens.
size() != 9 )
continue;
300 if ( jid == 0 ) jid = 10000000 * gid;
305 std::stod( tokens[8] ) * Gaudi::Units::GeV );
308 error() <<
"Error from ParticlePropertySvc::push_back for particle='" << tokens[0] <<
"'" <<
endmsg;
325 const int ID = pp->
pdgID();
326 const int antiID = -1 * ID;
328 if ( ap && antiID == ap->pdgID() ) {
350 pp->setAntiParticle( ap );
361 template <
typename MAP,
typename SET>
362 void _load_( MAP&
m,
SET& result )
364 for (
auto i = m.begin(); m.end() != i; ++i ) {
365 result.insert( i->second );
402 if ( input >> p_name >> p_geant >> p_jetset >> p_charge >> p_mass >> p_ltime >> p_evtgen >> p_pythia >>
404 always() <<
" Add/Modify the particle: " 405 <<
" name='" << p_name <<
"'" 406 <<
" geant=" << p_geant <<
" jetset=" << p_jetset <<
" charge=" << p_charge <<
" mass=" << p_mass
407 <<
" ltime=" << p_ltime <<
" evtgen='" << p_evtgen <<
"'" 408 <<
" pythia=" << p_pythia <<
" maxwid=" << p_maxwid <<
endmsg;
411 p_ltime *
Gaudi::Units::s, p_evtgen, p_pythia, p_maxwid * Gaudi::Units::GeV );
416 error() <<
" could not parse '" << item <<
"'" <<
endmsg;
427 #pragma warning( push ) 428 #pragma warning( disable : 1572 ) 467 log <<
" M:" << o->
mass() <<
"/" << n->
mass() <<
"'";
490 #pragma warning( pop ) int pdgID() const
Get the PDG (= JETSET) ID.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
StatusCode rebuild()
rebuild "the linear container" from the map
StatusCode initialize() override
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
int geantID() const
Get the GEANT3 ID.
StatusCode finalize() override
This service provides access to particle properties.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
double maxWidth() const
Get the max width deviation.
A trivial class to hold information about a single particle properties.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
StatusCode erase(int geantId) override
Erase a property by geant3 id.
StatusCode finalize() override
Finalise the service.
StatusCode initialize() override
Initialise the service.
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.
#define DECLARE_COMPONENT(type)
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.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::set< std::string > m_replaced
int jetsetID() const
Get the JETSET(StdHep) ID.
This class is used for returning status codes from appropriate routines.
double lifetime() const
Get the particle lifetime.
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID) ...
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
bool diff(const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
T back_inserter(T...args)
Gaudi::Property< std::vector< std::string > > m_other
double charge() const
Get the particle charge.
MsgStream & msgStream() const
Return an uninitialized MsgStream.
StatusCode addParticles()
std::set< std::unique_ptr< ParticleProperty > > m_owned
MapID m_idmap
Map for geant IDs.
Gaudi::Property< std::string > m_filename
Gaudi::Property< std::vector< std::string > > m_particles
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
StatusCode setAntiParticles()
helper (protected) function to set the valid particle<–>antiparticle relations
VectPP m_vectpp
Vector of all particle properties.
const std::string & particle() const
Get the particle name.
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
double mass() const
Get the particle mass.
int pythiaID() const
Get the Pythia ID.
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...
Helper functions to set/get the application return code.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
const std::string & evtGenName() const
Get the EvtGen name.