Geant4 VMC
Version 6.8
Toggle main menu visibility
Loading...
Searching...
No Matches
source
global
src
TG4ProcessMap.cxx
Go to the documentation of this file.
1
//------------------------------------------------
2
// The Geant4 Virtual Monte Carlo package
3
// Copyright (C) 2007 - 2022 Ivana Hrivnacova
4
// All rights reserved.
5
//
6
// For the licensing terms see geant4_vmc/LICENSE.
7
// Contact: root-vmc@cern.ch
8
//-------------------------------------------------
9
14
15
#include "
TG4ProcessMap.h
"
16
#include "
TG4G3PhysicsManager.h
"
17
#include "
TG4Globals.h
"
18
19
#include <G4VProcess.hh>
20
21
#include <iomanip>
22
23
TG4ProcessMap
*
TG4ProcessMap::fgInstance
= 0;
24
25
//_____________________________________________________________________________
26
TG4ProcessMap::TG4ProcessMap
() :
fMap
()
27
{
29
30
if
(
fgInstance
) {
31
TG4Globals::Exception
(
"TG4ProcessMap"
,
"TG4ProcessMap"
,
32
"Cannot create two instances of singleton."
);
33
}
34
35
fgInstance
=
this
;
36
}
37
38
//_____________________________________________________________________________
39
TG4ProcessMap::~TG4ProcessMap
()
40
{
42
43
fgInstance
= 0;
44
}
45
46
//
47
// private methods
48
//
49
50
//_____________________________________________________________________________
51
G4bool
TG4ProcessMap::IsDefined
(G4int subType)
52
{
54
55
if
(
fMap
.find(subType) ==
fMap
.end())
56
return
false
;
57
else
58
return
true
;
59
}
60
61
//
62
// public methods
63
//
64
65
//_____________________________________________________________________________
66
G4bool
TG4ProcessMap::Add
(
67
G4int subType, TMCProcess mcProcess,
TG4G3Control
g3Control)
68
{
70
71
if
(!
IsDefined
(subType)) {
72
// insert into map
73
// only in case it is not yet here
74
fMap
[subType] = std::pair(mcProcess, g3Control);
75
return
true
;
76
}
77
return
false
;
78
}
79
80
//_____________________________________________________________________________
81
void
TG4ProcessMap::PrintAll
()
const
82
{
84
85
if
(
fMap
.empty())
return
;
86
87
G4cout <<
"Dump of TG4ProcessMap - "
<<
fMap
.size()
88
<<
" entries:"
<< G4endl;
89
G4int counter = 0;
90
for
(
auto
[subType, codes] :
fMap
) {
91
// TO DO: get process sub-type name
92
G4cout <<
"Map element "
<< std::setw(3) << counter++ <<
" "
93
<< subType <<
" "
<< TMCProcessName[codes.first] <<
" "
94
<<
TG4G3ControlVector::GetControlName
(codes.second) << G4endl;
95
}
96
}
97
98
//_____________________________________________________________________________
99
void
TG4ProcessMap::Clear
()
100
{
102
103
fMap
.clear();
104
}
105
106
//_____________________________________________________________________________
107
std::pair<TMCProcess, TG4G3Control>
108
TG4ProcessMap::GetCodes
(
const
G4VProcess
* process)
const
109
{
112
113
if
(!process)
return
{ kPNoProcess,
kNoG3Controls
};
114
115
auto
i =
fMap
.find(process->GetProcessSubType());
116
if
(i ==
fMap
.end()) {
117
G4String text =
"Unknown process code for "
;
118
text += process->GetProcessName();
119
TG4Globals::Warning
(
"TG4ProcessMap"
,
"GetCodes"
, text);
120
return
{ kPNoProcess,
kNoG3Controls
};
121
}
122
else
{
123
return
(*i).second;
124
}
125
}
126
127
128
//_____________________________________________________________________________
129
TMCProcess
TG4ProcessMap::GetMCProcess
(
const
G4VProcess
* process)
const
130
{
132
133
return
GetCodes
(process).first;
134
}
135
136
//_____________________________________________________________________________
137
TG4G3Control
TG4ProcessMap::GetControl
(
const
G4VProcess
* process)
const
138
{
140
141
return
GetCodes
(process).second;
142
}
143
144
//_____________________________________________________________________________
145
G4String
TG4ProcessMap::GetMCProcessName
(
const
G4VProcess
* process)
const
146
{
148
149
if
(!process)
return
TMCProcessName[kPNoProcess];
150
151
return
TMCProcessName[
GetMCProcess
(process)];
152
}
153
154
//_____________________________________________________________________________
155
G4String
TG4ProcessMap::GetControlName
(
const
G4VProcess
* process)
const
156
{
158
159
if
(!process)
return
TG4G3ControlVector::GetControlName
(
kNoG3Controls
);
160
161
return
TG4G3ControlVector::GetControlName
(
GetControl
(process));
162
}
163
TG4G3PhysicsManager.h
Definition of the TG4G3PhysicsManager class.
TG4Globals.h
Definition of the TG4Globals class and basic container types.
TG4ProcessMap.h
Definition of the TG4ProcessMap class.
G4VProcess
TG4G3ControlVector::GetControlName
static const G4String & GetControlName(TG4G3Control control)
Definition
TG4G3ControlVector.cxx:170
TG4Globals::Warning
static void Warning(const TString &className, const TString &methodName, const TString &text)
Definition
TG4Globals.cxx:48
TG4Globals::Exception
static void Exception(const TString &className, const TString &methodName, const TString &text)
Definition
TG4Globals.cxx:33
TG4ProcessMap
Maps G4 process sub types to TMCProcess and TG4G3Control codes.
Definition
TG4ProcessMap.h:37
TG4ProcessMap::GetControl
TG4G3Control GetControl(const G4VProcess *process) const
Definition
TG4ProcessMap.cxx:137
TG4ProcessMap::PrintAll
void PrintAll() const
Definition
TG4ProcessMap.cxx:81
TG4ProcessMap::GetCodes
std::pair< TMCProcess, TG4G3Control > GetCodes(const G4VProcess *process) const
Definition
TG4ProcessMap.cxx:108
TG4ProcessMap::fMap
std::map< G4int, std::pair< TMCProcess, TG4G3Control > > fMap
map container
Definition
TG4ProcessMap.h:67
TG4ProcessMap::GetMCProcess
TMCProcess GetMCProcess(const G4VProcess *process) const
Definition
TG4ProcessMap.cxx:129
TG4ProcessMap::~TG4ProcessMap
~TG4ProcessMap()
Definition
TG4ProcessMap.cxx:39
TG4ProcessMap::TG4ProcessMap
TG4ProcessMap()
Definition
TG4ProcessMap.cxx:26
TG4ProcessMap::GetMCProcessName
G4String GetMCProcessName(const G4VProcess *process) const
Definition
TG4ProcessMap.cxx:145
TG4ProcessMap::Add
G4bool Add(G4int subType, TMCProcess mcProcess, TG4G3Control g3Control)
Definition
TG4ProcessMap.cxx:66
TG4ProcessMap::GetControlName
G4String GetControlName(const G4VProcess *process) const
Definition
TG4ProcessMap.cxx:155
TG4ProcessMap::IsDefined
G4bool IsDefined(G4int subType)
Definition
TG4ProcessMap.cxx:51
TG4ProcessMap::Clear
void Clear()
Definition
TG4ProcessMap.cxx:99
TG4ProcessMap::fgInstance
static TG4ProcessMap * fgInstance
this instance
Definition
TG4ProcessMap.h:64
TG4G3Control
TG4G3Control
Enumeration for G3 types of physics processes controls.
Definition
TG4G3Control.h:29
kNoG3Controls
@ kNoG3Controls
No process control.
Definition
TG4G3Control.h:157
Generated on
for Geant4 VMC by
1.17.0