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;
49 if (
System::getEnv(
"PARAMFILESROOT", m_filename.value() ) ) { m_filename.value() +=
"/data/ParticleTable.txt"; }
60 error() <<
" Could not set the properties " <<
endmsg;
66 error() <<
" Cannot retrieve the VFS service " <<
endmsg;
78 error() <<
" Could not treat particles! " <<
endmsg;
82 debug() <<
"ParticleProperties parsed successfully" <<
endmsg;
124 double mass,
double tlife,
const std::string& evtName,
int pythiaId,
127 auto i =
m_owned.
insert( std::make_unique<ParticleProperty>( particle, geantId, jetsetId, charge, mass, tlife,
128 evtName, pythiaId, maxWidth ) );
139 const int ID =
pp->geantID();
143 diff( ifind->second,
pp );
155 diff( ifind->second,
pp );
164 if ( 0 !=
pp->jetsetID() &&
"Tcherenkov" !=
pp->particle() ) {
165 const int ID =
pp->jetsetID();
169 diff( ifind->second,
pp );
178 if ( 0 !=
pp->pythiaID() && 0 !=
pp->jetsetID() &&
"Tcherenkov" !=
pp->particle() ) {
180 const int ID =
pp->pythiaID();
184 diff( ifind->second,
pp );
199 auto i =
std::find_if(
m.begin(),
m.end(), [&](
typename MAP::const_reference i ) {
return i.second ==
pp; } );
200 if ( i !=
m.end() ) {
m.erase( i ); }
232 error() <<
"Format of input file inconsistent with what expected" 233 <<
" - Check you are using ParticleData.txt" <<
endmsg;
243 error() <<
"Unable to open properties file : " << file <<
endmsg;
248 info() <<
"Opened particle properties file : " << file <<
endmsg;
256 if (
line.front() ==
'#' )
continue;
259 ba::trim_left_if(
line, ba::is_space() );
260 ba::split( tokens,
line, ba::is_space(), boost::token_compress_on );
261 if ( tokens.
size() != 9 )
continue;
266 if ( jid == 0 ) jid = 10000000 * gid;
274 error() <<
"Error from ParticlePropertySvc::push_back for particle='" << tokens[0] <<
"'" <<
endmsg;
287 if ( !
pp ) {
return nullptr; }
288 const int ID =
pp->pdgID();
289 const int antiID = -1 * ID;
291 if ( ap && antiID == ap->pdgID() ) {
return ap; }
305 if ( !
pp ) {
continue; }
307 if ( ap ) {
pp->setAntiParticle( ap ); }
316 template <
typename MAP,
typename SET>
317 void _load_( MAP&
m,
SET& result ) {
318 for (
auto i =
m.begin();
m.end() != i; ++i ) { result.insert( i->second ); }
352 if ( input >> p_name >> p_geant >> p_jetset >> p_charge >> p_mass >> p_ltime >> p_evtgen >> p_pythia >>
354 always() <<
" Add/Modify the particle: " 355 <<
" name='" << p_name <<
"'" 356 <<
" geant=" << p_geant <<
" jetset=" << p_jetset <<
" charge=" << p_charge <<
" mass=" << p_mass
357 <<
" ltime=" << p_ltime <<
" evtgen='" << p_evtgen <<
"'" 358 <<
" pythia=" << p_pythia <<
" maxwid=" << p_maxwid <<
endmsg;
364 error() <<
" could not parse '" << item <<
"'" <<
endmsg;
375 # pragma warning( push ) 376 # pragma warning( disable : 1572 ) 380 if ( o ==
n ) {
return false; }
392 log <<
" Name:'" << o->
particle() <<
"'/'" <<
n->particle() <<
"'";
394 if ( o->
geantID() !=
n->geantID() ) {
396 log <<
" G3ID:" << o->
geantID() <<
"/" <<
n->geantID() <<
"'";
398 if ( o->
pdgID() !=
n->pdgID() ) {
400 log <<
" PDGID:" << o->
pdgID() <<
"/" <<
n->pdgID() <<
"'";
404 log <<
" PYID:" << o->
pythiaID() <<
"/" <<
n->pythiaID() <<
"'";
406 if ( o->
charge() !=
n->charge() ) {
408 log <<
" Q:" << o->
charge() <<
"/" <<
n->charge() <<
"'";
410 if ( o->
mass() !=
n->mass() ) {
412 log <<
" M:" << o->
mass() <<
"/" <<
n->mass() <<
"'";
416 log <<
" T:" << o->
lifetime() <<
"/" <<
n->lifetime() <<
"'";
420 log <<
" EvtGen:" << o->
evtGenName() <<
"/" <<
n->evtGenName() <<
"'";
424 log <<
" WMAX:" << o->
maxWidth() <<
"/" <<
n->maxWidth() <<
"'";
433 # pragma warning( pop ) GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
bool diff(const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
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...
StatusCode finalize() override
This service provides access to particle properties.
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.
constexpr static const auto SUCCESS
StatusCode initialize() override
Initialise the service.
int pythiaID() const
Get the Pythia ID.
MapName m_namemap
Map for particle names.
StatusCode parse()
Parses the file and fill all the maps.
MsgStream & always() const
shortcut for the method msgStream(MSG::ALWAYS)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
SmartIF< IFileAccess > m_fileAccess
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.
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
std::set< std::string > m_replaced
double maxWidth() const
Get the max width deviation.
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID)
This class is used for returning status codes from appropriate routines.
int pdgID() const
Get the PDG (= JETSET) ID.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & msgStream() const
Return an uninitialized MsgStream.
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
const std::string & evtGenName() const
Get the EvtGen name.
T back_inserter(T... args)
Gaudi::Property< std::vector< std::string > > m_other
constexpr static const auto FAILURE
int geantID() const
Get the GEANT3 ID.
StatusCode addParticles()
std::set< std::unique_ptr< ParticleProperty > > m_owned
MapID m_idmap
Map for geant IDs.
Gaudi::Property< std::string > m_filename
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.
Gaudi::Property< std::vector< std::string > > m_particles
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
const std::string & particle() const
Get the particle name.
StatusCode setAntiParticles()
helper (protected) function to set the valid particle<-->antiparticle relations
VectPP m_vectpp
Vector of all particle properties.
double mass() const
Get the particle mass.
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...
Header file for std:chrono::duration-based Counters.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
double lifetime() const
Get the particle lifetime.
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
double charge() const
Get the particle charge.