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 "G4UnitsTable.hh" 50 51 //....oooOO0OOooo........oooOO0OOooo........oo 52 53 DetectorConstruction::DetectorConstruction() 54 { 55 // default geometrical parameters 56 fAbsorThickness = 1 * cm; 57 fAbsorSizeYZ = 1 * cm; 58 fWorldSizeX = 1.2 * fAbsorThickness; 59 fWorldSizeYZ = 1.2 * fAbsorSizeYZ; 60 61 // materials 62 DefineMaterials(); 63 SetAbsorMaterial("G4_Co"); 64 65 // create commands for interactive definitio 66 fDetectorMessenger = new DetectorMessenger(t 67 } 68 69 //....oooOO0OOooo........oooOO0OOooo........oo 70 71 DetectorConstruction::~DetectorConstruction() 72 { 73 delete fDetectorMessenger; 74 } 75 76 //....oooOO0OOooo........oooOO0OOooo........oo 77 78 G4VPhysicalVolume* DetectorConstruction::Const 79 { 80 return ConstructVolumes(); 81 } 82 83 //....oooOO0OOooo........oooOO0OOooo........oo 84 85 void DetectorConstruction::DefineMaterials() 86 { 87 // specific element name for thermal neutron 88 // (see G4ParticleHPThermalScatteringNames.c 89 90 G4int ncomponents, natoms; 91 92 // pressurized water 93 G4Element* H = new G4Element("TS_H_of_Water" 94 G4Element* O = new G4Element("Oxygen", "O", 95 G4Material* H2O = new G4Material("Water_ts", 96 593 * kelvi 97 H2O->AddElement(H, natoms = 2); 98 H2O->AddElement(O, natoms = 1); 99 H2O->GetIonisation()->SetMeanExcitationEnerg 100 101 // heavy water 102 G4Isotope* H2 = new G4Isotope("H2", 1, 2); 103 G4Element* D = new G4Element("TS_D_of_Heavy_ 104 D->AddIsotope(H2, 100 * perCent); 105 G4Material* D2O = new G4Material("HeavyWater 106 293.15 * ke 107 D2O->AddElement(D, natoms = 2); 108 D2O->AddElement(O, natoms = 1); 109 110 // graphite 111 G4Isotope* C12 = new G4Isotope("C12", 6, 12) 112 G4Element* C = new G4Element("TS_C_of_Graphi 113 C->AddIsotope(C12, 100. * perCent); 114 G4Material* graphite = new G4Material("graph 115 293 * 116 graphite->AddElement(C, natoms = 1); 117 118 // example of vacuum 119 fWorldMaterial = new G4Material("Galactic", 120 2.73 * kelvi 121 122 /// G4cout << *(G4Material::GetMaterialTable 123 } 124 125 //....oooOO0OOooo........oooOO0OOooo........oo 126 127 G4Material* DetectorConstruction::MaterialWith 128 129 { 130 // define a material from an isotope 131 // 132 G4int ncomponents; 133 G4double abundance, massfraction; 134 135 G4Isotope* isotope = new G4Isotope(symbol, Z 136 137 G4Element* element = new G4Element(name, sym 138 element->AddIsotope(isotope, abundance = 100 139 140 G4Material* material = new G4Material(name, 141 material->AddElement(element, massfraction = 142 143 return material; 144 } 145 146 //....oooOO0OOooo........oooOO0OOooo........oo 147 148 G4VPhysicalVolume* DetectorConstruction::Const 149 { 150 // Cleanup old geometry 151 G4GeometryManager::GetInstance()->OpenGeomet 152 G4PhysicalVolumeStore::GetInstance()->Clean( 153 G4LogicalVolumeStore::GetInstance()->Clean() 154 G4SolidStore::GetInstance()->Clean(); 155 156 // World 157 // 158 fWorldSizeX = 1.2 * fAbsorThickness; 159 fWorldSizeYZ = 1.2 * fAbsorSizeYZ; 160 161 G4Box* sWorld = new G4Box("World", // name 162 fWorldSizeX / 2, f 163 164 G4LogicalVolume* lWorld = new G4LogicalVolum 165 166 167 168 fWorldVolume = new G4PVPlacement(0, // no r 169 G4ThreeVect 170 lWorld, // 171 "World", / 172 0, // moth 173 false, // 174 0); // cop 175 176 // Absorber 177 // 178 G4Box* sAbsor = new G4Box("Absorber", // na 179 fAbsorThickness / 180 181 fLAbsor = new G4LogicalVolume(sAbsor, // sh 182 fAbsorMaterial 183 fAbsorMaterial 184 185 new G4PVPlacement(0, // no rotation 186 G4ThreeVector(), // at (0 187 fLAbsor, // logical volum 188 fAbsorMaterial->GetName(), 189 lWorld, // mother volume 190 false, // no boolean oper 191 0); // copy number 192 193 PrintParameters(); 194 195 // always return the root volume 196 // 197 return fWorldVolume; 198 } 199 200 //....oooOO0OOooo........oooOO0OOooo........oo 201 202 void DetectorConstruction::PrintParameters() 203 { 204 G4cout << "\n The Absorber is " << G4BestUni 205 << fAbsorMaterial->GetName() << "\n \ 206 << fAbsorMaterial << G4endl; 207 } 208 209 //....oooOO0OOooo........oooOO0OOooo........oo 210 211 void DetectorConstruction::SetAbsorMaterial(G4 212 { 213 // search the material by its name 214 G4Material* pttoMaterial = G4NistManager::In 215 216 if (pttoMaterial) { 217 fAbsorMaterial = pttoMaterial; 218 if (fLAbsor) { 219 fLAbsor->SetMaterial(fAbsorMaterial); 220 } 221 G4RunManager::GetRunManager()->PhysicsHasB 222 } 223 else { 224 G4cout << "\n--> warning from DetectorCons 225 << " not found" << G4endl; 226 } 227 } 228 229 //....oooOO0OOooo........oooOO0OOooo........oo 230 231 void DetectorConstruction::SetAbsorThickness(G 232 { 233 fAbsorThickness = value; 234 G4RunManager::GetRunManager()->ReinitializeG 235 } 236 237 //....oooOO0OOooo........oooOO0OOooo........oo 238 239 void DetectorConstruction::SetAbsorSizeYZ(G4do 240 { 241 fAbsorSizeYZ = value; 242 G4RunManager::GetRunManager()->ReinitializeG 243 } 244 245 //....oooOO0OOooo........oooOO0OOooo........oo 246