Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
GB06ParallelWorldForSlices.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 // $Id: $
30 //
32 
33 #include "G4Box.hh"
34 #include "G4LogicalVolume.hh"
35 #include "G4LogicalVolumeStore.hh"
36 #include "G4PVPlacement.hh"
37 #include "G4PVReplica.hh"
38 #include "G4PhysicalVolumeStore.hh"
39 #include "G4ThreeVector.hh"
40 #include "G4SystemOfUnits.hh"
41 
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47  : G4VUserParallelWorld(worldName)
48 {;}
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53 {;}
54 
55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
56 
58 {
59  // -- Inform about construction:
60  // -- (fWorldName is a protected data member of the base parallel world class)
61  G4cout << "Parallel World `" << fWorldName << "' constructed." << G4endl;
62 
63  // -------------------------
64  // Build parallel geometry:
65  // -------------------------
66 
67  // -- Obtain clone of mass geometry world from GetWorld() base class utility:
68  G4VPhysicalVolume* physicalParallelWorld = GetWorld();
69  G4LogicalVolume* logicalParallelWorld = physicalParallelWorld->GetLogicalVolume();
70 
71 
72  // -- We overlay a sliced geometry on top of the block of concrete in the mass geometry
73  // -- (ie, in the detector construction class), using the same dimensions.
74  // -- [Note that this is a choice : we can use different dimensions and shapes, creating
75  // -- a new solid for that.]
76  // -- For this we:
77  // -- - 1) get back the solid used to create the concrete shield;
78  // -- - 2) create a new logical volume of same shape than the shield and we place
79  // -- inside the slices
80  // -- - 3) place the sliced structure, using the placement of the physical volume of
81  // -- the concrete shield
82  // -- In all this construction, no materials are used, as only the volumes boundaries
83  // -- are of interest. Note that the absence of materials is only possible in parallel
84  // -- geometries.
85 
86 
87  // -- 1) get back the solid used to create the concrete shield:
88  // ------------------------------------------------------
89 
90  // -- get back the logical volume of the shield, using its name:
91  G4LogicalVolume* shieldLogical =
92  G4LogicalVolumeStore::GetInstance()->GetVolume("shield.logical");
93 
94  // -- get back the solid, a G4box in this case. We cast the pointer to access later on
95  // -- the G4Box class specific methods:
96  G4Box* shieldSolid = (G4Box*) shieldLogical->GetSolid();
97 
98  // -- we now re-create a logical volume for the mother volume of the slices:
99  G4LogicalVolume* motherForSlicesLogical =
100  new G4LogicalVolume(shieldSolid, // its solid
101  nullptr, // no material
102  "motherForSlices.logical"); // its name
103 
104 
105 
106  // -- 2) new logical volume of same shape than the shield and place inside the slices:
107  // -----------------------------------------------------------------------------
108 
109  // -- We create now the slices; we choose 20 slices:
110  const G4int nSlices(20);
111  // -- the solid for slices:
112  G4double halfSliceZ = shieldSolid->GetZHalfLength() / nSlices;
113  G4Box* sliceSolid = new G4Box("slice.solid",
114  shieldSolid->GetXHalfLength(),
115  shieldSolid->GetYHalfLength(),
116  halfSliceZ );
117 
118  // -- the logical volume for slices:
119  G4LogicalVolume* sliceLogical = new G4LogicalVolume(sliceSolid, // its solid
120  nullptr, // no material
121  "slice.logical"); // its name
122 
123  // -- we use a replica, to place the 20 slices in one go, along the Z axis:
124  new G4PVReplica( "slice.physical", // its name
125  sliceLogical, // its logical volume
126  motherForSlicesLogical, // its mother volume
127  kZAxis, // axis of replication
128  nSlices, // number of replica
129  2*halfSliceZ); // width of replica
130 
131 
132  // -- 3) place the sliced structure, using the concrete shield placement:
133  // ----------------------------------------------------------------
134 
135  // -- get back the physical volume of the shield, using its name:
136  // -- (note that we know we have only one physical volume with this name. If we had
137  // -- several, we should loop by ourselves on the store which is of
138  // -- std::vector<G4VPhysicalVolume*> type.)
140  shieldPhysical = G4PhysicalVolumeStore::GetInstance()->GetVolume("shield.physical");
141 
142  // -- get back the translation
143  // -- (we don't try to get back the rotation, we know we used nullptr):
144  G4ThreeVector translation = shieldPhysical->GetObjectTranslation();
145 
146  // -- finally, we place the sliced structure:
147  new G4PVPlacement( nullptr, // no rotation
148  translation, // translate as for the shield
149  motherForSlicesLogical, // its logical volume
150  "motherForSlices.physical", // its name
151  logicalParallelWorld, // its mother volume
152  false, // no boolean operation
153  0); // copy number
154 
155 }
156 
157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
158 
160 {
161  // -- Create the biasing operator:
162  auto biasingOperator = new GB06BOptrSplitAndKillByImportance("neutron","parallelOptr");
163  // -- Tell it it is active for this parallel geometry, passing the world
164  // -- volume of this geometry :
165  biasingOperator->SetParallelWorld( GetWorld() );
166 
167  // -- Attach to the logical volume where the biasing has to be applied:
168  auto slice = G4LogicalVolumeStore::GetInstance()->GetVolume("slice.logical");
169  biasingOperator->AttachTo(slice);
170 
171  // -- Create a simple "volume importance" map, linking replica numbers to importances:
172  // --------------------------------------------------------------------------------
173  // -- we define the map as going from an importance to 2*importance when going from
174  // -- a slice to the next one, in the Z direction.
175  // -- Get back the replica of slices:
176  G4PVReplica* slicePhysical =
178  G4int nReplica = slicePhysical->GetMultiplicity();
179  // -- We use and fill the map we defined in the biasing operator:
180  G4int importance = 1;
181  for ( G4int iReplica = 0 ; iReplica < nReplica ; iReplica++ )
182  {
183  (biasingOperator->GetImportanceMap())[ iReplica ] = importance;
184  importance *= 2;
185  }
186 
187 }
G4double GetYHalfLength() const
G4LogicalVolume * GetLogicalVolume() const
#define G4endl
Definition: G4ios.hh:61
G4VPhysicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
GB06ParallelWorldForSlices(G4String worldName)
Definition of the GB06ParallelWorldForSlices class.
Definition of the GB06BOptrSplitAndKillByImportance class.
double G4double
Definition: G4Types.hh:76
Definition: G4Box.hh:64
G4double GetXHalfLength() const
virtual G4int GetMultiplicity() const
Definition: G4PVReplica.cc:225
G4VPhysicalVolume * GetWorld()
static G4PhysicalVolumeStore * GetInstance()
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
G4VSolid * GetSolid() const
G4ThreeVector GetObjectTranslation() const
G4double GetZHalfLength() const
static G4LogicalVolumeStore * GetInstance()
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const