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
examples
extended
biasing
B01
exampleB01.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
//
28
//
29
//
30
// $Id$
31
//
32
//
33
// --------------------------------------------------------------
34
// GEANT 4 - exampleB01
35
//
36
// --------------------------------------------------------------
37
// Comments
38
//
39
// This example intends to show how to use importance sampling and scoring
40
// in the mass (tracking) geometry.
41
// A simple geometry consisting of a 180 cm high concrete cylinder
42
// divided into 18 slabs of 10cm each is created.
43
// Importance values are assigned to the 18 concrete slabs in the
44
// detector construction class for simplicity.
45
// Pairs of G4GeometryCell and importance values are stored in
46
// the importance store.
47
// The G4Scorer is used for the scoring. This is a top level
48
// class using the frame work provided for scoring.
49
//
50
51
// --------------------------------------------------------------
52
53
#include <iostream>
54
55
#include "
G4VPhysicalVolume.hh
"
56
#include "
G4RunManager.hh
"
57
#include "
G4UImanager.hh
"
58
#include "
G4GeometryManager.hh
"
59
60
// user classes
61
#include "
B01DetectorConstruction.hh
"
62
#include "
B01PhysicsList.hh
"
63
#include "
B01PrimaryGeneratorAction.hh
"
64
#include "
B01RunAction.hh
"
65
#include "
B01ScoreTable.hh
"
66
67
// Files specific for biasing and scoring
68
#include "
G4GeometrySampler.hh
"
69
#include "
G4IStore.hh
"
70
#include "
G4VWeightWindowStore.hh
"
71
#include "
G4WeightWindowAlgorithm.hh
"
72
73
74
int
main
(
int
argc,
char
**argv)
75
{
76
G4int
mode = 0;
77
if
(argc>1) mode = atoi(argv[1]);
78
79
G4int
numberOfEvents = 100;
80
G4long
myseed = 345354;
81
CLHEP::HepRandom::setTheSeed
(myseed);
82
83
G4RunManager
*runManager =
new
G4RunManager
;
84
85
// create the detector ---------------------------
86
B01DetectorConstruction
*detector =
new
B01DetectorConstruction
();
87
runManager->
SetUserInitialization
(detector);
88
// ---------------------------------------------------
89
runManager->
SetUserInitialization
(
new
B01PhysicsList
);
90
runManager->
SetUserAction
(
new
B01PrimaryGeneratorAction
);
91
runManager->
SetUserAction
(
new
B01RunAction
);
92
runManager->
Initialize
();
93
94
// pointers for importance store, weight-window store
95
// and weight-window algorithm
96
//
97
G4VIStore
*aIstore = 0;
98
G4VWeightWindowStore
*aWWstore = 0;
99
G4VWeightWindowAlgorithm
*wwAlg = 0;
100
101
// create sampler for biasing and scoring in the mass geometry
102
//
103
G4GeometrySampler
mgs(detector->
GetWorldVolume
(),
"neutron"
);
104
mgs.
SetParallel
(
false
);
105
106
if
(mode == 0)
107
{
108
// prepare for importance sampling
109
//
110
aIstore = detector->
CreateImportanceStore
();
111
mgs.PrepareImportanceSampling(aIstore, 0);
112
}
113
else
114
{
115
// prepare for weight window technique
116
// in this case the algoritm is initialized such that
117
// the weight window tehcnique does exactly the same as
118
// the importance sampling technique, therefore
119
// the place of action ( the locations where
120
// splitting and Russian roulette are to be applied)
121
// is chosen to be on the boundary between cells.
122
//
123
aWWstore = detector->
CreateWeightWindowStore
();
124
125
wwAlg =
new
G4WeightWindowAlgorithm
(1,
// upper limit factor
126
1,
// survival factor
127
100);
// max. number of splitting
128
129
mgs.PrepareWeightWindow(aWWstore, wwAlg,
onBoundary
);
// place of action
130
}
131
mgs.Configure();
132
133
runManager->
BeamOn
(numberOfEvents);
134
135
// print a table of the scores
136
//
137
B01ScoreTable
sp
(aIstore);
//ASO
138
139
// open geometry for clean biasing stores clean-up
140
//
141
G4GeometryManager::GetInstance
()->
OpenGeometry
();
142
143
if
(aIstore) {
144
delete
aIstore;
145
}
146
if
(aWWstore) {
147
delete
aWWstore;
148
}
149
if
(wwAlg) {
150
delete
wwAlg;
151
}
152
153
mgs.ClearSampling();
154
155
delete
runManager;
156
157
return
0;
158
}
Generated on Sat May 25 2013 14:32:17 for Geant4 by
1.8.4