Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // $Id: F05DetectorConstruction.cc 75672 2013-11-05 08:47:41Z gcosmo $ 26 // 27 // 27 /// \file field/field05/src/F05DetectorConstru 28 /// \file field/field05/src/F05DetectorConstruction.cc 28 /// \brief Implementation of the F05DetectorCo 29 /// \brief Implementation of the F05DetectorConstruction class 29 // 30 // 30 31 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 //....oooOO0OOooo........oooOO0OOooo........oo 33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 33 34 34 #include "F05DetectorConstruction.hh" 35 #include "F05DetectorConstruction.hh" 35 36 36 #include "F05Field.hh" << 37 #include "G4Material.hh" >> 38 #include "G4NistManager.hh" 37 39 38 #include "G4Box.hh" 40 #include "G4Box.hh" 39 #include "G4Colour.hh" << 40 #include "G4FieldManager.hh" << 41 #include "G4GeometryManager.hh" << 42 #include "G4LogicalVolume.hh" 41 #include "G4LogicalVolume.hh" 43 #include "G4LogicalVolumeStore.hh" << 44 #include "G4Material.hh" << 45 #include "G4NistManager.hh" << 46 #include "G4PVPlacement.hh" 42 #include "G4PVPlacement.hh" >> 43 >> 44 #include "G4GeometryManager.hh" 47 #include "G4PhysicalVolumeStore.hh" 45 #include "G4PhysicalVolumeStore.hh" >> 46 #include "G4LogicalVolumeStore.hh" 48 #include "G4SolidStore.hh" 47 #include "G4SolidStore.hh" >> 48 >> 49 #include "G4VisAttributes.hh" >> 50 #include "G4Colour.hh" >> 51 >> 52 #include "G4UserLimits.hh" 49 #include "G4SystemOfUnits.hh" 53 #include "G4SystemOfUnits.hh" >> 54 >> 55 #include "F05Field.hh" >> 56 >> 57 #include "G4FieldManager.hh" 50 #include "G4TransportationManager.hh" 58 #include "G4TransportationManager.hh" 51 #include "G4UserLimits.hh" << 52 #include "G4VisAttributes.hh" << 53 59 54 // #include "G4RepleteEofM.hh" << 60 //#include "G4RepleteEofM.hh" 55 #include "G4ChordFinder.hh" << 56 #include "G4ClassicalRK4.hh" << 57 #include "G4EqEMFieldWithSpin.hh" 61 #include "G4EqEMFieldWithSpin.hh" >> 62 >> 63 #include "G4ClassicalRK4.hh" 58 #include "G4MagIntegratorStepper.hh" 64 #include "G4MagIntegratorStepper.hh" >> 65 #include "G4ChordFinder.hh" 59 #include "G4PropagatorInField.hh" 66 #include "G4PropagatorInField.hh" 60 67 61 //....oooOO0OOooo........oooOO0OOooo........oo 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 62 69 63 F05DetectorConstruction::F05DetectorConstructi << 70 F05DetectorConstruction::F05DetectorConstruction() >> 71 : fVacuum(0), fWorldSizeXY(0), fWorldSizeZ(0), >> 72 fSolidWorld(0), fLogicWorld(0), fPhysiWorld(0) 64 { 73 { 65 // materials 74 // materials 66 DefineMaterials(); 75 DefineMaterials(); 67 } 76 } 68 77 69 //....oooOO0OOooo........oooOO0OOooo........oo 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 70 79 71 F05DetectorConstruction::~F05DetectorConstruct 80 F05DetectorConstruction::~F05DetectorConstruction() 72 { 81 { 73 delete fField; << 82 if (fField) delete fField; 74 } 83 } 75 84 76 //....oooOO0OOooo........oooOO0OOooo........oo 85 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 77 86 78 void F05DetectorConstruction::DefineMaterials( 87 void F05DetectorConstruction::DefineMaterials() 79 { 88 { 80 G4NistManager* nistMan = G4NistManager::Inst 89 G4NistManager* nistMan = G4NistManager::Instance(); 81 90 82 fVacuum = nistMan->FindOrBuildMaterial("G4_G 91 fVacuum = nistMan->FindOrBuildMaterial("G4_Galactic"); 83 92 84 G4cout << *(G4Material::GetMaterialTable()) 93 G4cout << *(G4Material::GetMaterialTable()) << G4endl; 85 } 94 } 86 95 87 //....oooOO0OOooo........oooOO0OOooo........oo 96 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 88 97 89 G4VPhysicalVolume* F05DetectorConstruction::Co 98 G4VPhysicalVolume* F05DetectorConstruction::Construct() 90 { 99 { 91 // 100 // 92 // World 101 // World 93 // 102 // 94 103 95 G4double worldSizeXY = 20.0 * m; << 104 fWorldSizeXY = 20.0*m; 96 G4double worldSizeZ = 1.0 * mm; << 105 fWorldSizeZ = 1.0*mm; 97 << 98 auto solidWorld = new G4Box("World", // its << 99 worldSizeXY / 2, << 100 << 101 auto logicWorld = new G4LogicalVolume(solidW << 102 fVacuu << 103 "World << 104 << 105 auto physiWorld = new G4PVPlacement(nullptr, << 106 G4ThreeV << 107 logicWor << 108 "World", << 109 nullptr, << 110 false, << 111 0); // << 112 106 >> 107 fSolidWorld = new G4Box("World", //its name >> 108 fWorldSizeXY/2,fWorldSizeXY/2,fWorldSizeZ/2); //its size >> 109 >> 110 fLogicWorld = new G4LogicalVolume(fSolidWorld, //its solid >> 111 fVacuum, //its material >> 112 "World"); //its name >> 113 >> 114 fPhysiWorld = new G4PVPlacement(0, //no rotation >> 115 G4ThreeVector(), //at (0,0,0) >> 116 fLogicWorld, //its logical volume >> 117 "World", //its name >> 118 0, //its mother volume >> 119 false, //no boolean operation >> 120 0); //copy number >> 121 113 G4UserLimits* stepLimit; 122 G4UserLimits* stepLimit; 114 stepLimit = new G4UserLimits(5 * mm); << 123 stepLimit = new G4UserLimits(5*mm); 115 << 116 logicWorld->SetUserLimits(stepLimit); << 117 124 >> 125 fLogicWorld->SetUserLimits(stepLimit); >> 126 118 // 127 // 119 // Visualization attributes 128 // Visualization attributes 120 // 129 // 121 // fLogicWorld->SetVisAttributes (G4VisAttri << 130 // fLogicWorld->SetVisAttributes (G4VisAttributes::Invisible); 122 131 123 // 132 // 124 // always return the physical World << 133 //always return the physical World 125 // 134 // 126 return physiWorld; << 135 return fPhysiWorld; 127 } 136 } 128 137 129 //....oooOO0OOooo........oooOO0OOooo........oo 138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 130 139 131 G4ThreadLocal F05Field* F05DetectorConstructio << 140 G4ThreadLocal F05Field* F05DetectorConstruction::fField = 0; 132 141 133 void F05DetectorConstruction::ConstructSDandFi 142 void F05DetectorConstruction::ConstructSDandField() 134 143 135 { 144 { 136 if (!fField) { 145 if (!fField) { 137 fField = new F05Field(); << 138 146 139 // G4RepleteEofM* equation = new G4Rep << 147 fField = new F05Field(); 140 auto equation = new G4EqEMFieldWithSpin(fF << 148 141 // equation->SetBField(); << 149 // G4RepleteEofM* equation = new G4RepleteEofM(fField); 142 // equation->SetEField(); << 150 G4EqEMFieldWithSpin* equation = new G4EqEMFieldWithSpin(fField); 143 // equation->SetSpin(); << 151 // equation->SetBField(); >> 152 // equation->SetEField(); >> 153 // equation->SetSpin(); 144 154 145 G4FieldManager* fieldManager = << 155 G4FieldManager* fieldManager 146 G4TransportationManager::GetTransportati << 156 = G4TransportationManager::GetTransportationManager()->GetFieldManager(); 147 fieldManager->SetDetectorField(fField); << 157 fieldManager->SetDetectorField(fField); 148 158 149 G4MagIntegratorStepper* stepper = new G4Cl << 159 G4MagIntegratorStepper* stepper = new G4ClassicalRK4(equation,12); 150 160 151 G4double minStep = 0.01 * mm; << 161 G4double minStep = 0.01*mm; 152 162 153 auto chordFinder = new G4ChordFinder((G4Ma << 163 G4ChordFinder* chordFinder = >> 164 new G4ChordFinder((G4MagneticField*)fField,minStep,stepper); 154 165 155 // Set accuracy parameters << 166 // Set accuracy parameters 156 G4double deltaChord = 3.0 * mm; << 167 G4double deltaChord = 3.0*mm; 157 chordFinder->SetDeltaChord(deltaChord); << 168 chordFinder->SetDeltaChord( deltaChord ); 158 169 159 // Maximum allowed integration error in on << 170 G4double deltaOneStep = 0.01*mm; 160 G4double deltaOneStep = 0.01 * mm; << 171 fieldManager->SetAccuraciesWithDeltaOneStep(deltaOneStep); 161 fieldManager->SetAccuraciesWithDeltaOneSte << 162 172 163 G4double deltaIntersection = 0.1 * mm; << 173 G4double deltaIntersection = 0.1*mm; 164 fieldManager->SetDeltaIntersection(deltaIn << 174 fieldManager->SetDeltaIntersection(deltaIntersection); 165 175 166 G4TransportationManager* transportManager << 176 G4TransportationManager* transportManager = >> 177 G4TransportationManager::GetTransportationManager(); 167 178 168 G4PropagatorInField* fieldPropagator = tra << 179 G4PropagatorInField* fieldPropagator = >> 180 transportManager->GetPropagatorInField(); 169 181 170 // Limits for relative accuracy of integra << 182 G4double epsMin = 2.5e-7*mm; 171 G4double epsMin = 2.5e-7; << 183 G4double epsMax = 0.05*mm; 172 G4double epsMax = 0.001; << 173 184 174 fieldPropagator->SetMinimumEpsilonStep(eps << 185 fieldPropagator->SetMinimumEpsilonStep(epsMin); 175 fieldPropagator->SetMaximumEpsilonStep(eps << 186 fieldPropagator->SetMaximumEpsilonStep(epsMax); 176 187 177 fieldManager->SetChordFinder(chordFinder); << 188 fieldManager->SetChordFinder(chordFinder); 178 } 189 } 179 } 190 } 180 191 181 //....oooOO0OOooo........oooOO0OOooo........oo 192 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 182 193