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 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oo 33 34 #include "DetectorConstruction.hh" 35 36 #include "DetectorMessenger.hh" 37 #include "PrimaryGeneratorAction.hh" 38 39 #include "G4Box.hh" 40 #include "G4GeometryManager.hh" 41 #include "G4LogicalVolume.hh" 42 #include "G4LogicalVolumeStore.hh" 43 #include "G4Material.hh" 44 #include "G4NistManager.hh" 45 #include "G4PVPlacement.hh" 46 #include "G4PhysicalConstants.hh" 47 #include "G4PhysicalVolumeStore.hh" 48 #include "G4RunManager.hh" 49 #include "G4SolidStore.hh" 50 #include "G4SystemOfUnits.hh" 51 #include "G4ThreeVector.hh" 52 #include "G4Tubs.hh" 53 #include "globals.hh" 54 55 //....oooOO0OOooo........oooOO0OOooo........oo 56 57 DetectorConstruction::DetectorConstruction() 58 : fMaterial(nullptr), 59 fExperimentalHall_log(nullptr), 60 fExperimentalHall_phys(nullptr), 61 fLogicLayer(nullptr), 62 fPhysiLayer(nullptr), 63 fLogicScoringUpDown(nullptr), 64 fPhysiScoringUpstream(nullptr), 65 fPhysiScoringDownstream(nullptr), 66 fLogicScoringSide(nullptr), 67 fPhysiScoringSide(nullptr), 68 fDetectorMessenger(nullptr), 69 fThickness(2.0 * CLHEP::m), 70 fDiameter(2.0 * CLHEP::m) //***LOOKHERE** 71 { 72 fMaterial = G4NistManager::Instance()->FindO 73 74 fDetectorMessenger = new DetectorMessenger(t 75 } 76 77 //....oooOO0OOooo........oooOO0OOooo........oo 78 79 DetectorConstruction::~DetectorConstruction() 80 { 81 delete fDetectorMessenger; 82 } 83 84 //....oooOO0OOooo........oooOO0OOooo........oo 85 86 G4VPhysicalVolume* DetectorConstruction::Const 87 { 88 return ConstructLayer(); 89 } 90 91 //....oooOO0OOooo........oooOO0OOooo........oo 92 93 G4VPhysicalVolume* DetectorConstruction::Const 94 { 95 // Clean old geometry, if any. 96 G4GeometryManager::GetInstance()->OpenGeomet 97 G4PhysicalVolumeStore::GetInstance()->Clean( 98 G4LogicalVolumeStore::GetInstance()->Clean() 99 G4SolidStore::GetInstance()->Clean(); 100 101 // The target layer is a cylinder, with axis 102 // and positioned at the center, (0.0, 0.0, 103 // The world volume (experimental hall) is a 104 // and it is filled of "G4_Galactic" materia 105 106 G4double expHall_x = 0.6 * fDiameter; // ha 107 // 108 G4double expHall_y = 0.6 * fDiameter; // ha 109 // 110 G4double expHall_z = 0.6 * fThickness; // h 111 // 112 113 G4Material* vacuum = G4NistManager::Instance 114 115 // Experimental hall 116 G4Box* experimentalHall_box = new G4Box("exp 117 fExperimentalHall_log = new G4LogicalVolume( 118 119 120 121 122 123 fExperimentalHall_phys = new G4PVPlacement(0 124 G 125 " 126 f 127 0 128 f 129 0 130 131 // Target 132 G4Tubs* solidLayer = new G4Tubs("solidLayer" 133 0.0, // inn 134 0.5 * fDiame 135 0.5 * fThick 136 0.0, // sta 137 2.0 * pi); 138 fLogicLayer = new G4LogicalVolume(solidLayer 139 fMaterial, 140 "logicLaye 141 0, // fie 142 0, // sen 143 0); // us 144 fPhysiLayer = new G4PVPlacement(0, // rotat 145 G4ThreeVecto 146 "physiLayer" 147 fLogicLayer, 148 fExperimenta 149 false, // b 150 0); // copy 151 152 // Three scoring volumes: one thin layer dow 153 // one thin layer sur 154 // one thin layer ups 155 G4Tubs* solidScoringUpDown = new G4Tubs("sol 156 0.0, 157 0.5 158 0.5 159 0.0, 160 2.0 161 fLogicScoringUpDown = new G4LogicalVolume(so 162 va 163 "l 164 0, 165 0, 166 0) 167 G4double zScoringUpDown = 0.5 * (fThickness 168 fPhysiScoringUpstream = new G4PVPlacement(0, 169 G4 170 // 171 "p 172 fL 173 fE 174 fa 175 0) 176 fPhysiScoringDownstream = new G4PVPlacement( 177 178 179 180 181 182 183 184 185 G4Tubs* solidScoringSide = new G4Tubs("solid 186 0.5 * 187 0.5 * 188 0.5 * 189 0.0, 190 2.0 * 191 fLogicScoringSide = new G4LogicalVolume(soli 192 vacu 193 "log 194 0, 195 0, 196 0); 197 fPhysiScoringSide = new G4PVPlacement(0, // 198 G4Thre 199 "physi 200 fLogic 201 fExper 202 false, 203 0); / 204 205 G4cout << G4endl << "DetectorConstruction::C 206 << "\t World (box) size: " << G4endl 207 << "\t y : -/+ " << expHall_y << " mm 208 << "\t z : -/+ " << expHall_z << " mm 209 << "\t Target layer (cylinder) size: 210 << " mm ;" 211 << "\t y : -/+ " << 0.5 * fDiameter < 212 << "\t z : -/+ " << 0.5 * fThickness 213 214 return fExperimentalHall_phys; 215 } 216 217 //....oooOO0OOooo........oooOO0OOooo........oo 218 219 void DetectorConstruction::SetMaterial(const G 220 { 221 fMaterial = G4NistManager::Instance()->FindO 222 if (!fMaterial) { 223 G4cout << G4endl << G4endl << "WARNING: th 224 << G4endl << " ===> the default 225 fMaterial = G4NistManager::Instance()->Fin 226 } 227 if (fLogicLayer) fLogicLayer->SetMaterial(fM 228 } 229 230 //....oooOO0OOooo........oooOO0OOooo........oo 231 232 void DetectorConstruction::UpdateGeometry() 233 { 234 G4RunManager::GetRunManager()->ReinitializeG 235 PrintParameters(); 236 // Update also the position of the gun 237 const PrimaryGeneratorAction* pPrimaryAction 238 G4RunManager::GetRunManager()->GetUserPrim 239 if (pPrimaryAction) pPrimaryAction->SetGunPo 240 } 241 242 //....oooOO0OOooo........oooOO0OOooo........oo 243 244 void DetectorConstruction::PrintParameters() 245 { 246 G4cout << G4endl << G4endl << " ------ Dete 247 << " Material = " << fMateria 248 << " Thickness = " << fThickne 249 << " Diameter = " << fDiamete 250 << " ScoringThickness = " << fScoring 251 << " -------------------------------- 252 } 253 254 //....oooOO0OOooo........oooOO0OOooo........oo 255