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