LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
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 86 of file exampleB03.cc.

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