Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4AdjointProcessEquivalentToDirectProcess.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//
27//
28//
29// ------------------------------------------------------------
30// GEANT 4 class implementation file
31//
32// Class Description
33//
34// This class is for adjoint process equivalent to direct process
35
36// ------------------------------------------------------------
37// Created by L.Desorgher 25 Sept. 2009 Inspired from G4WrapperProcess
38// ------------------------------------------------------------
39
41#include "G4DynamicParticle.hh"
43 G4VProcess* aProcess,
44 G4ParticleDefinition* fwd_particle_def)
45:G4VProcess(aName)
46{
47 theDirectProcess =aProcess;
48 theProcessType = theDirectProcess->GetProcessType();
49 theFwdParticleDef = fwd_particle_def;
50}
51
52
54{
55 if (theDirectProcess!=0) delete theDirectProcess;
56}
57
59{
60 theDirectProcess->ResetNumberOfInteractionLengthLeft();
61}
62
65 G4double previousStepSize,
66 G4double currentMinimumStep,
67 G4double& proposedSafety,
68 G4GPILSelection* selection )
69{
70
71
72 //Change the particle definition to the direct one
73 //------------------------------------------------
74 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle());
75 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition();
76
77 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts());
79 theDynPart->SetDefinition(theFwdParticleDef);
80
81
82 //Call the direct process
83 //----------------------
84 G4double GPIL = theDirectProcess->
86 previousStepSize,
87 currentMinimumStep,
88 proposedSafety,
89 selection );
90
91
92 //Restore the adjoint particle definition to the direct one
93 //------------------------------------------------
94 theDynPart->SetDefinition(adjPartDef);
95 theDynPart->SetPreAssignedDecayProducts(decayProducts);
96
97
98 return GPIL;
99
100}
101
105{ //Change the particle definition to the direct one
106 //------------------------------------------------
107 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle());
108 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition();
109
110 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts());
112 theDynPart->SetDefinition(theFwdParticleDef);
113
114
115 //Call the direct process
116 //----------------------
117
118
119 G4double GPIL = theDirectProcess->AtRestGetPhysicalInteractionLength( track, condition );
120
121 //Restore the adjoint particle definition to the direct one
122 //------------------------------------------------
123 theDynPart->SetDefinition(adjPartDef);
124 theDynPart->SetPreAssignedDecayProducts(decayProducts);
125
126 return GPIL;
127
128
129}
130
133 G4double previousStepSize,
135{
136 //Change the particle definition to the direct one
137 //------------------------------------------------
138 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle());
139 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition();
140
141 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts());
142
144 theDynPart->SetDefinition(theFwdParticleDef);
145
146
147 //Call the direct process
148 //----------------------
149
150
151 G4double GPIL = theDirectProcess->PostStepGetPhysicalInteractionLength( track,
152 previousStepSize,
153 condition );
154
155 //Restore the adjoint particle definition to the direct one
156 //------------------------------------------------
157 theDynPart->SetDefinition(adjPartDef);
158 theDynPart->SetPreAssignedDecayProducts(decayProducts);
159
160 return GPIL;
161
162
163}
164/*
165
166void G4AdjointProcessEquivalentToDirectProcess::SetProcessManager(const G4ProcessManager* procMan)
167{
168 theDirectProcess->SetProcessManager(procMan);
169}
170
171const G4ProcessManager* G4AdjointProcessEquivalentToDirectProcess::GetProcessManager()
172{
173 return theDirectProcess->GetProcessManager();
174}
175*/
177 const G4Step& stepData )
178{
179 //Change the particle definition to the direct one
180 //------------------------------------------------
181 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle());
182 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition();
183
184 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts());
185
187 theDynPart->SetDefinition(theFwdParticleDef);
188
189
190 //Call the direct process
191 //----------------------
192
193 G4VParticleChange* partChange = theDirectProcess->PostStepDoIt( track, stepData );
194
195
196 //Restore the adjoint particle definition to the direct one
197 //------------------------------------------------
198 theDynPart->SetDefinition(adjPartDef);
199 theDynPart->SetPreAssignedDecayProducts(decayProducts);
200
201 return partChange;
202
203
204
205}
206
208 const G4Step& stepData )
209{
210 //Change the particle definition to the direct one
211 //------------------------------------------------
212 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle());
213 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition();
214
215 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts());
216
218 theDynPart->SetDefinition(theFwdParticleDef);
219
220
221 //Call the direct process
222 //----------------------
223 G4VParticleChange* partChange =theDirectProcess->AlongStepDoIt( track, stepData );
224
225 //Restore the adjoint particle definition to the direct one
226 //------------------------------------------------
227 theDynPart->SetDefinition(adjPartDef);
228 theDynPart->SetPreAssignedDecayProducts(decayProducts);
229
230 return partChange;
231}
232
234 const G4Step& stepData )
235{
236 //Change the particle definition to the direct one
237 //------------------------------------------------
238 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle());
239 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition();
240
241 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts());
242
244 theDynPart->SetDefinition(theFwdParticleDef);
245
246
247 //Call the direct process
248 //----------------------
249 G4VParticleChange* partChange =theDirectProcess->AtRestDoIt( track, stepData );
250
251 //Restore the adjoint particle definition to the direct one
252 //------------------------------------------------
253 theDynPart->SetDefinition(adjPartDef);
254 theDynPart->SetPreAssignedDecayProducts(decayProducts);
255
256 return partChange;
257
258
259}
260
262{
263 return theDirectProcess->IsApplicable(*theFwdParticleDef);
264}
265
267{
268 return theDirectProcess->BuildPhysicsTable(*theFwdParticleDef);
269}
270
272{
273 return theDirectProcess->PreparePhysicsTable(*theFwdParticleDef);
274}
275
278 const G4String& directory,
279 G4bool ascii)
280{
281 return theDirectProcess->StorePhysicsTable(theFwdParticleDef, directory, ascii);
282}
283
286 const G4String& directory,
287 G4bool ascii)
288{
289 return theDirectProcess->RetrievePhysicsTable(theFwdParticleDef, directory, ascii);
290}
291
293{
294 //Change the particle definition to the direct one
295 //------------------------------------------------
296 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track->GetDynamicParticle());
297 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition();
298
299 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts());
301 theDynPart->SetDefinition(theFwdParticleDef);
302
303 theDirectProcess->StartTracking(track);
304
305 //Restore the adjoint particle definition to the direct one
306 //------------------------------------------------
307 theDynPart->SetDefinition(adjPartDef);
308 theDynPart->SetPreAssignedDecayProducts(decayProducts);
309
310
311 return;
312
313}
314
316{
317 theDirectProcess->EndTracking();
318}
319
G4double condition(const G4ErrorSymMatrix &m)
G4ForceCondition
G4GPILSelection
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData)
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &directory, G4bool ascii=false)
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &stepData)
virtual G4double AlongStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &directory, G4bool ascii=false)
G4AdjointProcessEquivalentToDirectProcess(const G4String &aName, G4VProcess *aProcess, G4ParticleDefinition *fwd_particle_def)
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
virtual G4double AtRestGetPhysicalInteractionLength(const G4Track &track, G4ForceCondition *condition)
virtual G4bool IsApplicable(const G4ParticleDefinition &)
virtual G4VParticleChange * AtRestDoIt(const G4Track &track, const G4Step &stepData)
virtual void PreparePhysicsTable(const G4ParticleDefinition &)
void SetPreAssignedDecayProducts(G4DecayProducts *aDecayProducts)
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
const G4DecayProducts * GetPreAssignedDecayProducts() const
G4ParticleDefinition * GetDefinition() const
Definition: G4Step.hh:62
const G4DynamicParticle * GetDynamicParticle() const
G4ProcessType theProcessType
Definition: G4VProcess.hh:346
virtual G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)=0
virtual void ResetNumberOfInteractionLengthLeft()
Definition: G4VProcess.cc:80
virtual G4VParticleChange * AtRestDoIt(const G4Track &track, const G4Step &stepData)=0
virtual G4bool RetrievePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
Definition: G4VProcess.hh:211
G4ProcessType GetProcessType() const
Definition: G4VProcess.hh:388
virtual G4VParticleChange * PostStepDoIt(const G4Track &track, const G4Step &stepData)=0
virtual G4bool IsApplicable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:182
virtual G4VParticleChange * AlongStepDoIt(const G4Track &track, const G4Step &stepData)=0
virtual void StartTracking(G4Track *)
Definition: G4VProcess.cc:87
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:187
virtual G4bool StorePhysicsTable(const G4ParticleDefinition *, const G4String &, G4bool)
Definition: G4VProcess.hh:206
virtual void PreparePhysicsTable(const G4ParticleDefinition &)
Definition: G4VProcess.hh:194
virtual G4double AtRestGetPhysicalInteractionLength(const G4Track &track, G4ForceCondition *condition)=0
virtual void EndTracking()
Definition: G4VProcess.cc:102