Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
exampleB02.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: exampleB02.cc 109717 2018-05-08 13:41:05Z gcosmo $
31 //
32 //
33 // --------------------------------------------------------------
34 // GEANT 4 - exampleB02
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 //
48 
49 // --------------------------------------------------------------
50 
51 #include <iostream>
52 
53 #include <stdlib.h>
54 
55 #include "G4Types.hh"
56 
57 #ifdef G4MULTITHREADED
58 #include "G4MTRunManager.hh"
59 #else
60 #include "G4RunManager.hh"
61 #endif
62 
63 #include "G4VPhysicalVolume.hh"
64 #include "G4UImanager.hh"
65 #include "G4GeometryManager.hh"
66 
67 // user classes
70 #include "FTFP_BERT.hh"
71 #include "G4ImportanceBiasing.hh"
73 
75 // #include "B02PrimaryGeneratorAction.hh"
76 // #include "B02RunAction.hh"
77 
78 // Files specific for biasing and scoring
79 #include "G4GeometrySampler.hh"
80 #include "G4IStore.hh"
81 #include "G4VWeightWindowStore.hh"
83 
84 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
85 
86 int main(int argc, char **argv)
87 {
88  G4int mode = 0;
89  if (argc>1) mode = atoi(argv[1]);
90  if(mode != 0) {
91  G4cout << " mode not used yet, refer to B01 to see WeightWindow technique "
92  << mode << G4endl;
93  }
94 
95  G4int numberOfEvents = 100;
96  G4long myseed = 345354;
97 
98 #ifdef G4MULTITHREADED
99  G4MTRunManager * runManager = new G4MTRunManager;
100  G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl;
101  G4cout << " but using two! " << G4endl;
102  runManager->SetNumberOfThreads(2);
103  // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
104 #else
105  G4RunManager * runManager = new G4RunManager;
106 #endif
107 
108  G4Random::setTheSeed(myseed);
109 
110  // create the detector ---------------------------
112  runManager->SetUserInitialization(detector);
113 
114  G4String parallelName("ParallelBiasingWorld");
116  new B02ImportanceDetectorConstruction(parallelName);
117  detector->RegisterParallelWorld(pdet);
118 
119  G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron");
120 
121  pgs.SetParallel(true);
122 
123  G4VModularPhysicsList* physicsList = new FTFP_BERT;
124  physicsList->RegisterPhysics(new G4ImportanceBiasing(&pgs,parallelName));
125  physicsList->RegisterPhysics(new G4ParallelWorldPhysics(parallelName));
126 
127  runManager->SetUserInitialization(physicsList);
128 
129  // Set user action classes through Worker Initialization
130  //
132  runManager->SetUserInitialization(actions);
133 
134  runManager->Initialize();
135 
136  pdet->CreateImportanceStore();
137 
138  //temporary fix before runManager->BeamOn works...
139  G4UImanager* UImanager = G4UImanager::GetUIpointer();
140  G4String command1 = "/control/cout/setCoutFile threadOut";
141  UImanager->ApplyCommand(command1);
142  G4String command2 = "/run/beamOn " +
143  G4UIcommand::ConvertToString(numberOfEvents);
144  UImanager->ApplyCommand(command2);
145 
146  // open geometry for clean biasing stores clean-up
147  //
149 
150  // pgs.ClearSampling();
151 
152  delete runManager;
153 
154  return 0;
155 }
156 
157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the B02ImportanceDetectorConstruction class.
void SetNumberOfThreads(G4int n)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
#define G4endl
Definition: G4ios.hh:61
G4int G4GetNumberOfCores()
Definition: G4Threading.cc:127
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
Definition of the B02ActionInitialization class.
long G4long
Definition: G4Types.hh:80
void RegisterPhysics(G4VPhysicsConstructor *)
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
Definition of the B02DetectorConstruction class.
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
void SetParallel(G4bool paraflag)
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
void RegisterParallelWorld(G4VUserParallelWorld *)
virtual void Initialize()