Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F04PhysicsList.cc
Go to the documentation of this file.
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 //
28 //
29 //
30 #include "F04PhysicsList.hh"
32 
33 #include "F04ExtraPhysics.hh"
34 #include "G4OpticalPhysics.hh"
35 
36 #include "G4LossTableManager.hh"
37 
38 #include "G4ProcessManager.hh"
39 #include "G4ParticleTypes.hh"
40 #include "G4ParticleTable.hh"
41 
42 #include "G4PhysListFactory.hh"
43 
44 #include "G4Gamma.hh"
45 #include "G4Electron.hh"
46 #include "G4Positron.hh"
47 
48 #include "F04StepMax.hh"
49 
50 #include "G4ProcessTable.hh"
51 
52 #include "G4PionDecayMakeSpin.hh"
53 #include "G4DecayWithSpin.hh"
54 
55 #include "G4DecayTable.hh"
58 
59 #include "G4SystemOfUnits.hh"
60 
61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
62 
64 {
66 
67  defaultCutValue = 1.*mm;
68  fCutForGamma = defaultCutValue;
69  fCutForElectron = defaultCutValue;
70  fCutForPositron = defaultCutValue;
71 
72  fMessenger = new F04PhysicsListMessenger(this);
73 
74  SetVerboseLevel(1);
75 
76  G4PhysListFactory factory;
77  G4VModularPhysicsList* phys = NULL;
78 
79  if (factory.IsReferencePhysList(physName))
80  phys =factory.GetReferencePhysList(physName);
81 
82  // Physics List is defined via environment variable PHYSLIST
83  if (!phys) phys = factory.ReferencePhysList();
84 
85  if (!phys) G4Exception("WLSPhysicsList::WLSPhysicsList","InvalidSetup",
86  FatalException,"PhysicsList does not exist");
87 
88  for (G4int i = 0; ; ++i) {
89  G4VPhysicsConstructor* elem =
90  const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i));
91  if (elem == NULL) break;
92  G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
93  RegisterPhysics(elem);
94  }
95 
98 
99  fStepMaxProcess = new F04StepMax();
100  fMaxChargedStep = DBL_MAX;
101 }
102 
103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
104 
106 {
107  delete fMessenger;
108 
109  delete fStepMaxProcess;
110 }
111 
112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
113 
115 {
117 
118  G4DecayTable* muonPlusDecayTable = new G4DecayTable();
119  muonPlusDecayTable -> Insert(new
120  G4MuonDecayChannelWithSpin("mu+",0.986));
121  muonPlusDecayTable -> Insert(new
123  G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(muonPlusDecayTable);
124 
125  G4DecayTable* muonMinusDecayTable = new G4DecayTable();
126  muonMinusDecayTable -> Insert(new
127  G4MuonDecayChannelWithSpin("mu-",0.986));
128  muonMinusDecayTable -> Insert(new
130  G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(muonMinusDecayTable);
131 }
132 
133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
134 
136 {
138 
139  G4DecayWithSpin* decayWithSpin = new G4DecayWithSpin();
140 
142 
143  G4VProcess* decay;
144  decay = processTable->FindProcess("Decay",G4MuonPlus::MuonPlus());
145 
146  G4ProcessManager* pmanager;
147  pmanager = G4MuonPlus::MuonPlus()->GetProcessManager();
148 
149  if (pmanager) {
150  if (decay) pmanager->RemoveProcess(decay);
151  pmanager->AddProcess(decayWithSpin);
152  // set ordering for PostStepDoIt and AtRestDoIt
153  pmanager ->SetProcessOrdering(decayWithSpin, idxPostStep);
154  pmanager ->SetProcessOrdering(decayWithSpin, idxAtRest);
155  }
156 
157  decay = processTable->FindProcess("Decay",G4MuonMinus::MuonMinus());
158 
160 
161  if (pmanager) {
162  if (decay) pmanager->RemoveProcess(decay);
163  pmanager->AddProcess(decayWithSpin);
164  // set ordering for PostStepDoIt and AtRestDoIt
165  pmanager ->SetProcessOrdering(decayWithSpin, idxPostStep);
166  pmanager ->SetProcessOrdering(decayWithSpin, idxAtRest);
167  }
168 
169  G4PionDecayMakeSpin* poldecay = new G4PionDecayMakeSpin();
170 
171  decay = processTable->FindProcess("Decay",G4PionPlus::PionPlus());
172 
173  pmanager = G4PionPlus::PionPlus()->GetProcessManager();
174 
175  if (pmanager) {
176  if (decay) pmanager->RemoveProcess(decay);
177  pmanager->AddProcess(poldecay);
178  // set ordering for PostStepDoIt and AtRestDoIt
179  pmanager ->SetProcessOrdering(poldecay, idxPostStep);
180  pmanager ->SetProcessOrdering(poldecay, idxAtRest);
181  }
182 
183  decay = processTable->FindProcess("Decay",G4PionMinus::PionMinus());
184 
186 
187  if (pmanager) {
188  if (decay) pmanager->RemoveProcess(decay);
189  pmanager->AddProcess(poldecay);
190  // set ordering for PostStepDoIt and AtRestDoIt
191  pmanager ->SetProcessOrdering(poldecay, idxPostStep);
192  pmanager ->SetProcessOrdering(poldecay, idxAtRest);
193  }
194 
195  AddStepMax();
196 }
197 
198 /*
199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
200 
201 void F04PhysicsList::RemoveFromPhysicsList(const G4String& name)
202 {
203  G4bool success = false;
204  for (G4PhysConstVector::iterator p = physicsVector->begin();
205  p != physicsVector->end(); ++p) {
206  G4VPhysicsConstructor* e = (*p);
207  if (e->GetPhysicsName() == name) {
208  physicsVector->erase(p);
209  success = true;
210  break;
211  }
212  }
213  if (!success) {
214  std::ostringstream message;
215  message << "PhysicsList::RemoveFromPhysicsList "<< name << "not found";
216  G4Exception(message.str().c_str());
217  }
218 }
219 
220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
221 
222 void F04PhysicsList::ClearPhysics()
223 {
224  for (G4PhysConstVector::iterator p = physicsVector->begin();
225  p != physicsVector->end(); ++p) {
226  delete (*p);
227  }
228  physicsVector->clear();
229 }
230 */
231 
232 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
233 
235 {
236  if (verboseLevel >0) {
237  G4cout << "F04PhysicsList::SetCuts:";
238  G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length")
239  << G4endl;
240  }
241 
242  // set cut values for gamma at first and for e- second and next for e+,
243  // because some processes for e+/e- need cut values for gamma
244  SetCutValue(fCutForGamma, "gamma");
245  SetCutValue(fCutForElectron, "e-");
246  SetCutValue(fCutForPositron, "e+");
247 
249 }
250 
251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
252 
254 {
255  fCutForGamma = cut;
256  SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
257 }
258 
259 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
260 
262 {
263  fCutForElectron = cut;
264  SetParticleCuts(fCutForElectron, G4Electron::Electron());
265 }
266 
267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
268 
270 {
271  fCutForPositron = cut;
272  SetParticleCuts(fCutForPositron, G4Positron::Positron());
273 }
274 
275 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
276 
278 {
279  fMaxChargedStep = step ;
280  fStepMaxProcess->SetStepMax(fMaxChargedStep);
281 }
282 
283 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
284 
286 {
287  return fStepMaxProcess;
288 }
289 
290 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
291 
293 {
294  // Step limitation seen as a process
295 
297  while ((*theParticleIterator)()){
299  G4ProcessManager* pmanager = particle->GetProcessManager();
300 
301  if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
302  {
303  if (pmanager) pmanager ->AddDiscreteProcess(fStepMaxProcess);
304  }
305  }
306 }