source: trunk/examples/extended/electromagnetic/TestEm1/src/PhysicsList.cc

Last change on this file was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 10.6 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// $Id: PhysicsList.cc,v 1.12 2009/09/15 12:51:49 maire Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32
33#include "PhysicsList.hh"
34#include "PhysicsListMessenger.hh"
35 
36#include "PhysListEmStandard.hh"
37
38#include "G4EmStandardPhysics.hh"
39#include "G4EmStandardPhysics_option1.hh"
40#include "G4EmStandardPhysics_option2.hh"
41#include "G4EmStandardPhysics_option3.hh"
42#include "G4EmLivermorePhysics.hh"
43#include "G4EmPenelopePhysics.hh"
44
45#include "DetectorConstruction.hh"
46
47#include "G4LossTableManager.hh"
48#include "G4UnitsTable.hh"
49
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51
52PhysicsList::PhysicsList(DetectorConstruction* p) 
53: G4VModularPhysicsList()
54{
55  G4LossTableManager::Instance();
56  pDet = p;
57 
58  currentDefaultCut   = 1.0*mm;
59  cutForGamma         = currentDefaultCut;
60  cutForElectron      = currentDefaultCut;
61  cutForPositron      = currentDefaultCut;
62
63  pMessenger = new PhysicsListMessenger(this);
64
65  SetVerboseLevel(1);
66
67  // EM physics
68  emName = G4String("local");
69  emPhysicsList = new PhysListEmStandard(emName);
70
71}
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74
75PhysicsList::~PhysicsList()
76{
77  delete pMessenger;
78}
79
80//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
81
82// Bosons
83#include "G4ChargedGeantino.hh"
84#include "G4Geantino.hh"
85#include "G4Gamma.hh"
86#include "G4OpticalPhoton.hh"
87
88// leptons
89#include "G4MuonPlus.hh"
90#include "G4MuonMinus.hh"
91#include "G4NeutrinoMu.hh"
92#include "G4AntiNeutrinoMu.hh"
93
94#include "G4Electron.hh"
95#include "G4Positron.hh"
96#include "G4NeutrinoE.hh"
97#include "G4AntiNeutrinoE.hh"
98
99// Mesons
100#include "G4PionPlus.hh"
101#include "G4PionMinus.hh"
102#include "G4PionZero.hh"
103#include "G4Eta.hh"
104#include "G4EtaPrime.hh"
105
106#include "G4KaonPlus.hh"
107#include "G4KaonMinus.hh"
108#include "G4KaonZero.hh"
109#include "G4AntiKaonZero.hh"
110#include "G4KaonZeroLong.hh"
111#include "G4KaonZeroShort.hh"
112
113// Baryons
114#include "G4Proton.hh"
115#include "G4AntiProton.hh"
116#include "G4Neutron.hh"
117#include "G4AntiNeutron.hh"
118
119// Nuclei
120#include "G4Deuteron.hh"
121#include "G4Triton.hh"
122#include "G4Alpha.hh"
123#include "G4GenericIon.hh"
124
125//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126
127void PhysicsList::ConstructParticle()
128{
129// pseudo-particles
130  G4Geantino::GeantinoDefinition();
131  G4ChargedGeantino::ChargedGeantinoDefinition();
132 
133// gamma
134  G4Gamma::GammaDefinition();
135 
136// optical photon
137  G4OpticalPhoton::OpticalPhotonDefinition();
138
139// leptons
140  G4Electron::ElectronDefinition();
141  G4Positron::PositronDefinition();
142  G4MuonPlus::MuonPlusDefinition();
143  G4MuonMinus::MuonMinusDefinition();
144
145  G4NeutrinoE::NeutrinoEDefinition();
146  G4AntiNeutrinoE::AntiNeutrinoEDefinition();
147  G4NeutrinoMu::NeutrinoMuDefinition();
148  G4AntiNeutrinoMu::AntiNeutrinoMuDefinition(); 
149
150// mesons
151  G4PionPlus::PionPlusDefinition();
152  G4PionMinus::PionMinusDefinition();
153  G4PionZero::PionZeroDefinition();
154  G4Eta::EtaDefinition();
155  G4EtaPrime::EtaPrimeDefinition();
156  G4KaonPlus::KaonPlusDefinition();
157  G4KaonMinus::KaonMinusDefinition();
158  G4KaonZero::KaonZeroDefinition();
159  G4AntiKaonZero::AntiKaonZeroDefinition();
160  G4KaonZeroLong::KaonZeroLongDefinition();
161  G4KaonZeroShort::KaonZeroShortDefinition();
162
163// barions
164  G4Proton::ProtonDefinition();
165  G4AntiProton::AntiProtonDefinition();
166  G4Neutron::NeutronDefinition();
167  G4AntiNeutron::AntiNeutronDefinition();
168
169// ions
170  G4Deuteron::DeuteronDefinition();
171  G4Triton::TritonDefinition();
172  G4Alpha::AlphaDefinition();
173  G4GenericIon::GenericIonDefinition();
174}
175
176//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
177
178#include "G4EmProcessOptions.hh"
179#include "G4Decay.hh"
180#include "G4ProcessManager.hh"
181
182void PhysicsList::ConstructProcess()
183{
184  // Transportation
185  //
186  AddTransportation();
187
188  // Electromagnetic physics list
189  //
190  emPhysicsList->ConstructProcess();
191 
192  // Em options
193  //
194  G4EmProcessOptions emOptions;
195  emOptions.SetBuildCSDARange(true);
196  emOptions.SetDEDXBinningForCSDARange(8*20);
197   
198  // Decay Process
199  //
200  AddDecay();
201
202  // step limitation (as a full process)
203  // 
204  AddStepMax();   
205}
206
207//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
208
209void PhysicsList::AddPhysicsList(const G4String& name)
210{
211  if (verboseLevel>1) {
212    G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
213  }
214 
215  if (name == emName) return;
216
217  if (name == "local") {
218
219    emName = name;
220    delete emPhysicsList;
221    emPhysicsList = new PhysListEmStandard(name);
222   
223  } else if (name == "emstandard_opt0") {
224
225    emName = name;
226    delete emPhysicsList;
227    emPhysicsList = new G4EmStandardPhysics();
228
229  } else if (name == "emstandard_opt1") {
230
231    emName = name;
232    delete emPhysicsList;
233    emPhysicsList = new G4EmStandardPhysics_option1();
234
235  } else if (name == "emstandard_opt2") {
236
237    emName = name;
238    delete emPhysicsList;
239    emPhysicsList = new G4EmStandardPhysics_option2();
240
241  } else if (name == "emstandard_opt3") {
242
243    emName = name;
244    delete emPhysicsList;
245    emPhysicsList = new G4EmStandardPhysics_option3();
246
247  } else if (name == "emlivermore") {
248    emName = name;
249    delete emPhysicsList;
250    emPhysicsList = new G4EmLivermorePhysics();
251   
252  } else if (name == "empenelope") {
253    emName = name;
254    delete emPhysicsList;
255    emPhysicsList = new G4EmPenelopePhysics();
256           
257  } else {
258
259    G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
260           << " is not defined"
261           << G4endl;
262  }
263}
264//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
265
266#include "G4Decay.hh"
267
268void PhysicsList::AddDecay()
269{ 
270  // Decay Process
271  //
272  G4Decay* fDecayProcess = new G4Decay();
273
274  theParticleIterator->reset();
275  while( (*theParticleIterator)() ){
276    G4ParticleDefinition* particle = theParticleIterator->value();
277    G4ProcessManager* pmanager = particle->GetProcessManager();
278
279    if (fDecayProcess->IsApplicable(*particle)) { 
280
281      pmanager ->AddProcess(fDecayProcess);
282
283      // set ordering for PostStepDoIt and AtRestDoIt
284      pmanager ->SetProcessOrdering(fDecayProcess, idxPostStep);
285      pmanager ->SetProcessOrdering(fDecayProcess, idxAtRest);
286
287    }
288  }
289}
290
291//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
292
293#include "StepMax.hh"
294
295void PhysicsList::AddStepMax()
296{
297  // Step limitation seen as a process
298  StepMax* stepMaxProcess = new StepMax();
299
300  theParticleIterator->reset();
301  while ((*theParticleIterator)()){
302      G4ParticleDefinition* particle = theParticleIterator->value();
303      G4ProcessManager* pmanager = particle->GetProcessManager();
304
305      if (stepMaxProcess->IsApplicable(*particle))
306        {
307          pmanager ->AddDiscreteProcess(stepMaxProcess);
308        }
309  }
310}
311
312//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
313
314#include "G4Gamma.hh"
315#include "G4Electron.hh"
316#include "G4Positron.hh"
317
318void PhysicsList::SetCuts()
319{   
320  if (verboseLevel >0){
321    G4cout << "PhysicsList::SetCuts:";
322    G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length") << G4endl;
323  } 
324
325  // set cut values for gamma at first and for e- second and next for e+,
326  // because some processes for e+/e- need cut values for gamma
327  SetCutValue(cutForGamma, "gamma");
328  SetCutValue(cutForElectron, "e-");
329  SetCutValue(cutForPositron, "e+");
330
331  if (verboseLevel>0) DumpCutValuesTable();
332}
333
334//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
335
336void PhysicsList::SetCutForGamma(G4double cut)
337{
338  cutForGamma = cut;
339  SetParticleCuts(cutForGamma, G4Gamma::Gamma());
340}
341
342//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
343
344void PhysicsList::SetCutForElectron(G4double cut)
345{
346  cutForElectron = cut;
347  SetParticleCuts(cutForElectron, G4Electron::Electron());
348}
349
350//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
351
352void PhysicsList::SetCutForPositron(G4double cut)
353{
354  cutForPositron = cut;
355  SetParticleCuts(cutForPositron, G4Positron::Positron());
356}
357
358//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
359
360#include "G4Material.hh"
361
362void PhysicsList::GetRange(G4double val)
363{
364  G4LogicalVolume* lBox = pDet->GetWorld()->GetLogicalVolume();
365  G4ParticleTable* particleTable =  G4ParticleTable::GetParticleTable();
366  const G4MaterialCutsCouple* couple = lBox->GetMaterialCutsCouple();
367  const G4Material* currMat = lBox->GetMaterial();
368
369  G4ParticleDefinition* part;
370  G4double cut;
371  part = particleTable->FindParticle("e-");
372  cut = G4LossTableManager::Instance()->GetRange(part,val,couple);
373  G4cout << "material : " << currMat->GetName()       << G4endl;
374  G4cout << "particle : " << part->GetParticleName()  << G4endl;
375  G4cout << "energy   : " << G4BestUnit(val,"Energy") << G4endl;
376  G4cout << "range    : " << G4BestUnit(cut,"Length") << G4endl;
377}
378
379//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
380
381
Note: See TracBrowser for help on using the repository browser.