source: trunk/examples/advanced/radiation_monitor/physics/src/RadmonPhysicsList.cc @ 807

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

update

File size: 6.4 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// File name:     RadmonPhysicsList.cc
28// Creation date: Nov 2005
29// Main author:   Riccardo Capra <capra@ge.infn.it>
30//
31// Id:            $Id: RadmonPhysicsList.cc,v 1.6 2006/06/29 16:18:57 gunter Exp $
32// Tag:           $Name:  $
33//
34
35// Include files
36#include "RadmonPhysicsList.hh"
37
38#include "RadmonVPhysicsLayout.hh"
39#include "RadmonVSubPhysicsList.hh"
40#include "RadmonVSubPhysicsListFactory.hh"
41#include "RadmonPhysicsInfoList.hh"
42#include "RadmonSteppingAction.hh"
43#include "RadmonPhysicsSteppingAction.hh"
44
45                                                RadmonPhysicsList :: RadmonPhysicsList(RadmonVPhysicsLayout * layout, RadmonVSubPhysicsListFactory * factory)
46:
47 physicsLayout(layout),
48 subPhysicsListFactory(factory),
49 steppingAction(0),
50 initializationMethodsCalled(false),
51 changed(true)
52{
53 if (physicsLayout==0)
54  G4Exception("RadmonPhysicsList::RadmonPhysicsList: layout==0.");
55
56 if (factory==0)
57  G4Exception("RadmonPhysicsList::RadmonPhysicsList: factory==0.");
58 
59 physicsLayout->AttachObserver(this);
60}
61
62
63
64                                                RadmonPhysicsList :: ~RadmonPhysicsList()
65{
66 physicsLayout->DetachObserver(this);
67 
68 if (steppingAction)
69 {
70  RadmonSteppingAction::Instance()->DetachObserver(steppingAction);
71  delete steppingAction;
72 }
73 
74 Destruct();
75 
76 delete subPhysicsListFactory;
77}
78
79
80
81
82
83void                                            RadmonPhysicsList :: OnLayoutChange(void)
84{
85 if (initializationMethodsCalled)
86 {
87  G4cout << "RadmonPhysicsList::OnLayoutChange: Physics initialization done, changes to the physics will be ignored" << G4endl;
88  return;
89 }
90 
91 changed=true;
92}
93
94
95
96
97
98void                                            RadmonPhysicsList :: ConstructParticle(void)
99{
100}
101
102
103
104void                                            RadmonPhysicsList :: ConstructProcess(void)
105{
106 CheckUpdate();
107 initializationMethodsCalled=true;
108 
109 if (!steppingAction)
110 {
111  steppingAction=new RadmonPhysicsSteppingAction;
112  RadmonSteppingAction::Instance()->AttachObserver(steppingAction);
113 }
114 
115 SubPhysiscsLists::iterator i(subPhysiscsLists.begin());
116 const SubPhysiscsLists::iterator end(subPhysiscsLists.end());
117 
118 while (i!=end)
119 {
120  (*i)->ConstructParticle();
121 
122  i++;
123 }
124 
125 UpdateProcessManagers();
126
127 i=subPhysiscsLists.begin();
128 while (i!=end)
129 {
130  (*i)->ConstructProcess();
131  UpdateProcessManagers();
132 
133  i++;
134 }
135
136 AddTransportation();
137}
138
139
140
141void                                            RadmonPhysicsList :: SetCuts(void)
142{
143 CheckUpdate();
144 initializationMethodsCalled=true;
145
146 SubPhysiscsLists::iterator i(subPhysiscsLists.begin());
147 const SubPhysiscsLists::iterator end(subPhysiscsLists.end());
148 
149 while (i!=end)
150 {
151  (*i)->ConstructParticle();
152 
153  i++;
154 }
155
156 i=subPhysiscsLists.begin();
157 while (i!=end)
158 {
159  (*i)->SetCuts();
160 
161  i++;
162 }
163}
164
165
166
167
168
169void                                            RadmonPhysicsList :: Destruct(void)
170{
171 SubPhysiscsLists::iterator i(subPhysiscsLists.begin());
172 const SubPhysiscsLists::iterator end(subPhysiscsLists.end());
173 
174 while (i!=end)
175 {
176  delete (*i);
177 
178  i++;
179 }
180 
181 subPhysiscsLists.clear();
182}
183
184
185
186
187
188void                                            RadmonPhysicsList :: CheckUpdate(void)
189{
190 if (!changed)
191  return;
192 
193 changed=false;
194 
195 Destruct();
196 
197 const G4int n(physicsLayout->GetNPhysicsLists());
198 
199 for (G4int i(0); i<n; i++)
200 {
201  G4String name(physicsLayout->GetPhysicsListName(i));
202 
203  RadmonVSubPhysicsList * subPhysicsList(subPhysicsListFactory->CreateSubPhysicsList(name));
204 
205  if (subPhysicsList!=0)
206  {
207   G4int j(physicsLayout->GetPhysicsListNAttributes(name));
208   
209   while (j>0)
210   {
211    j--;
212   
213    const G4String & attributeName(physicsLayout->GetPhysicsListAttributeName(name, j));
214    subPhysicsList->SetPhysicsListAttribute(attributeName, physicsLayout->GetPhysicsListAttribute(name, attributeName));
215   }
216   
217   SubPhysiscsLists::const_iterator k(subPhysiscsLists.begin());
218   const SubPhysiscsLists::const_iterator end(subPhysiscsLists.end());
219   
220   while (k!=end)
221   {
222    if (subPhysicsList->Provides().CollidesWith((*k)->Provides()))
223     G4cout << "RadmonPhysicsList::OnLayoutChange: Warning physics list \"" << name << "\" provides features common to other physics list." << G4endl;
224
225    k++;
226   }
227   
228   subPhysiscsLists.push_back(subPhysicsList);
229  }
230  else
231   G4cout << "RadmonPhysicsList::OnLayoutChange: Physics list with name \"" << name << "\" not found." << G4endl;
232 }
233}
234
235
236
237
238
239void                                            RadmonPhysicsList :: UpdateProcessManagers(void)
240{
241 G4ParticleTable * particleTable(G4ParticleTable::GetParticleTable());
242 G4ParticleTable::G4PTblDicIterator & particleIterator(*particleTable->GetIterator());
243 
244 particleIterator.reset();
245 while (particleIterator())
246 {
247  G4ParticleDefinition * particle(particleIterator.value());
248 
249  if (particle->GetProcessManager()==0)
250   AddProcessManager(particle);
251 }
252}
253
Note: See TracBrowser for help on using the repository browser.