source: trunk/examples/extended/field/field04/src/F04PhysicsList.cc@ 1347

Last change on this file since 1347 was 1342, checked in by garnier, 15 years ago

update ti head

File size: 8.7 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28
29#include "F04PhysicsList.hh"
30#include "F04PhysicsListMessenger.hh"
31
32#include "F04ExtraPhysics.hh"
33#include "G4OpticalPhysics.hh"
34
35#include "G4LossTableManager.hh"
36
37#include "G4ProcessManager.hh"
38#include "G4ParticleTypes.hh"
39#include "G4ParticleTable.hh"
40
41#include "G4PhysListFactory.hh"
42
43#include "G4Gamma.hh"
44#include "G4Electron.hh"
45#include "G4Positron.hh"
46
47#include "F04StepMax.hh"
48
49#include "G4ProcessTable.hh"
50
51#include "G4PionDecayMakeSpin.hh"
52#include "G4DecayWithSpin.hh"
53
54#include "G4DecayTable.hh"
55#include "G4MuonDecayChannelWithSpin.hh"
56#include "G4MuonRadiativeDecayChannelWithSpin.hh"
57
58F04PhysicsList::F04PhysicsList(G4String physName) : G4VModularPhysicsList()
59{
60 G4LossTableManager::Instance();
61
62 defaultCutValue = 1.*mm;
63 fCutForGamma = defaultCutValue;
64 fCutForElectron = defaultCutValue;
65 fCutForPositron = defaultCutValue;
66
67 fMessenger = new F04PhysicsListMessenger(this);
68
69 SetVerboseLevel(1);
70
71 G4PhysListFactory factory;
72 G4VModularPhysicsList* phys = NULL;
73
74 if (factory.IsReferencePhysList(physName))
75 phys =factory.GetReferencePhysList(physName);
76
77 // Physics List is defined via environment variable PHYSLIST
78 if (!phys) phys = factory.ReferencePhysList();
79
80 if (!phys) G4Exception("WLSPhysicsList::WLSPhysicsList","InvalidSetup",
81 FatalException,"PhysicsList does not exist");
82
83 for (G4int i = 0; ; ++i) {
84 G4VPhysicsConstructor* elem =
85 const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i));
86 if (elem == NULL) break;
87 G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
88 RegisterPhysics(elem);
89 }
90
91 RegisterPhysics(new F04ExtraPhysics());
92 RegisterPhysics(new G4OpticalPhysics());
93
94 stepMaxProcess = new F04StepMax();
95}
96
97F04PhysicsList::~F04PhysicsList()
98{
99 delete fMessenger;
100
101 delete stepMaxProcess;
102}
103
104void F04PhysicsList::ConstructParticle()
105{
106 G4VModularPhysicsList::ConstructParticle();
107
108 G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
109 MuonPlusDecayTable -> Insert(new
110 G4MuonDecayChannelWithSpin("mu+",0.986));
111 MuonPlusDecayTable -> Insert(new
112 G4MuonRadiativeDecayChannelWithSpin("mu+",0.014));
113 G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
114
115 G4DecayTable* MuonMinusDecayTable = new G4DecayTable();
116 MuonMinusDecayTable -> Insert(new
117 G4MuonDecayChannelWithSpin("mu-",0.986));
118 MuonMinusDecayTable -> Insert(new
119 G4MuonRadiativeDecayChannelWithSpin("mu-",0.014));
120 G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(MuonMinusDecayTable);
121}
122
123void F04PhysicsList::ConstructProcess()
124{
125 G4VModularPhysicsList::ConstructProcess();
126
127 G4DecayWithSpin* decayWithSpin = new G4DecayWithSpin();
128
129 G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
130
131 G4VProcess* decay;
132 decay = processTable->FindProcess("Decay",G4MuonPlus::MuonPlus());
133
134 G4ProcessManager* fManager;
135 fManager = G4MuonPlus::MuonPlus()->GetProcessManager();
136
137 if (fManager) {
138 if (decay) fManager->RemoveProcess(decay);
139 fManager->AddProcess(decayWithSpin);
140 // set ordering for PostStepDoIt and AtRestDoIt
141 fManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
142 fManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
143 }
144
145 decay = processTable->FindProcess("Decay",G4MuonMinus::MuonMinus());
146
147 fManager = G4MuonMinus::MuonMinus()->GetProcessManager();
148
149 if (fManager) {
150 if (decay) fManager->RemoveProcess(decay);
151 fManager->AddProcess(decayWithSpin);
152 // set ordering for PostStepDoIt and AtRestDoIt
153 fManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
154 fManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
155 }
156
157 G4PionDecayMakeSpin* poldecay = new G4PionDecayMakeSpin();
158
159 decay = processTable->FindProcess("Decay",G4PionPlus::PionPlus());
160
161 fManager = G4PionPlus::PionPlus()->GetProcessManager();
162
163 if (fManager) {
164 if (decay) fManager->RemoveProcess(decay);
165 fManager->AddProcess(poldecay);
166 // set ordering for PostStepDoIt and AtRestDoIt
167 fManager ->SetProcessOrdering(poldecay, idxPostStep);
168 fManager ->SetProcessOrdering(poldecay, idxAtRest);
169 }
170
171 decay = processTable->FindProcess("Decay",G4PionMinus::PionMinus());
172
173 fManager = G4PionMinus::PionMinus()->GetProcessManager();
174
175 if (fManager) {
176 if (decay) fManager->RemoveProcess(decay);
177 fManager->AddProcess(poldecay);
178 // set ordering for PostStepDoIt and AtRestDoIt
179 fManager ->SetProcessOrdering(poldecay, idxPostStep);
180 fManager ->SetProcessOrdering(poldecay, idxAtRest);
181 }
182
183 AddStepMax();
184}
185
186/*
187void F04PhysicsList::RemoveFromPhysicsList(const G4String& name)
188{
189 G4bool success = false;
190 for (G4PhysConstVector::iterator p = physicsVector->begin();
191 p != physicsVector->end(); ++p) {
192 G4VPhysicsConstructor* e = (*p);
193 if (e->GetPhysicsName() == name) {
194 physicsVector->erase(p);
195 success = true;
196 break;
197 }
198 }
199 if (!success) {
200 std::ostringstream message;
201 message << "PhysicsList::RemoveFromPhysicsList "<< name << "not found";
202 G4Exception(message.str().c_str());
203 }
204}
205
206void F04PhysicsList::ClearPhysics()
207{
208 for (G4PhysConstVector::iterator p = physicsVector->begin();
209 p != physicsVector->end(); ++p) {
210 delete (*p);
211 }
212 physicsVector->clear();
213}
214*/
215
216void F04PhysicsList::SetCuts()
217{
218 if (verboseLevel >0) {
219 G4cout << "F04PhysicsList::SetCuts:";
220 G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length")
221 << G4endl;
222 }
223
224 // set cut values for gamma at first and for e- second and next for e+,
225 // because some processes for e+/e- need cut values for gamma
226 SetCutValue(fCutForGamma, "gamma");
227 SetCutValue(fCutForElectron, "e-");
228 SetCutValue(fCutForPositron, "e+");
229
230 if (verboseLevel>0) DumpCutValuesTable();
231}
232
233void F04PhysicsList::SetCutForGamma(G4double cut)
234{
235 fCutForGamma = cut;
236 SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
237}
238
239void F04PhysicsList::SetCutForElectron(G4double cut)
240{
241 fCutForElectron = cut;
242 SetParticleCuts(fCutForElectron, G4Electron::Electron());
243}
244
245void F04PhysicsList::SetCutForPositron(G4double cut)
246{
247 fCutForPositron = cut;
248 SetParticleCuts(fCutForPositron, G4Positron::Positron());
249}
250
251void F04PhysicsList::SetStepMax(G4double step)
252{
253 MaxChargedStep = step ;
254 stepMaxProcess->SetStepMax(MaxChargedStep);
255}
256
257F04StepMax* F04PhysicsList::GetStepMaxProcess()
258{
259 return stepMaxProcess;
260}
261
262void F04PhysicsList::AddStepMax()
263{
264 // Step limitation seen as a process
265
266 theParticleIterator->reset();
267 while ((*theParticleIterator)()){
268 G4ParticleDefinition* particle = theParticleIterator->value();
269 G4ProcessManager* pmanager = particle->GetProcessManager();
270
271 if (stepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
272 {
273 if (pmanager) pmanager ->AddDiscreteProcess(stepMaxProcess);
274 }
275 }
276}
Note: See TracBrowser for help on using the repository browser.