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