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 /// \file exoticphysics/monopole/src/G4Monopol 26 /// \file exoticphysics/monopole/src/G4MonopoleFieldSetup.cc 27 /// \brief Implementation of the G4MonopoleFie 27 /// \brief Implementation of the G4MonopoleFieldSetup class 28 // 28 // >> 29 // $Id: G4MonopoleFieldSetup.cc 66994 2013-01-29 14:34:08Z gcosmo $ 29 // 30 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 // 33 // 33 // 34 // 34 // G4MonopoleFieldSetup is responsible for set 35 // G4MonopoleFieldSetup is responsible for setting up a magnetic field 35 // and the ability to use it with two differen << 36 // and the ability to use it with two different equation of motions, 36 // one for monopoles and another for the rest << 37 // one for monopoles and another for the rest of the particles. 37 // << 38 // 38 // << 39 // 39 40 40 // =========================================== 41 // ======================================================================= 41 // Created: 13 May 2010, B. Bozsogi 42 // Created: 13 May 2010, B. Bozsogi 42 // =========================================== 43 // ======================================================================= 43 44 44 #include "G4MonopoleFieldSetup.hh" 45 #include "G4MonopoleFieldSetup.hh" >> 46 #include "G4MonopoleFieldMessenger.hh" 45 47 46 #include "G4ChordFinder.hh" << 48 #include "G4MagneticField.hh" >> 49 #include "G4UniformMagField.hh" 47 #include "G4FieldManager.hh" 50 #include "G4FieldManager.hh" 48 #include "G4MagIntegratorStepper.hh" << 51 #include "G4TransportationManager.hh" 49 #include "G4Mag_UsualEqRhs.hh" 52 #include "G4Mag_UsualEqRhs.hh" 50 #include "G4MagneticField.hh" << 51 #include "G4MonopoleEquation.hh" 53 #include "G4MonopoleEquation.hh" 52 #include "G4MonopoleFieldMessenger.hh" << 54 #include "G4MagIntegratorStepper.hh" 53 #include "G4TransportationManager.hh" << 55 #include "G4ChordFinder.hh" 54 #include "G4UniformMagField.hh" << 55 56 56 // #include "G4ExplicitEuler.hh" 57 // #include "G4ExplicitEuler.hh" 57 // #include "G4ImplicitEuler.hh" 58 // #include "G4ImplicitEuler.hh" 58 // #include "G4SimpleRunge.hh" 59 // #include "G4SimpleRunge.hh" 59 // #include "G4SimpleHeum.hh" 60 // #include "G4SimpleHeum.hh" 60 #include "G4ClassicalRK4.hh" 61 #include "G4ClassicalRK4.hh" 61 // #include "G4HelixExplicitEuler.hh" 62 // #include "G4HelixExplicitEuler.hh" 62 // #include "G4HelixImplicitEuler.hh" 63 // #include "G4HelixImplicitEuler.hh" 63 // #include "G4HelixSimpleRunge.hh" 64 // #include "G4HelixSimpleRunge.hh" 64 // #include "G4CashKarpRKF45.hh" 65 // #include "G4CashKarpRKF45.hh" 65 // #include "G4RKG3_Stepper.hh" 66 // #include "G4RKG3_Stepper.hh" 66 67 67 #include "G4SystemOfUnits.hh" 68 #include "G4SystemOfUnits.hh" 68 69 69 // G4MonopoleFieldSetup* G4MonopoleFieldSetup: << 70 G4MonopoleFieldSetup* G4MonopoleFieldSetup::fMonopoleFieldSetup=0; 70 71 71 //....oooOO0OOooo........oooOO0OOooo........oo 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 72 73 73 G4MonopoleFieldSetup::G4MonopoleFieldSetup() 74 G4MonopoleFieldSetup::G4MonopoleFieldSetup() 74 : fFieldManager(0), << 75 fChordFinder(0), << 76 fUsualChordFinder(0), << 77 fMonopoleChordFinder(0), << 78 fEquation(0), << 79 fMonopoleEquation(0), << 80 fMagneticField(0), << 81 fStepper(0), << 82 fMonopoleStepper(0), << 83 fMinStep(0.0), << 84 fZmagFieldValue(0.2 * tesla), << 85 fMonopoleFieldMessenger(0) << 86 { 75 { >> 76 fFieldManager = 0; >> 77 fChordFinder = 0; >> 78 fEquation = 0; >> 79 fMonopoleEquation = 0; >> 80 fMagneticField = 0; >> 81 fStepper = 0; >> 82 fMonopoleStepper = 0; >> 83 >> 84 fMinStep = 0.0; >> 85 87 fMonopoleFieldMessenger = new G4MonopoleFiel 86 fMonopoleFieldMessenger = new G4MonopoleFieldMessenger(this); 88 fFieldManager = GetGlobalFieldManager(); << 89 } 87 } 90 88 91 //....oooOO0OOooo........oooOO0OOooo........oo 89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 92 90 93 // G4MonopoleFieldSetup* G4MonopoleFieldSetup: << 91 G4MonopoleFieldSetup* G4MonopoleFieldSetup::GetMonopoleFieldSetup() 94 // { << 95 // if (0 == fMonopoleFieldSetup) << 96 // { << 97 // static G4ThreadLocal G4MonopoleFieldSe << 98 // fMonopoleFieldSetup = &theInstance; << 99 // } << 100 << 101 // return fMonopoleFieldSetup; << 102 // } << 103 << 104 //....oooOO0OOooo........oooOO0OOooo........oo << 105 << 106 G4MonopoleFieldSetup::~G4MonopoleFieldSetup() << 107 { 92 { 108 delete fMonopoleFieldMessenger; << 93 if (0 == fMonopoleFieldSetup) 109 if (fMagneticField) delete fMagneticField; << 94 { 110 // if(fChordFinder) delete fChordFinder; << 95 static G4MonopoleFieldSetup theInstance; 111 if (fUsualChordFinder) delete fUsualChordFin << 96 fMonopoleFieldSetup = &theInstance; 112 if (fMonopoleChordFinder) delete fMonopoleCh << 97 } 113 if (fStepper) delete fStepper; << 98 114 if (fMonopoleStepper) delete fMonopoleSteppe << 99 return fMonopoleFieldSetup; 115 } 100 } 116 101 117 //....oooOO0OOooo........oooOO0OOooo........oo 102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 118 103 119 void G4MonopoleFieldSetup::SetZMagFieldValue(G << 104 G4MonopoleFieldSetup::~G4MonopoleFieldSetup() 120 { 105 { 121 // set new magnetic field value and rebuild << 106 delete fMonopoleFieldMessenger; 122 fZmagFieldValue = val; << 107 if(fMagneticField) delete fMagneticField; 123 << 108 if(fChordFinder) delete fChordFinder; 124 ConstructMagField(); << 109 if(fStepper) delete fStepper; >> 110 if(fMonopoleStepper) delete fMonopoleStepper; 125 } 111 } 126 112 127 //....oooOO0OOooo........oooOO0OOooo........oo 113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 128 114 129 void G4MonopoleFieldSetup::ConstructMagField() << 115 void G4MonopoleFieldSetup::SetMagField(G4double fieldValue) 130 { 116 { 131 // apply a global uniform magnetic field alo << 117 //apply a global uniform magnetic field along Z axis 132 if (fMagneticField) { << 118 if (fMagneticField) { delete fMagneticField; } //delete the existing magn field 133 delete fMagneticField; << 134 } // delete the existing magn field << 135 << 136 if (fZmagFieldValue != 0.) // create a new << 137 { << 138 // G4cout << "Go to create new field ..." << 139 fMagneticField = new G4UniformMagField(G4T << 140 InitialiseAll(); << 141 } << 142 else { << 143 // G4cout << "Set field = 0 ..." << G4endl << 144 fMagneticField = 0; << 145 } << 146 119 147 fFieldManager->SetDetectorField(fMagneticFie << 120 if (fieldValue != 0.) // create a new one if non nul >> 121 { >> 122 fMagneticField = new G4UniformMagField(G4ThreeVector(0., 0., fieldValue)); >> 123 InitialiseAll(); >> 124 } >> 125 else >> 126 { >> 127 fMagneticField = 0; >> 128 fFieldManager->SetDetectorField(fMagneticField); >> 129 } 148 } 130 } 149 131 150 //....oooOO0OOooo........oooOO0OOooo........oo 132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 151 133 152 void G4MonopoleFieldSetup::InitialiseAll() << 134 void >> 135 G4MonopoleFieldSetup::InitialiseAll() 153 { 136 { 154 fEquation = new G4Mag_UsualEqRhs(fMagneticFi << 137 fFieldManager = G4TransportationManager::GetTransportationManager() >> 138 ->GetFieldManager(); >> 139 >> 140 fEquation = new G4Mag_UsualEqRhs(fMagneticField); 155 fMonopoleEquation = new G4MonopoleEquation(f 141 fMonopoleEquation = new G4MonopoleEquation(fMagneticField); 156 << 142 157 fMinStep = 0.01 * mm; // minimal step of 1 << 143 fMinStep = 0.01*mm ; // minimal step of 1 mm is default 158 << 144 159 fMonopoleStepper = new G4ClassicalRK4(fMonop << 145 fMonopoleStepper = new G4ClassicalRK4( fMonopoleEquation, 8 ); // for time information.. 160 fStepper = new G4ClassicalRK4(fEquation); << 146 fStepper = new G4ClassicalRK4( fEquation ); 161 << 147 162 fUsualChordFinder = new G4ChordFinder(fMagne << 163 fMonopoleChordFinder = new G4ChordFinder(fMa << 164 << 165 SetStepperAndChordFinder(0); 148 SetStepperAndChordFinder(0); 166 } 149 } 167 150 168 //....oooOO0OOooo........oooOO0OOooo........oo 151 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 169 152 170 void G4MonopoleFieldSetup::SetStepperAndChordF 153 void G4MonopoleFieldSetup::SetStepperAndChordFinder(G4int val) 171 { 154 { 172 if (fMagneticField) { << 155 if (fMagneticField) 173 fFieldManager->SetDetectorField(fMagneticF << 156 { 174 // if(fChordFinder) delete fChordFinder << 157 fFieldManager->SetDetectorField(fMagneticField ); 175 << 158 176 switch (val) { << 159 if(fChordFinder) delete fChordFinder; 177 // case 0: << 160 178 // fChordFinder = new G4ChordF << 161 switch (val) 179 // break; << 162 { 180 // case 1: << 181 // fChordFinder = new G4ChordF << 182 // << 183 // break; << 184 case 0: 163 case 0: 185 fChordFinder = fUsualChordFinder; << 164 fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fStepper); 186 break; 165 break; 187 case 1: << 166 case 1: 188 fChordFinder = fMonopoleChordFinder; << 167 fChordFinder = new G4ChordFinder( fMagneticField, fMinStep, fMonopoleStepper); 189 break; 168 break; 190 } << 169 } 191 << 170 192 fFieldManager->SetChordFinder(fChordFinder << 171 fFieldManager->SetChordFinder( fChordFinder ); 193 } 172 } 194 } 173 } 195 174 196 //....oooOO0OOooo........oooOO0OOooo........oo 175 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 197 176 198 G4FieldManager* G4MonopoleFieldSetup::GetGloba << 177 G4FieldManager* G4MonopoleFieldSetup::GetGlobalFieldManager() 199 { 178 { 200 return G4TransportationManager::GetTransport << 179 return G4TransportationManager::GetTransportationManager() >> 180 ->GetFieldManager(); 201 } 181 } 202 182 203 //....oooOO0OOooo........oooOO0OOooo........oo 183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 204 184