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 medical/fanoCavity/src/DetectorConst 27 /// \brief Implementation of the DetectorConst 28 // 29 30 // 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oo 33 34 #include "DetectorConstruction.hh" 35 36 #include "DetectorMessenger.hh" 37 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 "G4SolidStore.hh" 47 #include "G4SystemOfUnits.hh" 48 #include "G4Tubs.hh" 49 #include "G4UnitsTable.hh" 50 #include "G4VPhysicalVolume.hh" 51 52 //....oooOO0OOooo........oooOO0OOooo........oo 53 54 DetectorConstruction::DetectorConstruction() : 55 { 56 // default parameter values 57 fCavityThickness = 2 * mm; 58 fCavityRadius = 1 * cm; 59 60 fWallThickness = 5 * mm; 61 62 DefineMaterials(); 63 SetWallMaterial("G4_WATER"); 64 SetCavityMaterial("g4Water_gas"); 65 66 // create commands for interactive definitio 67 fDetectorMessenger = new DetectorMessenger(t 68 } 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 71 72 DetectorConstruction::~DetectorConstruction() 73 { 74 delete fDetectorMessenger; 75 } 76 77 //....oooOO0OOooo........oooOO0OOooo........oo 78 79 void DetectorConstruction::DefineMaterials() 80 { 81 G4double z, a; 82 83 G4Element* H = new G4Element("Hydrogen", "H" 84 G4Element* O = new G4Element("Oxygen", "O", 85 86 G4Material* H2O = new G4Material("Water", 1. 87 H2O->AddElement(H, 2); 88 H2O->AddElement(O, 1); 89 H2O->GetIonisation()->SetMeanExcitationEnerg 90 91 G4Material* gas = new G4Material("Water_gas" 92 gas->AddElement(H, 2); 93 gas->AddElement(O, 1); 94 gas->GetIonisation()->SetMeanExcitationEnerg 95 96 new G4Material("Graphite", 6, 12.01 * g / mo 97 new G4Material("Graphite_gas", 6, 12.01 * g 98 99 new G4Material("Aluminium", 13, 26.98 * g / 100 new G4Material("Aluminium_gas", 13, 26.98 * 101 102 // alternatively, use G4 data base 103 // 104 G4NistManager* nist = G4NistManager::Instanc 105 106 nist->FindOrBuildMaterial("G4_WATER"); 107 nist->BuildMaterialWithNewDensity("g4Water_g 108 109 // printout 110 G4cout << *(G4Material::GetMaterialTable()) 111 } 112 113 //....oooOO0OOooo........oooOO0OOooo........oo 114 115 G4VPhysicalVolume* DetectorConstruction::Const 116 { 117 if (fWall) { 118 return fWall; 119 } 120 121 // Chamber 122 // 123 fTotalThickness = fCavityThickness + 2 * fWa 124 fWallRadius = fCavityRadius + fWallThickness 125 126 G4Tubs* sChamber = new G4Tubs("Chamber", // 127 0., fWallRadiu 128 129 G4LogicalVolume* lChamber = new G4LogicalVol 130 131 132 133 fWall = new G4PVPlacement(0, // no rotation 134 G4ThreeVector(), 135 lChamber, // logi 136 "Wall", // name 137 0, // mother vol 138 false, // no bool 139 0); // copy numbe 140 141 // Cavity 142 // 143 G4Tubs* sCavity = new G4Tubs("Cavity", 0., f 144 145 G4LogicalVolume* lCavity = new G4LogicalVolu 146 147 148 149 fCavity = new G4PVPlacement(0, // no rotati 150 G4ThreeVector(), 151 lCavity, // log 152 "Cavity", // na 153 lChamber, // mo 154 false, // no bo 155 1); // copy num 156 157 PrintParameters(); 158 159 // 160 // always return the root volume 161 // 162 return fWall; 163 } 164 165 //....oooOO0OOooo........oooOO0OOooo........oo 166 167 void DetectorConstruction::PrintParameters() 168 { 169 G4cout << "\n------------------------------- 170 G4cout << "---> The Wall is " << G4BestUnit( 171 << fWallMaterial->GetName() << " ( " 172 << G4BestUnit(fWallMaterial->GetDensi 173 G4cout << " The Cavity is " << G4BestUni 174 << fCavityMaterial->GetName() << " ( 175 << G4BestUnit(fCavityMaterial->GetDen 176 G4cout << "\n------------------------------- 177 G4cout << G4endl; 178 } 179 180 //....oooOO0OOooo........oooOO0OOooo........oo 181 182 void DetectorConstruction::SetWallThickness(G4 183 { 184 fWallThickness = value; 185 } 186 187 //....oooOO0OOooo........oooOO0OOooo........oo 188 189 void DetectorConstruction::SetWallMaterial(con 190 { 191 // search the material by its name 192 G4Material* pttoMaterial = G4Material::GetMa 193 if (pttoMaterial) fWallMaterial = pttoMateri 194 } 195 196 //....oooOO0OOooo........oooOO0OOooo........oo 197 198 void DetectorConstruction::SetCavityThickness( 199 { 200 fCavityThickness = value; 201 } 202 203 //....oooOO0OOooo........oooOO0OOooo........oo 204 205 void DetectorConstruction::SetCavityRadius(G4d 206 { 207 fCavityRadius = value; 208 } 209 210 //....oooOO0OOooo........oooOO0OOooo........oo 211 212 void DetectorConstruction::SetCavityMaterial(c 213 { 214 // search the material by its name 215 G4Material* pttoMaterial = G4Material::GetMa 216 if (pttoMaterial) fCavityMaterial = pttoMate 217 } 218 219 //....oooOO0OOooo........oooOO0OOooo........oo 220