2 #include "TRestGeant4PhysicsInfo.h"
10 std::mutex insertMutex;
12 set<TString> TRestGeant4PhysicsInfo::GetAllParticles()
const {
13 set<TString> particles = {};
14 for (
const auto& [_, name] : fParticleNamesMap) {
15 particles.insert(name);
20 std::set<TString> TRestGeant4PhysicsInfo::GetAllProcesses()
const {
21 set<TString> processes = {};
22 for (
const auto& [_, name] : fProcessNamesMap) {
23 processes.insert(name);
28 std::set<TString> TRestGeant4PhysicsInfo::GetAllProcessTypes()
const {
29 set<TString> types = {};
30 for (
const auto& [_, type] : fProcessTypesMap) {
36 void TRestGeant4PhysicsInfo::PrintParticles()
const {
37 const auto particleNames = GetAllParticles();
38 cout <<
"Particles:" << endl;
39 for (
const auto& name : particleNames) {
40 const auto id = GetParticleID(name);
41 cout <<
"\t" << name <<
" - " <<
id << endl;
45 void TRestGeant4PhysicsInfo::PrintProcesses()
const {
46 const auto processNames = GetAllProcesses();
47 cout <<
"Processes:" << endl;
48 for (
const auto& name : processNames) {
49 const auto id = GetProcessID(name);
50 cout <<
"\t" << name <<
" - " <<
id << endl;
54 void TRestGeant4PhysicsInfo::Print()
const {
59 void TRestGeant4PhysicsInfo::InsertProcessName(Int_t
id,
const TString& processName,
60 const TString& processType) {
61 if (fProcessNamesMap.count(
id) > 0) {
64 std::lock_guard<std::mutex> lock(insertMutex);
65 fProcessNamesMap[id] = processName;
66 fProcessNamesReverseMap[processName] = id;
68 fProcessTypesMap[processName] = processType;
71 void TRestGeant4PhysicsInfo::InsertParticleName(Int_t
id,
const TString& particleName) {
72 if (fParticleNamesMap.count(
id) > 0) {
75 std::lock_guard<std::mutex> lock(insertMutex);
76 fParticleNamesMap[id] = particleName;
77 fParticleNamesReverseMap[particleName] = id;
80 template <
typename T,
typename U>
81 U GetOrDefaultMapValueFromKey(
const map<T, U>* pMap,
const T& key) {
82 if (pMap->count(key) > 0) {
88 TString TRestGeant4PhysicsInfo::GetProcessName(Int_t
id)
const {
89 return GetOrDefaultMapValueFromKey<Int_t, TString>(&fProcessNamesMap,
id);
92 Int_t TRestGeant4PhysicsInfo::GetProcessID(
const TString& processName)
const {
93 return GetOrDefaultMapValueFromKey<TString, Int_t>(&fProcessNamesReverseMap, processName);
96 TString TRestGeant4PhysicsInfo::GetParticleName(Int_t
id)
const {
97 return GetOrDefaultMapValueFromKey<Int_t, TString>(&fParticleNamesMap,
id);
100 Int_t TRestGeant4PhysicsInfo::GetParticleID(
const TString& processName)
const {
101 return GetOrDefaultMapValueFromKey<TString, Int_t>(&fParticleNamesReverseMap, processName);
104 TString TRestGeant4PhysicsInfo::GetProcessType(
const TString& processName)
const {
105 return GetOrDefaultMapValueFromKey<TString, TString>(&fProcessTypesMap, processName);