ATLAS Offline Software
Loading...
Searching...
No Matches
Generators
GeneratorModules
src
GenData.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
GeneratorModules/GenData.h
"
6
#include "GaudiKernel/ServiceHandle.h"
7
#include "GaudiKernel/IPartPropSvc.h"
8
#include "HepPDT/ParticleData.hh"
9
#include "HepPDT/ParticleDataTable.hh"
10
#include <atomic>
11
#include <iostream>
12
#include <cmath>
13
#include <cstdlib>
14
#include <mutex>
15
GenData::GenData
():
m_service_name
(
"PartPropSvc"
),
m_name
(
"GenData"
),
m_ppSvc
(
"PartPropSvc"
,
"GenData"
) {}
16
17
GenData::GenData
(
const
std::string& sname,
const
std::string& name):
m_service_name
(sname),
m_name
(name),
m_ppSvc
(sname, name) {}
18
19
GenData::ParticleInfo
GenData::particleInfo
(
int
absPid)
const
{
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
29
ParticleInfo
info;
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
}
37
38
std::optional<double>
GenData::particleMass
(
int
pdgId)
const
{
39
return
particleInfo
(std::abs(pdgId)).
mass
;
40
}
41
42
std::optional<double>
GenData::particleLifetime
(
int
pdgId)
const
{
43
return
particleInfo
(std::abs(pdgId)).
lifetime
;
44
}
45
46
std::optional<std::string>
GenData::particleName
(
int
pdgId)
const
{
47
return
particleInfo
(std::abs(pdgId)).
name
;
48
}
GenData.h
GenData::m_name
std::string m_name
Definition
GenData.h:47
GenData::particleInfo
ParticleInfo particleInfo(int absPid) const
Definition
GenData.cxx:19
GenData::particleName
std::optional< std::string > particleName(int pdgId) const
Get the name of a particle by PDG ID.
Definition
GenData.cxx:46
GenData::GenData
GenData()
Definition
GenData.cxx:15
GenData::particleMass
std::optional< double > particleMass(int pdgId) const
Get the mass of a particle by PDG ID.
Definition
GenData.cxx:38
GenData::m_ppSvc
ServiceHandle< IPartPropSvc > m_ppSvc
Definition
GenData.h:48
GenData::particleLifetime
std::optional< double > particleLifetime(int pdgId) const
Get the lifetime of a particle by PDG ID.
Definition
GenData.cxx:42
GenData::m_service_name
std::string m_service_name
Handle on the particle property service.
Definition
GenData.h:46
GenData::m_initialized
std::atomic< bool > m_initialized
Definition
GenData.h:49
GenData::ParticleInfo
Definition
GenData.h:38
GenData::ParticleInfo::lifetime
std::optional< double > lifetime
Definition
GenData.h:40
GenData::ParticleInfo::mass
std::optional< double > mass
Definition
GenData.h:39
GenData::ParticleInfo::name
std::optional< std::string > name
Definition
GenData.h:41
Generated on
for ATLAS Offline Software by
1.16.1