Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // >> 23 // $Id: G4MuBremsstrahlungModel.cc,v 1.12 2004/02/10 18:07:26 vnivanch Exp $ >> 24 // GEANT4 tag $Name: geant4-06-01 $ 26 // 25 // 27 // ------------------------------------------- 26 // ------------------------------------------------------------------- 28 // 27 // 29 // GEANT4 Class file 28 // GEANT4 Class file 30 // 29 // 31 // 30 // 32 // File name: G4MuBremsstrahlungModel 31 // File name: G4MuBremsstrahlungModel 33 // 32 // 34 // Author: Vladimir Ivanchenko on base 33 // Author: Vladimir Ivanchenko on base of Laszlo Urban code 35 // 34 // 36 // Creation date: 24.06.2002 35 // Creation date: 24.06.2002 37 // 36 // 38 // Modifications: 37 // Modifications: 39 // 38 // 40 // 04-12-02 Change G4DynamicParticle construct 39 // 04-12-02 Change G4DynamicParticle constructor in PostStepDoIt (V.Ivanchenko) 41 // 23-12-02 Change interface in order to move 40 // 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko) 42 // 24-01-03 Fix for compounds (V.Ivanchenko) 41 // 24-01-03 Fix for compounds (V.Ivanchenko) 43 // 27-01-03 Make models region aware (V.Ivanch 42 // 27-01-03 Make models region aware (V.Ivanchenko) 44 // 13-02-03 Add name (V.Ivanchenko) 43 // 13-02-03 Add name (V.Ivanchenko) 45 // 10-02-04 Add lowestKinEnergy (V.Ivanchenko) 44 // 10-02-04 Add lowestKinEnergy (V.Ivanchenko) 46 // 08-04-05 Major optimisation of internal int << 45 // 47 // 03-08-05 Angular correlations according to << 46 48 // 13-02-06 add ComputeCrossSectionPerAtom (mm << 47 // 49 // 21-03-06 Fix problem of initialisation in c << 48 // Class Description: 50 // 07-11-07 Improve sampling of final state (A << 49 // 51 // 28-02-08 Use precomputed Z^1/3 and Log(A) ( << 52 // 31-05-13 Use element selectors instead of l << 53 // 50 // 54 // ------------------------------------------- 51 // ------------------------------------------------------------------- 55 // 52 // 56 //....oooOO0OOooo........oooOO0OOooo........oo << 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 57 //....oooOO0OOooo........oooOO0OOooo........oo << 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 58 55 59 #include "G4MuBremsstrahlungModel.hh" 56 #include "G4MuBremsstrahlungModel.hh" 60 #include "G4PhysicalConstants.hh" << 61 #include "G4SystemOfUnits.hh" << 62 #include "G4Gamma.hh" 57 #include "G4Gamma.hh" 63 #include "G4MuonMinus.hh" 58 #include "G4MuonMinus.hh" 64 #include "G4MuonPlus.hh" 59 #include "G4MuonPlus.hh" 65 #include "Randomize.hh" 60 #include "Randomize.hh" 66 #include "G4Material.hh" 61 #include "G4Material.hh" 67 #include "G4Element.hh" 62 #include "G4Element.hh" 68 #include "G4ElementVector.hh" 63 #include "G4ElementVector.hh" 69 #include "G4ProductionCutsTable.hh" 64 #include "G4ProductionCutsTable.hh" 70 #include "G4ModifiedMephi.hh" << 71 #include "G4ParticleChangeForLoss.hh" << 72 #include "G4Log.hh" << 73 65 74 //....oooOO0OOooo........oooOO0OOooo........oo 66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 75 //....oooOO0OOooo........oooOO0OOooo........oo << 76 67 77 const G4double G4MuBremsstrahlungModel::xgi[] << 68 // static members 78 {0.03377,0.16940,0.38069,0.61931,0.83060,0.9 << 69 // 79 const G4double G4MuBremsstrahlungModel::wgi[] << 70 G4double G4MuBremsstrahlungModel::zdat[]={1.,4.,13.,29.,92.}; 80 {0.08566,0.18038,0.23396,0.23396,0.18038,0.0 << 71 G4double G4MuBremsstrahlungModel::adat[]={1.01,9.01,26.98,63.55,238.03}; 81 G4double G4MuBremsstrahlungModel::fDN[] = {0.0 << 72 G4double G4MuBremsstrahlungModel::tdat[]={1.e3,1.e4,1.e5,1.e6,1.e7,1.e8,1.e9,1.e10}; >> 73 >> 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 82 75 83 G4MuBremsstrahlungModel::G4MuBremsstrahlungMod << 76 G4MuBremsstrahlungModel::G4MuBremsstrahlungModel(const G4ParticleDefinition*, 84 77 const G4String& nam) 85 : G4VEmModel(nam), 78 : G4VEmModel(nam), 86 sqrte(std::sqrt(G4Exp(1.))), << 79 highKinEnergy(100.*TeV), 87 lowestKinEnergy(0.1*CLHEP::GeV), << 80 lowKinEnergy(1.0*keV), 88 minThreshold(0.9*CLHEP::keV) << 81 lowestKinEnergy(1.0*GeV), 89 { << 82 minThreshold(1.0*keV), 90 theGamma = G4Gamma::Gamma(); << 83 nzdat(5), 91 nist = G4NistManager::Instance(); << 84 ntdat(8), 92 << 85 NBIN(1000), 93 SetAngularDistribution(new G4ModifiedMephi() << 86 cutFixed(0.98*keV), 94 << 87 samplingTablesAreFilled(false) 95 if (nullptr != p) { SetParticle(p); } << 88 {} 96 if (0.0 == fDN[1]) { << 89 97 for (G4int i=1; i<93; ++i) { << 90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 98 G4double dn = 1.54*nist->GetA27(i); << 91 99 fDN[i] = dn; << 92 G4MuBremsstrahlungModel::~G4MuBremsstrahlungModel() 100 if(1 < i) { << 93 { 101 fDN[i] /= std::pow(dn, 1./G4double(i)); << 94 size_t n = partialSumSigma.size(); 102 } << 95 if(n > 0) { >> 96 for(size_t i=0; i<n; i++) { >> 97 delete partialSumSigma[i]; 103 } 98 } 104 } 99 } 105 } 100 } 106 101 107 //....oooOO0OOooo........oooOO0OOooo........oo << 102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 108 103 109 G4double G4MuBremsstrahlungModel::MinEnergyCut << 104 G4double G4MuBremsstrahlungModel::HighEnergyLimit(const G4ParticleDefinition*) 110 << 111 { 105 { 112 return minThreshold; << 106 return highKinEnergy; 113 } 107 } 114 108 115 //....oooOO0OOooo........oooOO0OOooo........oo << 109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 116 110 117 G4double G4MuBremsstrahlungModel::MinPrimaryEn << 111 G4double G4MuBremsstrahlungModel::LowEnergyLimit(const G4ParticleDefinition*) 118 << 119 << 120 { 112 { 121 return std::max(lowestKinEnergy, cut); << 113 return lowKinEnergy; 122 } 114 } 123 115 124 //....oooOO0OOooo........oooOO0OOooo........oo << 116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 125 117 126 void G4MuBremsstrahlungModel::SetParticle(cons << 118 G4double G4MuBremsstrahlungModel::MinEnergyCut(const G4ParticleDefinition*, >> 119 const G4MaterialCutsCouple*) 127 { 120 { 128 if(nullptr == particle) { << 121 return minThreshold; 129 particle = p; << 130 mass = particle->GetPDGMass(); << 131 rmass = mass/CLHEP::electron_mass_c2 ; << 132 cc = CLHEP::classic_electr_radius/rmass ; << 133 coeff = 16.*CLHEP::fine_structure_const*cc << 134 } << 135 } 122 } 136 123 137 //....oooOO0OOooo........oooOO0OOooo........oo << 124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 138 125 139 void G4MuBremsstrahlungModel::Initialise(const << 126 G4bool G4MuBremsstrahlungModel::IsInCharge(const G4ParticleDefinition* p) 140 const << 141 { 127 { 142 SetParticle(p); << 128 return (p == G4MuonMinus::MuonMinus() || p == G4MuonPlus::MuonPlus()); 143 if(nullptr == fParticleChange) { << 144 fParticleChange = GetParticleChangeForLoss << 145 } << 146 if(IsMaster() && p == particle && lowestKinE << 147 InitialiseElementSelectors(p, cuts); << 148 } << 149 } 129 } 150 130 151 //....oooOO0OOooo........oooOO0OOooo........oo 131 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 152 132 153 void G4MuBremsstrahlungModel::InitialiseLocal( << 133 void G4MuBremsstrahlungModel::Initialise(const G4ParticleDefinition*, 154 << 134 const G4DataVector& cuts) 155 { 135 { 156 if(p == particle && lowestKinEnergy < HighEn << 136 const G4ProductionCutsTable* theCoupleTable= 157 SetElementSelectors(masterModel->GetElemen << 137 G4ProductionCutsTable::GetProductionCutsTable(); >> 138 size_t numOfCouples = theCoupleTable->GetTableSize(); >> 139 G4double fixedEnergy = 0.5*highKinEnergy; >> 140 // G4double fixedEnergy = 500000.*TeV; >> 141 >> 142 for (size_t ii=0; ii<partialSumSigma.size(); ii++){ >> 143 G4DataVector* a=partialSumSigma[ii]; >> 144 if ( a ) delete a; >> 145 } >> 146 partialSumSigma.clear(); >> 147 for (size_t i=0; i<numOfCouples; i++) { >> 148 const G4MaterialCutsCouple* couple = theCoupleTable->GetMaterialCutsCouple(i); >> 149 const G4Material* material = couple->GetMaterial(); >> 150 G4DataVector* dv = ComputePartialSumSigma(material, fixedEnergy,cuts[i]); >> 151 partialSumSigma.push_back(dv); 158 } 152 } >> 153 if(!samplingTablesAreFilled) MakeSamplingTables(); >> 154 159 } 155 } 160 156 161 //....oooOO0OOooo........oooOO0OOooo........oo << 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 162 158 163 G4double G4MuBremsstrahlungModel::ComputeDEDXP << 159 G4double G4MuBremsstrahlungModel::ComputeDEDX(const G4MaterialCutsCouple* couple, 164 << 165 160 const G4ParticleDefinition*, 166 161 G4double kineticEnergy, 167 162 G4double cutEnergy) 168 { 163 { 169 G4double dedx = 0.0; 164 G4double dedx = 0.0; 170 if (kineticEnergy <= lowestKinEnergy) { retu << 165 if (kineticEnergy <= lowestKinEnergy) return dedx; 171 166 172 G4double cut = std::max(cutEnergy, minThresh << 167 G4double tmax = kineticEnergy; 173 cut = std::min(cut, kineticEnergy); << 168 G4double cut = std::min(cutEnergy,tmax); 174 169 >> 170 const G4Material* material = couple->GetMaterial(); 175 const G4ElementVector* theElementVector = ma 171 const G4ElementVector* theElementVector = material->GetElementVector(); 176 const G4double* theAtomicNumDensityVector = << 172 const G4double* theAtomicNumDensityVector = material->GetAtomicNumDensityVector(); 177 material->GetAtomicNumDensityVector(); << 178 173 179 // loop for elements in the material 174 // loop for elements in the material 180 for (size_t i=0; i<material->GetNumberOfElem << 175 for (size_t i=0; i<material->GetNumberOfElements(); i++) { 181 G4double loss = << 176 182 ComputMuBremLoss((*theElementVector)[i]- << 177 G4double Z = (*theElementVector)[i]->GetZ(); >> 178 G4double A = (*theElementVector)[i]->GetA()/(g/mole) ; >> 179 >> 180 G4double loss = ComputMuBremLoss(Z, A, kineticEnergy, cut); >> 181 183 dedx += loss*theAtomicNumDensityVector[i]; 182 dedx += loss*theAtomicNumDensityVector[i]; 184 } 183 } 185 // G4cout << "BR e= " << kineticEnergy << " << 184 if(dedx < 0.) dedx = 0.; 186 dedx = std::max(dedx, 0.); << 187 return dedx; 185 return dedx; 188 } 186 } 189 187 190 //....oooOO0OOooo........oooOO0OOooo........oo << 188 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 191 189 192 G4double G4MuBremsstrahlungModel::ComputMuBrem << 190 G4double G4MuBremsstrahlungModel::ComputMuBremLoss(G4double Z, G4double A, 193 191 G4double tkin, G4double cut) 194 { 192 { 195 G4double totalEnergy = mass + tkin; << 193 G4double totalEnergy = (G4MuonPlus::MuonPlus())->GetPDGMass() + tkin; 196 static const G4double ak1 = 0.05; << 194 G4double ak1 = 0.05; 197 static const G4int k2 = 5; << 195 G4int k2=5; >> 196 G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623}; >> 197 G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566}; 198 G4double loss = 0.; 198 G4double loss = 0.; 199 199 200 G4double vcut = cut/totalEnergy; 200 G4double vcut = cut/totalEnergy; 201 G4int kkk = (G4int)(vcut/ak1) + k2; << 201 G4double vmax = tkin/totalEnergy; 202 if (kkk > 8) { kkk = 8; } << 202 203 else if (kkk < 1) { kkk = 1; } << 203 G4double aaa = 0.; 204 G4double hhh = vcut/(G4double)(kkk); << 204 G4double bbb = vcut; 205 << 205 if(vcut>vmax) bbb=vmax ; 206 G4double aa = 0.; << 206 G4int kkk = (G4int)((bbb-aaa)/ak1)+k2 ; 207 for(G4int l=0; l<kkk; ++l) { << 207 G4double hhh=(bbb-aaa)/float(kkk) ; 208 for(G4int i=0; i<6; ++i) { << 208 >> 209 G4double aa = aaa; >> 210 for(G4int l=0; l<kkk; l++) >> 211 { >> 212 for(G4int i=0; i<6; i++) >> 213 { 209 G4double ep = (aa + xgi[i]*hhh)*totalEne 214 G4double ep = (aa + xgi[i]*hhh)*totalEnergy; 210 loss += ep*wgi[i]*ComputeDMicroscopicCro << 215 loss += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, A, ep); 211 } 216 } 212 aa += hhh; 217 aa += hhh; 213 } 218 } 214 219 215 loss *= hhh*totalEnergy; << 220 loss *=hhh*totalEnergy ; >> 221 216 return loss; 222 return loss; 217 } 223 } 218 224 219 //....oooOO0OOooo........oooOO0OOooo........oo << 225 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 220 226 221 G4double G4MuBremsstrahlungModel::ComputeMicro 227 G4double G4MuBremsstrahlungModel::ComputeMicroscopicCrossSection( 222 G4d 228 G4double tkin, 223 G4d 229 G4double Z, >> 230 G4double A, 224 G4d 231 G4double cut) 225 { 232 { 226 G4double totalEnergy = tkin + mass; << 233 G4double totalEnergy = (G4MuonPlus::MuonPlus())->GetPDGMass() + tkin; 227 static const G4double ak1 = 2.3; << 234 G4double ak1 = 2.3; 228 static const G4int k2 = 4; << 235 G4int k2 = 4; >> 236 G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623}; >> 237 G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566}; 229 G4double cross = 0.; 238 G4double cross = 0.; 230 239 231 if(cut >= tkin) return cross; 240 if(cut >= tkin) return cross; 232 241 233 G4double vcut = cut/totalEnergy; 242 G4double vcut = cut/totalEnergy; 234 G4double vmax = tkin/totalEnergy; 243 G4double vmax = tkin/totalEnergy; 235 244 236 G4double aaa = G4Log(vcut); << 245 G4double aaa = log(vcut); 237 G4double bbb = G4Log(vmax); << 246 G4double bbb = log(vmax); 238 G4int kkk = (G4int)((bbb-aaa)/ak1) + k2 ; << 247 G4int kkk = (G4int)((bbb-aaa)/ak1)+k2 ; 239 if(kkk > 8) { kkk = 8; } << 248 G4double hhh = (bbb-aaa)/float(kkk); 240 else if (kkk < 1) { kkk = 1; } << 249 241 G4double hhh = (bbb-aaa)/(G4double)(kkk); << 242 G4double aa = aaa; 250 G4double aa = aaa; 243 251 244 for(G4int l=0; l<kkk; ++l) { << 252 for(G4int l=0; l<kkk; l++) 245 for(G4int i=0; i<6; ++i) { << 253 { 246 G4double ep = G4Exp(aa + xgi[i]*hhh)*tot << 254 for(G4int i=0; i<6; i++) 247 cross += ep*wgi[i]*ComputeDMicroscopicCr << 255 { >> 256 G4double ep = exp(aa + xgi[i]*hhh)*totalEnergy; >> 257 cross += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, A, ep); 248 } 258 } 249 aa += hhh; 259 aa += hhh; 250 } 260 } 251 261 252 cross *= hhh; << 262 cross *=hhh; 253 //G4cout << "BR e= " << tkin<< " cross= " < << 263 254 return cross; 264 return cross; 255 } 265 } 256 266 257 //....oooOO0OOooo........oooOO0OOooo........oo 267 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 258 268 259 G4double G4MuBremsstrahlungModel::ComputeDMicr 269 G4double G4MuBremsstrahlungModel::ComputeDMicroscopicCrossSection( 260 G4d 270 G4double tkin, 261 G4d 271 G4double Z, >> 272 G4double A, 262 G4d 273 G4double gammaEnergy) 263 // differential cross section 274 // differential cross section 264 { 275 { >> 276 G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass(); >> 277 >> 278 static const G4double sqrte=sqrt(exp(1.)) ; >> 279 static const G4double bh=202.4,bh1=446.,btf=183.,btf1=1429. ; >> 280 static const G4double rmass=particleMass/electron_mass_c2 ; >> 281 static const G4double cc=classic_electr_radius/rmass ; >> 282 static const G4double coeff= 16.*fine_structure_const*cc*cc/3. ; >> 283 265 G4double dxsection = 0.; 284 G4double dxsection = 0.; 266 if(gammaEnergy > tkin) { return dxsection; } << 267 285 268 G4double E = tkin + mass ; << 286 if( gammaEnergy > tkin) return dxsection ; >> 287 >> 288 G4double E = tkin + particleMass ; 269 G4double v = gammaEnergy/E ; 289 G4double v = gammaEnergy/E ; 270 G4double delta = 0.5*mass*mass*v/(E-gammaEne << 290 G4double delta = 0.5*particleMass*particleMass*v/(E-gammaEnergy) ; 271 G4double rab0 = delta*sqrte ; << 291 G4double rab0=delta*sqrte ; >> 292 >> 293 G4double z13 = exp(-log(Z)/3.) ; >> 294 G4double dn = 1.54*exp(0.27*log(A)) ; 272 295 273 G4int iz = G4lrint(Z); << 296 G4double b,b1,dnstar ; 274 if(iz < 1) { iz = 1; } << 297 275 else if(iz > 92) { iz = 92; } << 298 if(Z<1.5) 276 << 299 { 277 G4double z13 = 1.0/nist->GetZ13(iz); << 300 b=bh; 278 G4double dnstar = fDN[iz]; << 301 b1=bh1; 279 << 302 dnstar=dn ; 280 G4double b,b1; << 303 } 281 if(1 == iz) { << 304 else 282 b = bh; << 305 { 283 b1 = bh1; << 306 b=btf; 284 } else { << 307 b1=btf1; 285 b = btf; << 308 dnstar = exp((1.-1./Z)*log(dn)) ; 286 b1 = btf1; << 287 } 309 } 288 310 289 // nucleus contribution logarithm 311 // nucleus contribution logarithm 290 G4double rab1 = b*z13; << 312 G4double rab1=b*z13; 291 G4double fn = G4Log(rab1/(dnstar*(CLHEP::ele << 313 G4double fn=log(rab1/(dnstar*(electron_mass_c2+rab0*rab1))* 292 (mass + delta*(dnstar*sqrte-2.))); << 314 (particleMass+delta*(dnstar*sqrte-2.))) ; 293 fn = std::max(fn, 0.); << 315 if(fn <0.) fn = 0. ; 294 // electron contribution logarithm 316 // electron contribution logarithm 295 G4double epmax1 = E/(1.+0.5*mass*rmass/E); << 317 G4double epmax1=E/(1.+0.5*particleMass*rmass/E) ; 296 G4double fe = 0.; << 318 G4double fe=0.; 297 if(gammaEnergy < epmax1) { << 319 if(gammaEnergy<epmax1) 298 G4double rab2 = b1*z13*z13; << 320 { 299 fe = G4Log(rab2*mass/((1.+delta*rmass/(CLH << 321 G4double rab2=b1*z13*z13 ; 300 (CLHEP::electron_mass_c2+rab0*rab2))); << 322 fe=log(rab2*particleMass/((1.+delta*rmass/(electron_mass_c2*sqrte))* 301 fe = std::max(fe, 0.); << 323 (electron_mass_c2+rab0*rab2))) ; >> 324 if(fe<0.) fe=0. ; 302 } 325 } 303 326 304 dxsection = coeff*(1.-v*(1. - 0.75*v))*Z*(fn 327 dxsection = coeff*(1.-v*(1. - 0.75*v))*Z*(fn*Z + fe)/gammaEnergy; 305 dxsection = std::max(dxsection, 0.0); << 328 306 return dxsection; 329 return dxsection; 307 } 330 } 308 331 309 //....oooOO0OOooo........oooOO0OOooo........oo << 332 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 310 333 311 G4double G4MuBremsstrahlungModel::ComputeCross << 334 G4double G4MuBremsstrahlungModel::CrossSection(const G4MaterialCutsCouple* couple, 312 con << 335 const G4ParticleDefinition*, 313 << 336 G4double kineticEnergy, 314 << 337 G4double cutEnergy, 315 << 338 G4double maxEnergy) 316 << 317 { 339 { 318 G4double cross = 0.0; 340 G4double cross = 0.0; 319 if (kineticEnergy <= lowestKinEnergy) return << 341 if (cutEnergy >= maxEnergy || kineticEnergy <= lowestKinEnergy) return cross; >> 342 320 G4double tmax = std::min(maxEnergy, kineticE 343 G4double tmax = std::min(maxEnergy, kineticEnergy); 321 G4double cut = std::min(cutEnergy, kineticE << 344 G4double cut = std::min(cutEnergy, tmax); 322 if (cut < minThreshold) cut = minThreshold; << 345 323 if (cut >= tmax) return cross; << 346 const G4Material* material = couple->GetMaterial(); 324 << 347 const G4ElementVector* theElementVector = material->GetElementVector() ; 325 cross = ComputeMicroscopicCrossSection (kine << 348 const G4double* theAtomNumDensityVector = material->GetAtomicNumDensityVector(); 326 if(tmax < kineticEnergy) { << 349 327 cross -= ComputeMicroscopicCrossSection(ki << 350 for (size_t i=0; i<material->GetNumberOfElements(); i++) { >> 351 >> 352 G4double Z = (*theElementVector)[i]->GetZ(); >> 353 G4double A = (*theElementVector)[i]->GetA()/(g/mole) ; >> 354 >> 355 G4double cr = ComputeMicroscopicCrossSection(kineticEnergy, Z, A, cut); >> 356 >> 357 if(tmax < kineticEnergy) { >> 358 cr -= ComputeMicroscopicCrossSection(kineticEnergy, Z, A, tmax); >> 359 } >> 360 cross += theAtomNumDensityVector[i] * cr; 328 } 361 } >> 362 329 return cross; 363 return cross; 330 } 364 } 331 365 332 //....oooOO0OOooo........oooOO0OOooo........oo << 366 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 367 >> 368 G4DataVector* G4MuBremsstrahlungModel::ComputePartialSumSigma( >> 369 const G4Material* material, >> 370 G4double kineticEnergy, >> 371 G4double cut) >> 372 >> 373 // Build the table of cross section per element. The table is built for MATERIALS. >> 374 // This table is used by DoIt to select randomly an element in the material. >> 375 { >> 376 G4int nElements = material->GetNumberOfElements(); >> 377 const G4ElementVector* theElementVector = material->GetElementVector(); >> 378 const G4double* theAtomNumDensityVector = material->GetAtomicNumDensityVector(); >> 379 >> 380 G4DataVector* dv = new G4DataVector(); >> 381 >> 382 G4double cross = 0.0; >> 383 >> 384 for (G4int i=0; i<nElements; i++ ) { >> 385 >> 386 G4double Z = (*theElementVector)[i]->GetZ(); >> 387 G4double A = (*theElementVector)[i]->GetA()/(g/mole) ; >> 388 cross += theAtomNumDensityVector[i] * ComputeMicroscopicCrossSection(kineticEnergy, >> 389 Z, A, cut); >> 390 dv->push_back(cross); >> 391 } >> 392 return dv; >> 393 } >> 394 >> 395 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 396 >> 397 void G4MuBremsstrahlungModel::MakeSamplingTables() >> 398 { >> 399 >> 400 G4double AtomicNumber,AtomicWeight,KineticEnergy, >> 401 TotalEnergy,Maxep ; >> 402 G4double particleMass = (G4MuonPlus::MuonPlus())->GetPDGMass(); >> 403 >> 404 for (G4int iz=0; iz<nzdat; iz++) >> 405 { >> 406 AtomicNumber = zdat[iz]; >> 407 AtomicWeight = adat[iz]*g/mole ; >> 408 >> 409 for (G4int it=0; it<ntdat; it++) >> 410 { >> 411 KineticEnergy = tdat[it]; >> 412 TotalEnergy = KineticEnergy + particleMass; >> 413 Maxep = KineticEnergy ; >> 414 >> 415 G4double CrossSection = 0.0 ; >> 416 >> 417 // calculate the differential cross section >> 418 // numerical integration in >> 419 // log ............... >> 420 G4double c = log(Maxep/cutFixed) ; >> 421 G4double ymin = -5. ; >> 422 G4double ymax = 0. ; >> 423 G4double dy = (ymax-ymin)/NBIN ; >> 424 >> 425 G4double y = ymin - 0.5*dy ; >> 426 G4double yy = ymin - dy ; >> 427 G4double x = exp(y); >> 428 G4double fac = exp(dy); >> 429 G4double dx = exp(yy)*(fac - 1.0); >> 430 >> 431 for (G4int i=0 ; i<NBIN; i++) >> 432 { >> 433 y += dy ; >> 434 x *= fac; >> 435 dx*= fac; >> 436 G4double ep = cutFixed*exp(c*x) ; >> 437 >> 438 CrossSection += ep*dx*ComputeDMicroscopicCrossSection( >> 439 KineticEnergy,AtomicNumber, >> 440 AtomicWeight,ep) ; >> 441 ya[i]=y ; >> 442 proba[iz][it][i] = CrossSection ; >> 443 >> 444 } >> 445 >> 446 proba[iz][it][NBIN] = CrossSection ; >> 447 ya[NBIN] = 0. ; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! >> 448 >> 449 if(CrossSection > 0.) >> 450 { >> 451 for(G4int ib=0; ib<=NBIN; ib++) >> 452 { >> 453 proba[iz][it][ib] /= CrossSection ; >> 454 } >> 455 } >> 456 } >> 457 } >> 458 samplingTablesAreFilled = true; >> 459 } >> 460 >> 461 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 333 462 334 void G4MuBremsstrahlungModel::SampleSecondarie << 463 G4DynamicParticle* G4MuBremsstrahlungModel::SampleSecondary( 335 std::vector<G4Dy << 464 const G4MaterialCutsCouple* couple, 336 const G4Material << 465 const G4DynamicParticle* dp, 337 const G4DynamicP << 466 G4double minEnergy, 338 G4double minEner << 467 G4double maxEnergy) 339 G4double maxEner << 340 { 468 { 341 G4double kineticEnergy = dp->GetKineticEnerg << 469 G4double kineticEnergy = dp->GetKineticEnergy(); 342 // check against insufficient energy 470 // check against insufficient energy 343 G4double tmax = std::min(kineticEnergy, maxE 471 G4double tmax = std::min(kineticEnergy, maxEnergy); 344 G4double tmin = std::min(kineticEnergy, minE << 472 G4double tmin = std::min(tmax, minEnergy); 345 tmin = std::max(tmin, minThreshold); << 346 if(tmin >= tmax) return; << 347 473 348 // ===== sampling of energy transfer ====== << 474 static G4double ysmall = -100. ; >> 475 static G4double ytablelow = -5. ; 349 476 350 G4ParticleMomentum partDirection = dp->GetMo << 477 G4ParticleMomentum ParticleDirection = dp->GetMomentumDirection(); 351 478 352 // select randomly one element constituing t 479 // select randomly one element constituing the material 353 const G4Element* anElement = SelectRandomAto << 480 const G4Element* anElement = SelectRandomAtom(couple); 354 G4double Z = anElement->GetZ(); << 355 G4double func1 = tmin* << 356 ComputeDMicroscopicCrossSection(kineticEne << 357 481 358 G4double gEnergy; << 482 G4double totalEnergy = kineticEnergy + dp->GetMass(); 359 G4double func2; << 360 483 361 G4double xmin = G4Log(tmin/minThreshold); << 484 G4double dy = 5./G4float(NBIN); 362 G4double xmax = G4Log(tmax/tmin); << 485 >> 486 // This sampling should be checked!!! VI >> 487 G4double ymin=log(log(tmin/cutFixed)/log(tmax/cutFixed)); >> 488 >> 489 if(ymin < ysmall) return 0; >> 490 >> 491 // sampling using tables >> 492 >> 493 G4double v,x,y ; >> 494 G4int iy; >> 495 // select sampling table ; >> 496 G4double lnZ = log(anElement->GetZ()) ; >> 497 G4double delmin = 1.e10 ; >> 498 G4double del ; >> 499 G4int izz = 0; >> 500 G4int itt = 0; >> 501 G4int NBINminus1; >> 502 NBINminus1 = NBIN-1 ; >> 503 for (G4int iz=0; iz<nzdat; iz++) >> 504 { >> 505 del = abs(lnZ-log(zdat[iz])) ; >> 506 if(del<delmin) >> 507 { >> 508 delmin=del ; >> 509 izz=iz ; >> 510 } >> 511 } >> 512 >> 513 delmin = 1.e10 ; >> 514 for (G4int it=0; it<ntdat; it++) >> 515 { >> 516 del = abs(log(tmax)-log(tdat[it])) ; >> 517 if(del<delmin) >> 518 { >> 519 delmin=del; >> 520 itt=it ; >> 521 } >> 522 } >> 523 G4int iymin = G4int((ymin+5.)/dy+0.5) ; 363 524 364 do { 525 do { 365 gEnergy = minThreshold*G4Exp(xmin + G4Unif << 526 if(ymin < ytablelow) 366 func2 = gEnergy*ComputeDMicroscopicCrossSe << 527 { >> 528 y = ymin + G4UniformRand()*(ytablelow-ymin) ; >> 529 } >> 530 else >> 531 { >> 532 G4double r = G4UniformRand() ; >> 533 >> 534 iy = iymin-1 ; >> 535 delmin = proba[izz][itt][NBINminus1]-proba[izz][itt][iymin] ; >> 536 do { >> 537 iy += 1 ; >> 538 } while ((r > (proba[izz][itt][iy]-proba[izz][itt][iymin])/delmin) >> 539 &&(iy < NBINminus1)) ; >> 540 >> 541 //sampling is Done uniformly in y in the bin >> 542 y = ya[iy] + G4UniformRand() * ( ya[iy+1] - ya[iy] ) ; >> 543 } >> 544 >> 545 x = exp(y) ; >> 546 >> 547 v = cutFixed*exp(x*log(tmax/cutFixed)) ; 367 548 368 // Loop checking, 03-Aug-2015, Vladimir Iv << 549 } while ( v <= 0.); 369 } while(func2 < func1*G4UniformRand()); << 370 550 371 // angles of the emitted gamma using general << 372 G4ThreeVector gamDir = << 373 GetAngularDistribution()->SampleDirection( << 374 << 375 // create G4DynamicParticle object for the G 551 // create G4DynamicParticle object for the Gamma 376 G4DynamicParticle* gamma = new G4DynamicPart << 552 G4double GammaEnergy = v; 377 vdp->push_back(gamma); << 553 >> 554 // angles of the emitted gamma. ( Z - axis along the parent particle) >> 555 // Teta = electron_mass_c2/TotalEnergy for the moment ..... >> 556 >> 557 G4double Teta = electron_mass_c2/totalEnergy ; >> 558 G4double Phi = twopi * G4UniformRand() ; >> 559 G4double dirx = sin(Teta)*cos(Phi) , diry = sin(Teta)*sin(Phi) , >> 560 dirz = cos(Teta) ; >> 561 >> 562 G4ThreeVector GammaDirection ( dirx, diry, dirz); >> 563 GammaDirection.rotateUz(ParticleDirection); >> 564 >> 565 G4DynamicParticle* aGamma = new G4DynamicParticle(); >> 566 aGamma->SetDefinition(G4Gamma::Gamma()); >> 567 aGamma->SetKineticEnergy(GammaEnergy); >> 568 aGamma->SetMomentumDirection(GammaDirection); >> 569 >> 570 return aGamma; >> 571 } >> 572 >> 573 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 574 >> 575 std::vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondaries( >> 576 const G4MaterialCutsCouple* couple, >> 577 const G4DynamicParticle* dp, >> 578 G4double tmin, >> 579 G4double maxEnergy) >> 580 { >> 581 std::vector<G4DynamicParticle*>* vdp = new std::vector<G4DynamicParticle*>; >> 582 G4DynamicParticle* aGamma = SampleSecondary(couple,dp,tmin,maxEnergy); >> 583 vdp->push_back(aGamma); >> 584 >> 585 return vdp; >> 586 } >> 587 >> 588 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 589 >> 590 const G4Element* G4MuBremsstrahlungModel::SelectRandomAtom( >> 591 const G4MaterialCutsCouple* couple) const >> 592 { >> 593 // select randomly 1 element within the material >> 594 >> 595 const G4Material* material = couple->GetMaterial(); >> 596 G4int nElements = material->GetNumberOfElements(); >> 597 const G4ElementVector* theElementVector = material->GetElementVector(); >> 598 if(1 == nElements) return (*theElementVector)[0]; >> 599 else if(1 > nElements) return 0; 378 600 379 // compute post-interaction kinematics of pr << 601 G4DataVector* dv = partialSumSigma[couple->GetIndex()]; 380 // energy-momentum conservation << 602 G4double rval = G4UniformRand()*((*dv)[nElements-1]); 381 const G4double totMomentum = << 603 for (G4int i=0; i<nElements; i++) { 382 std::sqrt(kineticEnergy*(kineticEnergy + 2 << 604 if (rval <= (*dv)[i]) return (*theElementVector)[i]; 383 G4ThreeVector dir = << 384 (totMomentum*dp->GetMomentumDirection() - << 385 const G4double finalE = kineticEnergy - gEne << 386 << 387 // if secondary gamma energy is higher than << 388 // then stop tracking the primary particle a << 389 // instead of the primary one << 390 if (gEnergy > SecondaryThreshold()) { << 391 fParticleChange->ProposeTrackStatus(fStopA << 392 fParticleChange->SetProposedKineticEnergy( << 393 G4DynamicParticle* newdp = new G4DynamicPa << 394 vdp->push_back(newdp); << 395 } else { << 396 // continue tracking the primary e-/e+ oth << 397 fParticleChange->SetProposedMomentumDirect << 398 fParticleChange->SetProposedKineticEnergy( << 399 } 605 } >> 606 return (*theElementVector)[nElements-1]; 400 } 607 } 401 608 402 //....oooOO0OOooo........oooOO0OOooo........oo 609 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 403 610