Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
exampleB03.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: exampleB03.cc 70528 2013-05-31 16:50:36Z gcosmo $
31 //
32 //
33 // --------------------------------------------------------------
34 // GEANT 4 - exampleB03
35 //
36 // --------------------------------------------------------------
37 // Comments
38 //
39 // This example intends to show how to use both importance sampling and a
40 // customized scoring making use of the scoring framework
41 // in a parallel geometry.
42 //
43 // A simple geometry consisting of a 180 cm high concrete cylinder
44 // is constructed in the mass geometry.
45 // A geometry is constructed in the parallel geometry
46 // in order to assign importance values to slabs
47 // of width 10cm and for scoring. The parallel world volume should
48 // overlap the mass world volume and the radii of the slabs is larger
49 // than the radius of the concrete cylinder in the mass geometry.
50 // Pairs of G4GeometryCell and importance values are stored in
51 // the importance store.
52 // The scoring uses the primitive scorers via the Multi Functional Detector
53 //
54 //
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
57 #include <iostream>
58 
59 #include "G4Types.hh"
60 
61 #ifdef G4MULTITHREADED
62 #include "G4MTRunManager.hh"
63 #else
64 #include "G4RunManager.hh"
65 #endif
66 
67 #include "G4VPhysicalVolume.hh"
68 #include "G4UImanager.hh"
69 #include "G4SystemOfUnits.hh"
70 
72 #include "B03PhysicsList.hh"
73 
75 // #include "B03PrimaryGeneratorAction.hh"
76 // #include "B03RunAction.hh"
77 
78 // construction for the parallel geometry
80 
81 // Files specific for biasing and scoring
82 //#include "G4Scorer.hh"
83 // #include "G4GeometrySampler.hh"
84 #include "G4IStore.hh"
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
88 int main(int , char **)
89 {
90  G4int numberOfEvents = 100;
91 
92  G4long myseed = 345354;
93 
94 #ifdef G4MULTITHREADED
95  G4MTRunManager * runManager = new G4MTRunManager;
96  G4cout << " Number of cores: " << G4Threading::G4GetNumberOfCores() << G4endl;
97  G4cout << " but using only two! " << G4endl;
98  runManager->SetNumberOfThreads(2);
99  // runManager->SetNumberOfThreads(G4Threading::G4GetNumberOfCores());
100 #else
101  G4RunManager * runManager = new G4RunManager;
102 #endif
103 
104  G4Random::setTheSeed(myseed);
105 
106  // create the detector ---------------------------
108  runManager->SetUserInitialization(detector);
109  // ---------------------------------------------------
110 
111  // create a parallel detector
112  G4String parallelName("ParallelBiasingWorld");
114  new B03ImportanceDetectorConstruction(parallelName);
115  detector->RegisterParallelWorld(pdet);
116 
117  // G4GeometrySampler pgs(pdet->GetWorldVolume(),"neutron");
118  // B03PhysicsList* physlist = new B03PhysicsList;
119  // name of first parallel world:
120  B03PhysicsList* physlist = new B03PhysicsList(parallelName);
121  // push parallel world to store in case of multiple worlds:
122  physlist->AddParallelWorldName(parallelName);
123  // physlist->AddParallelWorldName(parallelName);
124  //physlist->AddParallelWorldName(sparallelName);
125  // physlist->AddBiasing(&pgs,parallelName);
126 
127  runManager->SetUserInitialization(physlist);
128 
129  // Set user action classes through Worker Initialization
130  //
132  runManager->SetUserInitialization(actions);
133 
134 // runManager->SetUserAction(new B03PrimaryGeneratorAction);
135 // // runManager->SetUserAction(new B03PrimaryGeneratorAction(ifElectron));
136 // runManager->SetUserAction(new B03RunAction);
137 
138  runManager->Initialize();
139 
140  G4VPhysicalVolume& aghostWorld = pdet->GetWorldVolumeAddress();
141  G4cout << " ghost world: " << pdet->GetName() << G4endl;
142 
143  // create an importance
144  G4IStore *aIstore = G4IStore::GetInstance(pdet->GetName());
145 
146  // create a geometry cell for the world volume replpicanumber is 0!
147  G4GeometryCell gWorldVolumeCell(aghostWorld, 0);
148  // set world volume importance to 1
149  aIstore->AddImportanceGeometryCell(1, gWorldVolumeCell);
150 
151  // set importance values and create scorers
152  G4int cell(1);
153  for (cell=1; cell<=18; cell++) {
154  G4GeometryCell gCell = pdet->GetGeometryCell(cell);
155  G4cout << " adding cell: " << cell
156  << " replica: " << gCell.GetReplicaNumber()
157  << " name: " << gCell.GetPhysicalVolume().GetName() << G4endl;
158  G4double imp = std::pow(2.0,cell-1);
159  //x aIstore.AddImportanceGeometryCell(imp, gCell);
160  aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), cell);
161  }
162 
163  // creating the geometry cell and add both to the store
164  // G4GeometryCell gCell = pdet->GetGeometryCell(18);
165 
166  // create importance geometry cell pair for the "rest"cell
167  // with the same importance as the last concrete cell
168  G4GeometryCell gCell = pdet->GetGeometryCell(19);
169  // G4double imp = std::pow(2.0,18);
170  G4double imp = std::pow(2.0,17);
171  aIstore->AddImportanceGeometryCell(imp, gCell.GetPhysicalVolume(), 19);
172 
173  //temporary fix before runManager->BeamOn works...
174  G4UImanager* UImanager = G4UImanager::GetUIpointer();
175  G4String command1 = "/control/cout/setCoutFile fileName";
176  UImanager->ApplyCommand(command1);
177 
178  G4String command2 = "/run/beamOn "
179  + G4UIcommand::ConvertToString(numberOfEvents);;
180  UImanager->ApplyCommand(command2);
181 
182  // runManager->BeamOn(numberOfEvents);
183 
184  // pgs.ClearSampling();
185 
186  delete runManager;
187 
188  return 0;
189 }
190 
191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetNumberOfThreads(G4int n)
void AddImportanceGeometryCell(G4double importance, const G4GeometryCell &gCell)
Definition: G4IStore.cc:107
G4int GetReplicaNumber() const
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:466
void AddParallelWorldName(G4String &pname)
#define G4endl
Definition: G4ios.hh:61
G4int G4GetNumberOfCores()
Definition: G4Threading.cc:127
Definition of the B03DetectorConstruction class.
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:73
virtual void SetUserInitialization(G4VUserDetectorConstruction *userInit)
double G4double
Definition: G4Types.hh:76
long G4long
Definition: G4Types.hh:80
Definition of the B03ImportanceDetectorConstruction class.
const G4VPhysicalVolume & GetPhysicalVolume() const
Definition of the B03PhysicsList class.
int main(int argc, char **argv)
Definition: genwindef.cc:359
Definition of the B03ActionInitialization class.
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:374
int G4int
Definition: G4Types.hh:78
static G4IStore * GetInstance()
Definition: G4IStore.cc:236
G4GLOB_DLL std::ostream G4cout
void RegisterParallelWorld(G4VUserParallelWorld *)
virtual void Initialize()
const G4String & GetName() const