LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
exampleB03.cc File Reference

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

#include <iostream>
#include "G4Types.hh"
#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 "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 87 of file exampleB03.cc.

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