Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
WLSPhysicsList.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 //
31 
32 #include "WLSPhysicsList.hh"
34 
35 #include "WLSExtraPhysics.hh"
36 #include "WLSOpticalPhysics.hh"
37 
38 #include "G4LossTableManager.hh"
39 
40 #include "G4ProcessManager.hh"
41 #include "G4ParticleTypes.hh"
42 #include "G4ParticleTable.hh"
43 
44 #include "G4PhysListFactory.hh"
45 
46 #include "G4Gamma.hh"
47 #include "G4Electron.hh"
48 #include "G4Positron.hh"
49 
50 #include "WLSStepMax.hh"
51 
52 #include "G4ProcessTable.hh"
53 
54 #include "G4PionDecayMakeSpin.hh"
55 #include "G4DecayWithSpin.hh"
56 
57 #include "G4DecayTable.hh"
60 
62 
63 #include "G4SystemOfUnits.hh"
64 
66 {
68 
69  defaultCutValue = 1.*mm;
70  fCutForGamma = defaultCutValue;
71  fCutForElectron = defaultCutValue;
72  fCutForPositron = defaultCutValue;
73 
74  G4PhysListFactory factory;
75  G4VModularPhysicsList* phys = NULL;
76  if (factory.IsReferencePhysList(physName)) {
77  phys = factory.GetReferencePhysList(physName);
78  if(!phys)G4Exception("WLSPhysicsList::WLSPhysicsList","InvalidSetup",
79  FatalException,"PhysicsList does not exist");
80  fMessenger = new WLSPhysicsListMessenger(this);
81  }
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  AbsorptionOn = true;
92 
93  physicsVector->push_back(new WLSExtraPhysics());
94  physicsVector->push_back(opticalPhysics = new WLSOpticalPhysics(AbsorptionOn));
95 
96  physicsVector->push_back(new G4RadioactiveDecayPhysics());
97 
98  stepMaxProcess = new WLSStepMax();
99 }
100 
102 {
103  delete fMessenger;
104 
105  delete stepMaxProcess;
106 }
107 
109 {
110  for (G4PhysConstVector::iterator p = physicsVector->begin();
111  p != physicsVector->end(); ++p) {
112  delete (*p);
113  }
114  physicsVector->clear();
115 }
116 
118 {
120 
121  G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
122  MuonPlusDecayTable -> Insert(new
123  G4MuonDecayChannelWithSpin("mu+",0.986));
124  MuonPlusDecayTable -> Insert(new
126  G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
127 
128  G4DecayTable* MuonMinusDecayTable = new G4DecayTable();
129  MuonMinusDecayTable -> Insert(new
130  G4MuonDecayChannelWithSpin("mu-",0.986));
131  MuonMinusDecayTable -> Insert(new
133  G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(MuonMinusDecayTable);
134 
135 }
136 
138 {
140 
141  SetVerbose(0);
142 
143  G4DecayWithSpin* decayWithSpin = new G4DecayWithSpin();
144 
146 
147  G4VProcess* decay;
148  decay = processTable->FindProcess("Decay",G4MuonPlus::MuonPlus());
149 
150  G4ProcessManager* fManager;
151  fManager = G4MuonPlus::MuonPlus()->GetProcessManager();
152 
153  if (fManager) {
154  if (decay) fManager->RemoveProcess(decay);
155  fManager->AddProcess(decayWithSpin);
156  // set ordering for PostStepDoIt and AtRestDoIt
157  fManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
158  fManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
159  }
160 
161  decay = processTable->FindProcess("Decay",G4MuonMinus::MuonMinus());
162 
164 
165  if (fManager) {
166  if (decay) fManager->RemoveProcess(decay);
167  fManager->AddProcess(decayWithSpin);
168  // set ordering for PostStepDoIt and AtRestDoIt
169  fManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
170  fManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
171  }
172 
173  G4PionDecayMakeSpin* poldecay = new G4PionDecayMakeSpin();
174 
175  decay = processTable->FindProcess("Decay",G4PionPlus::PionPlus());
176 
177  fManager = G4PionPlus::PionPlus()->GetProcessManager();
178 
179  if (fManager) {
180  if (decay) fManager->RemoveProcess(decay);
181  fManager->AddProcess(poldecay);
182  // set ordering for PostStepDoIt and AtRestDoIt
183  fManager ->SetProcessOrdering(poldecay, idxPostStep);
184  fManager ->SetProcessOrdering(poldecay, idxAtRest);
185  }
186 
187  decay = processTable->FindProcess("Decay",G4PionMinus::PionMinus());
188 
190 
191  if (fManager) {
192  if (decay) fManager->RemoveProcess(decay);
193  fManager->AddProcess(poldecay);
194  // set ordering for PostStepDoIt and AtRestDoIt
195  fManager ->SetProcessOrdering(poldecay, idxPostStep);
196  fManager ->SetProcessOrdering(poldecay, idxAtRest);
197  }
198 
199  AddStepMax();
200 
201 }
202 
204 {
205  G4bool success = false;
206  for (G4PhysConstVector::iterator p = physicsVector->begin();
207  p != physicsVector->end(); ++p) {
208  G4VPhysicsConstructor* e = (*p);
209  if (e->GetPhysicsName() == name) {
210  physicsVector->erase(p);
211  success = true;
212  break;
213  }
214  }
215  if (!success) {
216  G4ExceptionDescription message;
217  message << "PhysicsList::RemoveFromEMPhysicsList "<< name << "not found";
218  G4Exception("example WLSPhysicsList::RemoveFromPhysicsList()",
219  "ExamWLSPhysicsList01",FatalException,message);
220  }
221 }
222 
224 {
225  AbsorptionOn = toggle;
226  RemoveFromPhysicsList("Optical");
227  physicsVector->push_back(opticalPhysics = new WLSOpticalPhysics(toggle));
228  opticalPhysics->ConstructProcess();
229 }
230 
232 {
233  if (verboseLevel >0) {
234  G4cout << "WLSPhysicsList::SetCuts:";
235  G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length")
236  << G4endl;
237  }
238 
239  // set cut values for gamma at first and for e- second and next for e+,
240  // because some processes for e+/e- need cut values for gamma
241  SetCutValue(fCutForGamma, "gamma");
242  SetCutValue(fCutForElectron, "e-");
243  SetCutValue(fCutForPositron, "e+");
244 
246 }
247 
249 {
250  fCutForGamma = cut;
251  SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
252 }
253 
255 {
256  fCutForElectron = cut;
257  SetParticleCuts(fCutForElectron, G4Electron::Electron());
258 }
259 
261 {
262  fCutForPositron = cut;
263  SetParticleCuts(fCutForPositron, G4Positron::Positron());
264 }
265 
267 {
268  MaxChargedStep = step;
269  stepMaxProcess->SetStepMax(MaxChargedStep);
270 }
271 
273 {
274  return stepMaxProcess;
275 }
276 
278 {
279  // Step limitation seen as a process
280 
282  while ((*theParticleIterator)()){
284  G4ProcessManager* pmanager = particle->GetProcessManager();
285 
286  if (stepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
287  {
288  if (pmanager) pmanager ->AddDiscreteProcess(stepMaxProcess);
289  }
290  }
291 }
292 
294 {
295  opticalPhysics->SetNbOfPhotonsCerenkov(MaxNumber);
296 }
297 
299 {
300  opticalPhysics->GetCerenkovProcess()->SetVerboseLevel(verbose);
301  opticalPhysics->GetScintillationProcess()->SetVerboseLevel(verbose);
302  opticalPhysics->GetAbsorptionProcess()->SetVerboseLevel(verbose);
303  opticalPhysics->GetRayleighScatteringProcess()->SetVerboseLevel(verbose);
304  opticalPhysics->GetMieHGScatteringProcess()->SetVerboseLevel(verbose);
305  opticalPhysics->GetBoundaryProcess()->SetVerboseLevel(verbose);
306 }