Geant4  10.03.p03
 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 //
26 // $Id: WLSPhysicsList.cc 101181 2016-11-08 15:08:33Z gcosmo $
27 //
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 #include "FTFP_BERT.hh"
46 #include "QGSP_BERT_HP.hh"
47 
48 #include "G4Gamma.hh"
49 #include "G4Electron.hh"
50 #include "G4Positron.hh"
51 
52 #include "WLSStepMax.hh"
53 
54 #include "G4ProcessTable.hh"
55 
56 #include "G4PionDecayMakeSpin.hh"
57 #include "G4DecayWithSpin.hh"
58 
59 #include "G4DecayTable.hh"
62 
64 
65 #include "G4SystemOfUnits.hh"
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 
70 {
72 
73  defaultCutValue = 1.*mm;
74  fCutForGamma = defaultCutValue;
75  fCutForElectron = defaultCutValue;
76  fCutForPositron = defaultCutValue;
77 
78 // G4PhysListFactory factory;
79  G4VModularPhysicsList* phys = NULL;
80  if (physName == "QGSP_BERT_HP") {
81  phys = new QGSP_BERT_HP;
82  } else {
83  phys = new FTFP_BERT;
84  }
85 // if (factory.IsReferencePhysList(physName)) {
86 // phys = factory.GetReferencePhysList(physName);
87 // if(!phys)G4Exception("WLSPhysicsList::WLSPhysicsList","InvalidSetup",
88 // FatalException,"PhysicsList does not exist");
89  fMessenger = new WLSPhysicsListMessenger(this);
90 // }
91 
92  for (G4int i = 0; ; ++i) {
93  G4VPhysicsConstructor* elem =
94  const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i));
95  if (elem == NULL) break;
96  G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
97  RegisterPhysics(elem);
98  }
99 
100  fAbsorptionOn = true;
101 
103  RegisterPhysics(fOpticalPhysics = new WLSOpticalPhysics(fAbsorptionOn));
104 
106 
107  fStepMaxProcess = new WLSStepMax();
108 }
109 
110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
111 
113 {
114  delete fMessenger;
115 
116  delete fStepMaxProcess;
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
120 
122 {
123  for (G4PhysConstVector::iterator p = fPhysicsVector->begin();
124  p != fPhysicsVector->end(); ++p) {
125  delete (*p);
126  }
127  fPhysicsVector->clear();
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131 
133 {
135 
136  G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
137  MuonPlusDecayTable -> Insert(new
138  G4MuonDecayChannelWithSpin("mu+",0.986));
139  MuonPlusDecayTable -> Insert(new
141  G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
142 
143  G4DecayTable* MuonMinusDecayTable = new G4DecayTable();
144  MuonMinusDecayTable -> Insert(new
145  G4MuonDecayChannelWithSpin("mu-",0.986));
146  MuonMinusDecayTable -> Insert(new
148  G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(MuonMinusDecayTable);
149 
150 }
151 
152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
153 
155 {
157 
158  SetVerbose(0);
159 
160  G4DecayWithSpin* decayWithSpin = new G4DecayWithSpin();
161 
163 
164  G4VProcess* decay;
165  decay = processTable->FindProcess("Decay",G4MuonPlus::MuonPlus());
166 
167  G4ProcessManager* pManager;
168  pManager = G4MuonPlus::MuonPlus()->GetProcessManager();
169 
170  if (pManager) {
171  if (decay) pManager->RemoveProcess(decay);
172  pManager->AddProcess(decayWithSpin);
173  // set ordering for PostStepDoIt and AtRestDoIt
174  pManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
175  pManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
176  }
177 
178  decay = processTable->FindProcess("Decay",G4MuonMinus::MuonMinus());
179 
181 
182  if (pManager) {
183  if (decay) pManager->RemoveProcess(decay);
184  pManager->AddProcess(decayWithSpin);
185  // set ordering for PostStepDoIt and AtRestDoIt
186  pManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
187  pManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
188  }
189 
190  G4PionDecayMakeSpin* poldecay = new G4PionDecayMakeSpin();
191 
192  decay = processTable->FindProcess("Decay",G4PionPlus::PionPlus());
193 
194  pManager = G4PionPlus::PionPlus()->GetProcessManager();
195 
196  if (pManager) {
197  if (decay) pManager->RemoveProcess(decay);
198  pManager->AddProcess(poldecay);
199  // set ordering for PostStepDoIt and AtRestDoIt
200  pManager ->SetProcessOrdering(poldecay, idxPostStep);
201  pManager ->SetProcessOrdering(poldecay, idxAtRest);
202  }
203 
204  decay = processTable->FindProcess("Decay",G4PionMinus::PionMinus());
205 
207 
208  if (pManager) {
209  if (decay) pManager->RemoveProcess(decay);
210  pManager->AddProcess(poldecay);
211  // set ordering for PostStepDoIt and AtRestDoIt
212  pManager ->SetProcessOrdering(poldecay, idxPostStep);
213  pManager ->SetProcessOrdering(poldecay, idxAtRest);
214  }
215 
216  AddStepMax();
217 
218 }
219 
220 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
221 
223 {
224  G4bool success = false;
225  for (G4PhysConstVector::iterator p = fPhysicsVector->begin();
226  p != fPhysicsVector->end(); ++p) {
227  G4VPhysicsConstructor* e = (*p);
228  if (e->GetPhysicsName() == name) {
229  fPhysicsVector->erase(p);
230  success = true;
231  break;
232  }
233  }
234  if (!success) {
235  G4ExceptionDescription message;
236  message << "PhysicsList::RemoveFromEMPhysicsList "<< name << "not found";
237  G4Exception("example WLSPhysicsList::RemoveFromPhysicsList()",
238  "ExamWLSPhysicsList01",FatalException,message);
239  }
240 }
241 
242 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
243 
245 {
246  fAbsorptionOn = toggle;
247  RemoveFromPhysicsList("Optical");
248  fPhysicsVector->
249  push_back(fOpticalPhysics = new WLSOpticalPhysics(toggle));
250  fOpticalPhysics->ConstructProcess();
251 }
252 
253 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
254 
256 {
257  if (verboseLevel >0) {
258  G4cout << "WLSPhysicsList::SetCuts:";
259  G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length")
260  << G4endl;
261  }
262 
263  // set cut values for gamma at first and for e- second and next for e+,
264  // because some processes for e+/e- need cut values for gamma
265  SetCutValue(fCutForGamma, "gamma");
266  SetCutValue(fCutForElectron, "e-");
267  SetCutValue(fCutForPositron, "e+");
268 
270 }
271 
272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
273 
275 {
276  fCutForGamma = cut;
277  SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
278 }
279 
280 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
281 
283 {
284  fCutForElectron = cut;
285  SetParticleCuts(fCutForElectron, G4Electron::Electron());
286 }
287 
288 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
289 
291 {
292  fCutForPositron = cut;
293  SetParticleCuts(fCutForPositron, G4Positron::Positron());
294 }
295 
296 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
297 
299 {
300  fStepMaxProcess->SetStepMax(step);
301 }
302 
303 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
304 
306 {
307  return fStepMaxProcess;
308 }
309 
310 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
311 
313 {
314  // Step limitation seen as a process
315 
317  particleIterator->reset();
318  while ((*particleIterator)()){
319  G4ParticleDefinition* particle = particleIterator->value();
320  G4ProcessManager* pmanager = particle->GetProcessManager();
321 
322  if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
323  {
324  if (pmanager) pmanager ->AddDiscreteProcess(fStepMaxProcess);
325  }
326  }
327 }
328 
329 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
330 
332 {
333  fOpticalPhysics->SetNbOfPhotonsCerenkov(maxNumber);
334 }
335 
336 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
337 
339 {
340  fOpticalPhysics->GetCerenkovProcess()->SetVerboseLevel(verbose);
341  fOpticalPhysics->GetScintillationProcess()->SetVerboseLevel(verbose);
342  fOpticalPhysics->GetAbsorptionProcess()->SetVerboseLevel(verbose);
343  fOpticalPhysics->GetRayleighScatteringProcess()->SetVerboseLevel(verbose);
344  fOpticalPhysics->GetMieHGScatteringProcess()->SetVerboseLevel(verbose);
345  fOpticalPhysics->GetBoundaryProcess()->SetVerboseLevel(verbose);
346 }
const XML_Char * name
Definition: expat.h:151
static G4MuonPlus * MuonPlus()
Definition: G4MuonPlus.cc:99
void RegisterPhysics(G4VPhysicsConstructor *)
static G4MuonPlus * MuonPlusDefinition()
Definition: G4MuonPlus.cc:94
static G4LossTableManager * Instance()
static constexpr double mm
Definition: G4SIunits.hh:115
void SetCutValue(G4double aCut, const G4String &pname)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const char * p
Definition: xmltok.h:285
void SetNbOfPhotonsCerenkov(G4int)
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4Scintillation * GetScintillationProcess()
Provide control of the physics list and cut parameters.
G4OpMieHG * GetMieHGScatteringProcess()
WLSStepMax * GetStepMaxProcess()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetNbOfPhotonsCerenkov(G4int)
int G4int
Definition: G4Types.hh:78
void SetStepMax(G4double)
virtual void ConstructParticle()
virtual void ConstructProcess()
void ClearPhysics()
Make sure that the physics list is empty.
virtual ~WLSPhysicsList()
void SetParticleCuts(G4double cut, G4ParticleDefinition *particle, G4Region *region=0)
void DumpCutValuesTable(G4int flag=1)
G4GLOB_DLL std::ostream G4cout
const G4VPhysicsConstructor * GetPhysics(G4int index) const
ParticleList decay(Cluster *const c)
Carries out a cluster decay.
G4Cerenkov * GetCerenkovProcess()
virtual G4bool IsApplicable(const G4ParticleDefinition &)
Definition: WLSStepMax.cc:57
bool G4bool
Definition: G4Types.hh:79
void Insert(const PVNodeID *pvPath, size_t pathLength, G4int index, Node *node)
Definition of the WLSStepMax class.
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
virtual void ConstructProcess()
G4OpAbsorption * GetAbsorptionProcess()
static G4PionPlus * PionPlus()
Definition: G4PionPlus.cc:98
G4OpBoundaryProcess * GetBoundaryProcess()
const G4String & GetPhysicsName() const
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
static G4Gamma * Gamma()
Definition: G4Gamma.cc:86
Definition of the WLSOpticalPhysics class.
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetCutForPositron(G4double)
Definition of the WLSPhysicsListMessenger class.
Definition of the WLSExtraPhysics class.
static G4Positron * Positron()
Definition: G4Positron.cc:94
void SetCutForGamma(G4double)
void RemoveFromPhysicsList(const G4String &)
Remove specific physics from physics list.
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
Definition of the WLSPhysicsList class.
G4ProcessManager * GetProcessManager() const
static G4PionMinus * PionMinus()
Definition: G4PionMinus.cc:98
static G4MuonMinus * MuonMinusDefinition()
Definition: G4MuonMinus.cc:95
std::vector< G4InuclElementaryParticle >::iterator particleIterator
Definition: G4BigBanger.cc:65
static G4MuonMinus * MuonMinus()
Definition: G4MuonMinus.cc:100
static G4Electron * Electron()
Definition: G4Electron.cc:94
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
#define G4endl
Definition: G4ios.hh:61
void SetCutForElectron(G4double)
double G4double
Definition: G4Types.hh:76
TQGSP_BERT_HP< G4VModularPhysicsList > QGSP_BERT_HP
Definition: QGSP_BERT_HP.hh:62
void SetAbsorption(G4bool)
WLSPhysicsList(G4String)
G4VProcess * RemoveProcess(G4VProcess *aProcess)
static G4ProcessTable * GetProcessTable()
void SetVerbose(G4int)
G4VProcess * FindProcess(const G4String &processName, const G4String &particleName) const
void SetVerboseLevel(G4int value)
Definition: G4VProcess.hh:437
void SetStepMax(G4double)
Definition: WLSStepMax.cc:64
G4OpRayleigh * GetRayleighScatteringProcess()