-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPhysicsList.cc
309 lines (241 loc) · 9.38 KB
/
PhysicsList.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
// Geant4 Libraries
//
#include "G4LossTableManager.hh"
#include "G4ProcessManager.hh"
#include "G4ParticleTypes.hh"
#include "G4ParticleTable.hh"
#include "FTFP_BERT.hh"
#include "QGSP_BERT_HP.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Positron.hh"
#include "G4ProcessTable.hh"
#include "G4PionDecayMakeSpin.hh"
#include "G4DecayWithSpin.hh"
#include "G4DecayTable.hh"
#include "G4MuonDecayChannelWithSpin.hh"
#include "G4MuonRadiativeDecayChannelWithSpin.hh"
#include "G4RadioactiveDecayPhysics.hh"
#include "G4SystemOfUnits.hh"
// Local Libraries
//
#include "PhysicsListMessenger.hh"
#include "StepMax.hh"
#include "PhysicsList.hh"
#include "ExtraPhysics.hh"
#include "OpticalPhysics.hh"
PhysicsList::PhysicsList(G4String physName) : G4VModularPhysicsList()
{
G4LossTableManager::Instance();
defaultCutValue = 1.*mm;
fCutForGamma = defaultCutValue;
fCutForElectron = defaultCutValue;
fCutForPositron = defaultCutValue;
// G4PhysListFactory factory;
G4VModularPhysicsList* phys = NULL;
if (physName == "QGSP_BERT_HP") {
phys = new QGSP_BERT_HP;
} else {
phys = new FTFP_BERT;
}
// if (factory.IsReferencePhysList(physName)) {
// phys = factory.GetReferencePhysList(physName);
// if(!phys)G4Exception("PhysicsList::PhysicsList","InvalidSetup",
// FatalException,"PhysicsList does not exist");
fMessenger = new PhysicsListMessenger(this);
// }
for (G4int i = 0; ; ++i) {
G4VPhysicsConstructor* elem =
const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i));
if (elem == NULL) break;
G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
RegisterPhysics(elem);
}
fAbsorptionOn = true;
RegisterPhysics(new ExtraPhysics());
RegisterPhysics(fOpticalPhysics = new OpticalPhysics(fAbsorptionOn));
RegisterPhysics(new G4RadioactiveDecayPhysics());
fStepMaxProcess = new StepMax();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
PhysicsList::~PhysicsList()
{
delete fMessenger;
delete fStepMaxProcess;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ClearPhysics()
{
for (G4PhysConstVector::iterator p = fPhysicsVector->begin();
p != fPhysicsVector->end(); ++p) {
delete (*p);
}
fPhysicsVector->clear();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ConstructParticle()
{
G4VModularPhysicsList::ConstructParticle();
G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
MuonPlusDecayTable -> Insert(new
G4MuonDecayChannelWithSpin("mu+",0.986));
MuonPlusDecayTable -> Insert(new
G4MuonRadiativeDecayChannelWithSpin("mu+",0.014));
G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
G4DecayTable* MuonMinusDecayTable = new G4DecayTable();
MuonMinusDecayTable -> Insert(new
G4MuonDecayChannelWithSpin("mu-",0.986));
MuonMinusDecayTable -> Insert(new
G4MuonRadiativeDecayChannelWithSpin("mu-",0.014));
G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(MuonMinusDecayTable);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::ConstructProcess()
{
G4VModularPhysicsList::ConstructProcess();
SetVerbose(0);
G4DecayWithSpin* decayWithSpin = new G4DecayWithSpin();
G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
G4VProcess* decay;
decay = processTable->FindProcess("Decay",G4MuonPlus::MuonPlus());
G4ProcessManager* pManager;
pManager = G4MuonPlus::MuonPlus()->GetProcessManager();
if (pManager) {
if (decay) pManager->RemoveProcess(decay);
pManager->AddProcess(decayWithSpin);
// set ordering for PostStepDoIt and AtRestDoIt
pManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
pManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
}
decay = processTable->FindProcess("Decay",G4MuonMinus::MuonMinus());
pManager = G4MuonMinus::MuonMinus()->GetProcessManager();
if (pManager) {
if (decay) pManager->RemoveProcess(decay);
pManager->AddProcess(decayWithSpin);
// set ordering for PostStepDoIt and AtRestDoIt
pManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
pManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
}
G4PionDecayMakeSpin* poldecay = new G4PionDecayMakeSpin();
decay = processTable->FindProcess("Decay",G4PionPlus::PionPlus());
pManager = G4PionPlus::PionPlus()->GetProcessManager();
if (pManager) {
if (decay) pManager->RemoveProcess(decay);
pManager->AddProcess(poldecay);
// set ordering for PostStepDoIt and AtRestDoIt
pManager ->SetProcessOrdering(poldecay, idxPostStep);
pManager ->SetProcessOrdering(poldecay, idxAtRest);
}
decay = processTable->FindProcess("Decay",G4PionMinus::PionMinus());
pManager = G4PionMinus::PionMinus()->GetProcessManager();
if (pManager) {
if (decay) pManager->RemoveProcess(decay);
pManager->AddProcess(poldecay);
// set ordering for PostStepDoIt and AtRestDoIt
pManager ->SetProcessOrdering(poldecay, idxPostStep);
pManager ->SetProcessOrdering(poldecay, idxAtRest);
}
AddStepMax();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::RemoveFromPhysicsList(const G4String& name)
{
G4bool success = false;
for (G4PhysConstVector::iterator p = fPhysicsVector->begin();
p != fPhysicsVector->end(); ++p) {
G4VPhysicsConstructor* e = (*p);
if (e->GetPhysicsName() == name) {
fPhysicsVector->erase(p);
success = true;
break;
}
}
if (!success) {
G4ExceptionDescription message;
message << "PhysicsList::RemoveFromEMPhysicsList "<< name << "not found";
G4Exception("example PhysicsList::RemoveFromPhysicsList()",
"ExamPhysicsList01",FatalException,message);
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetAbsorption(G4bool toggle)
{
fAbsorptionOn = toggle;
RemoveFromPhysicsList("Optical");
fPhysicsVector->
push_back(fOpticalPhysics = new OpticalPhysics(toggle));
fOpticalPhysics->ConstructProcess();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCuts()
{
if (verboseLevel >0) {
G4cout << "PhysicsList::SetCuts:";
G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length")
<< G4endl;
}
// set cut values for gamma at first and for e- second and next for e+,
// because some processes for e+/e- need cut values for gamma
SetCutValue(fCutForGamma, "gamma");
SetCutValue(fCutForElectron, "e-");
SetCutValue(fCutForPositron, "e+");
if (verboseLevel>0) DumpCutValuesTable();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForGamma(G4double cut)
{
fCutForGamma = cut;
SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForElectron(G4double cut)
{
fCutForElectron = cut;
SetParticleCuts(fCutForElectron, G4Electron::Electron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetCutForPositron(G4double cut)
{
fCutForPositron = cut;
SetParticleCuts(fCutForPositron, G4Positron::Positron());
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetStepMax(G4double step)
{
fStepMaxProcess->SetStepMax(step);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
StepMax* PhysicsList::GetStepMaxProcess()
{
return fStepMaxProcess;
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::AddStepMax()
{
// Step limitation seen as a process
auto particleIterator=GetParticleIterator();
particleIterator->reset();
while ((*particleIterator)()){
G4ParticleDefinition* particle = particleIterator->value();
G4ProcessManager* pmanager = particle->GetProcessManager();
if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
{
if (pmanager) pmanager ->AddDiscreteProcess(fStepMaxProcess);
}
}
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetNbOfPhotonsCerenkov(G4int maxNumber)
{
fOpticalPhysics->SetNbOfPhotonsCerenkov(maxNumber);
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void PhysicsList::SetVerbose(G4int verbose)
{
fOpticalPhysics->GetCerenkovProcess()->SetVerboseLevel(verbose);
fOpticalPhysics->GetScintillationProcess()->SetVerboseLevel(verbose);
fOpticalPhysics->GetAbsorptionProcess()->SetVerboseLevel(verbose);
fOpticalPhysics->GetRayleighScatteringProcess()->SetVerboseLevel(verbose);
fOpticalPhysics->GetMieHGScatteringProcess()->SetVerboseLevel(verbose);
fOpticalPhysics->GetBoundaryProcess()->SetVerboseLevel(verbose);
}