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

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

#include <iostream>
#include <stdlib.h>
#include "G4RunManager.hh"
#include "G4VPhysicalVolume.hh"
#include "G4UImanager.hh"
#include "G4GeometryManager.hh"
#include "B02DetectorConstruction.hh"
#include "B02ImportanceDetectorConstruction.hh"
#include "FTFP_BERT.hh"
#include "G4ImportanceBiasing.hh"
#include "G4ParallelWorldPhysics.hh"
#include "B02ActionInitialization.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/B02 example.

Definition in file exampleB02.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 84 of file exampleB02.cc.

85 {
86  G4int mode = 0;
87  if (argc>1) mode = atoi(argv[1]);
88  if(mode != 0) {
89  G4cout << " mode not used yet, refer to B01 to see WeightWindow technique "
90  << mode << G4endl;
91  }
92 
93  G4int numberOfEvents = 100;
94  G4long myseed = 345354;
95 
96 #ifdef G4MULTITHREADED
97  G4MTRunManager * runManager = new G4MTRunManager;
98  G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl;
99  G4cout << " but using two! " << G4endl;
100  runManager->SetNumberOfThreads(2);
101  // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
102 #else
103  G4RunManager * runManager = new G4RunManager;
104 #endif
105 
106  G4Random::setTheSeed(myseed);
107 
108  // create the detector ---------------------------
109  B02DetectorConstruction* detector = new B02DetectorConstruction();
110  runManager->SetUserInitialization(detector);
111 
112  G4String parallelName("ParallelBiasingWorld");
113  B02ImportanceDetectorConstruction* pdet =
114  new B02ImportanceDetectorConstruction(parallelName);
115  detector->RegisterParallelWorld(pdet);
116 
117  G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron");
118 
119  pgs.SetParallel(true);
120 
121  G4VModularPhysicsList* physicsList = new FTFP_BERT;
122  physicsList->RegisterPhysics(new G4ImportanceBiasing(&pgs,parallelName));
123  physicsList->RegisterPhysics(new G4ParallelWorldPhysics(parallelName));
124 
125  runManager->SetUserInitialization(physicsList);
126 
127  // Set user action classes through Worker Initialization
128  //
129  B02ActionInitialization* actions = new B02ActionInitialization;
130  runManager->SetUserInitialization(actions);
131 
132  runManager->Initialize();
133 
134  pdet->CreateImportanceStore();
135 
136  //temporary fix before runManager->BeamOn works...
137  G4UImanager* UImanager = G4UImanager::GetUIpointer();
138  G4String command1 = "/control/cout/setCoutFile threadOut";
139  UImanager->ApplyCommand(command1);
140  G4String command2 = "/run/beamOn " +
141  G4UIcommand::ConvertToString(numberOfEvents);
142  UImanager->ApplyCommand(command2);
143 
144  // open geometry for clean biasing stores clean-up
145  //
146  G4GeometryManager::GetInstance()->OpenGeometry();
147 
148  // pgs.ClearSampling();
149 
150  delete runManager;
151 
152  return 0;
153 }