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 DetectorConstruction.cc 27 /// \brief Implementation of the DetectorConst 28 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 33 #include "DetectorConstruction.hh" 34 35 #include "DetectorMessenger.hh" 36 37 #include "G4Box.hh" 38 #include "G4GeometryManager.hh" 39 #include "G4LogicalVolume.hh" 40 #include "G4LogicalVolumeStore.hh" 41 #include "G4Material.hh" 42 #include "G4NistManager.hh" 43 #include "G4PVPlacement.hh" 44 #include "G4PhysicalConstants.hh" 45 #include "G4PhysicalVolumeStore.hh" 46 #include "G4RunManager.hh" 47 #include "G4SolidStore.hh" 48 #include "G4SystemOfUnits.hh" 49 #include "G4Tubs.hh" 50 #include "G4UnitsTable.hh" 51 52 //....oooOO0OOooo........oooOO0OOooo........oo 53 54 DetectorConstruction::DetectorConstruction() 55 { 56 fAbsorRadius = 15 * mm; 57 fAbsorLength = 60 * mm; 58 fContainThickness = 2.4 * mm; 59 DefineMaterials(); 60 SetAbsorMaterial("BeO"); 61 SetContainMaterial("Stainless-Steel"); 62 fDetectorMessenger = new DetectorMessenger(t 63 } 64 65 //....oooOO0OOooo........oooOO0OOooo........oo 66 67 DetectorConstruction::~DetectorConstruction() 68 { 69 delete fDetectorMessenger; 70 } 71 72 //....oooOO0OOooo........oooOO0OOooo........oo 73 74 G4VPhysicalVolume* DetectorConstruction::Const 75 { 76 return ConstructVolumes(); 77 } 78 79 //....oooOO0OOooo........oooOO0OOooo........oo 80 81 void DetectorConstruction::DefineMaterials() 82 { 83 G4int ncomponents, natoms; 84 85 G4Element* Be = new G4Element("Beryllium", " 86 G4Element* N = new G4Element("Nitrogen", "N" 87 G4Element* O = new G4Element("Oxygen", "O", 88 G4Element* Cr = new G4Element("Chromium", "C 89 G4Element* Fe = new G4Element("Iron", "Fe", 90 G4Element* Ni = new G4Element("Nickel", "Ni" 91 92 G4Material* BeO = new G4Material("BeO", 3.05 93 BeO->AddElement(Be, natoms = 1); 94 BeO->AddElement(O, natoms = 1); 95 96 G4Material* inox = new G4Material("Stainless 97 inox->AddElement(Fe, 74 * perCent); 98 inox->AddElement(Cr, 18 * perCent); 99 inox->AddElement(Ni, 8 * perCent); 100 101 G4Material* Air = new G4Material("Air", 1.29 102 Air->AddElement(N, 70. * perCent); 103 Air->AddElement(O, 30. * perCent); 104 105 fWorldMaterial = Air; 106 107 /// G4cout << *(G4Material::GetMaterialTable 108 } 109 110 //....oooOO0OOooo........oooOO0OOooo........oo 111 112 G4Material* DetectorConstruction::MaterialWith 113 114 { 115 // define a material from an isotope 116 // 117 G4int ncomponents; 118 G4double abundance, massfraction; 119 120 G4Isotope* isotope = new G4Isotope(symbol, Z 121 122 G4Element* element = new G4Element(name, sym 123 element->AddIsotope(isotope, abundance = 100 124 125 G4Material* material = new G4Material(name, 126 material->AddElement(element, massfraction = 127 128 return material; 129 } 130 131 //....oooOO0OOooo........oooOO0OOooo........oo 132 133 G4VPhysicalVolume* DetectorConstruction::Const 134 { 135 // Cleanup old geometry 136 G4GeometryManager::GetInstance()->OpenGeomet 137 G4PhysicalVolumeStore::GetInstance()->Clean( 138 G4LogicalVolumeStore::GetInstance()->Clean() 139 G4SolidStore::GetInstance()->Clean(); 140 141 // compute dimensions 142 G4double ContainRadius = fAbsorRadius + fCon 143 G4double ContainLength = fAbsorLength + 2 * 144 145 G4double WorldSizeXY = 2.4 * ContainRadius; 146 G4double WorldSizeZ = 1.2 * ContainLength; 147 148 // World 149 // 150 G4Box* sWorld = new G4Box("World", // name 151 0.5 * WorldSizeXY, 152 153 G4LogicalVolume* lWorld = new G4LogicalVolum 154 155 156 157 fPWorld = new G4PVPlacement(0, // no rotati 158 G4ThreeVector(), 159 lWorld, // logi 160 "World", // nam 161 0, // mother vo 162 false, // no bo 163 0); // copy num 164 165 // Container 166 // 167 G4Tubs* sContain = new G4Tubs("Container", 168 0., ContainRad 169 170 fLContain = new G4LogicalVolume(sContain, / 171 fContainMate 172 fContainMate 173 174 new G4PVPlacement(0, // no rotation 175 G4ThreeVector(), // at (0 176 fLContain, // logical vol 177 fContainMaterial->GetName( 178 lWorld, // mother volume 179 false, // no boolean oper 180 0); // copy number 181 182 // Absorber 183 // 184 G4Tubs* sAbsor = new G4Tubs("Absorber", // 185 0., fAbsorRadius 186 187 fLAbsor = new G4LogicalVolume(sAbsor, // sh 188 fAbsorMaterial 189 fAbsorMaterial 190 191 new G4PVPlacement(0, // no rotation 192 G4ThreeVector(), // at (0 193 fLAbsor, // logical volum 194 fAbsorMaterial->GetName(), 195 fLContain, // mother vol 196 false, // no boolean oper 197 0); // copy number 198 199 PrintParameters(); 200 201 // always return the root volume 202 // 203 return fPWorld; 204 } 205 206 //....oooOO0OOooo........oooOO0OOooo........oo 207 208 void DetectorConstruction::PrintParameters() 209 { 210 G4cout << "\n The Absorber is a cylinder of 211 << " radius = " << G4BestUnit(fAbsor 212 << " length = " << G4BestUnit(fAbsor 213 G4cout << " The Container is a cylinder of " 214 << " thickness = " << G4BestUnit(fCo 215 216 G4cout << "\n" << fAbsorMaterial << G4endl; 217 G4cout << "\n" << fContainMaterial << G4endl 218 } 219 220 //....oooOO0OOooo........oooOO0OOooo........oo 221 222 void DetectorConstruction::SetAbsorMaterial(G4 223 { 224 // search the material by its name 225 G4Material* pttoMaterial = G4NistManager::In 226 227 if (pttoMaterial) { 228 fAbsorMaterial = pttoMaterial; 229 if (fLAbsor) { 230 fLAbsor->SetMaterial(fAbsorMaterial); 231 } 232 G4RunManager::GetRunManager()->PhysicsHasB 233 } 234 else { 235 G4cout << "\n--> warning from DetectorCons 236 << " not found" << G4endl; 237 } 238 } 239 240 //....oooOO0OOooo........oooOO0OOooo........oo 241 242 void DetectorConstruction::SetContainMaterial( 243 { 244 // search the material by its name 245 G4Material* pttoMaterial = G4NistManager::In 246 247 if (pttoMaterial) { 248 fContainMaterial = pttoMaterial; 249 if (fLContain) { 250 fLContain->SetMaterial(fContainMaterial) 251 } 252 G4RunManager::GetRunManager()->PhysicsHasB 253 } 254 else { 255 G4cout << "\n--> warning from DetectorCons 256 << " not found" << G4endl; 257 } 258 } 259 260 //....oooOO0OOooo........oooOO0OOooo........oo 261 262 void DetectorConstruction::SetAbsorRadius(G4do 263 { 264 fAbsorRadius = value; 265 G4RunManager::GetRunManager()->ReinitializeG 266 } 267 268 //....oooOO0OOooo........oooOO0OOooo........oo 269 270 void DetectorConstruction::SetAbsorLength(G4do 271 { 272 fAbsorLength = value; 273 G4RunManager::GetRunManager()->ReinitializeG 274 } 275 276 //....oooOO0OOooo........oooOO0OOooo........oo 277 278 void DetectorConstruction::SetContainThickness 279 { 280 fContainThickness = value; 281 G4RunManager::GetRunManager()->ReinitializeG 282 } 283 284 //....oooOO0OOooo........oooOO0OOooo........oo 285