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