Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4ProcessMapPhysics.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
16#include "TG4Globals.h"
17#include "TG4ProcessMap.h"
18#include "TG4StackPopper.h"
19
20#include <TVirtualMC.h>
21#include <TVirtualMCDecayer.h>
22
23#include <G4ParticleDefinition.hh>
24#include <G4ProcessManager.hh>
25#include <G4Version.hh>
26
27// G4 process code headers
28#include <G4DecayProcessType.hh>
29#include <G4EmProcessSubType.hh>
30#include <G4FastSimulationProcessType.hh>
31#include <G4HadronicProcessType.hh>
32#include <G4OpProcessSubType.hh>
33#include <G4ProcessType.hh>
34#include <G4TransportationProcessType.hh>
35
36#include <set>
37#include <map>
38
39//_____________________________________________________________________________
42{
44
45 FillMap();
46}
47
48//_____________________________________________________________________________
50 const G4String& name)
51 : TG4VPhysicsConstructor(name, theVerboseLevel)
52{
54
55 FillMap();
56}
57
58//_____________________________________________________________________________
63
64//
65// private methods
66//
67
68//_____________________________________________________________________________
70{
72
74
75 // clang-format off
76 // G4EmProcessSubType: 1 - 26; 40; 49
77 pMap->Add(fCoulombScattering, kPCoulombScattering, kMULS); // G4 value: 1
78 pMap->Add(fIonisation, kPEnergyLoss, kG3LOSS); // G4 value: 2
79 pMap->Add(fBremsstrahlung, kPBrem, kBREM ); // G4 value: 3
80 pMap->Add(fPairProdByCharged, kPPair, kPAIR); // G4 value: 4
81 pMap->Add(fAnnihilation, kPAnnihilation, kANNI); // G4 value: 5
82 pMap->Add(fAnnihilationToMuMu, kPAnnihilation, kANNI); // G4 value: 6
83 // Add code
84 pMap->Add(fAnnihilationToHadrons, kPAnnihilation, kANNI); // G4 value: 7
85 // Add code
86 pMap->Add(fNuclearStopping, kPCoulombScattering, kMULS); // G4 value: 8
87 // CHECK ??
88 pMap->Add(fElectronGeneralProcess, kPNull, kNoG3Controls); // G4 value: 9
89
90 pMap->Add(fMultipleScattering, kPMultipleScattering, kMULS); // G4 value: 10
91
92 pMap->Add(fRayleigh, kPRayleigh, kRAYL); // G4 value: 11
93 pMap->Add(fPhotoElectricEffect, kPPhotoelectric, kPHOT); // G4 value: 12
94 pMap->Add(fComptonScattering, kPCompton, kCOMP); // G4 value: 13
95 pMap->Add(fGammaConversion, kPPair, kPAIR); // G4 value: 14
96 pMap->Add(fGammaConversionToMuMu, kPPair, kPAIR); // G4 value: 15
97 // Add code
98 pMap->Add(fGammaGeneralProcess, kPNull, kNoG3Controls); // G4 value: 16
99 pMap->Add(fPositronGeneralProcess, kPNull, kNoG3Controls); // G4 value: 17
100 pMap->Add(fAnnihilationToTauTau, kPAnnihilation, kANNI); // G4 value: 18
101 // Add code
102
103 pMap->Add(fCerenkov, kPCerenkov, kCKOV); // G4 value: 21
104 pMap->Add(fScintillation, kPScintillation, kNoG3Controls); // G4 value: 22
105 pMap->Add(fSynchrotronRadiation, kPSynchrotron, kSYNC); // G4 value: 23
106 pMap->Add(fTransitionRadiation, kPTransitionRadiation, kNoG3Controls); // G4 value: 24
107
108 pMap->Add(fSurfaceReflection, kPNull, kNoG3Controls); // G4 value: 25
109 // low energy G4MicroElecSurface process
110 pMap->Add(fGammaReflection, kPNull, kNoG3Controls); // G4 value: 26
111
112 // G4OpProcessSubType: 31 - 36
113 pMap->Add(fOpAbsorption, kPLightAbsorption, kLABS); // G4 value: 31
114 pMap->Add(fOpBoundary, kPLightScattering, kLABS); // G4 value: 32
115 pMap->Add(fOpRayleigh, kPRayleigh, kRAYL); // G4 value: 33
116 pMap->Add(fOpWLS, kPLightWLShifting, kNoG3Controls); // G4 value: 34
117 pMap->Add(fOpMieHG, kPLightScattering, kNoG3Controls); // G4 value: 35
118 // Add code
119 pMap->Add(fOpWLS2, kPLightWLShifting, kNoG3Controls); // G4 value: 36
120 // Add code
121
122 // G4EmProcessSubType: 40; 49
123 pMap->Add(fDarkBremsstrahlung, kPNull, kNoG3Controls); // G4 value: 40
124 pMap->Add(fMuonPairProdByCharged, kPNull, kNoG3Controls); // G4 value: 49
125
126 // G4HadronicProcessType: 111 - 161; 210; 310
127 pMap->Add(fHadronElastic, kPHElastic, kHADR); // G4 value: 111
128 pMap->Add(fNeutronGeneral, kPNull, kNoG3Controls); // G4 value: 116
129 pMap->Add(fHadronInelastic, kPHInhelastic, kHADR); // G4 value: 121
130 pMap->Add(fCapture, kPNCapture, kHADR); // G4 value: 131
131 pMap->Add(fMuAtomicCapture, kPHadronic, kHADR); // G4 value: 132
132 // Add code
133 // was: kPNCapture, kHADR
134 pMap->Add(fFission, kPNuclearFission, kHADR); // G4 value: 141
135 pMap->Add(fHadronAtRest, kPHadronic, kHADR); // G4 value: 151
136 // Add code - G4HadronStoppingProcess, "hadronCaptureAtRest"
137 // was: kPNCapture, kHADR
138 pMap->Add(fLeptonAtRest, kPHadronic, kHADR); // G4 value: 152
139 // No process defined with this code
140 pMap->Add(fChargeExchange, kPHadronic, kHADR); // G4 value: 161
141 pMap->Add(fNuOscillation, kPHadronic, kHADR); // G4 value: 165
142 pMap->Add(fNuElectron, kPHadronic, kHADR); // G4 value: 166
143 pMap->Add(fNuNucleus, kPHadronic, kHADR); // G4 value: 167
144 pMap->Add(fRadioactiveDecay, kPDecay, kDCAY); // G4 value: 210
145 pMap->Add(fEMDissociation, kPHadronic, kHADR); // G4 value: 310
146 // No process defined with this code
147
148 // TG4HadronicProcessType: 171 - 174
149 pMap->Add(fElectronNuclear, kPElectronNuclear, kHADR); // TG4 value: 171
150 pMap->Add(fPositronNuclear, kPPositronNuclear, kHADR); // TG4 value: 172
151 pMap->Add(fMuonNuclear, kPMuonNuclear, kMUNU); // TG4 value: 173
152 pMap->Add(fPhotoNuclear, kPPhotoNuclear, kPFIS); // TG4 value: 174
153
154 // G4DecayProcessType: 201 - 231
155 pMap->Add(DECAY, kPDecay, kDCAY); // G4 value: 201
156 pMap->Add(DECAY_WithSpin, kPDecay, kDCAY); // G4 value: 202
157 pMap->Add(DECAY_PionMakeSpin, kPDecay, kDCAY); // G4 value: 203
158 // DECAY_Radioactive ( G4 value: 210) - already added with G4HadronicProcessType
159 pMap->Add(DECAY_Unknown, kPDecay, kDCAY); // G4 value: 211
160 pMap->Add(DECAY_MuAtom, kPDecay, kDCAY); // G4 value: 221
161 pMap->Add(DECAY_External, kPDecay, kDCAY); // G4 value: 231
162
163 // G4TransportationProcessType: 91, 92
164 pMap->Add(TRANSPORTATION, kPTransportation, kNoG3Controls); // G4 value: 91
165 pMap->Add(COUPLED_TRANSPORTATION, kPTransportation, kNoG3Controls); // G4 value: 92
166
167 // G4FastSimulationProcessType: 301
168 pMap->Add(FASTSIM_ManagerProcess, kPNull, kNoG3Controls); // G4 value: 301
169
170 // G4TransportationProcessType: 401 - 491
171 // following processes belong to 'General' type
172 pMap->Add(STEP_LIMITER, kStepMax, kNoG3Controls); // G4 value: 401
173 pMap->Add(USER_SPECIAL_CUTS, kPStop, kNoG3Controls); // G4 value: 402
174 pMap->Add(NEUTRON_KILLER, kPStop, kNoG3Controls); // G4 value: 403
175 // was kPHadronic, kHADR
176 pMap->Add(PARALLEL_WORLD_PROCESS, kPNull, kNoG3Controls); // G4 value: 491
177
178 // TG4BiasingProcessType: 501
179 pMap->Add(fBiasing, kPNull, kNoG3Controls); // TG4 value: 501
180
181 // TG4StackPopperProcessType: 601
182 pMap->Add(fStackPopper, kPNull, kNoG3Controls); // TG4 value: 601
183}
184
185//_____________________________________________________________________________
187{
190
191
192 auto processName = process->GetProcessName();
193
194 if (! G4StrUtil::contains(processName, "Nuclear")) return;
195
196 std::set<std::pair<G4String, G4int>> newCodes =
197 {{ "electron", fElectronNuclear },
198 { "positron", fPositronNuclear },
199 { "muon", fMuonNuclear },
200 { "mu-", fMuonNuclear },
201 { "photon", fPhotoNuclear }};
202
203 for ( auto newCode : newCodes) {
204 if ( G4StrUtil::contains(processName, newCode.first)) {
205 process->SetProcessSubType(newCode.second);
206 return;
207 }
208 }
209}
210
211//_____________________________________________________________________________
213{
215
216 // Do nothing if process has defined sub type
217 if (process->GetProcessSubType() > 0) return false;
218
219 auto processName = process->GetProcessName();
220
221 if (G4StrUtil::contains(processName, "biasLimiter")) {
222 process->SetProcessSubType(STEP_LIMITER);
223 return false;
224 }
225
226 if (G4StrUtil::contains(processName, "biasWrapper")) {
227 // do not update sub type and skip this process evaluation
228 return true;
229 }
230
231 return false;
232}
233
234//
235// protected methods
236//
237
238//_____________________________________________________________________________
243
244//_____________________________________________________________________________
246{
249
250 if (VerboseLevel() > 1) {
251 G4cout << "TG4ProcessMapPhysics::ConstructProcess: " << G4endl;
252 }
253
254 auto pMap = TG4ProcessMap::Instance();
255 G4bool success = true;
256
257 auto aParticleIterator = GetParticleIterator();
258 aParticleIterator->reset();
259 while ((*aParticleIterator)()) {
260 // skip iteration if particle does not have a process manager
261 if (!aParticleIterator->value()->GetProcessManager()) continue;
262
263 auto processVector =
264 aParticleIterator->value()->GetProcessManager()->GetProcessList();
265
266 for (size_t i = 0; i < processVector->length(); i++) {
267
268 if (UpdateOrSkipBiasingProcess((*processVector)[i])) continue;
269
270 if ((*processVector)[i]->GetProcessSubType() == fHadronInelastic) {
271 UpdateHadronicProcessSubType((*processVector)[i]);
272 }
273
274 auto newCodes = pMap->GetCodes((*processVector)[i]);
275 if (newCodes.first == kPNoProcess) {
276 G4String text = "Unknown process codes for ";
277 text += (*processVector)[i]->GetProcessName();
278 text += " process type: ";
279 text += std::to_string((*processVector)[i]->GetProcessType());
280 text += " process sub type: ";
281 text += std::to_string((*processVector)[i]->GetProcessSubType());
282 TG4Globals::Warning("TG4ProcessMapPhysics", "ConstructProcess", text);
283 success = false;
284 }
285 }
286 }
287
288 if (VerboseLevel() > 0) {
289 if (success)
290 G4cout << "### Processes mapped to VMC codes ok" << G4endl;
291 else
292 G4cout << "### Processes mapped to VMC codes: some proceesses unknown."
293 << G4endl;
294 }
295}
Definition of the TG4Globals class and basic container types.
Definition of the TG4ProcessMapPhysics class.
Definition of the TG4ProcessMap class.
Definition of the TG4StackPopper class.
static void Warning(const TString &className, const TString &methodName, const TString &text)
TG4ProcessMapPhysics(const G4String &name="ProcessMap")
G4bool UpdateOrSkipBiasingProcess(G4VProcess *process)
void ConstructProcess() override
Construct physics processes.
void ConstructParticle() override
Construct particles.
void UpdateHadronicProcessSubType(G4VProcess *process)
Maps G4 process sub types to TMCProcess and TG4G3Control codes.
static TG4ProcessMap * Instance()
G4bool Add(G4int subType, TMCProcess mcProcess, TG4G3Control g3Control)
Abstract base class for physics constructors with verbose.
virtual G4int VerboseLevel() const
@ kDCAY
@ kPAIR
@ kPFIS
@ kNoG3Controls
No process control.
@ kHADR
@ kANNI
@ kRAYL
@ kG3LOSS
@ kCOMP
@ kBREM
@ kMUNU
@ kLABS
@ kSYNC
@ kCKOV
@ kMULS
@ kPHOT
@ fPositronNuclear
@ fMuonNuclear
@ fElectronNuclear
@ fPhotoNuclear
@ fStackPopper