ATLAS Offline Software
Loading...
Searching...
No Matches
GenData Class Reference

GenData is a class for particle data access. More...

#include <GenData.h>

Collaboration diagram for GenData:

Classes

struct  ParticleInfo

Public Member Functions

 GenData ()
 GenData (const std::string &sname, const std::string &name)
virtual ~GenData ()=default
std::optional< double > particleMass (int pdgId) const
 Get the mass of a particle by PDG ID.
std::optional< double > particleLifetime (int pdgId) const
 Get the lifetime of a particle by PDG ID.
std::optional< std::string > particleName (int pdgId) const
 Get the name of a particle by PDG ID.

Private Member Functions

ParticleInfo particleInfo (int absPid) const

Private Attributes

std::string m_service_name {"PartPropSvc"}
 Handle on the particle property service.
std::string m_name {"GenData"}
ServiceHandle< IPartPropSvc > m_ppSvc
std::atomic< bool > m_initialized {false}

Detailed Description

GenData is a class for particle data access.

Definition at line 18 of file GenData.h.

Constructor & Destructor Documentation

◆ GenData() [1/2]

GenData::GenData ( )

Definition at line 15 of file GenData.cxx.

15: m_service_name("PartPropSvc"), m_name("GenData"), m_ppSvc("PartPropSvc", "GenData") {}
std::string m_name
Definition GenData.h:47
ServiceHandle< IPartPropSvc > m_ppSvc
Definition GenData.h:48
std::string m_service_name
Handle on the particle property service.
Definition GenData.h:46

◆ GenData() [2/2]

GenData::GenData ( const std::string & sname,
const std::string & name )

Definition at line 17 of file GenData.cxx.

17: m_service_name(sname), m_name(name), m_ppSvc(sname, name) {}

◆ ~GenData()

virtual GenData::~GenData ( )
virtualdefault

Member Function Documentation

◆ particleInfo()

GenData::ParticleInfo GenData::particleInfo ( int absPid) const
private

Definition at line 19 of file GenData.cxx.

19 {
20
21 if (!m_initialized) {
22 if (m_ppSvc.retrieve().isFailure()) {
23 std::cerr << "GenData: failed to retrieve IPartPropSvc(" << m_service_name << ", " << m_name << ")\n";
24 std::abort();
25 }
26 m_initialized = true;
27 }
28
30 if (const HepPDT::ParticleData* particle = m_ppSvc->PDT()->particle(HepPDT::ParticleID(absPid))) {
31 info.mass = particle->mass().value();
32 info.lifetime = particle->lifetime();
33 info.name = particle->name();
34 }
35 return info;
36}
std::atomic< bool > m_initialized
Definition GenData.h:49
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses

◆ particleLifetime()

std::optional< double > GenData::particleLifetime ( int pdgId) const

Get the lifetime of a particle by PDG ID.

Definition at line 42 of file GenData.cxx.

42 {
43 return particleInfo(std::abs(pdgId)).lifetime;
44}
ParticleInfo particleInfo(int absPid) const
Definition GenData.cxx:19
std::optional< double > lifetime
Definition GenData.h:40

◆ particleMass()

std::optional< double > GenData::particleMass ( int pdgId) const

Get the mass of a particle by PDG ID.

Definition at line 38 of file GenData.cxx.

38 {
39 return particleInfo(std::abs(pdgId)).mass;
40}
std::optional< double > mass
Definition GenData.h:39

◆ particleName()

std::optional< std::string > GenData::particleName ( int pdgId) const

Get the name of a particle by PDG ID.

Definition at line 46 of file GenData.cxx.

46 {
47 return particleInfo(std::abs(pdgId)).name;
48}
std::optional< std::string > name
Definition GenData.h:41

Member Data Documentation

◆ m_initialized

std::atomic<bool> GenData::m_initialized {false}
mutableprivate

Definition at line 49 of file GenData.h.

49{false};

◆ m_name

std::string GenData::m_name {"GenData"}
private

Definition at line 47 of file GenData.h.

47{"GenData"};

◆ m_ppSvc

ServiceHandle<IPartPropSvc> GenData::m_ppSvc
private

Definition at line 48 of file GenData.h.

◆ m_service_name

std::string GenData::m_service_name {"PartPropSvc"}
private

Handle on the particle property service.

Definition at line 46 of file GenData.h.

46{"PartPropSvc"};

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