2#include "TRestGeant4PhysicsInfo.h"
10set<TString> TRestGeant4PhysicsInfo::GetAllParticles()
const {
11 set<TString> particles = {};
12 for (
const auto& [_, name] : fParticleNamesMap) {
13 particles.insert(name);
18std::set<TString> TRestGeant4PhysicsInfo::GetAllProcesses()
const {
19 set<TString> processes = {};
20 for (
const auto& [_, name] : fProcessNamesMap) {
21 processes.insert(name);
26std::set<TString> TRestGeant4PhysicsInfo::GetAllProcessTypes()
const {
27 set<TString> types = {};
28 for (
const auto& [_, type] : fProcessTypesMap) {
34void TRestGeant4PhysicsInfo::PrintParticles()
const {
35 const auto particleNames = GetAllParticles();
36 cout <<
"Particles:" << endl;
37 for (
const auto& name : particleNames) {
38 const auto id = GetParticleID(name);
39 cout <<
"\t" << name <<
" - " <<
id << endl;
43void TRestGeant4PhysicsInfo::PrintProcesses()
const {
44 const auto processNames = GetAllProcesses();
45 cout <<
"Processes:" << endl;
46 for (
const auto& name : processNames) {
47 const auto id = GetProcessID(name);
48 cout <<
"\t" << name <<
" - " <<
id << endl;
52void TRestGeant4PhysicsInfo::Print()
const {
57void TRestGeant4PhysicsInfo::InsertProcessName(Int_t
id,
const TString& processName,
58 const TString& processType) {
59 if (fProcessNamesMap.count(
id) > 0) {
62 std::lock_guard<std::mutex> lock(fMutex);
63 fProcessNamesMap[id] = processName;
64 fProcessNamesReverseMap[processName] = id;
66 fProcessTypesMap[processName] = processType;
69void TRestGeant4PhysicsInfo::InsertParticleName(Int_t
id,
const TString& particleName) {
70 if (fParticleNamesMap.count(
id) > 0) {
73 std::lock_guard<std::mutex> lock(fMutex);
74 fParticleNamesMap[id] = particleName;
75 fParticleNamesReverseMap[particleName] = id;
78template <
typename T,
typename U>
79U GetOrDefaultMapValueFromKey(
const map<T, U>* pMap,
const T& key) {
80 if (pMap->count(key) > 0) {
86TString TRestGeant4PhysicsInfo::GetProcessName(Int_t
id)
const {
87 return GetOrDefaultMapValueFromKey<Int_t, TString>(&fProcessNamesMap,
id);
90Int_t TRestGeant4PhysicsInfo::GetProcessID(
const TString& processName)
const {
91 return GetOrDefaultMapValueFromKey<TString, Int_t>(&fProcessNamesReverseMap, processName);
94TString TRestGeant4PhysicsInfo::GetParticleName(Int_t
id)
const {
95 return GetOrDefaultMapValueFromKey<Int_t, TString>(&fParticleNamesMap,
id);
98Int_t TRestGeant4PhysicsInfo::GetParticleID(
const TString& processName)
const {
99 return GetOrDefaultMapValueFromKey<TString, Int_t>(&fParticleNamesReverseMap, processName);
102TString TRestGeant4PhysicsInfo::GetProcessType(
const TString& processName)
const {
103 return GetOrDefaultMapValueFromKey<TString, TString>(&fProcessTypesMap, processName);