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 exoticphysics/monopole/src/DetectorC 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 "G4Box.hh" 38 #include "G4GeometryManager.hh" 39 #include "G4LogicalVolume.hh" 40 #include "G4LogicalVolumeStore.hh" 41 #include "G4Material.hh" 42 #include "G4MonopoleFieldSetup.hh" 43 #include "G4NistManager.hh" 44 #include "G4PVPlacement.hh" 45 #include "G4PhysicalVolumeStore.hh" 46 #include "G4SolidStore.hh" 47 #include "G4StateManager.hh" 48 #include "G4UniformMagField.hh" 49 #include "G4UnitsTable.hh" 50 #include "G4UserLimits.hh" 51 // #include "G4FieldManager.hh" 52 // #include "G4TransportationManager.hh" 53 #include "G4AutoDelete.hh" 54 #include "G4GlobalMagFieldMessenger.hh" 55 #include "G4RunManager.hh" 56 #include "G4SystemOfUnits.hh" 57 #include "G4ThreeVector.hh" 58 59 //....oooOO0OOooo........oooOO0OOooo........oo 60 61 DetectorConstruction::DetectorConstruction() 62 : G4VUserDetectorConstruction(), 63 fWorldMaterial(0), 64 fAbsorMaterial(0), 65 fLogAbsor(0), 66 fMonFieldSetup(), 67 fDetectorMessenger(0) 68 { 69 // default parameter values 70 fAbsorSizeX = fAbsorSizeYZ = 10 * cm; 71 fWorldSizeX = fWorldSizeYZ = 1.2 * fAbsorSiz 72 fMaxStepSize = 5 * mm; 73 74 SetMaterial("G4_Al"); 75 fWorldMaterial = G4NistManager::Instance()-> 76 77 // create commands for interactive definitio 78 fDetectorMessenger = new DetectorMessenger(t 79 } 80 81 //....oooOO0OOooo........oooOO0OOooo........oo 82 83 DetectorConstruction::~DetectorConstruction() 84 { 85 delete fDetectorMessenger; 86 // delete fMonFieldSetup; 87 } 88 89 //....oooOO0OOooo........oooOO0OOooo........oo 90 91 G4VPhysicalVolume* DetectorConstruction::Const 92 { 93 G4GeometryManager::GetInstance()->OpenGeomet 94 G4PhysicalVolumeStore::GetInstance()->Clean( 95 G4LogicalVolumeStore::GetInstance()->Clean() 96 G4SolidStore::GetInstance()->Clean(); 97 98 /**************************** World *** 99 G4Box* sWorld = new G4Box("world", fWorldSiz 100 101 G4LogicalVolume* lWorld = new G4LogicalVolum 102 103 G4VPhysicalVolume* pWorld = new G4PVPlacemen 104 105 106 107 108 109 110 111 /************************** Absorber * 112 G4Box* sAbsor = new G4Box("Absorber", fAbsor 113 114 fLogAbsor = new G4LogicalVolume(sAbsor, fAbs 115 116 new G4PVPlacement(0, // no rotation 117 G4ThreeVector(), // at (0 118 fLogAbsor, // logical vol 119 "Absorber", // name 120 lWorld, // mother volume 121 false, // no boolean oper 122 0); // copy number 123 fLogAbsor->SetUserLimits(new G4UserLimits(fM 124 125 PrintParameters(); 126 127 /************ always return the World vo 128 return pWorld; 129 } 130 131 //....oooOO0OOooo........oooOO0OOooo........oo 132 133 void DetectorConstruction::PrintParameters() 134 { 135 G4cout << "\n------------------------------- 136 G4cout << "---> The Absorber is " << G4BestU 137 << fAbsorMaterial->GetName() << G4end 138 G4cout << "\n------------------------------- 139 } 140 141 //....oooOO0OOooo........oooOO0OOooo........oo 142 143 void DetectorConstruction::SetSizeX(G4double v 144 { 145 if (value > 0.0) { 146 fAbsorSizeX = value; 147 fWorldSizeX = 1.2 * fAbsorSizeX; 148 if (G4StateManager::GetStateManager()->Get 149 G4RunManager::GetRunManager()->Reinitial 150 } 151 } 152 } 153 154 //....oooOO0OOooo........oooOO0OOooo........oo 155 156 void DetectorConstruction::SetSizeYZ(G4double 157 { 158 if (value > 0.0) { 159 fAbsorSizeYZ = value; 160 fWorldSizeYZ = 1.2 * fAbsorSizeYZ; 161 if (G4StateManager::GetStateManager()->Get 162 G4RunManager::GetRunManager()->Reinitial 163 } 164 } 165 } 166 167 //....oooOO0OOooo........oooOO0OOooo........oo 168 169 void DetectorConstruction::SetMaterial(const G 170 { 171 // search the material by its name 172 G4Material* mat = G4NistManager::Instance()- 173 if (!mat) { 174 G4cout << "!!! DetectorConstruction::SetMa 175 << "> does not exist in DB" << G4en 176 return; 177 } 178 // new material is found out 179 if (mat != fAbsorMaterial) { 180 fAbsorMaterial = mat; 181 if (fLogAbsor) { 182 fLogAbsor->SetMaterial(mat); 183 } 184 G4RunManager::GetRunManager()->PhysicsHasB 185 } 186 } 187 188 //....oooOO0OOooo........oooOO0OOooo........oo 189 190 void DetectorConstruction::ConstructSDandField 191 { 192 // Define magnetic field 193 if (!fMonFieldSetup.Get()) { 194 G4MonopoleFieldSetup* fieldSetup = new G4M 195 G4AutoDelete::Register(fieldSetup); // Ke 196 fMonFieldSetup.Put(fieldSetup); 197 } 198 fMonFieldSetup.Get()->ConstructMagField(); 199 } 200 201 //....oooOO0OOooo........oooOO0OOooo........oo 202 203 void DetectorConstruction::SetMaxStepSize(G4do 204 { 205 fMaxStepSize = step; 206 if (fLogAbsor) { 207 fLogAbsor->SetUserLimits(new G4UserLimits( 208 } 209 } 210 211 //....oooOO0OOooo........oooOO0OOooo........oo 212