ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4AdjointProcessEquivalentToDirectProcess.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4AdjointProcessEquivalentToDirectProcess.cc
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
40
#include "
G4AdjointProcessEquivalentToDirectProcess.hh
"
41
#include "
G4DynamicParticle.hh
"
42
G4AdjointProcessEquivalentToDirectProcess::G4AdjointProcessEquivalentToDirectProcess
(
const
G4String
& aName,
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
53
G4AdjointProcessEquivalentToDirectProcess::~G4AdjointProcessEquivalentToDirectProcess
()
54
{
55
if
(
theDirectProcess
!=0)
delete
theDirectProcess
;
56
}
57
58
void
G4AdjointProcessEquivalentToDirectProcess::ResetNumberOfInteractionLengthLeft
()
59
{
60
theDirectProcess
->
ResetNumberOfInteractionLengthLeft
();
61
}
62
63
G4double
G4AdjointProcessEquivalentToDirectProcess::
64
AlongStepGetPhysicalInteractionLength
(
const
G4Track
&
track
,
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
());
78
theDynPart->
SetPreAssignedDecayProducts
((
G4DecayProducts
*)(0));
79
theDynPart->
SetDefinition
(
theFwdParticleDef
);
80
81
82
//Call the direct process
83
//----------------------
84
G4double
GPIL =
theDirectProcess
->
85
AlongStepGetPhysicalInteractionLength
( track,
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
102
G4double
G4AdjointProcessEquivalentToDirectProcess::
103
AtRestGetPhysicalInteractionLength
(
const
G4Track
&
track
,
104
G4ForceCondition
*
condition
)
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
());
111
theDynPart->
SetPreAssignedDecayProducts
((
G4DecayProducts
*)(0));
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
131
G4double
G4AdjointProcessEquivalentToDirectProcess::
132
PostStepGetPhysicalInteractionLength
(
const
G4Track
&
track
,
133
G4double
previousStepSize,
134
G4ForceCondition
*
condition
)
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
143
theDynPart->
SetPreAssignedDecayProducts
((
G4DecayProducts
*)(0));
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
166
void G4AdjointProcessEquivalentToDirectProcess::SetProcessManager(const G4ProcessManager* procMan)
167
{
168
theDirectProcess->SetProcessManager(procMan);
169
}
170
171
const G4ProcessManager* G4AdjointProcessEquivalentToDirectProcess::GetProcessManager()
172
{
173
return theDirectProcess->GetProcessManager();
174
}
175
*/
176
G4VParticleChange
*
G4AdjointProcessEquivalentToDirectProcess::PostStepDoIt
(
const
G4Track
&
track
,
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
186
theDynPart->
SetPreAssignedDecayProducts
((
G4DecayProducts
*)(0));
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
207
G4VParticleChange
*
G4AdjointProcessEquivalentToDirectProcess::AlongStepDoIt
(
const
G4Track
&
track
,
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
217
theDynPart->
SetPreAssignedDecayProducts
((
G4DecayProducts
*)(0));
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
233
G4VParticleChange
*
G4AdjointProcessEquivalentToDirectProcess::AtRestDoIt
(
const
G4Track
&
track
,
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
243
theDynPart->
SetPreAssignedDecayProducts
((
G4DecayProducts
*)(0));
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
261
G4bool
G4AdjointProcessEquivalentToDirectProcess::IsApplicable
(
const
G4ParticleDefinition
&)
262
{
263
return
theDirectProcess
->
IsApplicable
(*
theFwdParticleDef
);
264
}
265
266
void
G4AdjointProcessEquivalentToDirectProcess::BuildPhysicsTable
(
const
G4ParticleDefinition
& )
267
{
268
return
theDirectProcess
->
BuildPhysicsTable
(*
theFwdParticleDef
);
269
}
270
271
void
G4AdjointProcessEquivalentToDirectProcess::PreparePhysicsTable
(
const
G4ParticleDefinition
& )
272
{
273
return
theDirectProcess
->
PreparePhysicsTable
(*
theFwdParticleDef
);
274
}
275
276
G4bool
G4AdjointProcessEquivalentToDirectProcess::
277
StorePhysicsTable
(
const
G4ParticleDefinition
* ,
278
const
G4String
& directory,
279
G4bool
ascii)
280
{
281
return
theDirectProcess
->
StorePhysicsTable
(
theFwdParticleDef
, directory, ascii);
282
}
283
284
G4bool
G4AdjointProcessEquivalentToDirectProcess::
285
RetrievePhysicsTable
(
const
G4ParticleDefinition
* ,
286
const
G4String
& directory,
287
G4bool
ascii)
288
{
289
return
theDirectProcess
->
RetrievePhysicsTable
(
theFwdParticleDef
, directory, ascii);
290
}
291
292
void
G4AdjointProcessEquivalentToDirectProcess::StartTracking
(
G4Track
*
track
)
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
());
300
theDynPart->
SetPreAssignedDecayProducts
((
G4DecayProducts
*)(0));
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
315
void
G4AdjointProcessEquivalentToDirectProcess::EndTracking
()
316
{
317
theDirectProcess
->
EndTracking
();
318
}
319
geant4
tree
geant4-10.6-release
source
processes
electromagnetic
adjoint
src
G4AdjointProcessEquivalentToDirectProcess.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:28
using
1.8.2 with
ECCE GitHub integration