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 // 26 // 27 // ------------------------------------------- 27 // ------------------------------------------------------------------- 28 // 28 // 29 // GEANT4 Class file 29 // GEANT4 Class file 30 // 30 // 31 // 31 // 32 // File name: G4MuPairProductionModel 32 // File name: G4MuPairProductionModel 33 // 33 // 34 // Author: Vladimir Ivanchenko on base 34 // Author: Vladimir Ivanchenko on base of Laszlo Urban code 35 // 35 // 36 // Creation date: 24.06.2002 36 // Creation date: 24.06.2002 37 // 37 // 38 // Modifications: 38 // Modifications: 39 // 39 // 40 // 04-12-02 Change G4DynamicParticle construct 40 // 04-12-02 Change G4DynamicParticle constructor in PostStep (V.Ivanchenko) 41 // 23-12-02 Change interface in order to move 41 // 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko) 42 // 24-01-03 Fix for compounds (V.Ivanchenko) 42 // 24-01-03 Fix for compounds (V.Ivanchenko) 43 // 27-01-03 Make models region aware (V.Ivanch 43 // 27-01-03 Make models region aware (V.Ivanchenko) 44 // 13-02-03 Add model (V.Ivanchenko) 44 // 13-02-03 Add model (V.Ivanchenko) 45 // 06-06-03 Fix in cross section calculation f 45 // 06-06-03 Fix in cross section calculation for high energy (V.Ivanchenko) 46 // 20-10-03 2*xi in ComputeDDMicroscopicCrossS 46 // 20-10-03 2*xi in ComputeDDMicroscopicCrossSection (R.Kokoulin) 47 // 8 integration points in ComputeDMi 47 // 8 integration points in ComputeDMicroscopicCrossSection 48 // 12-01-04 Take min cut of e- and e+ not its 48 // 12-01-04 Take min cut of e- and e+ not its sum (V.Ivanchenko) 49 // 10-02-04 Update parameterisation using R.Ko 49 // 10-02-04 Update parameterisation using R.Kokoulin model (V.Ivanchenko) 50 // 28-04-04 For complex materials repeat calcu 50 // 28-04-04 For complex materials repeat calculation of max energy for each 51 // material (V.Ivanchenko) 51 // material (V.Ivanchenko) 52 // 01-11-04 Fix bug inside ComputeDMicroscopic 52 // 01-11-04 Fix bug inside ComputeDMicroscopicCrossSection (R.Kokoulin) 53 // 08-04-05 Major optimisation of internal int 53 // 08-04-05 Major optimisation of internal interfaces (V.Ivantchenko) 54 // 03-08-05 Add SetParticle method (V.Ivantche 54 // 03-08-05 Add SetParticle method (V.Ivantchenko) 55 // 23-10-05 Add protection in sampling of e+e- 55 // 23-10-05 Add protection in sampling of e+e- pair energy needed for 56 // low cuts (V.Ivantchenko) 56 // low cuts (V.Ivantchenko) 57 // 13-02-06 Add ComputeCrossSectionPerAtom (mm 57 // 13-02-06 Add ComputeCrossSectionPerAtom (mma) 58 // 24-04-07 Add protection in SelectRandomAtom 58 // 24-04-07 Add protection in SelectRandomAtom method (V.Ivantchenko) 59 // 12-05-06 Updated sampling (use cut) in Sele 59 // 12-05-06 Updated sampling (use cut) in SelectRandomAtom (A.Bogdanov) 60 // 11-10-07 Add ignoreCut flag (V.Ivanchenko) 60 // 11-10-07 Add ignoreCut flag (V.Ivanchenko) 61 61 62 // 62 // 63 // Class Description: 63 // Class Description: 64 // 64 // 65 // 65 // 66 // ------------------------------------------- 66 // ------------------------------------------------------------------- 67 // 67 // 68 //....oooOO0OOooo........oooOO0OOooo........oo 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 69 //....oooOO0OOooo........oooOO0OOooo........oo 69 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 70 70 71 #include "G4MuPairProductionModel.hh" 71 #include "G4MuPairProductionModel.hh" 72 #include "G4PhysicalConstants.hh" 72 #include "G4PhysicalConstants.hh" 73 #include "G4SystemOfUnits.hh" 73 #include "G4SystemOfUnits.hh" 74 #include "G4EmParameters.hh" 74 #include "G4EmParameters.hh" 75 #include "G4Electron.hh" 75 #include "G4Electron.hh" 76 #include "G4Positron.hh" 76 #include "G4Positron.hh" 77 #include "G4MuonMinus.hh" 77 #include "G4MuonMinus.hh" 78 #include "G4MuonPlus.hh" 78 #include "G4MuonPlus.hh" 79 #include "Randomize.hh" 79 #include "Randomize.hh" 80 #include "G4Material.hh" 80 #include "G4Material.hh" 81 #include "G4Element.hh" 81 #include "G4Element.hh" 82 #include "G4ElementVector.hh" 82 #include "G4ElementVector.hh" 83 #include "G4ElementDataRegistry.hh" << 84 #include "G4ProductionCutsTable.hh" 83 #include "G4ProductionCutsTable.hh" 85 #include "G4ParticleChangeForLoss.hh" 84 #include "G4ParticleChangeForLoss.hh" 86 #include "G4ModifiedMephi.hh" << 85 #include "G4ParticleChangeForGamma.hh" 87 #include "G4Log.hh" 86 #include "G4Log.hh" 88 #include "G4Exp.hh" 87 #include "G4Exp.hh" 89 #include "G4AutoLock.hh" << 90 << 91 #include <iostream> 88 #include <iostream> 92 #include <fstream> 89 #include <fstream> 93 90 94 //....oooOO0OOooo........oooOO0OOooo........oo 91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 95 92 96 const G4int G4MuPairProductionModel::ZDATPAIR[ << 93 // static members 97 << 94 // 98 const G4double G4MuPairProductionModel::xgi[] << 95 static const G4double ak1 = 6.9; 99 0.0198550717512320, 0.1016667612931865, 0. << 96 static const G4double ak2 = 1.0; 100 0.5917173212478250, 0.7627662049581645, 0. << 97 static const G4int zdat[5] = {1, 4, 13, 29, 92}; 101 }; << 102 98 103 const G4double G4MuPairProductionModel::wgi[] << 99 const G4double G4MuPairProductionModel::xgi[] = 104 0.0506142681451880, 0.1111905172266870, 0. << 100 { 0.0199, 0.1017, 0.2372, 0.4083, 0.5917, 0.7628, 0.8983, 0.9801 }; 105 0.1813418916891810, 0.1568533229389435, 0. << 101 const G4double G4MuPairProductionModel::wgi[8] = 106 }; << 102 { 0.0506, 0.1112, 0.1569, 0.1813, 0.1813, 0.1569, 0.1112, 0.0506 }; 107 << 108 namespace << 109 { << 110 G4Mutex theMuPairMutex = G4MUTEX_INITIALIZER << 111 << 112 const G4double ak1 = 6.9; << 113 const G4double ak2 = 1.0; << 114 } << 115 103 116 //....oooOO0OOooo........oooOO0OOooo........oo 104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 117 105 >> 106 using namespace std; >> 107 118 G4MuPairProductionModel::G4MuPairProductionMod 108 G4MuPairProductionModel::G4MuPairProductionModel(const G4ParticleDefinition* p, 119 109 const G4String& nam) 120 : G4VEmModel(nam), 110 : G4VEmModel(nam), 121 factorForCross(CLHEP::fine_structure_const*C << 111 particle(nullptr), 122 CLHEP::classic_electr_radius*CLHEP::class << 112 factorForCross(4.*fine_structure_const*fine_structure_const 123 4./(3.*CLHEP::pi)), << 113 *classic_electr_radius*classic_electr_radius/(3.*pi)), 124 sqrte(std::sqrt(G4Exp(1.))), << 114 sqrte(sqrt(G4Exp(1.))), 125 minPairEnergy(4.*CLHEP::electron_mass_c2), << 115 currentZ(0), 126 lowestKinEnergy(0.85*CLHEP::GeV) << 116 fParticleChange(nullptr), >> 117 minPairEnergy(4.*electron_mass_c2), >> 118 lowestKinEnergy(1.0*GeV), >> 119 nzdat(5), >> 120 nYBinPerDecade(4), >> 121 nbiny(1000), >> 122 nbine(0), >> 123 ymin(-5.), >> 124 dy(0.005), >> 125 fTableToFile(false) 127 { 126 { 128 nist = G4NistManager::Instance(); 127 nist = G4NistManager::Instance(); 129 128 130 theElectron = G4Electron::Electron(); 129 theElectron = G4Electron::Electron(); 131 thePositron = G4Positron::Positron(); 130 thePositron = G4Positron::Positron(); 132 131 133 if(nullptr != p) { << 132 particleMass = lnZ = z13 = z23 = 0.; >> 133 >> 134 // setup lowest limit dependent on particle mass >> 135 if(p) { 134 SetParticle(p); 136 SetParticle(p); 135 lowestKinEnergy = std::max(lowestKinEnergy << 137 lowestKinEnergy = std::max(lowestKinEnergy,p->GetPDGMass()*8.0); 136 } 138 } 137 emin = lowestKinEnergy; 139 emin = lowestKinEnergy; 138 emax = emin*10000.; << 140 emax = 10.*TeV; 139 SetAngularDistribution(new G4ModifiedMephi() << 140 } 141 } 141 142 142 //....oooOO0OOooo........oooOO0OOooo........oo 143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 143 144 >> 145 G4MuPairProductionModel::~G4MuPairProductionModel() >> 146 {} >> 147 >> 148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 149 144 G4double G4MuPairProductionModel::MinPrimaryEn 150 G4double G4MuPairProductionModel::MinPrimaryEnergy(const G4Material*, 145 151 const G4ParticleDefinition*, 146 152 G4double cut) 147 { 153 { 148 return std::max(lowestKinEnergy, cut); << 154 return std::max(lowestKinEnergy,cut); 149 } 155 } 150 156 151 //....oooOO0OOooo........oooOO0OOooo........oo 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 152 158 153 void G4MuPairProductionModel::Initialise(const 159 void G4MuPairProductionModel::Initialise(const G4ParticleDefinition* p, 154 const 160 const G4DataVector& cuts) 155 { 161 { 156 SetParticle(p); 162 SetParticle(p); 157 << 163 if(!fParticleChange) { fParticleChange = GetParticleChangeForLoss(); } 158 if (nullptr == fParticleChange) { << 159 fParticleChange = GetParticleChangeForLoss << 160 << 161 // define scale of internal table for each << 162 if (0 == nbine) { << 163 emin = std::max(lowestKinEnergy, LowEner << 164 emax = std::max(HighEnergyLimit(), emin* << 165 nbine = std::size_t(nYBinPerDecade*std:: << 166 if(nbine < 3) { nbine = 3; } << 167 << 168 ymin = G4Log(minPairEnergy/emin); << 169 dy = -ymin/G4double(nbiny); << 170 } << 171 if (p == particle) { << 172 G4int pdg = std::abs(p->GetPDGEncoding() << 173 if (pdg == 2212) { << 174 dataName = "pEEPairProd"; << 175 } else if (pdg == 321) { << 176 dataName = "kaonEEPairProd"; << 177 } else if (pdg == 211) { << 178 dataName = "pionEEPairProd"; << 179 } else if (pdg == 11) { << 180 dataName = "eEEPairProd"; << 181 } else if (pdg == 13) { << 182 if (GetName() == "muToMuonPairProd") { << 183 dataName = "muMuMuPairProd"; << 184 } else { << 185 dataName = "muEEPairProd"; << 186 } << 187 } << 188 } << 189 } << 190 164 191 // for low-energy application this process s 165 // for low-energy application this process should not work 192 if(lowestKinEnergy >= HighEnergyLimit()) { r 166 if(lowestKinEnergy >= HighEnergyLimit()) { return; } 193 167 194 if (p == particle) { << 168 // define scale of internal table for each thread only once 195 fElementData = << 169 if(0 == nbine) { 196 G4ElementDataRegistry::Instance()->GetEl << 170 emin = std::max(lowestKinEnergy, LowEnergyLimit()); 197 if (nullptr == fElementData) { << 171 emax = std::max(HighEnergyLimit(), emin*2); 198 G4AutoLock l(&theMuPairMutex); << 172 nbine = size_t(nYBinPerDecade*std::log10(emax/emin)); 199 fElementData = << 173 if(nbine < 3) { nbine = 3; } 200 G4ElementDataRegistry::Instance()->GetElemen << 174 201 if (nullptr == fElementData) { << 175 ymin = G4Log(minPairEnergy/emin); 202 fElementData = new G4ElementData(NZDATPAIR); << 176 dy = -ymin/G4double(nbiny); 203 fElementData->SetName(dataName); << 177 } 204 } << 178 205 G4bool useDataFile = G4EmParameters::Ins << 179 if(IsMaster() && p == particle) { 206 if (useDataFile) { useDataFile = Retrie << 180 if(!fElementData) { 207 if (!useDataFile) { MakeSamplingTables() << 181 fElementData = new G4ElementData(); 208 if (fTableToFile) { StoreTables(); } << 182 G4bool dataFile = G4EmParameters::Instance()->RetrieveMuDataFromFile(); 209 l.unlock(); << 183 if(dataFile) { dataFile = RetrieveTables(); } 210 } << 184 if(!dataFile) { MakeSamplingTables(); } 211 if (IsMaster()) { << 185 if(fTableToFile) { StoreTables(); } 212 InitialiseElementSelectors(p, cuts); << 186 } 213 } << 187 InitialiseElementSelectors(p, cuts); 214 } 188 } 215 } 189 } 216 190 217 //....oooOO0OOooo........oooOO0OOooo........oo 191 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 218 192 219 void G4MuPairProductionModel::InitialiseLocal( 193 void G4MuPairProductionModel::InitialiseLocal(const G4ParticleDefinition* p, 220 194 G4VEmModel* masterModel) 221 { 195 { 222 if(p == particle && lowestKinEnergy < HighEn 196 if(p == particle && lowestKinEnergy < HighEnergyLimit()) { 223 SetElementSelectors(masterModel->GetElemen 197 SetElementSelectors(masterModel->GetElementSelectors()); >> 198 fElementData = masterModel->GetElementData(); 224 } 199 } 225 } 200 } 226 201 227 //....oooOO0OOooo........oooOO0OOooo........oo 202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 228 203 229 G4double G4MuPairProductionModel::ComputeDEDXP 204 G4double G4MuPairProductionModel::ComputeDEDXPerVolume( 230 205 const G4Material* material, 231 206 const G4ParticleDefinition*, 232 207 G4double kineticEnergy, 233 208 G4double cutEnergy) 234 { 209 { 235 G4double dedx = 0.0; 210 G4double dedx = 0.0; 236 if (cutEnergy <= minPairEnergy || kineticEne 211 if (cutEnergy <= minPairEnergy || kineticEnergy <= lowestKinEnergy) 237 { return dedx; } 212 { return dedx; } 238 213 239 const G4ElementVector* theElementVector = ma 214 const G4ElementVector* theElementVector = material->GetElementVector(); 240 const G4double* theAtomicNumDensityVector = 215 const G4double* theAtomicNumDensityVector = 241 material->G 216 material->GetAtomicNumDensityVector(); 242 217 243 // loop for elements in the material 218 // loop for elements in the material 244 for (std::size_t i=0; i<material->GetNumberO << 219 for (size_t i=0; i<material->GetNumberOfElements(); ++i) { 245 G4double Z = (*theElementVector)[i]->GetZ 220 G4double Z = (*theElementVector)[i]->GetZ(); 246 G4double tmax = MaxSecondaryEnergyForElem 221 G4double tmax = MaxSecondaryEnergyForElement(kineticEnergy, Z); 247 G4double loss = ComputMuPairLoss(Z, kinet 222 G4double loss = ComputMuPairLoss(Z, kineticEnergy, cutEnergy, tmax); 248 dedx += loss*theAtomicNumDensityVector[i] 223 dedx += loss*theAtomicNumDensityVector[i]; 249 } 224 } 250 dedx = std::max(dedx, 0.0); 225 dedx = std::max(dedx, 0.0); 251 return dedx; 226 return dedx; 252 } 227 } 253 228 254 //....oooOO0OOooo........oooOO0OOooo........oo 229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 255 230 256 G4double G4MuPairProductionModel::ComputMuPair 231 G4double G4MuPairProductionModel::ComputMuPairLoss(G4double Z, 257 232 G4double tkin, 258 233 G4double cutEnergy, 259 234 G4double tmax) 260 { 235 { 261 G4double loss = 0.0; 236 G4double loss = 0.0; 262 237 263 G4double cut = std::min(cutEnergy, tmax); << 238 G4double cut = std::min(cutEnergy,tmax); 264 if(cut <= minPairEnergy) { return loss; } 239 if(cut <= minPairEnergy) { return loss; } 265 240 266 // calculate the rectricted loss 241 // calculate the rectricted loss 267 // numerical integration in log(PairEnergy) 242 // numerical integration in log(PairEnergy) 268 G4double aaa = G4Log(minPairEnergy); 243 G4double aaa = G4Log(minPairEnergy); 269 G4double bbb = G4Log(cut); 244 G4double bbb = G4Log(cut); 270 245 271 G4int kkk = std::min(std::max(G4lrint((bbb-a << 246 G4int kkk = (G4int)((bbb-aaa)/ak1+ak2); 272 G4double hhh = (bbb-aaa)/kkk; << 247 if (kkk > 8) { kkk = 8; } >> 248 else if (kkk < 1) { kkk = 1; } >> 249 >> 250 G4double hhh = (bbb-aaa)/(G4double)kkk; 273 G4double x = aaa; 251 G4double x = aaa; 274 252 275 for (G4int l=0 ; l<kkk; ++l) { 253 for (G4int l=0 ; l<kkk; ++l) { 276 for (G4int ll=0; ll<NINTPAIR; ++ll) { << 254 for (G4int ll=0; ll<8; ++ll) >> 255 { 277 G4double ep = G4Exp(x+xgi[ll]*hhh); 256 G4double ep = G4Exp(x+xgi[ll]*hhh); 278 loss += wgi[ll]*ep*ep*ComputeDMicroscopi 257 loss += wgi[ll]*ep*ep*ComputeDMicroscopicCrossSection(tkin, Z, ep); 279 } 258 } 280 x += hhh; 259 x += hhh; 281 } 260 } 282 loss *= hhh; 261 loss *= hhh; 283 loss = std::max(loss, 0.0); 262 loss = std::max(loss, 0.0); 284 return loss; 263 return loss; 285 } 264 } 286 265 287 //....oooOO0OOooo........oooOO0OOooo........oo 266 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 288 267 289 G4double G4MuPairProductionModel::ComputeMicro 268 G4double G4MuPairProductionModel::ComputeMicroscopicCrossSection( 290 G4d 269 G4double tkin, 291 G4d 270 G4double Z, 292 G4d 271 G4double cutEnergy) 293 { 272 { 294 G4double cross = 0.; 273 G4double cross = 0.; 295 G4double tmax = MaxSecondaryEnergyForElement 274 G4double tmax = MaxSecondaryEnergyForElement(tkin, Z); 296 G4double cut = std::max(cutEnergy, minPairE 275 G4double cut = std::max(cutEnergy, minPairEnergy); 297 if (tmax <= cut) { return cross; } 276 if (tmax <= cut) { return cross; } 298 277 >> 278 // G4double ak1=6.9 ; >> 279 // G4double ak2=1.0 ; 299 G4double aaa = G4Log(cut); 280 G4double aaa = G4Log(cut); 300 G4double bbb = G4Log(tmax); 281 G4double bbb = G4Log(tmax); 301 G4int kkk = std::min(std::max(G4lrint((bbb-a << 282 G4int kkk = (G4int)((bbb-aaa)/ak1 + ak2); >> 283 if(kkk > 8) { kkk = 8; } >> 284 else if (kkk < 1) { kkk = 1; } 302 285 303 G4double hhh = (bbb-aaa)/(kkk); << 286 G4double hhh = (bbb-aaa)/G4double(kkk); 304 G4double x = aaa; 287 G4double x = aaa; 305 288 306 for (G4int l=0; l<kkk; ++l) { << 289 for(G4int l=0; l<kkk; ++l) 307 for (G4int i=0; i<NINTPAIR; ++i) { << 290 { >> 291 for(G4int i=0; i<8; ++i) >> 292 { 308 G4double ep = G4Exp(x + xgi[i]*hhh); 293 G4double ep = G4Exp(x + xgi[i]*hhh); 309 cross += ep*wgi[i]*ComputeDMicroscopicCr 294 cross += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, ep); 310 } 295 } 311 x += hhh; 296 x += hhh; 312 } 297 } 313 298 314 cross *= hhh; 299 cross *= hhh; 315 cross = std::max(cross, 0.0); 300 cross = std::max(cross, 0.0); 316 return cross; 301 return cross; 317 } 302 } 318 303 319 //....oooOO0OOooo........oooOO0OOooo........oo 304 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 320 305 321 G4double G4MuPairProductionModel::ComputeDMicr 306 G4double G4MuPairProductionModel::ComputeDMicroscopicCrossSection( 322 G4d 307 G4double tkin, 323 G4d 308 G4double Z, 324 G4d 309 G4double pairEnergy) 325 // Calculates the differential (D) microscopi 310 // Calculates the differential (D) microscopic cross section 326 // using the cross section formula of R.P. Kok 311 // using the cross section formula of R.P. Kokoulin (18/01/98) 327 // Code modified by R.P. Kokoulin, V.N. Ivanch 312 // Code modified by R.P. Kokoulin, V.N. Ivanchenko (27/01/04) 328 { 313 { 329 static const G4double bbbtf= 183. ; 314 static const G4double bbbtf= 183. ; 330 static const G4double bbbh = 202.4 ; 315 static const G4double bbbh = 202.4 ; 331 static const G4double g1tf = 1.95e-5 ; 316 static const G4double g1tf = 1.95e-5 ; 332 static const G4double g2tf = 5.3e-5 ; 317 static const G4double g2tf = 5.3e-5 ; 333 static const G4double g1h = 4.4e-5 ; 318 static const G4double g1h = 4.4e-5 ; 334 static const G4double g2h = 4.8e-5 ; 319 static const G4double g2h = 4.8e-5 ; 335 320 336 if (pairEnergy <= minPairEnergy) << 337 return 0.0; << 338 << 339 G4double totalEnergy = tkin + particleMass; 321 G4double totalEnergy = tkin + particleMass; 340 G4double residEnergy = totalEnergy - pairEn 322 G4double residEnergy = totalEnergy - pairEnergy; >> 323 G4double massratio = particleMass/electron_mass_c2; >> 324 G4double massratio2 = massratio*massratio; >> 325 G4double cross = 0.; 341 326 342 if (residEnergy <= 0.75*sqrte*z13*particleMa << 327 G4double c3 = 0.75*sqrte*particleMass; 343 return 0.0; << 328 if (residEnergy <= c3*z13) { return cross; } 344 << 345 G4double a0 = 1.0 / (totalEnergy * residEner << 346 G4double alf = 4.0 * electron_mass_c2 / pair << 347 G4double rt = std::sqrt(1.0 - alf); << 348 G4double delta = 6.0 * particleMass * partic << 349 G4double tmnexp = alf/(1.0 + rt) + delta*rt; << 350 << 351 if(tmnexp >= 1.0) { return 0.0; } << 352 << 353 G4double tmn = G4Log(tmnexp); << 354 329 355 G4double massratio = particleMass/CLHEP::ele << 330 static const G4double c7 = 4.*CLHEP::electron_mass_c2; 356 G4double massratio2 = massratio*massratio; << 331 G4double c8 = 6.*particleMass*particleMass; 357 G4double inv_massratio2 = 1.0 / massratio2; << 332 G4double alf = c7/pairEnergy; >> 333 G4double a3 = 1. - alf; >> 334 if (a3 <= 0.) { return cross; } 358 335 359 // zeta calculation 336 // zeta calculation 360 G4double bbb,g1,g2; 337 G4double bbb,g1,g2; 361 if( Z < 1.5 ) { bbb = bbbh ; g1 = g1h ; g2 = 338 if( Z < 1.5 ) { bbb = bbbh ; g1 = g1h ; g2 = g2h ; } 362 else { bbb = bbbtf; g1 = g1tf; g2 = 339 else { bbb = bbbtf; g1 = g1tf; g2 = g2tf; } 363 340 364 G4double zeta = 0.0; << 341 G4double zeta = 0; 365 G4double z1exp = totalEnergy / (particleMass << 342 G4double zeta1 = 366 << 343 0.073*G4Log(totalEnergy/(particleMass+g1*z23*totalEnergy))-0.26; 367 // 35.221047195922 is the root of zeta1(x) = << 344 if ( zeta1 > 0.) 368 // condition below is the same as zeta1 > 0. << 369 if (z1exp > 35.221047195922) << 370 { 345 { 371 G4double z2exp = totalEnergy / (particleMa << 346 G4double zeta2 = 372 zeta = (0.073 * G4Log(z1exp) - 0.26) / (0. << 347 0.058*G4Log(totalEnergy/(particleMass+g2*z13*totalEnergy))-0.14; >> 348 zeta = zeta1/zeta2 ; 373 } 349 } 374 350 375 G4double z2 = Z*(Z+zeta); 351 G4double z2 = Z*(Z+zeta); 376 G4double screen0 = 2.*electron_mass_c2*sqrte 352 G4double screen0 = 2.*electron_mass_c2*sqrte*bbb/(z13*pairEnergy); 377 G4double beta = 0.5*pairEnergy*pairEnergy*a0 << 353 G4double a0 = totalEnergy*residEnergy; 378 G4double xi0 = 0.5*massratio2*beta; << 354 G4double a1 = pairEnergy*pairEnergy/a0; >> 355 G4double bet = 0.5*a1; >> 356 G4double xi0 = 0.25*massratio2*a1; >> 357 G4double del = c8/a0; >> 358 >> 359 G4double rta3 = sqrt(a3); >> 360 G4double tmnexp = alf/(1. + rta3) + del*rta3; >> 361 if(tmnexp >= 1.0) { return cross; } 379 362 380 // Gaussian integration in ln(1-ro) ( with 8 << 363 G4double tmn = G4Log(tmnexp); 381 G4double rho[NINTPAIR]; << 364 G4double sum = 0.; 382 G4double rho2[NINTPAIR]; << 383 G4double xi[NINTPAIR]; << 384 G4double xi1[NINTPAIR]; << 385 G4double xii[NINTPAIR]; << 386 << 387 for (G4int i = 0; i < NINTPAIR; ++i) << 388 { << 389 rho[i] = G4Exp(tmn*xgi[i]) - 1.0; // rho = << 390 rho2[i] = rho[i] * rho[i]; << 391 xi[i] = xi0*(1.0-rho2[i]); << 392 xi1[i] = 1.0 + xi[i]; << 393 xii[i] = 1.0 / xi[i]; << 394 } << 395 << 396 G4double ye1[NINTPAIR]; << 397 G4double ym1[NINTPAIR]; << 398 << 399 G4double b40 = 4.0 * beta; << 400 G4double b62 = 6.0 * beta + 2.0; << 401 365 402 for (G4int i = 0; i < NINTPAIR; ++i) << 366 // Gaussian integration in ln(1-ro) ( with 8 points) >> 367 for (G4int i=0; i<8; ++i) 403 { 368 { 404 G4double yeu = (b40 + 5.0) + (b40 - 1.0) * << 369 G4double a4 = G4Exp(tmn*xgi[i]); // a4 = (1.-asymmetry) 405 G4double yed = b62*G4Log(3.0 + xii[i]) + ( << 370 G4double a5 = a4*(2.-a4) ; 406 << 371 G4double a6 = 1.-a5 ; 407 G4double ymu = b62 * (1.0 + rho2[i]) + 6.0 << 372 G4double a7 = 1.+a6 ; 408 G4double ymd = (b40 + 3.0)*(1.0 + rho2[i]) << 373 G4double a9 = 3.+a6 ; 409 + 2.0 - 3.0 * rho2[i]; << 374 G4double xi = xi0*a5 ; 410 << 375 G4double xii = 1./xi ; 411 ye1[i] = 1.0 + yeu / yed; << 376 G4double xi1 = 1.+xi ; 412 ym1[i] = 1.0 + ymu / ymd; << 377 G4double screen = screen0*xi1/a5 ; 413 } << 378 G4double yeu = 5.-a6+4.*bet*a7 ; 414 << 379 G4double yed = 2.*(1.+3.*bet)*G4Log(3.+xii)-a6-a1*(2.-a6) ; 415 G4double be[NINTPAIR]; << 380 G4double ye1 = 1.+yeu/yed ; 416 G4double bm[NINTPAIR]; << 381 G4double ale = G4Log(bbb/z13*sqrt(xi1*ye1)/(1.+screen*ye1)) ; 417 << 382 G4double cre = 0.5*G4Log(1.+2.25*z23*xi1*ye1/massratio2) ; 418 for(G4int i = 0; i < NINTPAIR; ++i) { << 383 G4double be; 419 if(xi[i] <= 1000.0) { << 384 420 be[i] = ((2.0 + rho2[i])*(1.0 + beta) + << 385 if (xi <= 1.e3) { 421 xi[i]*(3.0 + rho2[i]))*G4Log(1.0 + xi << 386 be = ((2.+a6)*(1.+bet)+xi*a9)*G4Log(1.+xii)+(a5-bet)/xi1-a9; 422 (1.0 - rho2[i] - beta)/xi1[i] - (3.0 + rho2[ << 387 } else { 423 } else { << 388 be = (3.-a6+a1*a7)/(2.*xi); 424 be[i] = 0.5*(3.0 - rho2[i] + 2.0*beta*(1 << 389 } 425 } << 390 G4double fe = (ale-cre)*be; 426 << 391 if ( fe < 0.) fe = 0. ; 427 if(xi[i] >= 0.001) { << 392 428 G4double a10 = (1.0 + 2.0 * beta) * (1.0 << 393 G4double ymu = 4.+a6 +3.*bet*a7 ; 429 bm[i] = ((1.0 + rho2[i])*(1.0 + 1.5 * be << 394 G4double ymd = a7*(1.5+a1)*G4Log(3.+xi)+1.-1.5*a6 ; 430 xi[i] * (1.0 - rho2[i] - beta) << 395 G4double ym1 = 1.+ymu/ymd ; >> 396 G4double alm_crm = G4Log(bbb*massratio/(1.5*z23*(1.+screen*ym1))); >> 397 G4double a10,bm; >> 398 if ( xi >= 1.e-3) >> 399 { >> 400 a10 = (1.+a1)*a5 ; >> 401 bm = (a7*(1.+1.5*bet)-a10*xii)*G4Log(xi1)+xi*(a5-bet)/xi1+a10; 431 } else { 402 } else { 432 bm[i] = 0.5*(5.0 - rho2[i] + beta * (3.0 << 403 bm = (5.-a6+bet*a9)*(xi/2.); 433 } 404 } 434 } << 435 << 436 G4double sum = 0.0; << 437 << 438 for (G4int i = 0; i < NINTPAIR; ++i) { << 439 G4double screen = screen0*xi1[i]/(1.0 - rh << 440 G4double ale = G4Log(bbb/z13*std::sqrt(xi1 << 441 G4double cre = 0.5*G4Log(1. + 2.25*z23*xi1 << 442 405 443 G4double fe = (ale-cre)*be[i]; << 406 G4double fm = alm_crm*bm; 444 fe = std::max(fe, 0.0); << 407 if ( fm < 0.) { fm = 0.; } 445 408 446 G4double alm_crm = G4Log(bbb*massratio/(1. << 409 sum += wgi[i]*a4*(fe+fm/massratio2); 447 G4double fm = std::max(alm_crm*bm[i], 0.0) << 448 << 449 sum += wgi[i]*(1.0 + rho[i])*(fe + fm); << 450 } 410 } 451 411 452 return -tmn*sum*factorForCross*z2*residEnerg << 412 cross = -tmn*sum*factorForCross*z2*residEnergy/(totalEnergy*pairEnergy); >> 413 cross = std::max(cross, 0.0); >> 414 return cross; 453 } 415 } 454 416 455 //....oooOO0OOooo........oooOO0OOooo........oo 417 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 456 418 457 G4double G4MuPairProductionModel::ComputeCross 419 G4double G4MuPairProductionModel::ComputeCrossSectionPerAtom( 458 con 420 const G4ParticleDefinition*, 459 421 G4double kineticEnergy, 460 422 G4double Z, G4double, 461 423 G4double cutEnergy, 462 424 G4double maxEnergy) 463 { 425 { 464 G4double cross = 0.0; 426 G4double cross = 0.0; 465 if (kineticEnergy <= lowestKinEnergy) { retu 427 if (kineticEnergy <= lowestKinEnergy) { return cross; } 466 428 467 G4double maxPairEnergy = MaxSecondaryEnergyF 429 G4double maxPairEnergy = MaxSecondaryEnergyForElement(kineticEnergy, Z); 468 G4double tmax = std::min(maxEnergy, maxPairE 430 G4double tmax = std::min(maxEnergy, maxPairEnergy); 469 G4double cut = std::max(cutEnergy, minPairE 431 G4double cut = std::max(cutEnergy, minPairEnergy); 470 if (cut >= tmax) { return cross; } 432 if (cut >= tmax) { return cross; } 471 433 472 cross = ComputeMicroscopicCrossSection(kinet 434 cross = ComputeMicroscopicCrossSection(kineticEnergy, Z, cut); 473 if(tmax < kineticEnergy) { 435 if(tmax < kineticEnergy) { 474 cross -= ComputeMicroscopicCrossSection(ki 436 cross -= ComputeMicroscopicCrossSection(kineticEnergy, Z, tmax); 475 } 437 } 476 return cross; 438 return cross; 477 } 439 } 478 440 479 //....oooOO0OOooo........oooOO0OOooo........oo 441 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 480 442 481 void G4MuPairProductionModel::MakeSamplingTabl 443 void G4MuPairProductionModel::MakeSamplingTables() 482 { 444 { 483 G4double factore = G4Exp(G4Log(emax/emin)/G4 445 G4double factore = G4Exp(G4Log(emax/emin)/G4double(nbine)); 484 446 485 for (G4int iz=0; iz<NZDATPAIR; ++iz) { << 447 for (G4int iz=0; iz<nzdat; ++iz) { 486 448 487 G4double Z = ZDATPAIR[iz]; << 449 G4double Z = zdat[iz]; 488 G4Physics2DVector* pv = new G4Physics2DVec 450 G4Physics2DVector* pv = new G4Physics2DVector(nbiny+1,nbine+1); 489 G4double kinEnergy = emin; 451 G4double kinEnergy = emin; 490 452 491 for (std::size_t it=0; it<=nbine; ++it) { << 453 for (size_t it=0; it<=nbine; ++it) { 492 454 493 pv->PutY(it, G4Log(kinEnergy/CLHEP::MeV) << 455 pv->PutY(it, G4Log(kinEnergy/MeV)); 494 G4double maxPairEnergy = MaxSecondaryEne 456 G4double maxPairEnergy = MaxSecondaryEnergyForElement(kinEnergy, Z); 495 /* 457 /* 496 G4cout << "it= " << it << " E= " << kinE 458 G4cout << "it= " << it << " E= " << kinEnergy 497 << " " << particle->GetParticleN 459 << " " << particle->GetParticleName() 498 << " maxE= " << maxPairEnergy << 460 << " maxE= " << maxPairEnergy << " minE= " << minPairEnergy 499 << " ymin= " << ymin << G4endl; 461 << " ymin= " << ymin << G4endl; 500 */ 462 */ 501 G4double coef = G4Log(minPairEnergy/kinE 463 G4double coef = G4Log(minPairEnergy/kinEnergy)/ymin; 502 G4double ymax = G4Log(maxPairEnergy/kinE 464 G4double ymax = G4Log(maxPairEnergy/kinEnergy)/coef; 503 G4double fac = (ymax - ymin)/dy; 465 G4double fac = (ymax - ymin)/dy; 504 std::size_t imax = (std::size_t)fac; << 466 size_t imax = (size_t)fac; 505 fac -= (G4double)imax; 467 fac -= (G4double)imax; 506 468 507 G4double xSec = 0.0; 469 G4double xSec = 0.0; 508 G4double x = ymin; 470 G4double x = ymin; 509 /* 471 /* 510 G4cout << "Z= " << currentZ << " z13= " 472 G4cout << "Z= " << currentZ << " z13= " << z13 511 << " mE= " << maxPairEnergy << " 473 << " mE= " << maxPairEnergy << " ymin= " << ymin 512 << " dy= " << dy << " c= " << co 474 << " dy= " << dy << " c= " << coef << G4endl; 513 */ 475 */ 514 // start from zero 476 // start from zero 515 pv->PutValue(0, it, 0.0); 477 pv->PutValue(0, it, 0.0); 516 if(0 == it) { pv->PutX(nbiny, 0.0); } 478 if(0 == it) { pv->PutX(nbiny, 0.0); } 517 479 518 for (std::size_t i=0; i<nbiny; ++i) { << 480 for (size_t i=0; i<nbiny; ++i) { 519 481 520 if(0 == it) { pv->PutX(i, x); } 482 if(0 == it) { pv->PutX(i, x); } 521 483 522 if(i < imax) { 484 if(i < imax) { 523 G4double ep = kinEnergy*G4Exp(coef*( 485 G4double ep = kinEnergy*G4Exp(coef*(x + dy*0.5)); 524 486 525 // not multiplied by interval, becau 487 // not multiplied by interval, because table 526 // will be used only for sampling 488 // will be used only for sampling 527 //G4cout << "i= " << i << " x= " << 489 //G4cout << "i= " << i << " x= " << x << "E= " << kinEnergy 528 // << " Egamma= " << ep << G 490 // << " Egamma= " << ep << G4endl; 529 xSec += ep*ComputeDMicroscopicCrossS 491 xSec += ep*ComputeDMicroscopicCrossSection(kinEnergy, Z, ep); 530 492 531 // last bin before the kinematic lim 493 // last bin before the kinematic limit 532 } else if(i == imax) { 494 } else if(i == imax) { 533 G4double ep = kinEnergy*G4Exp(coef*( 495 G4double ep = kinEnergy*G4Exp(coef*(x + fac*dy*0.5)); 534 xSec += ep*fac*ComputeDMicroscopicCr 496 xSec += ep*fac*ComputeDMicroscopicCrossSection(kinEnergy, Z, ep); 535 } 497 } 536 pv->PutValue(i + 1, it, xSec); 498 pv->PutValue(i + 1, it, xSec); 537 x += dy; 499 x += dy; 538 } 500 } 539 kinEnergy *= factore; 501 kinEnergy *= factore; 540 502 541 // to avoid precision lost 503 // to avoid precision lost 542 if(it+1 == nbine) { kinEnergy = emax; } 504 if(it+1 == nbine) { kinEnergy = emax; } 543 } 505 } 544 fElementData->InitialiseForElement(iz, pv) << 506 fElementData->InitialiseForElement(zdat[iz], pv); 545 } 507 } 546 } 508 } 547 509 548 //....oooOO0OOooo........oooOO0OOooo........oo 510 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 549 511 550 void G4MuPairProductionModel::SampleSecondarie 512 void G4MuPairProductionModel::SampleSecondaries( 551 std::vector<G4Dy 513 std::vector<G4DynamicParticle*>* vdp, 552 const G4Material 514 const G4MaterialCutsCouple* couple, 553 const G4DynamicP 515 const G4DynamicParticle* aDynamicParticle, 554 G4double tmin, 516 G4double tmin, 555 G4double tmax) 517 G4double tmax) 556 { 518 { 557 G4double kinEnergy = aDynamicParticle->GetKi << 519 G4double kineticEnergy = aDynamicParticle->GetKineticEnergy(); 558 //G4cout << "------- G4MuPairProductionModel 520 //G4cout << "------- G4MuPairProductionModel::SampleSecondaries E(MeV)= " 559 // << kinEnergy << " " << 521 // << kineticEnergy << " " 560 // << aDynamicParticle->GetDefinitio 522 // << aDynamicParticle->GetDefinition()->GetParticleName() << G4endl; 561 G4double totalEnergy = kinEnergy + particl << 523 G4double totalEnergy = kineticEnergy + particleMass; 562 G4double totalMomentum = 524 G4double totalMomentum = 563 std::sqrt(kinEnergy*(kinEnergy + 2.0*parti << 525 sqrt(kineticEnergy*(kineticEnergy + 2.0*particleMass)); 564 526 565 G4ThreeVector partDirection = aDynamicPartic 527 G4ThreeVector partDirection = aDynamicParticle->GetMomentumDirection(); 566 528 567 // select randomly one element constituing t 529 // select randomly one element constituing the material 568 const G4Element* anElement = SelectRandomAto << 530 const G4Element* anElement = SelectRandomAtom(couple,particle,kineticEnergy); 569 531 570 // define interval of energy transfer 532 // define interval of energy transfer 571 G4double maxPairEnergy = MaxSecondaryEnergyF << 533 G4double maxPairEnergy = MaxSecondaryEnergyForElement(kineticEnergy, 572 534 anElement->GetZ()); 573 G4double maxEnergy = std::min(tmax, maxPairE << 535 G4double maxEnergy = std::min(tmax, maxPairEnergy); 574 G4double minEnergy = std::max(tmin, minPairE << 536 G4double minEnergy = std::max(tmin, minPairEnergy); 575 537 576 if (minEnergy >= maxEnergy) { return; } << 538 if(minEnergy >= maxEnergy) { return; } 577 //G4cout << "emin= " << minEnergy << " emax= 539 //G4cout << "emin= " << minEnergy << " emax= " << maxEnergy 578 // << " minPair= " << minPairEnergy << " max 540 // << " minPair= " << minPairEnergy << " maxpair= " << maxPairEnergy 579 // << " ymin= " << ymin << " dy= " << dy 541 // << " ymin= " << ymin << " dy= " << dy << G4endl; 580 542 581 G4double coeff = G4Log(minPairEnergy/kinEner << 543 G4double coeff = G4Log(minPairEnergy/kineticEnergy)/ymin; 582 544 583 // compute limits 545 // compute limits 584 G4double yymin = G4Log(minEnergy/kinEnergy)/ << 546 G4double yymin = G4Log(minEnergy/kineticEnergy)/coeff; 585 G4double yymax = G4Log(maxEnergy/kinEnergy)/ << 547 G4double yymax = G4Log(maxEnergy/kineticEnergy)/coeff; 586 548 587 //G4cout << "yymin= " << yymin << " yymax= 549 //G4cout << "yymin= " << yymin << " yymax= " << yymax << G4endl; 588 550 589 // units should not be used, bacause table w 551 // units should not be used, bacause table was built without 590 G4double logTkin = G4Log(kinEnergy/CLHEP::Me << 552 G4double logTkin = G4Log(kineticEnergy/MeV); 591 553 592 // sample e-e+ energy, pair energy first 554 // sample e-e+ energy, pair energy first 593 555 594 // select sample table via Z 556 // select sample table via Z 595 G4int iz1(0), iz2(0); 557 G4int iz1(0), iz2(0); 596 for (G4int iz=0; iz<NZDATPAIR; ++iz) { << 558 for(G4int iz=0; iz<nzdat; ++iz) { 597 if(currentZ == ZDATPAIR[iz]) { << 559 if(currentZ == zdat[iz]) { 598 iz1 = iz2 = iz; << 560 iz1 = iz2 = currentZ; 599 break; 561 break; 600 } else if(currentZ < ZDATPAIR[iz]) { << 562 } else if(currentZ < zdat[iz]) { 601 iz2 = iz; << 563 iz2 = zdat[iz]; 602 if(iz > 0) { iz1 = iz-1; } << 564 if(iz > 0) { iz1 = zdat[iz-1]; } 603 else { iz1 = iz2; } 565 else { iz1 = iz2; } 604 break; 566 break; 605 } 567 } 606 } 568 } 607 if (0 == iz1) { iz1 = iz2 = NZDATPAIR-1; } << 569 if(0 == iz1) { iz1 = iz2 = zdat[nzdat-1]; } 608 570 609 G4double pairEnergy = 0.0; << 571 G4double PairEnergy = 0.0; 610 G4int count = 0; 572 G4int count = 0; 611 //G4cout << "start loop Z1= " << iz1 << " Z2 573 //G4cout << "start loop Z1= " << iz1 << " Z2= " << iz2 << G4endl; 612 do { 574 do { 613 ++count; 575 ++count; 614 // sampling using only one random number 576 // sampling using only one random number 615 G4double rand = G4UniformRand(); 577 G4double rand = G4UniformRand(); 616 578 617 G4double x = FindScaledEnergy(iz1, rand, l 579 G4double x = FindScaledEnergy(iz1, rand, logTkin, yymin, yymax); 618 if(iz1 != iz2) { 580 if(iz1 != iz2) { 619 G4double x2 = FindScaledEnergy(iz2, rand 581 G4double x2 = FindScaledEnergy(iz2, rand, logTkin, yymin, yymax); 620 G4double lz1= nist->GetLOGZ(ZDATPAIR[iz1 << 582 G4double lz1= nist->GetLOGZ(iz1); 621 G4double lz2= nist->GetLOGZ(ZDATPAIR[iz2 << 583 G4double lz2= nist->GetLOGZ(iz2); 622 //G4cout << count << ". x= " << x << " 584 //G4cout << count << ". x= " << x << " x2= " << x2 623 // << " Z1= " << iz1 << " Z2 585 // << " Z1= " << iz1 << " Z2= " << iz2 << G4endl; 624 x += (x2 - x)*(lnZ - lz1)/(lz2 - lz1); 586 x += (x2 - x)*(lnZ - lz1)/(lz2 - lz1); 625 } 587 } 626 //G4cout << "x= " << x << " coeff= " << c 588 //G4cout << "x= " << x << " coeff= " << coeff << G4endl; 627 pairEnergy = kinEnergy*G4Exp(x*coeff); << 589 PairEnergy = kineticEnergy*G4Exp(x*coeff); 628 590 629 // Loop checking, 03-Aug-2015, Vladimir Iv 591 // Loop checking, 03-Aug-2015, Vladimir Ivanchenko 630 } while((pairEnergy < minEnergy || pairEnerg << 592 } while((PairEnergy < minEnergy || PairEnergy > maxEnergy) && 10 > count); 631 593 632 //G4cout << "## pairEnergy(GeV)= " << pairEn << 594 //G4cout << "## PairEnergy(GeV)= " << PairEnergy/GeV 633 // << " Etot(GeV)= " << totalEnergy/ 595 // << " Etot(GeV)= " << totalEnergy/GeV << G4endl; 634 596 635 // sample r=(E+-E-)/pairEnergy ( uniformly << 597 // sample r=(E+-E-)/PairEnergy ( uniformly .....) 636 G4double rmax = 598 G4double rmax = 637 (1.-6.*particleMass*particleMass/(totalEne << 599 (1.-6.*particleMass*particleMass/(totalEnergy*(totalEnergy-PairEnergy))) 638 *std::sqrt(1.-minPairEnergy/pairEnergy); << 600 *sqrt(1.-minPairEnergy/PairEnergy); 639 G4double r = rmax * (-1.+2.*G4UniformRand()) 601 G4double r = rmax * (-1.+2.*G4UniformRand()) ; 640 602 641 // compute energies from pairEnergy,r << 603 // compute energies from PairEnergy,r 642 G4double eEnergy = (1.-r)*pairEnergy*0.5; << 604 G4double ElectronEnergy = (1.-r)*PairEnergy*0.5; 643 G4double pEnergy = pairEnergy - eEnergy; << 605 G4double PositronEnergy = PairEnergy - ElectronEnergy; 644 << 606 645 // Sample angles << 607 // The angle of the emitted virtual photon is sampled 646 G4ThreeVector eDirection, pDirection; << 608 // according to the muon bremsstrahlung model 647 // << 609 648 GetAngularDistribution()->SamplePairDirectio << 610 G4double gam = totalEnergy/particleMass; 649 << 611 G4double gmax = gam*std::min(1.0, totalEnergy/PairEnergy - 1.0); 650 << 612 G4double gmax2= gmax*gmax; 651 // create G4DynamicParticle object for e+e- << 613 G4double x = G4UniformRand()*gmax2/(1.0 + gmax2); 652 eEnergy = std::max(eEnergy - CLHEP::electron << 614 653 pEnergy = std::max(pEnergy - CLHEP::electron << 615 G4double theta = sqrt(x/(1.0 - x))/gam; 654 auto aParticle1 = new G4DynamicParticle(theE << 616 G4double sint = sin(theta); 655 auto aParticle2 = new G4DynamicParticle(theP << 617 G4double phi = twopi * G4UniformRand() ; 656 // Fill output vector << 618 G4double dirx = sint*cos(phi), diry = sint*sin(phi), dirz = cos(theta) ; 657 vdp->push_back(aParticle1); << 619 658 vdp->push_back(aParticle2); << 620 G4ThreeVector gDirection(dirx, diry, dirz); >> 621 gDirection.rotateUz(partDirection); >> 622 >> 623 // the angles of e- and e+ assumed to be the same as virtual gamma >> 624 >> 625 // create G4DynamicParticle object for the particle1 >> 626 G4double ekin = std::max(ElectronEnergy - electron_mass_c2,0.0); >> 627 G4DynamicParticle* aParticle1 = >> 628 new G4DynamicParticle(theElectron, gDirection, ekin); >> 629 >> 630 // create G4DynamicParticle object for the particle2 >> 631 ekin = std::max(PositronEnergy - electron_mass_c2,0.0); >> 632 G4DynamicParticle* aParticle2 = >> 633 new G4DynamicParticle(thePositron, gDirection, ekin); 659 634 660 // primary change 635 // primary change 661 kinEnergy -= pairEnergy; << 636 kineticEnergy -= (ElectronEnergy + PositronEnergy); >> 637 fParticleChange->SetProposedKineticEnergy(kineticEnergy); >> 638 662 partDirection *= totalMomentum; 639 partDirection *= totalMomentum; 663 partDirection -= (aParticle1->GetMomentum() 640 partDirection -= (aParticle1->GetMomentum() + aParticle2->GetMomentum()); 664 partDirection = partDirection.unit(); 641 partDirection = partDirection.unit(); >> 642 fParticleChange->SetProposedMomentumDirection(partDirection); 665 643 666 // if energy transfer is higher than thresho << 644 // add secondary 667 // then stop tracking the primary particle a << 645 vdp->push_back(aParticle1); 668 if (pairEnergy > SecondaryThreshold()) { << 646 vdp->push_back(aParticle2); 669 fParticleChange->ProposeTrackStatus(fStopA << 670 fParticleChange->SetProposedKineticEnergy( << 671 auto newdp = new G4DynamicParticle(particl << 672 vdp->push_back(newdp); << 673 } else { // continue tracking the primary e- << 674 fParticleChange->SetProposedMomentumDirect << 675 fParticleChange->SetProposedKineticEnergy( << 676 } << 677 //G4cout << "-- G4MuPairProductionModel::Sam 647 //G4cout << "-- G4MuPairProductionModel::SampleSecondaries done" << G4endl; 678 } 648 } 679 649 680 //....oooOO0OOooo........oooOO0OOooo........oo 650 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 681 651 682 G4double << 683 G4MuPairProductionModel::FindScaledEnergy(G4in << 684 G4double logTkin, << 685 G4double yymin, G4double yymax) << 686 { << 687 G4double res = yymin; << 688 G4Physics2DVector* pv = fElementData->GetEle << 689 if (nullptr != pv) { << 690 G4double pmin = pv->Value(yymin, logTkin); << 691 G4double pmax = pv->Value(yymax, logTkin); << 692 G4double p0 = pv->Value(0.0, logTkin); << 693 if(p0 <= 0.0) { DataCorrupted(ZDATPAIR[iz] << 694 else { res = pv->FindLinearX((pmin + rand* << 695 } else { << 696 DataCorrupted(ZDATPAIR[iz], logTkin); << 697 } << 698 return res; << 699 } << 700 << 701 //....oooOO0OOooo........oooOO0OOooo........oo << 702 << 703 void G4MuPairProductionModel::DataCorrupted(G4 652 void G4MuPairProductionModel::DataCorrupted(G4int Z, G4double logTkin) const 704 { 653 { 705 G4ExceptionDescription ed; 654 G4ExceptionDescription ed; 706 ed << "G4ElementData is not properly initial 655 ed << "G4ElementData is not properly initialized Z= " << Z 707 << " Ekin(MeV)= " << G4Exp(logTkin) 656 << " Ekin(MeV)= " << G4Exp(logTkin) 708 << " IsMasterThread= " << IsMaster() 657 << " IsMasterThread= " << IsMaster() 709 << " Model " << GetName(); 658 << " Model " << GetName(); 710 G4Exception("G4MuPairProductionModel::()", " << 659 G4Exception("G4MuPairProductionModel::()","em0033",FatalException, >> 660 ed,""); 711 } 661 } 712 662 713 //....oooOO0OOooo........oooOO0OOooo........oo 663 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 714 664 715 void G4MuPairProductionModel::StoreTables() co 665 void G4MuPairProductionModel::StoreTables() const 716 { 666 { 717 for (G4int iz=0; iz<NZDATPAIR; ++iz) { << 667 for (G4int iz=0; iz<nzdat; ++iz) { 718 G4int Z = ZDATPAIR[iz]; << 668 G4int Z = zdat[iz]; 719 G4Physics2DVector* pv = fElementData->GetE 669 G4Physics2DVector* pv = fElementData->GetElement2DData(Z); 720 if(nullptr == pv) { << 670 if(!pv) { DataCorrupted(Z, 1.0); } 721 DataCorrupted(Z, 1.0); << 722 return; << 723 } << 724 std::ostringstream ss; 671 std::ostringstream ss; 725 ss << "mupair/" << particle->GetParticleNa 672 ss << "mupair/" << particle->GetParticleName() << Z << ".dat"; 726 std::ofstream outfile(ss.str()); 673 std::ofstream outfile(ss.str()); 727 pv->Store(outfile); 674 pv->Store(outfile); 728 } 675 } 729 } 676 } 730 677 731 //....oooOO0OOooo........oooOO0OOooo........oo 678 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 732 679 733 G4bool G4MuPairProductionModel::RetrieveTables 680 G4bool G4MuPairProductionModel::RetrieveTables() 734 { 681 { 735 for (G4int iz=0; iz<NZDATPAIR; ++iz) { << 682 char* path = std::getenv("G4LEDATA"); 736 G4double Z = ZDATPAIR[iz]; << 683 G4String dir(""); >> 684 if (path) { >> 685 std::ostringstream ost; >> 686 ost << path << "/mupair/"; >> 687 dir = ost.str(); >> 688 } else { >> 689 dir = "./mupair/"; >> 690 } >> 691 >> 692 for (G4int iz=0; iz<nzdat; ++iz) { >> 693 G4double Z = zdat[iz]; 737 G4Physics2DVector* pv = new G4Physics2DVec 694 G4Physics2DVector* pv = new G4Physics2DVector(nbiny+1,nbine+1); >> 695 if(!pv) { >> 696 DataCorrupted(Z, 2.0); >> 697 return false; >> 698 } 738 std::ostringstream ss; 699 std::ostringstream ss; 739 ss << G4EmParameters::Instance()->GetDirLE << 700 ss << dir << particle->GetParticleName() << Z << ".dat"; 740 << particle->GetParticleName() << Z << << 741 std::ifstream infile(ss.str(), std::ios::i 701 std::ifstream infile(ss.str(), std::ios::in); 742 if(!pv->Retrieve(infile)) { << 702 if(!pv->Retrieve(infile)) { return false; } 743 delete pv; << 703 fElementData->InitialiseForElement(Z, pv); 744 return false; << 745 } << 746 fElementData->InitialiseForElement(iz, pv) << 747 } 704 } 748 return true; 705 return true; 749 } 706 } 750 707 751 //....oooOO0OOooo........oooOO0OOooo........oo 708 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 709 >> 710 752 711