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