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

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

#include <iostream>
#include <stdlib.h>
#include "G4Types.hh"
#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 92 of file exampleB01.cc.

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