Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
exampleB01.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
28 //
29 //
30 // $Id: exampleB01.cc 109715 2018-05-08 13:40:02Z gcosmo $
31 //
32 //
33 // --------------------------------------------------------------
34 // GEANT 4 - exampleB01
35 //
36 // --------------------------------------------------------------
37 // Comments
38 //
39 // This example intends to show how to use importance sampling and scoring
40 // in the mass (tracking) geometry.
41 // A simple geometry consisting of a 180 cm high concrete cylinder
42 // divided into 18 slabs of 10cm each is created.
43 // Importance values are assigned to the 18 concrete slabs in the
44 // detector construction class for simplicity.
45 // Pairs of G4GeometryCell and importance values are stored in
46 // the importance store.
47 // Scoring is carried out by the multifunctional detector (MFD) and
48 // sensitive detectors
49 //
50 // Alex Howard (alexander.howard@cern.ch):
51 // 22/11/13: Migrated to the new MT compliant design which moves the
52 // biasing process to the physicslist constructor - here
53 // via the modular physicslists
54 //
55 
56 // --------------------------------------------------------------
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
59 #include <iostream>
60 
61 #include <stdlib.h>
62 
63 #include "G4Types.hh"
64 
65 #ifdef G4MULTITHREADED
66 #include "G4MTRunManager.hh"
67 #else
68 #include "G4RunManager.hh"
69 #endif
70 
71 #include "G4VPhysicalVolume.hh"
72 #include "G4UImanager.hh"
73 #include "G4GeometryManager.hh"
74 
75 // user classes
77 #include "FTFP_BERT.hh"
78 #include "G4ImportanceBiasing.hh"
79 #include "G4WeightWindowBiasing.hh"
80 
82 // #include "B01PrimaryGeneratorAction.hh"
83 // #include "B01RunAction.hh"
84 
85 // Files specific for biasing and scoring
86 #include "G4GeometrySampler.hh"
87 #include "G4IStore.hh"
88 #include "G4VWeightWindowStore.hh"
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 
93 int main(int argc, char **argv)
94 {
95  G4int mode = 0;
96  if (argc>1) mode = atoi(argv[1]);
97 
98  G4int numberOfEvents = 100;
99  G4long myseed = 345354;
100 
101 #ifdef G4MULTITHREADED
102  G4MTRunManager * runManager = new G4MTRunManager;
103  G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl;
104  G4cout << " and using 2 of them! " << G4endl;
105  runManager->SetNumberOfThreads(2);
106  // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
107 #else
108  G4RunManager * runManager = new G4RunManager;
109 #endif
110 
111  G4Random::setTheSeed(myseed);
112 
113  G4VWeightWindowAlgorithm *wwAlg = 0; // pointer for WeightWindow (mode>0)
114 
115  // create the detector ---------------------------
117  runManager->SetUserInitialization(detector);
118  G4GeometrySampler mgs(detector->GetWorldVolume(),"neutron");
119 
120  G4VModularPhysicsList* physicsList = new FTFP_BERT;
121  if(mode == 0)
122  {
123  physicsList->RegisterPhysics(new G4ImportanceBiasing(&mgs));
124  }
125  else
126  {
127  wwAlg = new G4WeightWindowAlgorithm(1, // upper limit factor
128  1, // survival factor
129  100); // max. number of splitting
130 
131  physicsList->RegisterPhysics(new G4WeightWindowBiasing
132  (&mgs, wwAlg, onBoundary));
133  // place of action
134  }
135  runManager->SetUserInitialization(physicsList);
136 
137  // Set user action classes through Worker Initialization
138  //
140  runManager->SetUserInitialization(actions);
141 
142  runManager->Initialize();
143 
144  if (mode == 0)
145  {
146  detector->CreateImportanceStore();
147  }
148  else
149  {
150  detector->CreateWeightWindowStore();
151  }
152 
153  // runManager->BeamOn(numberOfEvents);
154 
155  //temporary fix before runManager->BeamOn works...
156  G4UImanager* UImanager = G4UImanager::GetUIpointer();
157  G4String command1 = "/control/cout/setCoutFile threadOut";
158  UImanager->ApplyCommand(command1);
159  G4String command2 = "/run/beamOn " +
160  G4UIcommand::ConvertToString(numberOfEvents);;
161  UImanager->ApplyCommand(command2);
162 
163  // open geometry for clean biasing stores clean-up
164  //
166 
167  if (wwAlg) {
168  delete wwAlg;
169  }
170 
171  // mgs.ClearSampling();
172 
173  delete runManager;
174 
175  return 0;
176 }
177 
178 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetNumberOfThreads(G4int n)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
G4VPhysicalVolume * GetWorldVolume()
Definition of the B01ActionInitialization class.
G4int G4GetNumberOfCores()
Definition: G4Threading.cc:127
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
G4VWeightWindowStore * CreateWeightWindowStore()
long G4long
Definition: G4Types.hh:80
static G4GeometryManager * GetInstance()
void OpenGeometry(G4VPhysicalVolume *vol=0)
int main(int argc, char **argv)
Definition: genwindef.cc:359
TFTFP_BERT< G4VModularPhysicsList > FTFP_BERT
Definition: FTFP_BERT.hh:63
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
Definition of the B01DetectorConstruction class.
virtual void Initialize()