Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
exampleB03.cc File Reference

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

#include <iostream>
#include "G4RunManager.hh"
#include "G4VPhysicalVolume.hh"
#include "G4UImanager.hh"
#include "G4SystemOfUnits.hh"
#include "B03DetectorConstruction.hh"
#include "B03PhysicsList.hh"
#include "B03ActionInitialization.hh"
#include "B03ImportanceDetectorConstruction.hh"
#include "G4GeometrySampler.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

int main ( int  ,
char **   
)

Definition at line 88 of file exampleB03.cc.

References G4IStore::AddImportanceGeometryCell(), B03PhysicsList::AddParallelWorldName(), G4UImanager::ApplyCommand(), G4UIcommand::ConvertToString(), G4cout, G4endl, G4Threading::G4GetNumberOfCores(), B03ImportanceDetectorConstruction::GetGeometryCell(), G4IStore::GetInstance(), G4VUserParallelWorld::GetName(), G4VPhysicalVolume::GetName(), G4GeometryCell::GetPhysicalVolume(), G4GeometryCell::GetReplicaNumber(), G4UImanager::GetUIpointer(), B03ImportanceDetectorConstruction::GetWorldVolume(), B03ImportanceDetectorConstruction::GetWorldVolumeAddress(), G4RunManager::Initialize(), G4VUserDetectorConstruction::RegisterParallelWorld(), G4MTRunManager::SetNumberOfThreads(), and G4RunManager::SetUserInitialization().

89 {
90  G4int numberOfEvents = 100;
91 
92  G4long myseed = 345354;
93 
94 #ifdef G4MULTITHREADED
95  G4MTRunManager * runManager = new G4MTRunManager;
96  G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl;
97  G4cout << " but using only two! " << G4endl;
98  runManager->SetNumberOfThreads(2);
99  // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
100 #else
101  G4RunManager * runManager = new G4RunManager;
102 #endif
103 
104  G4Random::setTheSeed(myseed);
105 
106  // create the detector ---------------------------
108  runManager->SetUserInitialization(detector);
109  // ---------------------------------------------------
110 
111  // create a parallel detector
112  G4String parallelName("ParallelBiasingWorld");
114  new B03ImportanceDetectorConstruction(parallelName);
115  detector->RegisterParallelWorld(pdet);
116 
117  G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron");
118  B03PhysicsList* physlist = new B03PhysicsList;
119  physlist->AddParallelWorldName(parallelName);
120  //physlist->AddParallelWorldName(sparallelName);
121  physlist->AddBiasing(&pgs,parallelName);
122 
123  runManager->SetUserInitialization(physlist);
124 
125  // Set user action classes through Worker Initialization
126  //
128  runManager->SetUserInitialization(actions);
129 
130 // runManager->SetUserAction(new B03PrimaryGeneratorAction);
131 // // runManager->SetUserAction(new B03PrimaryGeneratorAction(ifElectron));
132 // runManager->SetUserAction(new B03RunAction);
133 
134  runManager->Initialize();
135 
136  G4VPhysicalVolume& aghostWorld = pdet->GetWorldVolumeAddress();
137  G4cout << " ghost world: " << pdet->GetName() << G4endl;
138 
139  // create an importance
140  G4IStore *aIstore = G4IStore::GetInstance(pdet->GetName());
141 
142  // create a geometry cell for the world volume replpicanumber is 0!
143  G4GeometryCell gWorldVolumeCell(aghostWorld, 0);
144  // set world volume importance to 1
145  aIstore->AddImportanceGeometryCell(1, gWorldVolumeCell);
146 
147  // set importance values and create scorers
148  G4int cell(1);
149  for (cell=1; cell<=18; cell++) {
150  G4GeometryCell gCell = pdet->GetGeometryCell(cell);
151  G4cout << " adding cell: " << cell
152  << " replica: " << gCell.GetReplicaNumber()
153  << " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
154  G4double imp = std::pow(2.0,cell-1);
155  //x aIstore.AddImportanceGeometryCell(imp, gCell);
156  aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell);
157  }
158 
159  // creating the geometry cell and add both to the store
160  // G4GeometryCell gCell = pdet->GetGeometryCell(18);
161 
162 
163  // create importance geometry cell pair for the "rest"cell
164  // with the same importance as the last concrete cell
165  G4GeometryCell gCell = pdet->GetGeometryCell(19);
166  // G4double imp = std::pow(2.0,18);
167  G4double imp = std::pow(2.0,17);
168  aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19);
169 
170  //temporary fix before runManager->BeamOn works...
171  G4UImanager* UImanager = G4UImanager::GetUIpointer();
172  G4String command1 = "/control/cout/setCoutFile fileName";
173  UImanager->ApplyCommand(command1);
174 
175  G4String command2 = "/run/beamOn "
176  + G4UIcommand::ConvertToString(numberOfEvents);;
177  UImanager->ApplyCommand(command2);
178 
179  // runManager->BeamOn(numberOfEvents);
180 
181  pgs.ClearSampling();
182 
183  delete runManager;
184 
185  return 0;
186 }
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
void SetNumberOfThreads(G4int n)
long G4long
Definition: G4Types.hh:80
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:357
int G4int
Definition: G4Types.hh:78
void RegisterParallelWorld(G4VUserParallelWorld *)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
G4int G4GetNumberOfCores()
Definition: G4Threading.cc:102
G4int GetReplicaNumber() const
void AddImportanceGeometryCell(G4double importance, const G4GeometryCell &gCell)
Definition: G4IStore.cc:104
const G4VPhysicalVolume & GetPhysicalVolume() const
static G4IStore * GetInstance()
Definition: G4IStore.cc:211
void AddParallelWorldName(G4String &pname)
virtual void Initialize()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419