Loading...
Searching...
No Matches
Functions
exampleB03.cc File Reference

Main program of the biasing/B03 example. More...

#include <iostream>
#include "G4Types.hh"
#include "G4RunManagerFactory.hh"
#include "G4VPhysicalVolume.hh"
#include "G4UImanager.hh"
#include "G4SystemOfUnits.hh"
#include "B03DetectorConstruction.hh"
#include "B03PhysicsList.hh"
#include "B03ActionInitialization.hh"
#include "B03ImportanceDetectorConstruction.hh"
#include "G4IStore.hh"

Go to the source code of this file.

Functions

int main (int, char **)
 

Detailed Description

Main program of the biasing/B03 example.

Definition in file exampleB03.cc.

Function Documentation

◆ main()

int main ( int  ,
char **   
)

Definition at line 83 of file exampleB03.cc.

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}
void AddParallelWorldName(G4String &pname)

Applications | User Support | Publications | Collaboration