Loading...
Searching...
No Matches
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//
26/// \file biasing/B01/exampleB01.cc
27/// \brief Main program of the biasing/B01 example
28//
29//
30//
31//
32// --------------------------------------------------------------
33// GEANT 4 - exampleB01
34//
35// --------------------------------------------------------------
36// Comments
37//
38// This example intends to show how to use importance sampling and scoring
39// in the mass (tracking) geometry.
40// A simple geometry consisting of a 180 cm high concrete cylinder
41// divided into 18 slabs of 10cm each is created.
42// Importance values are assigned to the 18 concrete slabs in the
43// detector construction class for simplicity.
44// Pairs of G4GeometryCell and importance values are stored in
45// the importance store.
46// Scoring is carried out by the multifunctional detector (MFD) and
47// sensitive detectors
48//
49// Alex Howard (alexander.howard@cern.ch):
50// 22/11/13: Migrated to the new MT compliant design which moves the
51// biasing process to the physicslist constructor - here
52// via the modular physicslists
53//
54
55// --------------------------------------------------------------
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57
58#include <iostream>
59
60#include <stdlib.h>
61
62#include "G4Types.hh"
63
64#include "G4RunManagerFactory.hh"
65
66#include "G4VPhysicalVolume.hh"
67#include "G4UImanager.hh"
68#include "G4GeometryManager.hh"
69
70// user classes
72#include "FTFP_BERT.hh"
73#include "G4ImportanceBiasing.hh"
74#include "G4WeightWindowBiasing.hh"
75
77// #include "B01PrimaryGeneratorAction.hh"
78// #include "B01RunAction.hh"
79
80// Files specific for biasing and scoring
81#include "G4GeometrySampler.hh"
82#include "G4IStore.hh"
83#include "G4VWeightWindowStore.hh"
84#include "G4WeightWindowAlgorithm.hh"
85
86//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87
88int main(int argc, char **argv)
89{
90 G4int mode = 0;
91 if (argc>1) mode = atoi(argv[1]);
92
93 G4int numberOfEvents = 100;
94 G4long myseed = 345354;
95
96 auto* runManager = G4RunManagerFactory::CreateRunManager();
97 runManager->SetNumberOfThreads(2);
98
99 G4Random::setTheSeed(myseed);
100
101 G4VWeightWindowAlgorithm *wwAlg = 0; // pointer for WeightWindow (mode>0)
102
103 // create the detector ---------------------------
105 runManager->SetUserInitialization(detector);
106 G4GeometrySampler mgs(detector->GetWorldVolume(),"neutron");
107
108 G4VModularPhysicsList* physicsList = new FTFP_BERT;
109 if(mode == 0)
110 {
111 physicsList->RegisterPhysics(new G4ImportanceBiasing(&mgs));
112 }
113 else
114 {
115 wwAlg = new G4WeightWindowAlgorithm(1, // upper limit factor
116 1, // survival factor
117 100); // max. number of splitting
118
119 physicsList->RegisterPhysics(new G4WeightWindowBiasing
120 (&mgs, wwAlg, onBoundary));
121 // place of action
122 }
123 runManager->SetUserInitialization(physicsList);
124
125 // Set user action classes through Worker Initialization
126 //
128 runManager->SetUserInitialization(actions);
129
130 runManager->Initialize();
131
132 if (mode == 0)
133 {
134 detector->CreateImportanceStore();
135 }
136 else
137 {
138 detector->CreateWeightWindowStore();
139 }
140
141 // runManager->BeamOn(numberOfEvents);
142
143 //temporary fix before runManager->BeamOn works...
144 G4UImanager* UImanager = G4UImanager::GetUIpointer();
145 G4String command1 = "/control/cout/setCoutFile threadOut";
146 UImanager->ApplyCommand(command1);
147 G4String command2 = "/run/beamOn " +
148 G4UIcommand::ConvertToString(numberOfEvents);;
149 UImanager->ApplyCommand(command2);
150
151 // open geometry for clean biasing stores clean-up
152 //
153 G4GeometryManager::GetInstance()->OpenGeometry();
154
155 if (wwAlg) {
156 delete wwAlg;
157 }
158
159 // mgs.ClearSampling();
160
161 delete runManager;
162
163 return 0;
164}
165
166//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the B01ActionInitialization class.
Definition of the B01DetectorConstruction class.
G4VPhysicalVolume * GetWorldVolume()
G4VWeightWindowStore * CreateWeightWindowStore()
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration