Loading...
Searching...
No Matches
exampleB03.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/B03/exampleB03.cc
27/// \brief Main program of the biasing/B03 example
28//
29//
30//
31//
32// --------------------------------------------------------------
33// GEANT 4 - exampleB03
34//
35// --------------------------------------------------------------
36// Comments
37//
38// This example intends to show how to use both importance sampling and a
39// customized scoring making use of the scoring framework
40// in a parallel geometry.
41//
42// A simple geometry consisting of a 180 cm high concrete cylinder
43// is constructed in the mass geometry.
44// A geometry is constructed in the parallel geometry
45// in order to assign importance values to slabs
46// of width 10cm and for scoring. The parallel world volume should
47// overlap the mass world volume and the radii of the slabs is larger
48// than the radius of the concrete cylinder in the mass geometry.
49// Pairs of G4GeometryCell and importance values are stored in
50// the importance store.
51// The scoring uses the primitive scorers via the Multi Functional Detector
52//
53//
54//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55
56#include <iostream>
57
58#include "G4Types.hh"
59
60#include "G4RunManagerFactory.hh"
61
62#include "G4VPhysicalVolume.hh"
63#include "G4UImanager.hh"
64#include "G4SystemOfUnits.hh"
65
67#include "B03PhysicsList.hh"
68
70// #include "B03PrimaryGeneratorAction.hh"
71// #include "B03RunAction.hh"
72
73// construction for the parallel geometry
75
76// Files specific for biasing and scoring
77//#include "G4Scorer.hh"
78// #include "G4GeometrySampler.hh"
79#include "G4IStore.hh"
80
81//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
82
83int main(int , char **)
84{
85 G4int numberOfEvents = 100;
86
87 G4long myseed = 345354;
88
89 auto* runManager = G4RunManagerFactory::CreateRunManager();
90 runManager->SetNumberOfThreads(2);
91
92 G4Random::setTheSeed(myseed);
93
94 // create the detector ---------------------------
96 runManager->SetUserInitialization(detector);
97 // ---------------------------------------------------
98
99 // create a parallel detector
100 G4String parallelName("ParallelBiasingWorld");
102 new B03ImportanceDetectorConstruction(parallelName);
103 detector->RegisterParallelWorld(pdet);
104
105 // G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron");
106 // B03PhysicsList* physlist = new B03PhysicsList;
107 // name of first parallel world:
108 B03PhysicsList* physlist = new B03PhysicsList(parallelName);
109 // push parallel world to store in case of multiple worlds:
110 physlist->AddParallelWorldName(parallelName);
111 // physlist->AddParallelWorldName(parallelName);
112 //physlist->AddParallelWorldName(sparallelName);
113 // physlist->AddBiasing(&pgs,parallelName);
114
115 runManager->SetUserInitialization(physlist);
116
117 // Set user action classes through Worker Initialization
118 //
120 runManager->SetUserInitialization(actions);
121
122// runManager->SetUserAction(new B03PrimaryGeneratorAction);
123// // runManager->SetUserAction(new B03PrimaryGeneratorAction(ifElectron));
124// runManager->SetUserAction(new B03RunAction);
125
126 runManager->Initialize();
127
128 G4VPhysicalVolume& aghostWorld = pdet->GetWorldVolumeAddress();
129 G4cout << " ghost world: " << pdet->GetName() << G4endl;
130
131 // create an importance
132 G4IStore *aIstore = G4IStore::GetInstance(pdet->GetName());
133
134 // create a geometry cell for the world volume replpicanumber is 0!
135 G4GeometryCell gWorldVolumeCell(aghostWorld, 0);
136 // set world volume importance to 1
137 aIstore->AddImportanceGeometryCell(1, gWorldVolumeCell);
138
139 // set importance values and create scorers
140 G4int cell(1);
141 for (cell=1; cell<=18; cell++) {
142 G4GeometryCell gCell = pdet->GetGeometryCell(cell);
143 G4cout << " adding cell: " << cell
144 << " replica: " << gCell.GetReplicaNumber()
145 << " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
146 G4double imp = std::pow(2.0,cell-1);
147 //x aIstore.AddImportanceGeometryCell(imp, gCell);
148 aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell);
149 }
150
151 // creating the geometry cell and add both to the store
152 // G4GeometryCell gCell = pdet->GetGeometryCell(18);
153
154 // create importance geometry cell pair for the "rest"cell
155 // with the same importance as the last concrete cell
156 G4GeometryCell gCell = pdet->GetGeometryCell(19);
157 // G4double imp = std::pow(2.0,18);
158 G4double imp = std::pow(2.0,17);
159 aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19);
160
161 //temporary fix before runManager->BeamOn works...
162 G4UImanager* UImanager = G4UImanager::GetUIpointer();
163 G4String command1 = "/control/cout/setCoutFile fileName";
164 UImanager->ApplyCommand(command1);
165
166 G4String command2 = "/run/beamOn "
167 + G4UIcommand::ConvertToString(numberOfEvents);;
168 UImanager->ApplyCommand(command2);
169
170 // runManager->BeamOn(numberOfEvents);
171
172 // pgs.ClearSampling();
173
174 delete runManager;
175
176 return 0;
177}
178
179//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the B03ActionInitialization class.
Definition of the B03DetectorConstruction class.
Definition of the B03ImportanceDetectorConstruction class.
Definition of the B03PhysicsList class.
void AddParallelWorldName(G4String &pname)
int main()
Definition testCommon.cc:47

Applications | User Support | Publications | Collaboration