Geant4_10
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 78066 2013-12-03 11:08:36Z 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 
102  //This looks complex, but it is not:
103  //Get from base-class the pointer of the phsyicsVector
104  //to be used. Remember: G4VModularPhysicsList is now a split class.
105  //Why G4VModularPhysicsList::RegisterPhysics method is not used instead?
106  //If possible we can remove this...
107  fPhysicsVector =
108  GetSubInstanceManager().offset[GetInstanceID()].physicsVector;
109 
110  fPhysicsVector->push_back(new WLSExtraPhysics());
111  fPhysicsVector->push_back(fOpticalPhysics =
112  new WLSOpticalPhysics(fAbsorptionOn));
113 
114  fPhysicsVector->push_back(new G4RadioactiveDecayPhysics());
115 
116  fStepMaxProcess = new WLSStepMax();
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
120 
122 {
123  delete fMessenger;
124 
125  delete fStepMaxProcess;
126 }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129 
131 {
132  for (G4PhysConstVector::iterator p = fPhysicsVector->begin();
133  p != fPhysicsVector->end(); ++p) {
134  delete (*p);
135  }
136  fPhysicsVector->clear();
137 }
138 
139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
140 
142 {
144 
145  G4DecayTable* MuonPlusDecayTable = new G4DecayTable();
146  MuonPlusDecayTable -> Insert(new
147  G4MuonDecayChannelWithSpin("mu+",0.986));
148  MuonPlusDecayTable -> Insert(new
150  G4MuonPlus::MuonPlusDefinition() -> SetDecayTable(MuonPlusDecayTable);
151 
152  G4DecayTable* MuonMinusDecayTable = new G4DecayTable();
153  MuonMinusDecayTable -> Insert(new
154  G4MuonDecayChannelWithSpin("mu-",0.986));
155  MuonMinusDecayTable -> Insert(new
157  G4MuonMinus::MuonMinusDefinition() -> SetDecayTable(MuonMinusDecayTable);
158 
159 }
160 
161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
162 
164 {
166 
167  SetVerbose(0);
168 
169  G4DecayWithSpin* decayWithSpin = new G4DecayWithSpin();
170 
172 
173  G4VProcess* decay;
174  decay = processTable->FindProcess("Decay",G4MuonPlus::MuonPlus());
175 
176  G4ProcessManager* pManager;
177  pManager = G4MuonPlus::MuonPlus()->GetProcessManager();
178 
179  if (pManager) {
180  if (decay) pManager->RemoveProcess(decay);
181  pManager->AddProcess(decayWithSpin);
182  // set ordering for PostStepDoIt and AtRestDoIt
183  pManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
184  pManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
185  }
186 
187  decay = processTable->FindProcess("Decay",G4MuonMinus::MuonMinus());
188 
190 
191  if (pManager) {
192  if (decay) pManager->RemoveProcess(decay);
193  pManager->AddProcess(decayWithSpin);
194  // set ordering for PostStepDoIt and AtRestDoIt
195  pManager ->SetProcessOrdering(decayWithSpin, idxPostStep);
196  pManager ->SetProcessOrdering(decayWithSpin, idxAtRest);
197  }
198 
199  G4PionDecayMakeSpin* poldecay = new G4PionDecayMakeSpin();
200 
201  decay = processTable->FindProcess("Decay",G4PionPlus::PionPlus());
202 
203  pManager = G4PionPlus::PionPlus()->GetProcessManager();
204 
205  if (pManager) {
206  if (decay) pManager->RemoveProcess(decay);
207  pManager->AddProcess(poldecay);
208  // set ordering for PostStepDoIt and AtRestDoIt
209  pManager ->SetProcessOrdering(poldecay, idxPostStep);
210  pManager ->SetProcessOrdering(poldecay, idxAtRest);
211  }
212 
213  decay = processTable->FindProcess("Decay",G4PionMinus::PionMinus());
214 
216 
217  if (pManager) {
218  if (decay) pManager->RemoveProcess(decay);
219  pManager->AddProcess(poldecay);
220  // set ordering for PostStepDoIt and AtRestDoIt
221  pManager ->SetProcessOrdering(poldecay, idxPostStep);
222  pManager ->SetProcessOrdering(poldecay, idxAtRest);
223  }
224 
225  AddStepMax();
226 
227 }
228 
229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
230 
232 {
233  G4bool success = false;
234  for (G4PhysConstVector::iterator p = fPhysicsVector->begin();
235  p != fPhysicsVector->end(); ++p) {
236  G4VPhysicsConstructor* e = (*p);
237  if (e->GetPhysicsName() == name) {
238  fPhysicsVector->erase(p);
239  success = true;
240  break;
241  }
242  }
243  if (!success) {
244  G4ExceptionDescription message;
245  message << "PhysicsList::RemoveFromEMPhysicsList "<< name << "not found";
246  G4Exception("example WLSPhysicsList::RemoveFromPhysicsList()",
247  "ExamWLSPhysicsList01",FatalException,message);
248  }
249 }
250 
251 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
252 
254 {
255  fAbsorptionOn = toggle;
256  RemoveFromPhysicsList("Optical");
257  fPhysicsVector->
258  push_back(fOpticalPhysics = new WLSOpticalPhysics(toggle));
259  fOpticalPhysics->ConstructProcess();
260 }
261 
262 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
263 
265 {
266  if (verboseLevel >0) {
267  G4cout << "WLSPhysicsList::SetCuts:";
268  G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length")
269  << G4endl;
270  }
271 
272  // set cut values for gamma at first and for e- second and next for e+,
273  // because some processes for e+/e- need cut values for gamma
274  SetCutValue(fCutForGamma, "gamma");
275  SetCutValue(fCutForElectron, "e-");
276  SetCutValue(fCutForPositron, "e+");
277 
279 }
280 
281 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
282 
284 {
285  fCutForGamma = cut;
286  SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
287 }
288 
289 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
290 
292 {
293  fCutForElectron = cut;
294  SetParticleCuts(fCutForElectron, G4Electron::Electron());
295 }
296 
297 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
298 
300 {
301  fCutForPositron = cut;
302  SetParticleCuts(fCutForPositron, G4Positron::Positron());
303 }
304 
305 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
306 
308 {
309  fStepMaxProcess->SetStepMax(step);
310 }
311 
312 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
313 
315 {
316  return fStepMaxProcess;
317 }
318 
319 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
320 
322 {
323  // Step limitation seen as a process
324 
325  theParticleIterator->reset();
326  while ((*theParticleIterator)()){
327  G4ParticleDefinition* particle = theParticleIterator->value();
328  G4ProcessManager* pmanager = particle->GetProcessManager();
329 
330  if (fStepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
331  {
332  if (pmanager) pmanager ->AddDiscreteProcess(fStepMaxProcess);
333  }
334  }
335 }
336 
337 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
338 
340 {
341  fOpticalPhysics->SetNbOfPhotonsCerenkov(maxNumber);
342 }
343 
344 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
345 
347 {
348  fOpticalPhysics->GetCerenkovProcess()->SetVerboseLevel(verbose);
349  fOpticalPhysics->GetScintillationProcess()->SetVerboseLevel(verbose);
350  fOpticalPhysics->GetAbsorptionProcess()->SetVerboseLevel(verbose);
351  fOpticalPhysics->GetRayleighScatteringProcess()->SetVerboseLevel(verbose);
352  fOpticalPhysics->GetMieHGScatteringProcess()->SetVerboseLevel(verbose);
353  fOpticalPhysics->GetBoundaryProcess()->SetVerboseLevel(verbose);
354 }
static G4MuonPlus * MuonPlus()
Definition: G4MuonPlus.cc:99
void RegisterPhysics(G4VPhysicsConstructor *)
static G4MuonPlus * MuonPlusDefinition()
Definition: G4MuonPlus.cc:94
static G4LossTableManager * Instance()
void SetCutValue(G4double aCut, const G4String &pname)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const char * p
Definition: xmltok.h:285
void SetNbOfPhotonsCerenkov(G4int)
static const G4VMPLManager & GetSubInstanceManager()
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4Scintillation * GetScintillationProcess()
Provide control of the physics list and cut parameters.
const XML_Char * name
Definition: expat.h:151
G4OpMieHG * GetMieHGScatteringProcess()
WLSStepMax * GetStepMaxProcess()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
void SetNbOfPhotonsCerenkov(G4int)
G4ProcessManager * GetProcessManager() const
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.
static G4RUN_DLL G4ThreadLocal T * offset
static G4PionMinus * PionMinus()
Definition: G4PionMinus.cc:98
static G4MuonMinus * MuonMinusDefinition()
Definition: G4MuonMinus.cc:95
static G4MuonMinus * MuonMinus()
Definition: G4MuonMinus.cc:100
static G4Electron * Electron()
Definition: G4Electron.cc:94
#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
#define theParticleIterator
void SetVerboseLevel(G4int value)
Definition: G4VProcess.hh:437
void SetStepMax(G4double)
Definition: WLSStepMax.cc:64
G4OpRayleigh * GetRayleighScatteringProcess()