Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // >> 27 // $Id: G4AdjointProcessEquivalentToDirectProcess.cc 69844 2013-05-16 09:19:33Z gcosmo $ >> 28 // >> 29 // 26 // ------------------------------------------- 30 // ------------------------------------------------------------ >> 31 // GEANT 4 class implementation file 27 // 32 // 28 // This class is for adjoint process equivalen << 33 // Class Description 29 // 34 // >> 35 // This class is for adjoint process equivalent to direct process >> 36 30 // ------------------------------------------- 37 // ------------------------------------------------------------ 31 // Created by L.Desorgher 25 Sept. << 38 // Created by L.Desorgher 25 Sept. 2009 Inspired from G4WrapperProcess 32 // ------------------------------------------- 39 // ------------------------------------------------------------ 33 40 34 #include "G4AdjointProcessEquivalentToDirectPr 41 #include "G4AdjointProcessEquivalentToDirectProcess.hh" 35 << 36 #include "G4DynamicParticle.hh" 42 #include "G4DynamicParticle.hh" 37 #include "G4ParticleDefinition.hh" << 43 G4AdjointProcessEquivalentToDirectProcess::G4AdjointProcessEquivalentToDirectProcess(const G4String& aName, 38 #include "G4VProcess.hh" << 44 G4VProcess* aProcess, 39 << 45 G4ParticleDefinition* fwd_particle_def) 40 G4AdjointProcessEquivalentToDirectProcess:: << 46 :G4VProcess(aName) 41 G4AdjointProcessEquivalentToDirectProcess( << 47 { 42 const G4String& aName, G4VProcess* aProces << 48 theDirectProcess =aProcess; 43 G4ParticleDefinition* fwd_particle_def) << 49 theProcessType = theDirectProcess->GetProcessType(); 44 : G4VProcess(aName) << 50 theFwdParticleDef = fwd_particle_def; 45 { << 46 fDirectProcess = aProcess; << 47 theProcessType = fDirectProcess->GetProcess << 48 fFwdParticleDef = fwd_particle_def; << 49 } 51 } 50 52 51 G4AdjointProcessEquivalentToDirectProcess:: << 53 52 ~G4AdjointProcessEquivalentToDirectProcess() << 54 G4AdjointProcessEquivalentToDirectProcess::~G4AdjointProcessEquivalentToDirectProcess() 53 { 55 { 54 if(fDirectProcess != nullptr) << 56 if (theDirectProcess!=0) delete theDirectProcess; 55 delete fDirectProcess; << 56 } 57 } 57 58 58 void G4AdjointProcessEquivalentToDirectProcess << 59 void G4AdjointProcessEquivalentToDirectProcess::ResetNumberOfInteractionLengthLeft() 59 ResetNumberOfInteractionLengthLeft() << 60 { 60 { 61 fDirectProcess->ResetNumberOfInteractionLeng << 61 theDirectProcess->ResetNumberOfInteractionLengthLeft(); 62 } 62 } 63 63 64 G4double G4AdjointProcessEquivalentToDirectPro 64 G4double G4AdjointProcessEquivalentToDirectProcess:: 65 AlongStepGetPhysicalInteractionLength(const << 65 AlongStepGetPhysicalInteractionLength( const G4Track& track, 66 G4doub << 66 G4double previousStepSize, 67 G4doub << 67 G4double currentMinimumStep, 68 G4doub << 68 G4double& proposedSafety, 69 G4GPIL << 69 G4GPILSelection* selection ) 70 { << 70 { 71 // Change the particle definition to the dir << 71 72 G4DynamicParticle* theDynPart = << 72 73 const_cast<G4DynamicParticle*>(track.GetDy << 73 //Change the particle definition to the direct one 74 G4ParticleDefinition* adjPartDef = theDynPar << 74 //------------------------------------------------ 75 << 75 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle()); 76 G4DecayProducts* decayProducts = << 76 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition(); 77 const_cast<G4DecayProducts*>(theDynPart->G << 77 78 theDynPart->SetPreAssignedDecayProducts((G4D << 78 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts()); 79 theDynPart->SetDefinition(fFwdParticleDef); << 79 theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0)); 80 << 80 theDynPart->SetDefinition(theFwdParticleDef); 81 // Call the direct process << 81 82 G4double GPIL = fDirectProcess->AlongStepGet << 82 83 track, previousStepSize, currentMinimumSte << 83 //Call the direct process 84 << 84 //---------------------- 85 // Restore the adjoint particle definition t << 85 G4double GPIL = theDirectProcess-> >> 86 AlongStepGetPhysicalInteractionLength( track, >> 87 previousStepSize, >> 88 currentMinimumStep, >> 89 proposedSafety, >> 90 selection ); >> 91 >> 92 >> 93 //Restore the adjoint particle definition to the direct one >> 94 //------------------------------------------------ 86 theDynPart->SetDefinition(adjPartDef); 95 theDynPart->SetDefinition(adjPartDef); 87 theDynPart->SetPreAssignedDecayProducts(deca 96 theDynPart->SetPreAssignedDecayProducts(decayProducts); 88 << 97 >> 98 89 return GPIL; 99 return GPIL; >> 100 90 } 101 } 91 102 92 G4double << 103 G4double G4AdjointProcessEquivalentToDirectProcess:: 93 G4AdjointProcessEquivalentToDirectProcess::AtR << 104 AtRestGetPhysicalInteractionLength( const G4Track& track, 94 const G4Track& track, G4ForceCondition* cond << 105 G4ForceCondition* condition ) 95 { << 106 { //Change the particle definition to the direct one 96 // Change the particle definition to the dir << 107 //------------------------------------------------ 97 G4DynamicParticle* theDynPart = << 108 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle()); 98 const_cast<G4DynamicParticle*>(track.GetDy << 99 G4ParticleDefinition* adjPartDef = theDynPar 109 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition(); 100 << 110 101 G4DecayProducts* decayProducts = << 111 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts()); 102 const_cast<G4DecayProducts*>(theDynPart->G << 112 theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0)); 103 theDynPart->SetPreAssignedDecayProducts((G4D << 113 theDynPart->SetDefinition(theFwdParticleDef); 104 theDynPart->SetDefinition(fFwdParticleDef); << 114 105 << 115 106 // Call the direct process << 116 //Call the direct process 107 G4double GPIL = << 117 //---------------------- 108 fDirectProcess->AtRestGetPhysicalInteracti << 118 109 << 119 110 // Restore the adjoint particle definition t << 120 G4double GPIL = theDirectProcess->AtRestGetPhysicalInteractionLength( track, condition ); >> 121 >> 122 //Restore the adjoint particle definition to the direct one >> 123 //------------------------------------------------ 111 theDynPart->SetDefinition(adjPartDef); 124 theDynPart->SetDefinition(adjPartDef); 112 theDynPart->SetPreAssignedDecayProducts(deca 125 theDynPart->SetPreAssignedDecayProducts(decayProducts); 113 << 126 114 return GPIL; 127 return GPIL; >> 128 >> 129 115 } 130 } 116 131 117 G4double << 132 G4double G4AdjointProcessEquivalentToDirectProcess:: 118 G4AdjointProcessEquivalentToDirectProcess::Pos << 133 PostStepGetPhysicalInteractionLength( const G4Track& track, 119 const G4Track& track, G4double previousStepS << 134 G4double previousStepSize, 120 { << 135 G4ForceCondition* condition ) 121 // Change the particle definition to the dir << 136 { 122 G4DynamicParticle* theDynPart = << 137 //Change the particle definition to the direct one 123 const_cast<G4DynamicParticle*>(track.GetDy << 138 //------------------------------------------------ >> 139 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle()); 124 G4ParticleDefinition* adjPartDef = theDynPar 140 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition(); 125 << 141 126 G4DecayProducts* decayProducts = << 142 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts()); 127 const_cast<G4DecayProducts*>(theDynPart->G << 143 128 << 144 theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0)); 129 theDynPart->SetPreAssignedDecayProducts((G4D << 145 theDynPart->SetDefinition(theFwdParticleDef); 130 theDynPart->SetDefinition(fFwdParticleDef); << 146 131 << 147 132 // Call the direct process << 148 //Call the direct process 133 G4double GPIL = fDirectProcess->PostStepGetP << 149 //---------------------- 134 track, previousStepSize, condition); << 150 135 << 151 136 // Restore the adjoint particle definition t << 152 G4double GPIL = theDirectProcess->PostStepGetPhysicalInteractionLength( track, >> 153 previousStepSize, >> 154 condition ); >> 155 >> 156 //Restore the adjoint particle definition to the direct one >> 157 //------------------------------------------------ 137 theDynPart->SetDefinition(adjPartDef); 158 theDynPart->SetDefinition(adjPartDef); 138 theDynPart->SetPreAssignedDecayProducts(deca 159 theDynPart->SetPreAssignedDecayProducts(decayProducts); 139 << 160 140 return GPIL; << 161 return GPIL; >> 162 >> 163 >> 164 } >> 165 /* >> 166 >> 167 void G4AdjointProcessEquivalentToDirectProcess::SetProcessManager(const G4ProcessManager* procMan) >> 168 { >> 169 theDirectProcess->SetProcessManager(procMan); 141 } 170 } 142 171 143 G4VParticleChange* G4AdjointProcessEquivalentT << 172 const G4ProcessManager* G4AdjointProcessEquivalentToDirectProcess::GetProcessManager() 144 const G4Track& track, const G4Step& stepData << 173 { >> 174 return theDirectProcess->GetProcessManager(); >> 175 } >> 176 */ >> 177 G4VParticleChange* G4AdjointProcessEquivalentToDirectProcess::PostStepDoIt( const G4Track& track, >> 178 const G4Step& stepData ) 145 { 179 { 146 // Change the particle definition to the dir << 180 //Change the particle definition to the direct one 147 G4DynamicParticle* theDynPart = << 181 //------------------------------------------------ 148 const_cast<G4DynamicParticle*>(track.GetDy << 182 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle()); 149 G4ParticleDefinition* adjPartDef = theDynPar 183 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition(); 150 << 184 151 G4DecayProducts* decayProducts = << 185 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts()); 152 const_cast<G4DecayProducts*>(theDynPart->G << 186 153 << 187 theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0)); 154 theDynPart->SetPreAssignedDecayProducts((G4D << 188 theDynPart->SetDefinition(theFwdParticleDef); 155 theDynPart->SetDefinition(fFwdParticleDef); << 189 156 << 190 157 // Call the direct process << 191 //Call the direct process 158 G4VParticleChange* partChange = fDirectProce << 192 //---------------------- 159 << 193 160 // Restore the adjoint particle definition t << 194 G4VParticleChange* partChange = theDirectProcess->PostStepDoIt( track, stepData ); >> 195 >> 196 >> 197 //Restore the adjoint particle definition to the direct one >> 198 //------------------------------------------------ 161 theDynPart->SetDefinition(adjPartDef); 199 theDynPart->SetDefinition(adjPartDef); 162 theDynPart->SetPreAssignedDecayProducts(deca 200 theDynPart->SetPreAssignedDecayProducts(decayProducts); 163 << 201 164 return partChange; 202 return partChange; >> 203 >> 204 >> 205 165 } 206 } 166 207 167 G4VParticleChange* G4AdjointProcessEquivalentT << 208 G4VParticleChange* G4AdjointProcessEquivalentToDirectProcess::AlongStepDoIt( const G4Track& track, 168 const G4Track& track, const G4Step& stepData << 209 const G4Step& stepData ) 169 { << 210 { 170 // Change the particle definition to the dir << 211 //Change the particle definition to the direct one 171 G4DynamicParticle* theDynPart = << 212 //------------------------------------------------ 172 const_cast<G4DynamicParticle*>(track.GetDy << 213 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle()); 173 G4ParticleDefinition* adjPartDef = theDynPar 214 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition(); 174 << 215 175 G4DecayProducts* decayProducts = << 216 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts()); 176 const_cast<G4DecayProducts*>(theDynPart->G << 217 177 << 218 theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0)); 178 theDynPart->SetPreAssignedDecayProducts((G4D << 219 theDynPart->SetDefinition(theFwdParticleDef); 179 theDynPart->SetDefinition(fFwdParticleDef); << 220 180 << 221 181 // Call the direct process << 222 //Call the direct process 182 G4VParticleChange* partChange = << 223 //---------------------- 183 fDirectProcess->AlongStepDoIt(track, stepD << 224 G4VParticleChange* partChange =theDirectProcess->AlongStepDoIt( track, stepData ); 184 << 225 185 // Restore the adjoint particle definition t << 226 //Restore the adjoint particle definition to the direct one >> 227 //------------------------------------------------ 186 theDynPart->SetDefinition(adjPartDef); 228 theDynPart->SetDefinition(adjPartDef); 187 theDynPart->SetPreAssignedDecayProducts(deca 229 theDynPart->SetPreAssignedDecayProducts(decayProducts); 188 << 230 189 return partChange; << 231 return partChange; 190 } 232 } 191 << 233 192 G4VParticleChange* G4AdjointProcessEquivalentT << 234 G4VParticleChange* G4AdjointProcessEquivalentToDirectProcess::AtRestDoIt( const G4Track& track, 193 const G4Track& track, const G4Step& stepData << 235 const G4Step& stepData ) 194 { << 236 { 195 // Change the particle definition to the dir << 237 //Change the particle definition to the direct one 196 G4DynamicParticle* theDynPart = << 238 //------------------------------------------------ 197 const_cast<G4DynamicParticle*>(track.GetDy << 239 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track.GetDynamicParticle()); 198 G4ParticleDefinition* adjPartDef = theDynPar 240 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition(); 199 << 241 200 G4DecayProducts* decayProducts = << 242 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts()); 201 const_cast<G4DecayProducts*>(theDynPart->G << 243 202 << 244 theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0)); 203 theDynPart->SetPreAssignedDecayProducts((G4D << 245 theDynPart->SetDefinition(theFwdParticleDef); 204 theDynPart->SetDefinition(fFwdParticleDef); << 246 205 << 247 206 // Call the direct process << 248 //Call the direct process 207 G4VParticleChange* partChange = fDirectProce << 249 //---------------------- 208 << 250 G4VParticleChange* partChange =theDirectProcess->AtRestDoIt( track, stepData ); 209 // Restore the adjoint particle definition t << 251 >> 252 //Restore the adjoint particle definition to the direct one >> 253 //------------------------------------------------ 210 theDynPart->SetDefinition(adjPartDef); 254 theDynPart->SetDefinition(adjPartDef); 211 theDynPart->SetPreAssignedDecayProducts(deca 255 theDynPart->SetPreAssignedDecayProducts(decayProducts); 212 << 256 213 return partChange; << 257 return partChange; >> 258 >> 259 214 } 260 } 215 261 216 G4bool G4AdjointProcessEquivalentToDirectProce << 262 G4bool G4AdjointProcessEquivalentToDirectProcess::IsApplicable(const G4ParticleDefinition&) 217 const G4ParticleDefinition&) << 218 { 263 { 219 return fDirectProcess->IsApplicable(*fFwdPar << 264 return theDirectProcess->IsApplicable(*theFwdParticleDef); 220 } 265 } 221 266 222 void G4AdjointProcessEquivalentToDirectProcess << 267 void G4AdjointProcessEquivalentToDirectProcess::BuildPhysicsTable(const G4ParticleDefinition& ) 223 const G4ParticleDefinition&) << 224 { 268 { 225 return fDirectProcess->BuildPhysicsTable(*fF << 269 return theDirectProcess->BuildPhysicsTable(*theFwdParticleDef); 226 } 270 } 227 271 228 void G4AdjointProcessEquivalentToDirectProcess << 272 void G4AdjointProcessEquivalentToDirectProcess::PreparePhysicsTable(const G4ParticleDefinition& ) 229 const G4ParticleDefinition&) << 230 { 273 { 231 return fDirectProcess->PreparePhysicsTable(* << 274 return theDirectProcess->PreparePhysicsTable(*theFwdParticleDef); 232 } 275 } 233 276 234 G4bool G4AdjointProcessEquivalentToDirectProce << 277 G4bool G4AdjointProcessEquivalentToDirectProcess:: 235 const G4ParticleDefinition*, const G4String& << 278 StorePhysicsTable(const G4ParticleDefinition* , >> 279 const G4String& directory, >> 280 G4bool ascii) 236 { 281 { 237 return fDirectProcess->StorePhysicsTable(fFw << 282 return theDirectProcess->StorePhysicsTable(theFwdParticleDef, directory, ascii); 238 } << 283 } 239 << 284 240 G4bool G4AdjointProcessEquivalentToDirectProce << 285 G4bool G4AdjointProcessEquivalentToDirectProcess:: 241 const G4ParticleDefinition*, const G4String& << 286 RetrievePhysicsTable( const G4ParticleDefinition* , >> 287 const G4String& directory, >> 288 G4bool ascii) 242 { 289 { 243 return fDirectProcess->RetrievePhysicsTable( << 290 return theDirectProcess->RetrievePhysicsTable(theFwdParticleDef, directory, ascii); 244 << 291 } 245 } << 246 292 247 void G4AdjointProcessEquivalentToDirectProcess 293 void G4AdjointProcessEquivalentToDirectProcess::StartTracking(G4Track* track) 248 { 294 { 249 // Change the particle definition to the dir << 295 //Change the particle definition to the direct one 250 G4DynamicParticle* theDynPart = << 296 //------------------------------------------------ 251 const_cast<G4DynamicParticle*>(track->GetD << 297 G4DynamicParticle* theDynPart = const_cast<G4DynamicParticle*> (track->GetDynamicParticle()); 252 G4ParticleDefinition* adjPartDef = theDynPar 298 G4ParticleDefinition* adjPartDef = theDynPart->GetDefinition(); 253 << 299 254 G4DecayProducts* decayProducts = << 300 G4DecayProducts* decayProducts = const_cast<G4DecayProducts*> (theDynPart->GetPreAssignedDecayProducts()); 255 const_cast<G4DecayProducts*>(theDynPart->G << 301 theDynPart->SetPreAssignedDecayProducts((G4DecayProducts*)(0)); 256 theDynPart->SetPreAssignedDecayProducts((G4D << 302 theDynPart->SetDefinition(theFwdParticleDef); 257 theDynPart->SetDefinition(fFwdParticleDef); << 303 258 << 304 theDirectProcess->StartTracking(track); 259 fDirectProcess->StartTracking(track); << 305 260 << 306 //Restore the adjoint particle definition to the direct one 261 // Restore the adjoint particle definition t << 307 //------------------------------------------------ 262 theDynPart->SetDefinition(adjPartDef); 308 theDynPart->SetDefinition(adjPartDef); 263 theDynPart->SetPreAssignedDecayProducts(deca 309 theDynPart->SetPreAssignedDecayProducts(decayProducts); 264 << 310 265 return; << 311 >> 312 return; >> 313 266 } 314 } 267 315 268 void G4AdjointProcessEquivalentToDirectProcess 316 void G4AdjointProcessEquivalentToDirectProcess::EndTracking() 269 { 317 { 270 fDirectProcess->EndTracking(); << 318 theDirectProcess->EndTracking(); 271 } 319 } >> 320 272 321