Geant4  v4-10.4-release
GB05BOptnSplitAndKillByCrossSection.cc
이 파일의 문서화 페이지로 가기
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 *
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 *
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 //
30
31 #include "Randomize.hh"
33
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35
37 : G4VBiasingOperation(name),
38  fParticleChange(),
39  fInteractionLength(-1.0)
40 {}
41
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43
45 {}
46
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48
51  G4double,
53 {
54  *condition = NotForced;
55
56  // -- Sample the exponential law using the total interaction length of processes
57  // -- to couterbalance for:
58  G4double proposedStepLength = -std::log( G4UniformRand() ) * fInteractionLength;
59
60  return proposedStepLength;
61 }
62
63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
64
67  const G4Step* )
68 {
69
70  // -- This method is called if we have limited the step.
71  // -- We hence make the splitting or killing.
72
73  // Get track weight:
74  G4double initialWeight = track->GetWeight();
75
76  // The "particle change" is the object to be used to communicate to
77  // the tracking the update of the primary state and/or creation
78  // secondary tracks.
80
81  // -- Splitting and killing factors.
82  // -- They are taken the same, but the killing factor can be make bigger.
83  G4double splittingFactor = 2.0;
84  G4double killingFactor = 2.0;
85
86
87  if ( track->GetMomentumDirection().z() > 0 )
88  {
89  // -- We split if the track is moving forward:
90
91  // Define the tracks weight:
92  G4double weightOfTrack = initialWeight/splittingFactor;
93
94  // Ask currect track weight to be changed to new value:
95  fParticleChange.ProposeParentWeight( weightOfTrack );
96  // Now make clones of this track (this is the actual splitting):
97  // we will then have the primary and clone of it, hence the
98  // splitting by a factor 2:
99  G4Track* clone = new G4Track( *track );
100  clone->SetWeight( weightOfTrack );
102  // -- Below's call added for safety & illustration : inform particle change to not
103  // -- modify the clone (ie : daughter) weight to male it that of the
104  // -- primary. Here call not mandatory and both tracks have same weights.
106  }
107  else
108  {
109  // -- We apply Russian roulette if the track is moving backward:
110
111  // Shoot a random number (in ]0,1[ segment):
112  G4double random = G4UniformRand();
113  G4double killingProbability = 1.0 - 1.0/killingFactor;
114  if ( random < killingProbability )
115  {
116  // We ask for the the track to be killed:
118  }
119  else
120  {
121  // In this case, the track survives. We change its weight
122  // to conserve weight among killed and survival tracks:
123  fParticleChange.ProposeParentWeight( initialWeight*killingFactor );
124  }
125  }
126
127  return &fParticleChange;
128
129 }
130
131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
const XML_Char * name
Definition: expat.h:151
void SetWeight(G4double aValue)
virtual G4VParticleChange * GenerateBiasingFinalState(const G4Track *, const G4Step *) final
double z() const
void SetSecondaryWeightByProcess(G4bool)
G4double condition(const G4ErrorSymMatrix &m)