Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file GB06/src/GB06ParallelWorldForSlices. 27 /// \brief Implementation of the GB06ParallelW 28 // 29 // 30 #include "GB06ParallelWorldForSlices.hh" 31 32 #include "GB06BOptrSplitAndKillByImportance.hh 33 34 #include "G4Box.hh" 35 #include "G4LogicalVolume.hh" 36 #include "G4LogicalVolumeStore.hh" 37 #include "G4PVPlacement.hh" 38 #include "G4PVReplica.hh" 39 #include "G4PhysicalVolumeStore.hh" 40 #include "G4SystemOfUnits.hh" 41 #include "G4ThreeVector.hh" 42 43 //....oooOO0OOooo........oooOO0OOooo........oo 44 45 GB06ParallelWorldForSlices::GB06ParallelWorldF 46 : G4VUserParallelWorld(worldName) 47 { 48 ; 49 } 50 51 //....oooOO0OOooo........oooOO0OOooo........oo 52 53 GB06ParallelWorldForSlices::~GB06ParallelWorld 54 { 55 ; 56 } 57 58 //....oooOO0OOooo........oooOO0OOooo........oo 59 60 void GB06ParallelWorldForSlices::Construct() 61 { 62 // -- Inform about construction: 63 // -- (fWorldName is a protected data member 64 G4cout << "Parallel World `" << fWorldName < 65 66 // ------------------------- 67 // Build parallel geometry: 68 // ------------------------- 69 70 // -- Obtain clone of mass geometry world fr 71 G4VPhysicalVolume* physicalParallelWorld = G 72 G4LogicalVolume* logicalParallelWorld = phys 73 74 // -- We overlay a sliced geometry on top of 75 // -- (ie, in the detector construction clas 76 // -- [Note that this is a choice : we can u 77 // -- a new solid for that.] 78 // -- For this we: 79 // -- - 1) get back the solid used to cr 80 // -- - 2) create a new logical volume o 81 // -- inside the slices 82 // -- - 3) place the sliced structure, u 83 // -- the concrete shield 84 // -- In all this construction, no materials 85 // -- are of interest. Note that the absence 86 // -- geometries. 87 88 // -- 1) get back the solid used to create t 89 // ----------------------------------- 90 91 // -- get back the logical volume of the shi 92 G4LogicalVolume* shieldLogical = G4LogicalVo 93 94 // -- get back the solid, a G4box in this ca 95 // -- the G4Box class specific methods: 96 auto shieldSolid = (G4Box*)shieldLogical->Ge 97 98 // -- we now re-create a logical volume for 99 G4LogicalVolume* motherForSlicesLogical = 100 new G4LogicalVolume(shieldSolid, // its s 101 nullptr, // no materi 102 "motherForSlices.logic 103 104 // -- 2) new logical volume of same shape th 105 // ----------------------------------- 106 107 // -- We create now the slices; we choose 20 108 const G4int nSlices(20); 109 // -- the solid for slices: 110 G4double halfSliceZ = shieldSolid->GetZHalfL 111 G4Box* sliceSolid = new G4Box("slice.solid", 112 shieldSolid->G 113 114 // -- the logical volume for slices: 115 sliceLogical = new G4LogicalVolume(sliceSoli 116 nullptr, 117 "slice.lo 118 119 // -- we use a replica, to place the 20 slic 120 slicePhysical = new G4PVReplica("slice.physi 121 sliceLogical 122 motherForSli 123 kZAxis, // 124 nSlices, // 125 2 * halfSlic 126 127 // -- 3) place the sliced structure, using t 128 // ----------------------------------- 129 130 // -- get back the physical volume of the sh 131 // -- (note that we know we have only one ph 132 // -- several, we should loop by ourselves o 133 // -- std::vector<G4VPhysicalVolume*> type.) 134 G4VPhysicalVolume* shieldPhysical = 135 G4PhysicalVolumeStore::GetInstance()->GetV 136 137 // -- get back the translation 138 // -- (we don't try to get back the rotation 139 G4ThreeVector translation = shieldPhysical-> 140 141 // -- finally, we place the sliced structure 142 new G4PVPlacement(nullptr, // no rotation 143 translation, // translate 144 motherForSlicesLogical, / 145 "motherForSlices.physical" 146 logicalParallelWorld, // 147 false, // no boolean oper 148 0); // copy number 149 } 150 151 //....oooOO0OOooo........oooOO0OOooo........oo 152 153 void GB06ParallelWorldForSlices::ConstructSD() 154 { 155 // -- Create the biasing operator: 156 auto biasingOperator = new GB06BOptrSplitAnd 157 // -- Tell it it is active for this parallel 158 // -- volume of this geometry : 159 biasingOperator->SetParallelWorld(GetWorld() 160 161 // -- Attach to the logical volume where the 162 biasingOperator->AttachTo(sliceLogical); 163 164 // -- Create a simple "volume importance" ma 165 // -------------------------------------- 166 // -- we define the map as going from an imp 167 // -- a slice to the next one, in the Z dire 168 // -- Get back the replica of slices: 169 G4int nReplica = slicePhysical->GetMultiplic 170 // -- We use and fill the map we defined in 171 G4int importance = 1; 172 for (G4int iReplica = 0; iReplica < nReplica 173 (biasingOperator->GetImportanceMap())[iRep 174 importance *= 2; 175 } 176 } 177