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 "G4FieldManager.hh" 41 #include "G4GeometryManager.hh" 42 #include "G4LogicalVolume.hh" 43 #include "G4LogicalVolumeStore.hh" 44 #include "G4Material.hh" 45 #include "G4NistManager.hh" 46 #include "G4PVPlacement.hh" 47 #include "G4PhysicalConstants.hh" 48 #include "G4PhysicalVolumeStore.hh" 49 #include "G4RunManager.hh" 50 #include "G4SolidStore.hh" 51 #include "G4SystemOfUnits.hh" 52 #include "G4ThreeVector.hh" 53 #include "G4TransportationManager.hh" 54 #include "G4Tubs.hh" 55 #include "G4UniformMagField.hh" 56 #include "globals.hh" 57 58 //....oooOO0OOooo........oooOO0OOooo........oo 59 60 DetectorConstruction::DetectorConstruction() 61 : G4VUserDetectorConstruction(), 62 fTargetMaterial(nullptr), 63 fLogicExperimentalHall(nullptr), 64 fPhysExperimentalHall(nullptr), 65 fLogicTargetLayer(nullptr), 66 fPhysTargetLayer(nullptr), 67 fFieldMgr(nullptr), 68 fUniformMagField(nullptr), 69 fDetectorMessenger(nullptr), 70 fTargetInnerRadius(9.0 * mm), 71 fTargetOuterRadius(11.0 * mm) //***LOOKHE 72 { 73 fFieldMgr = G4TransportationManager::GetTran 74 //***LOOKHERE*** Default material 75 fTargetMaterial = G4NistManager::Instance()- 76 fDetectorMessenger = new DetectorMessenger(t 77 } 78 79 //....oooOO0OOooo........oooOO0OOooo........oo 80 81 DetectorConstruction::~DetectorConstruction() 82 { 83 delete fUniformMagField; 84 delete fDetectorMessenger; 85 } 86 87 //....oooOO0OOooo........oooOO0OOooo........oo 88 89 G4VPhysicalVolume* DetectorConstruction::Const 90 { 91 return ConstructLayer(); 92 } 93 94 //....oooOO0OOooo........oooOO0OOooo........oo 95 96 G4VPhysicalVolume* DetectorConstruction::Const 97 { 98 // Clean old geometry, if any 99 G4GeometryManager::GetInstance()->OpenGeomet 100 G4PhysicalVolumeStore::GetInstance()->Clean( 101 G4LogicalVolumeStore::GetInstance()->Clean() 102 G4SolidStore::GetInstance()->Clean(); 103 // The geometry consists of a cylinder with 104 // positioned at the center, (0.0, 0.0, 0.0) 105 // its material can be set via UI commands. 106 // The world volume (experimental hall) is a 107 // and it is filled of "G4_Galactic" materia 108 const G4double halfLength = 1.0 * m; //***L 109 const G4double expHall_x = 1.01 * halfLength 110 const G4double expHall_y = 1.01 * halfLength 111 const G4double expHall_z = 1.01 * halfLength 112 G4Material* vacuum = G4NistManager::Instance 113 G4Box* experimentalHallBox = new G4Box("expH 114 fLogicExperimentalHall = new G4LogicalVolume 115 116 117 118 119 120 fPhysExperimentalHall = new G4PVPlacement(0, 121 G4 122 "e 123 fL 124 0, 125 fa 126 0) 127 // Cylinder along the z-axis, with inner and 128 G4Tubs* solidTargetLayer = new G4Tubs("solid 129 fTarge 130 fTarge 131 halfLe 132 0.0, 133 2.0 * 134 fLogicTargetLayer = new G4LogicalVolume(soli 135 fTar 136 "log 137 0, 138 0, 139 0); 140 fPhysTargetLayer = new G4PVPlacement(0, // 141 G4Three 142 "physTa 143 fLogicT 144 fPhysEx 145 false, 146 0); // 147 PrintParameters(); 148 G4cout << G4endl << "DetectorConstruction::C 149 << "\t World (box) size: " << G4endl 150 << "\t y : -/+ " << expHall_y << " mm 151 << "\t z : -/+ " << expHall_z << " mm 152 << "\t Layer (cylinder) size : " << G 153 << " , " << fTargetOuterRadius << " m 154 << "\t \t length (along z) : " << 2.0 155 << G4endl; 156 return fPhysExperimentalHall; 157 } 158 159 //....oooOO0OOooo........oooOO0OOooo........oo 160 161 void DetectorConstruction::SetTargetMaterial(c 162 { 163 fTargetMaterial = G4NistManager::Instance()- 164 if (!fTargetMaterial) { 165 G4cout << G4endl << G4endl << "WARNING: th 166 << G4endl << " ===> the default 167 //***LOOKHERE*** Default material 168 fTargetMaterial = G4NistManager::Instance( 169 } 170 if (fLogicTargetLayer) fLogicTargetLayer->Se 171 } 172 173 //....oooOO0OOooo........oooOO0OOooo........oo 174 175 void DetectorConstruction::UpdateGeometry() 176 { 177 G4RunManager::GetRunManager()->ReinitializeG 178 PrintParameters(); 179 // Update also the position of the gun 180 const PrimaryGeneratorAction* pPrimaryAction 181 G4RunManager::GetRunManager()->GetUserPrim 182 if (pPrimaryAction) pPrimaryAction->SetGunPo 183 } 184 185 //....oooOO0OOooo........oooOO0OOooo........oo 186 187 void DetectorConstruction::PrintParameters() 188 { 189 G4cout << G4endl << G4endl << " ------ Dete 190 << " Material = " << fTarg 191 << " Target Inner Radius = " << fTarg 192 << " Target Outer Radius = " << fTarg 193 << " B [T] = " 194 << (fUniformMagField ? fUniformMagFie 195 : G4ThreeVector( 196 << G4endl << " ---------------------- 197 << G4endl; 198 } 199 200 //....oooOO0OOooo........oooOO0OOooo........oo 201 202 void DetectorConstruction::SetMagField(const G 203 { 204 if (fUniformMagField) delete fUniformMagFiel 205 if (std::abs(fieldValue) > 0.0) { 206 // Apply a global uniform magnetic field a 207 fUniformMagField = new G4UniformMagField(G 208 fFieldMgr->SetDetectorField(fUniformMagFie 209 fFieldMgr->CreateChordFinder(fUniformMagFi 210 } 211 } 212 213 //....oooOO0OOooo........oooOO0OOooo........oo 214