Go to the documentation of this file.
11 #include "boost/algorithm/string/classification.hpp"
12 #include "boost/algorithm/string/split.hpp"
13 #include "boost/algorithm/string/trim.hpp"
16 namespace ba = boost::algorithm;
29 constexpr
bool essentiallyEqual(
double const a,
double const b ) {
55 if (
System::getEnv(
"PARAMFILESROOT", m_filename.value() ) ) { m_filename.value() +=
"/data/ParticleTable.txt"; }
66 error() <<
" Cannot retrieve the VFS service " <<
endmsg;
72 error() <<
" Could not parse the file " <<
endmsg;
78 error() <<
" Could not treat particles! " <<
endmsg;
82 debug() <<
"ParticleProperties parsed successfully" <<
endmsg;
84 debug() <<
"Access properties" <<
endmsg;
96 info() <<
"Properties have been redefined for " <<
m_replaced.
size()
111 always() <<
"Properties have been redefined for " <<
m_replaced.
size()
124 double mass,
double tlife,
const std::string& evtName,
int pythiaId,
127 auto&
pp =
m_owned.
emplace_back( particle, geantId, jetsetId, charge, mass, tlife, evtName, pythiaId, maxWidth );
137 const int ID =
pp->geantID();
141 diff( ifind->second,
pp );
153 diff( ifind->second,
pp );
162 if ( 0 !=
pp->jetsetID() &&
"Tcherenkov" !=
pp->particle() ) {
163 const int ID =
pp->jetsetID();
167 diff( ifind->second,
pp );
176 if ( 0 !=
pp->pythiaID() && 0 !=
pp->jetsetID() &&
"Tcherenkov" !=
pp->particle() ) {
178 const int ID =
pp->pythiaID();
182 diff( ifind->second,
pp );
197 auto i =
std::find_if(
m.begin(),
m.end(), [&](
typename MAP::const_reference i ) { return i.second == pp; } );
198 if ( i !=
m.end() ) {
m.erase( i ); }
230 error() <<
"Format of input file inconsistent with what expected"
231 <<
" - Check you are using ParticleData.txt" <<
endmsg;
241 error() <<
"Unable to open properties file : " << file <<
endmsg;
246 info() <<
"Opened particle properties file : " << file <<
endmsg;
254 if (
line.front() ==
'#' )
continue;
257 ba::trim_left_if(
line, ba::is_space() );
258 ba::split( tokens,
line, ba::is_space(), boost::token_compress_on );
259 if ( tokens.
size() != 9 )
continue;
264 if ( jid == 0 ) jid = 10000000 * gid;
272 error() <<
"Error from ParticlePropertySvc::push_back for particle='" << tokens[0] <<
"'" <<
endmsg;
285 if ( !
pp ) {
return nullptr; }
286 const int ID =
pp->pdgID();
287 const int antiID = -1 * ID;
289 if ( ap && antiID == ap->pdgID() ) {
return ap; }
303 if ( !
pp ) {
continue; }
305 if ( ap ) {
pp->setAntiParticle( ap ); }
314 template <
typename MAP,
typename SET>
315 void _load_( MAP&
m,
SET& result ) {
316 for (
auto i =
m.begin();
m.end() != i; ++i ) { result.insert( i->second ); }
350 if ( input >> p_name >> p_geant >> p_jetset >> p_charge >> p_mass >> p_ltime >> p_evtgen >> p_pythia >>
352 always() <<
" Add/Modify the particle: "
353 <<
" name='" << p_name <<
"'"
354 <<
" geant=" << p_geant <<
" jetset=" << p_jetset <<
" charge=" << p_charge <<
" mass=" << p_mass
355 <<
" ltime=" << p_ltime <<
" evtgen='" << p_evtgen <<
"'"
356 <<
" pythia=" << p_pythia <<
" maxwid=" << p_maxwid <<
endmsg;
362 error() <<
" could not parse '" << item <<
"'" <<
endmsg;
372 if ( o ==
n ) {
return false; }
374 auto&
log = msgStream();
384 log <<
" Name:'" << o->
particle() <<
"'/'" <<
n->particle() <<
"'";
386 if ( o->
geantID() !=
n->geantID() ) {
388 log <<
" G3ID:" << o->
geantID() <<
"/" <<
n->geantID() <<
"'";
390 if ( o->
pdgID() !=
n->pdgID() ) {
392 log <<
" PDGID:" << o->
pdgID() <<
"/" <<
n->pdgID() <<
"'";
396 log <<
" PYID:" << o->
pythiaID() <<
"/" <<
n->pythiaID() <<
"'";
398 if ( essentiallyEqual( o->
charge(),
n->charge() ) ) {
400 log <<
" Q:" << o->
charge() <<
"/" <<
n->charge() <<
"'";
402 if ( essentiallyEqual( o->
mass(),
n->mass() ) ) {
404 log <<
" M:" << o->
mass() <<
"/" <<
n->mass() <<
"'";
406 if ( essentiallyEqual( o->
lifetime(),
n->lifetime() ) ) {
408 log <<
" T:" << o->
lifetime() <<
"/" <<
n->lifetime() <<
"'";
412 log <<
" EvtGen:" << o->
evtGenName() <<
"/" <<
n->evtGenName() <<
"'";
414 if ( essentiallyEqual( o->
maxWidth(),
n->maxWidth() ) ) {
416 log <<
" WMAX:" << o->
maxWidth() <<
"/" <<
n->maxWidth() <<
"'";
double charge() const
Get the particle charge.
StatusCode initialize() override
StatusCode setAntiParticles()
helper (protected) function to set the valid particle<-->antiparticle relations
SmartIF< IFileAccess > m_fileAccess
MapID m_idmap
Map for geant IDs.
MapStdHepID m_stdhepidmap
Map for StdHep Ids.
StatusCode erase(int geantId) override
Erase a property by geant3 id.
const std::string & evtGenName() const
Get the EvtGen name.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
StatusCode parse()
Parses the file and fill all the maps.
T back_inserter(T... args)
MapName m_namemap
Map for particle names.
Gaudi::Property< std::string > m_filename
int pythiaID() const
Get the Pythia ID.
StatusCode finalize() override
Finalise the service.
StatusCode finalize() override
const std::string & particle() const
Get the particle name.
MapPythiaID m_pythiaidmap
Map for Pythia Ids.
const ParticleProperty * anti(const ParticleProperty *pp) const
helper (protected) function to find an antiparticle for the given particle ID (StdHepID)
StatusCode rebuild()
rebuild "the linear container" from the map
int pdgID() const
Get the PDG (= JETSET) ID.
bool diff(const ParticleProperty *o, const ParticleProperty *n, const MSG::Level l=MSG::DEBUG) const
double mass() const
Get the particle mass.
Gaudi::Property< std::vector< std::string > > m_particles
double maxWidth() const
Get the max width deviation.
double lifetime() const
Get the particle lifetime.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Header file for std:chrono::duration-based Counters.
int geantID() const
Get the GEANT3 ID.
StatusCode addParticles()
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.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
std::deque< ParticleProperty > m_owned
T emplace_back(T... args)
Gaudi::Property< std::vector< std::string > > m_other
constexpr static const auto SUCCESS
#define DECLARE_COMPONENT(type)
StatusCode initialize() override
Initialise the service.
std::set< std::string > m_replaced
VectPP m_vectpp
Vector of all particle properties.
constexpr static const auto FAILURE
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.