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 // 26 // 27 /// \file GB05BOptrSplitAndKillByCrossSection. 27 /// \file GB05BOptrSplitAndKillByCrossSection.cc 28 /// \brief Implementation of the GB05BOptrSpli 28 /// \brief Implementation of the GB05BOptrSplitAndKillByCrossSection class 29 29 30 #include "GB05BOptrSplitAndKillByCrossSection. 30 #include "GB05BOptrSplitAndKillByCrossSection.hh" 31 << 31 #include "G4BiasingProcessInterface.hh" 32 #include "GB05BOptnSplitAndKillByCrossSection. 32 #include "GB05BOptnSplitAndKillByCrossSection.hh" 33 33 34 #include "G4BiasingProcessInterface.hh" << 35 #include "G4ParticleDefinition.hh" 34 #include "G4ParticleDefinition.hh" 36 #include "G4ParticleTable.hh" 35 #include "G4ParticleTable.hh" 37 #include "G4VProcess.hh" 36 #include "G4VProcess.hh" 38 37 39 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 40 39 41 GB05BOptrSplitAndKillByCrossSection::GB05BOptr << 40 GB05BOptrSplitAndKillByCrossSection:: 42 << 41 GB05BOptrSplitAndKillByCrossSection(G4String particleName, 43 : G4VBiasingOperator(name), fSetup(true) << 42 G4String name) >> 43 : G4VBiasingOperator(name), >> 44 fSetup(true) 44 { 45 { 45 fParticleToBias = G4ParticleTable::GetPartic 46 fParticleToBias = G4ParticleTable::GetParticleTable()->FindParticle(particleName); 46 47 47 if (fParticleToBias == 0) { << 48 if ( fParticleToBias == 0 ) 48 G4ExceptionDescription ed; << 49 { 49 ed << "Particle `" << particleName << "' n << 50 G4ExceptionDescription ed; 50 G4Exception("GB05BOptrSplitAndKillByCrossS << 51 ed << "Particle `" << particleName << "' not found !" << G4endl; 51 } << 52 G4Exception("GB05BOptrSplitAndKillByCrossSection(...)", 52 << 53 "exGB05.01", >> 54 JustWarning, >> 55 ed); >> 56 } >> 57 53 fSplitAndKillByCrossSection = 58 fSplitAndKillByCrossSection = 54 new GB05BOptnSplitAndKillByCrossSection("s << 59 new GB05BOptnSplitAndKillByCrossSection("splitterFor_"+particleName); >> 60 55 } 61 } 56 62 57 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 64 59 GB05BOptrSplitAndKillByCrossSection::~GB05BOpt 65 GB05BOptrSplitAndKillByCrossSection::~GB05BOptrSplitAndKillByCrossSection() 60 { 66 { 61 delete fSplitAndKillByCrossSection; 67 delete fSplitAndKillByCrossSection; 62 } 68 } 63 69 64 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 71 66 void GB05BOptrSplitAndKillByCrossSection::Star 72 void GB05BOptrSplitAndKillByCrossSection::StartRun() 67 { 73 { 68 // --------------- 74 // --------------- 69 // -- Setup stage: 75 // -- Setup stage: 70 // --------------- 76 // --------------- 71 // -- Start by collecting the pointer of the 77 // -- Start by collecting the pointer of the physics processes 72 // -- considered for the splitting by cross- 78 // -- considered for the splitting by cross-sections. Doing so, 73 // -- this also verifies that these physics 79 // -- this also verifies that these physics processes are each 74 // -- under control of a G4BiasingProcessInt 80 // -- under control of a G4BiasingProcessInterface wrapper. 75 if (fSetup) { << 81 if ( fSetup ) 76 const G4ProcessManager* processManager = f << 82 { 77 const G4BiasingProcessSharedData* sharedDa << 83 const G4ProcessManager* processManager = fParticleToBias->GetProcessManager(); 78 G4BiasingProcessInterface::GetSharedData << 84 const G4BiasingProcessSharedData* sharedData = 79 if (sharedData) { << 85 G4BiasingProcessInterface::GetSharedData( processManager ); 80 for (size_t i = 0; i < fProcessesToEquip << 86 if ( sharedData ) 81 G4bool processFound(false); << 87 { 82 for (size_t j = 0; j < (sharedData->Ge << 88 for ( size_t i = 0 ; i < fProcessesToEquipoise.size() ; i++ ) 83 const G4BiasingProcessInterface* wra << 89 { 84 (sharedData->GetPhysicsBiasingProc << 90 G4bool processFound(false); 85 if (fProcessesToEquipoise[i] == wrap << 91 for ( size_t j = 0 ; 86 fProcesses.push_back(wrapperProces << 92 j < (sharedData->GetPhysicsBiasingProcessInterfaces()).size(); 87 processFound = true; << 93 j++ ) 88 break; << 94 { 89 } << 95 const G4BiasingProcessInterface* wrapperProcess = >> 96 (sharedData->GetPhysicsBiasingProcessInterfaces())[j]; >> 97 if ( fProcessesToEquipoise[i] == >> 98 wrapperProcess->GetWrappedProcess()->GetProcessName() ) >> 99 { >> 100 fProcesses.push_back( wrapperProcess->GetWrappedProcess() ); >> 101 processFound = true; >> 102 break; >> 103 } >> 104 } >> 105 if ( !processFound ) >> 106 { >> 107 G4String particleName = "(unknown)"; >> 108 if ( fParticleToBias != nullptr ) >> 109 { >> 110 particleName = fParticleToBias->GetParticleName(); >> 111 } >> 112 G4ExceptionDescription ed; >> 113 ed << "Process `" << fProcessesToEquipoise[i] >> 114 << "' not found for particle `" << particleName << "'" >> 115 << G4endl; >> 116 G4Exception("GB05BOptrSplitAndKillByCrossSection::StartRun(...)", >> 117 "exGB05.02", >> 118 JustWarning, >> 119 ed); >> 120 } >> 121 } 90 } 122 } 91 if (!processFound) { << 123 fSetup = false; 92 G4String particleName = "(unknown)"; << 124 } 93 if (fParticleToBias != nullptr) { << 125 94 particleName = fParticleToBias->Ge << 126 if ( fProcessesToEquipoise.size() == 0 || fProcesses.size() == 0 ) 95 } << 127 { 96 G4ExceptionDescription ed; << 128 G4ExceptionDescription ed; 97 ed << "Process `" << fProcessesToEqu << 129 ed << "No processes to counterbalance for defined or found ! " 98 << particleName << "'" << G4endl; << 130 << "Biasing will do nothing." 99 G4Exception("GB05BOptrSplitAndKillBy << 131 << G4endl; 100 JustWarning, ed); << 132 G4Exception("GB05BOptrSplitAndKillByCrossSection::StartRun(...)", 101 } << 133 "exGB05.03", 102 } << 134 JustWarning, >> 135 ed); 103 } 136 } 104 fSetup = false; << 105 } << 106 137 107 if (fProcessesToEquipoise.size() == 0 || fPr << 108 G4ExceptionDescription ed; << 109 ed << "No processes to counterbalance for << 110 << "Biasing will do nothing." << G4endl << 111 G4Exception("GB05BOptrSplitAndKillByCrossS << 112 } << 113 } 138 } 114 139 115 //....oooOO0OOooo........oooOO0OOooo........oo 140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 116 141 117 G4VBiasingOperation* GB05BOptrSplitAndKillByCr << 142 G4VBiasingOperation* 118 const G4Track* track, const G4BiasingProcess << 143 GB05BOptrSplitAndKillByCrossSection:: >> 144 ProposeNonPhysicsBiasingOperation(const G4Track* track, >> 145 const G4BiasingProcessInterface* /*callingProcess*/) 119 { 146 { >> 147 120 // ----------------------------------------- 148 // ----------------------------------------------------- 121 // -- Check if current particle type is the 149 // -- Check if current particle type is the one to bias: 122 // ----------------------------------------- 150 // ----------------------------------------------------- 123 if (track->GetDefinition() != fParticleToBia << 151 if ( track->GetDefinition() != fParticleToBias ) return 0; 124 152 125 // ----------------------------------------- 153 // -------------------------------------------------------------------- 126 // -- Compute the total cross-section for th 154 // -- Compute the total cross-section for the physics processes 127 // -- considered. 155 // -- considered. 128 // -- These physics processes have been upda 156 // -- These physics processes have been updated to the current track 129 // -- state by their related wrapper G4Biasi 157 // -- state by their related wrapper G4BiasingProcessInterface objects, 130 // -- the cross-sections/mean free pathes ar 158 // -- the cross-sections/mean free pathes are hence usable. 131 // ----------------------------------------- 159 // -------------------------------------------------------------------- 132 G4double totalCrossSection(0.0); 160 G4double totalCrossSection(0.0); 133 for (size_t i = 0; i < fProcesses.size(); i+ << 161 for ( size_t i = 0 ; i < fProcesses.size() ; i++ ) 134 G4double interactionLength = fProcesses[i] << 162 { 135 if (interactionLength < DBL_MAX / 10.) tot << 163 G4double interactionLength = fProcesses[i]->GetCurrentInteractionLength(); 136 } << 164 if ( interactionLength < DBL_MAX/10. ) 137 if (totalCrossSection < DBL_MIN) return 0; << 165 totalCrossSection += 1./interactionLength; 138 << 166 } 139 G4double totalInteractionLength = 1. / total << 167 if ( totalCrossSection < DBL_MIN ) return 0; 140 168 >> 169 G4double totalInteractionLength = 1./totalCrossSection; >> 170 141 // ----------------------------------------- 171 // --------------------------------------------------------------------- 142 // -- Passes the updated "absorption" cross- 172 // -- Passes the updated "absorption" cross-section (interaction length) 143 // -- to the biasing operation, and returns 173 // -- to the biasing operation, and returns this operation: 144 // ----------------------------------------- 174 // --------------------------------------------------------------------- 145 fSplitAndKillByCrossSection->SetInteractionL << 175 fSplitAndKillByCrossSection->SetInteractionLength( totalInteractionLength ); 146 << 176 147 return fSplitAndKillByCrossSection; 177 return fSplitAndKillByCrossSection; >> 178 148 } 179 } 149 180 150 void GB05BOptrSplitAndKillByCrossSection::AddP << 181 void GB05BOptrSplitAndKillByCrossSection:: >> 182 AddProcessToEquipoise(G4String processName) 151 { 183 { 152 fProcessesToEquipoise.push_back(processName) << 184 fProcessesToEquipoise.push_back( processName ); 153 } 185 } 154 186