Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4EmBiasingManager.hh
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//
26// $Id$
27//
28// -------------------------------------------------------------------
29//
30// GEANT4 Class header file
31//
32//
33// File name: G4EmBiasingManager
34//
35// Author: Vladimir Ivanchenko
36//
37// Creation date: 28.07.2011
38//
39// Modifications:
40//
41// Class Description:
42//
43// It is a class providing step limit for forced process biasing
44
45// -------------------------------------------------------------------
46//
47
48#ifndef G4EmBiasingManager_h
49#define G4EmBiasingManager_h 1
50
51#include "globals.hh"
53#include "G4DynamicParticle.hh"
54#include "Randomize.hh"
55#include <vector>
56
57//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
58
59class G4Region;
60class G4Track;
62class G4VEmModel;
66
68{
69public:
70
72
74
75 void Initialise(const G4ParticleDefinition& part,
76 const G4String& procName, G4int verbose);
77
78 // default parameters are possible
79 void ActivateForcedInteraction(G4double length = 0.0,
80 const G4String& r = "");
81
82 // no default parameters
83 void ActivateSecondaryBiasing(const G4String& region, G4double factor,
84 G4double energyLimit);
85
86 // return forced step limit
87 G4double GetStepLimit(G4int coupleIdx, G4double previousStep);
88
89 // return weight of splitting or Russian roulette
90 // G4DynamicParticle may be deleted
91 // two functions are required because of the different ParticleChange
92 // ApplySecondaryBiasing() are wrappers
93
94 // for G4VEmProcess
95 G4double ApplySecondaryBiasing(std::vector<G4DynamicParticle*>&,
96 const G4Track& track,
97 G4VEmModel* currentModel,
98 G4ParticleChangeForGamma* pParticleChange,
99 G4double& eloss,
100 G4int coupleIdx,
101 G4double tcut,
102 G4double safety = 0.0);
103
104 // for G4VEnergyLossProcess
105 G4double ApplySecondaryBiasing(std::vector<G4DynamicParticle*>&,
106 const G4Track& track,
107 G4VEmModel* currentModel,
108 G4ParticleChangeForLoss* pParticleChange,
109 G4double& eloss,
110 G4int coupleIdx,
111 G4double tcut,
112 G4double safety = 0.0);
113
114 // for G4VEnergyLossProcess
115 G4double ApplySecondaryBiasing(std::vector<G4Track*>&,
116 G4int coupleIdx);
117
118 inline G4bool SecondaryBiasingRegion(G4int coupleIdx);
119
120 inline G4bool ForcedInteractionRegion(G4int coupleIdx);
121
122 inline void ResetForcedInteraction();
123
124private:
125
126 void ApplyRangeCut(std::vector<G4DynamicParticle*>& vd,
127 const G4Track& track,
128 G4double& eloss,
129 G4double safety);
130
131 G4double ApplySplitting(std::vector<G4DynamicParticle*>& vd,
132 const G4Track& track,
133 G4VEmModel* currentModel,
134 G4int index,
135 G4double tcut);
136
137 inline G4double ApplyRussianRoulette(std::vector<G4DynamicParticle*>& vd,
138 G4int index);
139
140 // copy constructor and hide assignment operator
142 G4EmBiasingManager & operator=(const G4EmBiasingManager &right);
143
144 G4int nForcedRegions;
145 G4int nSecBiasedRegions;
146 std::vector<const G4Region*> forcedRegions;
147 std::vector<G4double> lengthForRegion;
148 std::vector<const G4Region*> secBiasedRegions;
149 std::vector<G4double> secBiasedWeight;
150 std::vector<G4double> secBiasedEnegryLimit;
151 std::vector<G4int> nBremSplitting;
152
153 std::vector<G4int> idxForcedCouple;
154 std::vector<G4int> idxSecBiasedCouple;
155
156 std::vector<G4DynamicParticle*> tmpSecondaries;
157
158 G4VEnergyLossProcess* eIonisation;
159
160 const G4ParticleDefinition* theElectron;
161
162 G4double fSafetyMin;
163 G4double currentStepLimit;
164 G4bool startTracking;
165};
166
167inline G4bool
169{
170 G4bool res = false;
171 if(nSecBiasedRegions > 0) {
172 if(idxSecBiasedCouple[coupleIdx] >= 0) { res = true; }
173 }
174 return res;
175}
176
178{
179 G4bool res = false;
180 if(nForcedRegions > 0) {
181 if(idxForcedCouple[coupleIdx] >= 0) { res = true; }
182 }
183 return res;
184}
185
187{
188 startTracking = true;
189}
190
191//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
192
193inline G4double
194G4EmBiasingManager::ApplyRussianRoulette(std::vector<G4DynamicParticle*>& vd,
195 G4int index)
196{
197 size_t n = vd.size();
198 G4double weight = secBiasedWeight[index];
199 for(size_t k=0; k<n; ++k) {
200 if(G4UniformRand()*weight > 1.0) {
201 const G4DynamicParticle* dp = vd[k];
202 delete dp;
203 vd[k] = 0;
204 }
205 }
206 return weight;
207}
208
209//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
210
211#endif
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4UniformRand()
Definition: Randomize.hh:53
G4bool ForcedInteractionRegion(G4int coupleIdx)
G4double ApplySecondaryBiasing(std::vector< G4DynamicParticle * > &, const G4Track &track, G4VEmModel *currentModel, G4ParticleChangeForGamma *pParticleChange, G4double &eloss, G4int coupleIdx, G4double tcut, G4double safety=0.0)
void ActivateSecondaryBiasing(const G4String &region, G4double factor, G4double energyLimit)
void Initialise(const G4ParticleDefinition &part, const G4String &procName, G4int verbose)
void ActivateForcedInteraction(G4double length=0.0, const G4String &r="")
G4bool SecondaryBiasingRegion(G4int coupleIdx)
G4double GetStepLimit(G4int coupleIdx, G4double previousStep)