Geant4 Cross Reference |
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 // 26 // 27 /// \file B1/src/DetectorConstruction.cc 28 /// \brief Implementation of the B1::DetectorConstruction class 29 30 #include "DetectorConstruction.hh" 31 32 #include "G4Box.hh" 33 #include "G4Cons.hh" 34 #include "G4LogicalVolume.hh" 35 #include "G4NistManager.hh" 36 #include "G4Orb.hh" 37 #include "G4PVPlacement.hh" 38 #include "G4RunManager.hh" 39 #include "G4Sphere.hh" 40 #include "G4SystemOfUnits.hh" 41 #include "G4Trd.hh" 42 43 namespace B1 44 { 45 46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 48 G4VPhysicalVolume* DetectorConstruction::Construct() 49 { 50 // Get nist material manager 51 G4NistManager* nist = G4NistManager::Instance(); 52 53 // Envelope parameters 54 // 55 G4double env_sizeXY = 20 * cm, env_sizeZ = 30 * cm; 56 G4Material* env_mat = nist->FindOrBuildMaterial("G4_WATER"); 57 58 // Option to switch on/off checking of volumes overlaps 59 // 60 G4bool checkOverlaps = true; 61 62 // 63 // World 64 // 65 G4double world_sizeXY = 1.2 * env_sizeXY; 66 G4double world_sizeZ = 1.2 * env_sizeZ; 67 G4Material* world_mat = nist->FindOrBuildMaterial("G4_AIR"); 68 69 auto solidWorld = 70 new G4Box("World", // its name 71 0.5 * world_sizeXY, 0.5 * world_sizeXY, 0.5 * world_sizeZ); // its size 72 73 auto logicWorld = new G4LogicalVolume(solidWorld, // its solid 74 world_mat, // its material 75 "World"); // its name 76 77 auto physWorld = new G4PVPlacement(nullptr, // no rotation 78 G4ThreeVector(), // at (0,0,0) 79 logicWorld, // its logical volume 80 "World", // its name 81 nullptr, // its mother volume 82 false, // no boolean operation 83 0, // copy number 84 checkOverlaps); // overlaps checking 85 86 // 87 // Envelope 88 // 89 auto solidEnv = new G4Box("Envelope", // its name 90 0.5 * env_sizeXY, 0.5 * env_sizeXY, 0.5 * env_sizeZ); // its size 91 92 auto logicEnv = new G4LogicalVolume(solidEnv, // its solid 93 env_mat, // its material 94 "Envelope"); // its name 95 96 new G4PVPlacement(nullptr, // no rotation 97 G4ThreeVector(), // at (0,0,0) 98 logicEnv, // its logical volume 99 "Envelope", // its name 100 logicWorld, // its mother volume 101 false, // no boolean operation 102 0, // copy number 103 checkOverlaps); // overlaps checking 104 105 // 106 // Shape 1 107 // 108 G4Material* shape1_mat = nist->FindOrBuildMaterial("G4_A-150_TISSUE"); 109 G4ThreeVector pos1 = G4ThreeVector(0, 2 * cm, -7 * cm); 110 111 // Conical section shape 112 G4double shape1_rmina = 0. * cm, shape1_rmaxa = 2. * cm; 113 G4double shape1_rminb = 0. * cm, shape1_rmaxb = 4. * cm; 114 G4double shape1_hz = 3. * cm; 115 G4double shape1_phimin = 0. * deg, shape1_phimax = 360. * deg; 116 auto solidShape1 = new G4Cons("Shape1", shape1_rmina, shape1_rmaxa, shape1_rminb, shape1_rmaxb, 117 shape1_hz, shape1_phimin, shape1_phimax); 118 119 auto logicShape1 = new G4LogicalVolume(solidShape1, // its solid 120 shape1_mat, // its material 121 "Shape1"); // its name 122 123 new G4PVPlacement(nullptr, // no rotation 124 pos1, // at position 125 logicShape1, // its logical volume 126 "Shape1", // its name 127 logicEnv, // its mother volume 128 false, // no boolean operation 129 0, // copy number 130 checkOverlaps); // overlaps checking 131 132 // 133 // Shape 2 134 // 135 G4Material* shape2_mat = nist->FindOrBuildMaterial("G4_BONE_COMPACT_ICRU"); 136 G4ThreeVector pos2 = G4ThreeVector(0, -1 * cm, 7 * cm); 137 138 // Trapezoid shape 139 G4double shape2_dxa = 12 * cm, shape2_dxb = 12 * cm; 140 G4double shape2_dya = 10 * cm, shape2_dyb = 16 * cm; 141 G4double shape2_dz = 6 * cm; 142 auto solidShape2 = 143 new G4Trd("Shape2", // its name 144 0.5 * shape2_dxa, 0.5 * shape2_dxb, 0.5 * shape2_dya, 0.5 * shape2_dyb, 145 0.5 * shape2_dz); // its size 146 147 auto logicShape2 = new G4LogicalVolume(solidShape2, // its solid 148 shape2_mat, // its material 149 "Shape2"); // its name 150 151 new G4PVPlacement(nullptr, // no rotation 152 pos2, // at position 153 logicShape2, // its logical volume 154 "Shape2", // its name 155 logicEnv, // its mother volume 156 false, // no boolean operation 157 0, // copy number 158 checkOverlaps); // overlaps checking 159 160 // Set Shape2 as scoring volume 161 // 162 fScoringVolume = logicShape2; 163 164 // 165 // always return the physical World 166 // 167 return physWorld; 168 } 169 170 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 171 172 } // namespace B1 173