LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
exampleB01.cc File Reference

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

#include <iostream>
#include <stdlib.h>
#include "G4RunManager.hh"
#include "G4VPhysicalVolume.hh"
#include "G4UImanager.hh"
#include "G4GeometryManager.hh"
#include "B01DetectorConstruction.hh"
#include "FTFP_BERT.hh"
#include "G4ImportanceBiasing.hh"
#include "G4WeightWindowBiasing.hh"
#include "B01ActionInitialization.hh"
#include "G4GeometrySampler.hh"
#include "G4IStore.hh"
#include "G4VWeightWindowStore.hh"
#include "G4WeightWindowAlgorithm.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Main program of the biasing/B01 example.

Definition in file exampleB01.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 91 of file exampleB01.cc.

92 {
93  G4int mode = 0;
94  if (argc>1) mode = atoi(argv[1]);
95 
96  G4int numberOfEvents = 100;
97  G4long myseed = 345354;
98 
99 #ifdef G4MULTITHREADED
100  G4MTRunManager * runManager = new G4MTRunManager;
101  G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl;
102  G4cout << " and using 2 of them! " << G4endl;
103  runManager->SetNumberOfThreads(2);
104  // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
105 #else
106  G4RunManager * runManager = new G4RunManager;
107 #endif
108 
109  G4Random::setTheSeed(myseed);
110 
111  G4VWeightWindowAlgorithm *wwAlg = 0; // pointer for WeightWindow (mode>0)
112 
113  // create the detector ---------------------------
114  B01DetectorConstruction* detector = new B01DetectorConstruction();
115  runManager->SetUserInitialization(detector);
116  G4GeometrySampler mgs(detector->GetWorldVolume(),"neutron");
117 
118  G4VModularPhysicsList* physicsList = new FTFP_BERT;
119  if(mode == 0)
120  {
121  physicsList->RegisterPhysics(new G4ImportanceBiasing(&mgs));
122  }
123  else
124  {
125  wwAlg = new G4WeightWindowAlgorithm(1, // upper limit factor
126  1, // survival factor
127  100); // max. number of splitting
128 
129  physicsList->RegisterPhysics(new G4WeightWindowBiasing
130  (&mgs, wwAlg, onBoundary));
131  // place of action
132  }
133  runManager->SetUserInitialization(physicsList);
134 
135  // Set user action classes through Worker Initialization
136  //
137  B01ActionInitialization* actions = new B01ActionInitialization;
138  runManager->SetUserInitialization(actions);
139 
140  runManager->Initialize();
141 
142  if (mode == 0)
143  {
144  detector->CreateImportanceStore();
145  }
146  else
147  {
148  detector->CreateWeightWindowStore();
149  }
150 
151  // runManager->BeamOn(numberOfEvents);
152 
153  //temporary fix before runManager->BeamOn works...
154  G4UImanager* UImanager = G4UImanager::GetUIpointer();
155  G4String command1 = "/control/cout/setCoutFile threadOut";
156  UImanager->ApplyCommand(command1);
157  G4String command2 = "/run/beamOn " +
158  G4UIcommand::ConvertToString(numberOfEvents);;
159  UImanager->ApplyCommand(command2);
160 
161  // open geometry for clean biasing stores clean-up
162  //
163  G4GeometryManager::GetInstance()->OpenGeometry();
164 
165  if (wwAlg) {
166  delete wwAlg;
167  }
168 
169  // mgs.ClearSampling();
170 
171  delete runManager;
172 
173  return 0;
174 }