ECCE @ EIC Software
 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 
41 #include "G4DynamicParticle.hh"
43  G4VProcess* aProcess,
44  G4ParticleDefinition* fwd_particle_def)
45 :G4VProcess(aName)
46 {
47  theDirectProcess =aProcess;
49  theFwdParticleDef = fwd_particle_def;
50 }
51 
52 
54 {
55  if (theDirectProcess!=0) delete theDirectProcess;
56 }
57 
59 {
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());
111  theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0));
112  theDynPart->SetDefinition(theFwdParticleDef);
113 
114 
115  //Call the direct process
116  //----------------------
117 
118 
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 
143  theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0));
144  theDynPart->SetDefinition(theFwdParticleDef);
145 
146 
147  //Call the direct process
148  //----------------------
149 
150 
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 */
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 
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 
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 
262 {
264 }
265 
267 {
269 }
270 
272 {
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());
300  theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0));
301  theDynPart->SetDefinition(theFwdParticleDef);
302 
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 {
318 }
319