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 // 27 /// \file B4/B4a/src/DetectorConstruction.cc 28 /// \brief Implementation of the B4::DetectorC 29 30 #include "DetectorConstruction.hh" 31 32 #include "G4AutoDelete.hh" 33 #include "G4Box.hh" 34 #include "G4Colour.hh" 35 #include "G4GlobalMagFieldMessenger.hh" 36 #include "G4LogicalVolume.hh" 37 #include "G4Material.hh" 38 #include "G4NistManager.hh" 39 #include "G4PVPlacement.hh" 40 #include "G4PVReplica.hh" 41 #include "G4PhysicalConstants.hh" 42 #include "G4SystemOfUnits.hh" 43 #include "G4VisAttributes.hh" 44 45 namespace B4 46 { 47 48 //....oooOO0OOooo........oooOO0OOooo........oo 49 50 G4ThreadLocal G4GlobalMagFieldMessenger* Detec 51 52 //....oooOO0OOooo........oooOO0OOooo........oo 53 54 G4VPhysicalVolume* DetectorConstruction::Const 55 { 56 // Define materials 57 DefineMaterials(); 58 59 // Define volumes 60 return DefineVolumes(); 61 } 62 63 //....oooOO0OOooo........oooOO0OOooo........oo 64 65 void DetectorConstruction::DefineMaterials() 66 { 67 // Lead material defined using NIST Manager 68 auto nistManager = G4NistManager::Instance() 69 nistManager->FindOrBuildMaterial("G4_Pb"); 70 71 // Liquid argon material 72 G4double a; // mass of a mole; 73 G4double z; // z=mean number of protons; 74 G4double density; 75 new G4Material("liquidArgon", z = 18., a = 3 76 // The argon by NIST Manager is a gas with a 77 78 // Vacuum 79 new G4Material("Galactic", z = 1., a = 1.01 80 kStateGas, 2.73 * kelvin, 3.e 81 82 // Print materials 83 G4cout << *(G4Material::GetMaterialTable()) 84 } 85 86 //....oooOO0OOooo........oooOO0OOooo........oo 87 88 G4VPhysicalVolume* DetectorConstruction::Defin 89 { 90 // Geometry parameters 91 G4int nofLayers = 10; 92 G4double absoThickness = 10. * mm; 93 G4double gapThickness = 5. * mm; 94 G4double calorSizeXY = 10. * cm; 95 96 auto layerThickness = absoThickness + gapThi 97 auto calorThickness = nofLayers * layerThick 98 auto worldSizeXY = 1.2 * calorSizeXY; 99 auto worldSizeZ = 1.2 * calorThickness; 100 101 // Get materials 102 auto defaultMaterial = G4Material::GetMateri 103 auto absorberMaterial = G4Material::GetMater 104 auto gapMaterial = G4Material::GetMaterial(" 105 106 if (!defaultMaterial || !absorberMaterial || 107 G4ExceptionDescription msg; 108 msg << "Cannot retrieve materials already 109 G4Exception("DetectorConstruction::DefineV 110 } 111 112 // 113 // World 114 // 115 auto worldS = new G4Box("World", // its nam 116 worldSizeXY / 2, wor 117 118 auto worldLV = new G4LogicalVolume(worldS, 119 defaultMa 120 "World"); 121 122 auto worldPV = new G4PVPlacement(nullptr, / 123 G4ThreeVect 124 worldLV, / 125 "World", / 126 nullptr, / 127 false, // 128 0, // copy 129 fCheckOverl 130 131 // 132 // Calorimeter 133 // 134 auto calorimeterS = new G4Box("Calorimeter", 135 calorSizeXY / 136 137 auto calorLV = new G4LogicalVolume(calorimet 138 defaultMa 139 "Calorime 140 141 new G4PVPlacement(nullptr, // no rotation 142 G4ThreeVector(), // at (0 143 calorLV, // its logical v 144 "Calorimeter", // its nam 145 worldLV, // its mother v 146 false, // no boolean oper 147 0, // copy number 148 fCheckOverlaps); // check 149 150 // 151 // Layer 152 // 153 auto layerS = new G4Box("Layer", // its nam 154 calorSizeXY / 2, cal 155 156 auto layerLV = new G4LogicalVolume(layerS, 157 defaultMa 158 "Layer"); 159 160 new G4PVReplica("Layer", // its name 161 layerLV, // its logical vol 162 calorLV, // its mother 163 kZAxis, // axis of replicat 164 nofLayers, // number of rep 165 layerThickness); // witdth 166 167 // 168 // Absorber 169 // 170 auto absorberS = new G4Box("Abso", // its n 171 calorSizeXY / 2, 172 173 auto absorberLV = new G4LogicalVolume(absorb 174 absorb 175 "Abso" 176 177 fAbsorberPV = new G4PVPlacement(nullptr, // 178 G4ThreeVecto 179 absorberLV, 180 "Abso", // 181 layerLV, // 182 false, // n 183 0, // copy 184 fCheckOverla 185 186 // 187 // Gap 188 // 189 auto gapS = new G4Box("Gap", // its name 190 calorSizeXY / 2, calor 191 192 auto gapLV = new G4LogicalVolume(gapS, // i 193 gapMaterial 194 "Gap"); // 195 196 fGapPV = new G4PVPlacement(nullptr, // no r 197 G4ThreeVector(0., 198 gapLV, // its lo 199 "Gap", // its na 200 layerLV, // its 201 false, // no boo 202 0, // copy numbe 203 fCheckOverlaps); 204 205 // 206 // print parameters 207 // 208 G4cout << G4endl << "----------------------- 209 << "---> The calorimeter is " << nofL 210 << "mm of " << absorberMaterial->GetN 211 << gapMaterial->GetName() << " ] " << 212 << "--------------------------------- 213 214 // 215 // Visualization attributes 216 // 217 worldLV->SetVisAttributes(G4VisAttributes::G 218 calorLV->SetVisAttributes(G4VisAttributes(G4 219 220 // 221 // Always return the physical World 222 // 223 return worldPV; 224 } 225 226 //....oooOO0OOooo........oooOO0OOooo........oo 227 228 void DetectorConstruction::ConstructSDandField 229 { 230 // Create global magnetic field messenger. 231 // Uniform magnetic field is then created au 232 // the field value is not zero. 233 G4ThreeVector fieldValue; 234 fMagFieldMessenger = new G4GlobalMagFieldMes 235 fMagFieldMessenger->SetVerboseLevel(1); 236 237 // Register the field messenger for deleting 238 G4AutoDelete::Register(fMagFieldMessenger); 239 } 240 241 //....oooOO0OOooo........oooOO0OOooo........oo 242 243 } // namespace B4 244