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

Last change on this file since 812 was 807, checked in by garnier, 16 years ago

update

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