Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ChannelingOptrChangeCrossSection.cc
Go to the documentation of this file.
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//
29
31#include "G4ParticleTable.hh"
32#include "G4VProcess.hh"
33
34#include "Randomize.hh"
35
37
39#include "G4EmProcessSubType.hh"
41
42//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43
45 G4String name)
47fChannelingID(G4PhysicsModelCatalog::GetModelID("model_channeling")),
48fSetup(true){
49 fParticleToBias = G4ParticleTable::GetParticleTable()->FindParticle(particleName);
50
51 if ( fParticleToBias == 0 )
52 {
54 ed << "Particle `" << particleName << "' not found !" << G4endl;
55 G4Exception("G4ChannelingOptrChangeCrossSection(...)",
56 "G4Channeling",
58 ed);
59 }
60
61 fProcessToDensity["channeling"] = fDensityRatioNone;
62}
63
64//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65
67 for ( std::map< const G4BiasingProcessInterface*, G4BOptnChangeCrossSection* >::iterator
68 it = fChangeCrossSectionOperations.begin() ;
69 it != fChangeCrossSectionOperations.end() ;
70 it++ ) delete (*it).second;
71}
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74
76 if ( fSetup ){
77 const G4ProcessManager* processManager = fParticleToBias->GetProcessManager();
78 const G4BiasingProcessSharedData* sharedData =
80 if ( sharedData ){
81 for ( size_t i = 0 ; i < (sharedData->GetPhysicsBiasingProcessInterfaces()).size(); i++ ){
82 const G4BiasingProcessInterface* wrapperProcess =
83 (sharedData->GetPhysicsBiasingProcessInterfaces())[i];
84 G4String processName = wrapperProcess->GetWrappedProcess()->GetProcessName();
85 G4String operationName = "channelingChangeXS-" + processName;
86 fChangeCrossSectionOperations[wrapperProcess] =
87 new G4BOptnChangeCrossSection(operationName);
88
89 G4ProcessType type = wrapperProcess->GetWrappedProcess()->GetProcessType();
90 G4int subType = wrapperProcess->GetWrappedProcess()->GetProcessSubType();
91
92 switch (type) {
93 case fNotDefined:
94 fProcessToDensity[processName] = fDensityRatioNotDefined;
95 break;
96 case fTransportation:
97 fProcessToDensity[processName] = fDensityRatioNone;
98 break;
100 if(subType == fCoulombScattering ||
101 subType == fMultipleScattering){
102 fProcessToDensity[processName] = fDensityRatioNuD;
103 }
104 if(subType == fIonisation ||
105 subType == fPairProdByCharged ||
106 subType == fAnnihilation ||
107 subType == fAnnihilationToMuMu ||
108 subType == fAnnihilationToHadrons){
109 fProcessToDensity[processName] = fDensityRatioElD;
110 }
111 if(subType == fBremsstrahlung ||
112 subType == fNuclearStopping){
113 fProcessToDensity[processName] = fDensityRatioNuDElD;
114 }
115
116 if(subType == fCerenkov ||
117 subType == fScintillation ||
118 subType == fSynchrotronRadiation ||
119 subType == fTransitionRadiation){
120 fProcessToDensity[processName] = fDensityRatioNone;
121 }
122 if(subType == fRayleigh ||
123 subType == fPhotoElectricEffect ||
124 subType == fComptonScattering ||
125 subType == fGammaConversion ||
126 subType == fGammaConversionToMuMu){
127 fProcessToDensity[processName] = fDensityRatioNone;
128 }
129 break;
130 case fOptical:
131 fProcessToDensity[processName] = fDensityRatioNone;
132 break;
133 case fHadronic:
134 fProcessToDensity[processName] = fDensityRatioNuD;
135 break;
137 fProcessToDensity[processName] = fDensityRatioNuD;
138 break;
139 case fGeneral:
140 fProcessToDensity[processName] = fDensityRatioNone;
141 break;
142 case fDecay:
143 fProcessToDensity[processName] = fDensityRatioNone;
144 break;
146 fProcessToDensity[processName] = fDensityRatioNone;
147 break;
148 case fUserDefined:
149 fProcessToDensity[processName] = fDensityRatioNone;
150 break;
151 case fParallel:
152 fProcessToDensity[processName] = fDensityRatioNone;
153 break;
154 case fPhonon:
155 fProcessToDensity[processName] = fDensityRatioNone;
156 break;
157 case fUCN:
158 fProcessToDensity[processName] = fDensityRatioNone;
159 break;
160 default:
161 fProcessToDensity[processName] = fDensityRatioNone;
162 break;
163 }
164 }
165 }
166 fSetup = false;
167 }
168}
169
170//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
171
173G4ChannelingOptrChangeCrossSection::ProposeOccurenceBiasingOperation(const G4Track* track,
175 callingProcess)
176{
177 if ( track->GetDefinition() != fParticleToBias ) return 0;
178
179 G4double analogInteractionLength =
181 if ( analogInteractionLength > DBL_MAX/10. ) return 0;
182
183 G4double analogXS = 1./analogInteractionLength;
184
185 G4ChannelingTrackData* trackdata =
186 (G4ChannelingTrackData*)(track->GetAuxiliaryTrackInformation(fChannelingID));
187 if(trackdata==nullptr) return 0;
188
189 G4double XStransformation = 1.;
190 auto search = fProcessToDensity.find(callingProcess->GetWrappedProcess()->GetProcessName());
191 if(search != fProcessToDensity.end()) {
192 switch (search->second) {
194 XStransformation = trackdata->GetDensity();
195 break;
196 case fDensityRatioNuD:
197 XStransformation = trackdata->GetNuD();
198 break;
199 case fDensityRatioElD:
200 XStransformation = trackdata->GetElD();
201 break;
203 return 0;
204 break;
206 return 0;
207 break;
208 default:
209 return 0;
210 break;
211 }
212 }
213 else{
214 XStransformation = trackdata->GetDensity();
215 }
216
217 G4BOptnChangeCrossSection* operation = fChangeCrossSectionOperations[callingProcess];
218 G4VBiasingOperation* previousOperation = callingProcess->GetPreviousOccurenceBiasingOperation();
219
220 if ( previousOperation == 0 ){
221 operation->SetBiasedCrossSection( XStransformation * analogXS );
222 operation->Sample();
223 }
224 else{
225 if ( previousOperation != operation ){
227 ed << " Logic problem in operation handling !" << G4endl;
228 G4Exception("G4ChannelingOptrChangeCrossSection::ProposeOccurenceBiasingOperation(...)",
229 "G4Channeling",
231 ed);
232 return 0;
233 }
234 if ( operation->GetInteractionOccured() ){
235 operation->SetBiasedCrossSection( XStransformation * analogXS );
236 operation->Sample();
237 }
238 else{
239 operation->UpdateForStep( callingProcess->GetPreviousStepSize() );
240 operation->SetBiasedCrossSection( XStransformation * analogXS );
241 operation->UpdateForStep( 0.0 );
242 }
243 }
244
245 return operation;
246
247}
248
249//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
250
251void G4ChannelingOptrChangeCrossSection::
252OperationApplied(const G4BiasingProcessInterface* callingProcess,
254 G4VBiasingOperation* occurenceOperationApplied,
255 G4double,
257 const G4VParticleChange* )
258{
259 G4BOptnChangeCrossSection* operation = fChangeCrossSectionOperations[callingProcess];
260 if ( operation == occurenceOperationApplied ) operation->SetInteractionOccured();
261}
262
263//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4BiasingAppliedCase
@ fGammaConversionToMuMu
@ fAnnihilationToHadrons
@ fBremsstrahlung
@ fCoulombScattering
@ fGammaConversion
@ fRayleigh
@ fIonisation
@ fPairProdByCharged
@ fSynchrotronRadiation
@ fCerenkov
@ fAnnihilationToMuMu
@ fScintillation
@ fNuclearStopping
@ fComptonScattering
@ fTransitionRadiation
@ fAnnihilation
@ fMultipleScattering
@ fPhotoElectricEffect
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4ProcessType
@ fOptical
@ fPhonon
@ fParameterisation
@ fParallel
@ fUCN
@ fGeneral
@ fDecay
@ fElectromagnetic
@ fHadronic
@ fUserDefined
@ fTransportation
@ fPhotolepton_hadron
@ fNotDefined
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
void UpdateForStep(G4double stepLength)
void SetBiasedCrossSection(G4double xst, bool updateInteractionLength=false)
const G4BiasingProcessSharedData * GetSharedData() const
G4VBiasingOperation * GetPreviousOccurenceBiasingOperation() const
const std::vector< const G4BiasingProcessInterface * > & GetPhysicsBiasingProcessInterfaces() const
G4ChannelingOptrChangeCrossSection(G4String particleToBias, G4String name="ChannelingChangeXS")
G4ProcessManager * GetProcessManager() const
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
static G4ParticleTable * GetParticleTable()
G4VAuxiliaryTrackInformation * GetAuxiliaryTrackInformation(G4int id) const
Definition G4Track.cc:229
G4ParticleDefinition * GetDefinition() const
G4ProcessType GetProcessType() const
G4double GetCurrentInteractionLength() const
G4int GetProcessSubType() const
const G4String & GetProcessName() const
#define DBL_MAX
Definition templates.hh:62