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 hadronic/Hadr02/src/DetectorConstruc 27 /// \brief Implementation of the DetectorConst 28 // 29 // 30 ////////////////////////////////////////////// 31 // 32 // DetectorConstruction 33 // 34 // Created: 31.01.2003 V.Ivanchenko 35 // 36 // Modified: 37 // 04.06.2006 Adoptation of hadr01 (V.Ivanchen 38 // 39 ////////////////////////////////////////////// 40 // 41 42 #include "DetectorConstruction.hh" 43 44 #include "DetectorMessenger.hh" 45 #include "HistoManager.hh" 46 #include "TargetSD.hh" 47 48 #include "G4Colour.hh" 49 #include "G4GeometryManager.hh" 50 #include "G4LogicalVolume.hh" 51 #include "G4LogicalVolumeStore.hh" 52 #include "G4NistManager.hh" 53 #include "G4PVPlacement.hh" 54 #include "G4PhysicalConstants.hh" 55 #include "G4PhysicalVolumeStore.hh" 56 #include "G4RunManager.hh" 57 #include "G4SDManager.hh" 58 #include "G4SolidStore.hh" 59 #include "G4SystemOfUnits.hh" 60 #include "G4Tubs.hh" 61 #include "G4UnitsTable.hh" 62 #include "G4VisAttributes.hh" 63 #include "G4ios.hh" 64 65 //....oooOO0OOooo........oooOO0OOooo........oo 66 67 DetectorConstruction::DetectorConstruction() 68 : G4VUserDetectorConstruction(), 69 fRadius(10. * cm), 70 fTargetMaterial(0), 71 fWorldMaterial(0), 72 fTargetSD(0), 73 fLogicTarget(0), 74 fLogicWorld(0), 75 fDetectorMessenger(0) 76 77 { 78 fDetectorMessenger = new DetectorMessenger(t 79 80 fTargetMaterial = G4NistManager::Instance()- 81 fWorldMaterial = G4NistManager::Instance()-> 82 HistoManager::GetPointer()->SetTargetMateria 83 84 // Prepare sensitive detectors 85 fTargetSD = new TargetSD("targetSD"); 86 G4SDManager::GetSDMpointer()->AddNewDetector 87 } 88 89 //....oooOO0OOooo........oooOO0OOooo........oo 90 91 DetectorConstruction::~DetectorConstruction() 92 { 93 delete fDetectorMessenger; 94 } 95 96 G4VPhysicalVolume* DetectorConstruction::Const 97 { 98 // Cleanup old geometry 99 G4GeometryManager::GetInstance()->OpenGeomet 100 G4PhysicalVolumeStore::GetInstance()->Clean( 101 G4LogicalVolumeStore::GetInstance()->Clean() 102 G4SolidStore::GetInstance()->Clean(); 103 104 // Sizes 105 G4double checkR = fRadius + mm; 106 G4double worldR = fRadius + cm; 107 G4double targetZ = HistoManager::GetPointer( 108 G4double checkZ = targetZ + mm; 109 G4double worldZ = targetZ + cm; 110 111 G4int nSlices = HistoManager::GetPointer()-> 112 G4double sliceZ = targetZ / G4double(nSlices 113 114 // 115 // World 116 G4Tubs* solidW = new G4Tubs("World", 0., wor 117 fLogicWorld = new G4LogicalVolume(solidW, fW 118 G4VPhysicalVolume* world = 119 new G4PVPlacement(0, G4ThreeVector(), fLog 120 // 121 // Check volume 122 // 123 G4Tubs* solidC = new G4Tubs("Check", 0., che 124 G4LogicalVolume* logicCheck = new G4LogicalV 125 new G4PVPlacement(0, G4ThreeVector(), logicC 126 127 // 128 // Target volume 129 // 130 G4Tubs* solidA = new G4Tubs("Target", 0., fR 131 fLogicTarget = new G4LogicalVolume(solidA, f 132 fLogicTarget->SetSensitiveDetector(fTargetSD 133 134 G4double z = sliceZ - targetZ; 135 136 for (G4int i = 0; i < nSlices; i++) { 137 // physC = 138 new G4PVPlacement(0, G4ThreeVector(0.0, 0. 139 z += 2.0 * sliceZ; 140 } 141 G4cout << "### Target consist of " << nSlice 142 << " disks with R(mm)= " << fRadius / 143 << " Total Length(mm)= " << 2.0 * ta 144 145 // colors 146 G4VisAttributes zero = G4VisAttributes::GetI 147 fLogicWorld->SetVisAttributes(zero); 148 149 G4VisAttributes regWcolor(G4Colour(0.3, 0.3, 150 logicCheck->SetVisAttributes(regWcolor); 151 152 G4VisAttributes regCcolor(G4Colour(0., 0.3, 153 fLogicTarget->SetVisAttributes(regCcolor); 154 155 G4cout << *(G4Material::GetMaterialTable()) 156 157 return world; 158 } 159 160 //....oooOO0OOooo........oooOO0OOooo........oo 161 162 void DetectorConstruction::SetTargetMaterial(c 163 { 164 // search the material by its name 165 G4Material* material = G4NistManager::Instan 166 167 if (material && material != fTargetMaterial) 168 HistoManager::GetPointer()->SetTargetMater 169 fTargetMaterial = material; 170 if (fLogicTarget) { 171 fLogicTarget->SetMaterial(fTargetMateria 172 } 173 G4RunManager::GetRunManager()->PhysicsHasB 174 } 175 } 176 177 //....oooOO0OOooo........oooOO0OOooo........oo 178 179 void DetectorConstruction::SetWorldMaterial(co 180 { 181 // search the material by its name 182 G4Material* material = G4NistManager::Instan 183 184 if (material && material != fWorldMaterial) 185 fWorldMaterial = material; 186 if (fLogicWorld) { 187 fLogicWorld->SetMaterial(fWorldMaterial) 188 } 189 G4RunManager::GetRunManager()->PhysicsHasB 190 } 191 } 192 193 //....oooOO0OOooo........oooOO0OOooo........oo 194 195 void DetectorConstruction::SetTargetRadius(G4d 196 { 197 if (val > 0.0) { 198 fRadius = val; 199 G4RunManager::GetRunManager()->GeometryHas 200 } 201 } 202 203 //....oooOO0OOooo........oooOO0OOooo........oo 204