Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
processes
biasing
src
G4SamplingPostStepAction.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
//
26
//
27
// $Id$
28
//
29
// ----------------------------------------------------------------------
30
// GEANT 4 class source file
31
//
32
// G4SamplingPostStepAction.cc
33
//
34
// ----------------------------------------------------------------------
35
36
#include "
G4SamplingPostStepAction.hh
"
37
#include "
G4Track.hh
"
38
#include "
G4ParticleChange.hh
"
39
#include "
G4VImportanceSplitExaminer.hh
"
40
#include "
G4Nsplit_Weight.hh
"
41
#include "
G4VTrackTerminator.hh
"
42
#include <sstream>
43
44
G4SamplingPostStepAction::
45
G4SamplingPostStepAction
(
const
G4VTrackTerminator
&TrackTerminator)
46
: fTrackTerminator(TrackTerminator)
47
{
48
}
49
50
G4SamplingPostStepAction::~G4SamplingPostStepAction
()
51
{
52
}
53
54
void
G4SamplingPostStepAction::DoIt
(
const
G4Track
& aTrack,
55
G4ParticleChange
*aParticleChange,
56
const
G4Nsplit_Weight
&nw)
57
{
58
// evaluate results from sampler
59
if
(nw.
fN
>1)
60
{
61
// split track
62
Split(aTrack, nw, aParticleChange);
63
}
64
else
if
(nw.
fN
==1)
65
{
66
// don't split, but weight may be changed !
67
aParticleChange->
ProposeWeight
(nw.
fW
);
68
}
69
else
if
(nw.
fN
==0)
70
{
71
// kill track
72
fTrackTerminator.
KillTrack
();
73
}
74
else
75
{
76
// wrong answer
77
std::ostringstream os;
78
os <<
"Sampler returned nw = "
79
<< nw
80
<<
"\n"
;
81
G4String
msg = os.str();
82
83
G4Exception
(
"G4SamplingPostStepAction::DoIt()"
,
84
"InvalidCondition"
,
FatalException
, msg);
85
}
86
}
87
88
void
G4SamplingPostStepAction::Split(
const
G4Track
&aTrack,
89
const
G4Nsplit_Weight
&nw,
90
G4ParticleChange
*aParticleChange)
91
{
92
aParticleChange->
ProposeWeight
(nw.
fW
);
93
aParticleChange->
SetNumberOfSecondaries
(nw.
fN
-1);
94
95
for
(
G4int
i=1;i<nw.
fN
;i++)
96
{
97
G4Track
*ptrack =
new
G4Track
(aTrack);
98
99
// ptrack->SetCreatorProcess(aTrack.GetCreatorProcess());
100
ptrack->
SetWeight
(nw.
fW
);
101
102
if
(ptrack->
GetMomentumDirection
() != aTrack.
GetMomentumDirection
())
103
{
104
G4Exception
(
"G4SamplingPostStepAction::Split()"
,
"InvalidCondition"
,
105
FatalException
,
"Track with same momentum !"
);
106
}
107
aParticleChange->
AddSecondary
(ptrack);
108
}
109
return
;
110
}
Generated on Sat May 25 2013 14:33:29 for Geant4 by
1.8.4