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: G4MuBremsstrahlungModel.cc,v 1.36 2010-10-26 13:52:32 vnivanch Exp $ >> 27 // GEANT4 tag $Name: geant4-09-04-patch-02 $ 26 // 28 // 27 // ------------------------------------------- 29 // ------------------------------------------------------------------- 28 // 30 // 29 // GEANT4 Class file 31 // GEANT4 Class file 30 // 32 // 31 // 33 // 32 // File name: G4MuBremsstrahlungModel 34 // File name: G4MuBremsstrahlungModel 33 // 35 // 34 // Author: Vladimir Ivanchenko on base 36 // Author: Vladimir Ivanchenko on base of Laszlo Urban code 35 // 37 // 36 // Creation date: 24.06.2002 38 // Creation date: 24.06.2002 37 // 39 // 38 // Modifications: 40 // Modifications: 39 // 41 // 40 // 04-12-02 Change G4DynamicParticle construct 42 // 04-12-02 Change G4DynamicParticle constructor in PostStepDoIt (V.Ivanchenko) 41 // 23-12-02 Change interface in order to move 43 // 23-12-02 Change interface in order to move to cut per region (V.Ivanchenko) 42 // 24-01-03 Fix for compounds (V.Ivanchenko) 44 // 24-01-03 Fix for compounds (V.Ivanchenko) 43 // 27-01-03 Make models region aware (V.Ivanch 45 // 27-01-03 Make models region aware (V.Ivanchenko) 44 // 13-02-03 Add name (V.Ivanchenko) 46 // 13-02-03 Add name (V.Ivanchenko) 45 // 10-02-04 Add lowestKinEnergy (V.Ivanchenko) 47 // 10-02-04 Add lowestKinEnergy (V.Ivanchenko) 46 // 08-04-05 Major optimisation of internal int 48 // 08-04-05 Major optimisation of internal interfaces (V.Ivanchenko) 47 // 03-08-05 Angular correlations according to 49 // 03-08-05 Angular correlations according to PRM (V.Ivanchenko) 48 // 13-02-06 add ComputeCrossSectionPerAtom (mm 50 // 13-02-06 add ComputeCrossSectionPerAtom (mma) 49 // 21-03-06 Fix problem of initialisation in c 51 // 21-03-06 Fix problem of initialisation in case when cuts are not defined (VI) 50 // 07-11-07 Improve sampling of final state (A 52 // 07-11-07 Improve sampling of final state (A.Bogdanov) 51 // 28-02-08 Use precomputed Z^1/3 and Log(A) ( 53 // 28-02-08 Use precomputed Z^1/3 and Log(A) (V.Ivanchenko) 52 // 31-05-13 Use element selectors instead of l << 54 // >> 55 >> 56 // >> 57 // Class Description: >> 58 // 53 // 59 // 54 // ------------------------------------------- 60 // ------------------------------------------------------------------- 55 // 61 // 56 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 64 59 #include "G4MuBremsstrahlungModel.hh" 65 #include "G4MuBremsstrahlungModel.hh" 60 #include "G4PhysicalConstants.hh" << 61 #include "G4SystemOfUnits.hh" << 62 #include "G4Gamma.hh" 66 #include "G4Gamma.hh" 63 #include "G4MuonMinus.hh" 67 #include "G4MuonMinus.hh" 64 #include "G4MuonPlus.hh" 68 #include "G4MuonPlus.hh" 65 #include "Randomize.hh" 69 #include "Randomize.hh" 66 #include "G4Material.hh" 70 #include "G4Material.hh" 67 #include "G4Element.hh" 71 #include "G4Element.hh" 68 #include "G4ElementVector.hh" 72 #include "G4ElementVector.hh" 69 #include "G4ProductionCutsTable.hh" 73 #include "G4ProductionCutsTable.hh" 70 #include "G4ModifiedMephi.hh" << 71 #include "G4ParticleChangeForLoss.hh" 74 #include "G4ParticleChangeForLoss.hh" 72 #include "G4Log.hh" << 73 75 74 //....oooOO0OOooo........oooOO0OOooo........oo 76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 75 //....oooOO0OOooo........oooOO0OOooo........oo 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 76 78 77 const G4double G4MuBremsstrahlungModel::xgi[] << 79 using namespace std; 78 {0.03377,0.16940,0.38069,0.61931,0.83060,0.9 << 79 const G4double G4MuBremsstrahlungModel::wgi[] << 80 {0.08566,0.18038,0.23396,0.23396,0.18038,0.0 << 81 G4double G4MuBremsstrahlungModel::fDN[] = {0.0 << 82 80 83 G4MuBremsstrahlungModel::G4MuBremsstrahlungMod 81 G4MuBremsstrahlungModel::G4MuBremsstrahlungModel(const G4ParticleDefinition* p, 84 82 const G4String& nam) 85 : G4VEmModel(nam), 83 : G4VEmModel(nam), 86 sqrte(std::sqrt(G4Exp(1.))), << 84 particle(0), 87 lowestKinEnergy(0.1*CLHEP::GeV), << 85 sqrte(sqrt(exp(1.))), 88 minThreshold(0.9*CLHEP::keV) << 86 bh(202.4), >> 87 bh1(446.), >> 88 btf(183.), >> 89 btf1(1429.), >> 90 fParticleChange(0), >> 91 lowestKinEnergy(1.0*GeV), >> 92 minThreshold(1.0*keV) 89 { 93 { 90 theGamma = G4Gamma::Gamma(); 94 theGamma = G4Gamma::Gamma(); 91 nist = G4NistManager::Instance(); << 95 nist = G4NistManager::Instance(); 92 96 93 SetAngularDistribution(new G4ModifiedMephi() << 97 mass = rmass = cc = coeff = 1.0; 94 98 95 if (nullptr != p) { SetParticle(p); } << 99 if(p) { SetParticle(p); } 96 if (0.0 == fDN[1]) { << 97 for (G4int i=1; i<93; ++i) { << 98 G4double dn = 1.54*nist->GetA27(i); << 99 fDN[i] = dn; << 100 if(1 < i) { << 101 fDN[i] /= std::pow(dn, 1./G4double(i)); << 102 } << 103 } << 104 } << 105 } 100 } 106 101 107 //....oooOO0OOooo........oooOO0OOooo........oo 102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 108 103 109 G4double G4MuBremsstrahlungModel::MinEnergyCut << 104 G4MuBremsstrahlungModel::~G4MuBremsstrahlungModel() 110 << 111 { 105 { 112 return minThreshold; << 106 size_t n = partialSumSigma.size(); 113 } << 107 if(n > 0) { 114 << 108 for(size_t i=0; i<n; i++) { 115 //....oooOO0OOooo........oooOO0OOooo........oo << 109 delete partialSumSigma[i]; 116 << 110 } 117 G4double G4MuBremsstrahlungModel::MinPrimaryEn << 111 } 118 << 119 << 120 { << 121 return std::max(lowestKinEnergy, cut); << 122 } 112 } 123 113 124 //....oooOO0OOooo........oooOO0OOooo........oo 114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 125 115 126 void G4MuBremsstrahlungModel::SetParticle(cons << 116 G4double G4MuBremsstrahlungModel::MinEnergyCut(const G4ParticleDefinition*, >> 117 const G4MaterialCutsCouple*) 127 { 118 { 128 if(nullptr == particle) { << 119 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 } 120 } 136 121 137 //....oooOO0OOooo........oooOO0OOooo........oo 122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 138 123 139 void G4MuBremsstrahlungModel::Initialise(const 124 void G4MuBremsstrahlungModel::Initialise(const G4ParticleDefinition* p, 140 const 125 const G4DataVector& cuts) 141 { 126 { 142 SetParticle(p); << 127 if(p) { SetParticle(p); } 143 if(nullptr == fParticleChange) { << 144 fParticleChange = GetParticleChangeForLoss << 145 } << 146 if(IsMaster() && p == particle && lowestKinE << 147 InitialiseElementSelectors(p, cuts); << 148 } << 149 } << 150 128 151 //....oooOO0OOooo........oooOO0OOooo........oo << 129 // partial cross section is computed for fixed energy >> 130 G4double fixedEnergy = 0.5*HighEnergyLimit(); 152 131 153 void G4MuBremsstrahlungModel::InitialiseLocal( << 132 const G4ProductionCutsTable* theCoupleTable= 154 << 133 G4ProductionCutsTable::GetProductionCutsTable(); 155 { << 134 if(theCoupleTable) { 156 if(p == particle && lowestKinEnergy < HighEn << 135 G4int numOfCouples = theCoupleTable->GetTableSize(); 157 SetElementSelectors(masterModel->GetElemen << 136 >> 137 // clear old data >> 138 G4int nn = partialSumSigma.size(); >> 139 G4int nc = cuts.size(); >> 140 if(nn > 0) { >> 141 for (G4int ii=0; ii<nn; ii++){ >> 142 G4DataVector* a = partialSumSigma[ii]; >> 143 if ( a ) { delete a; } >> 144 } >> 145 partialSumSigma.clear(); >> 146 } >> 147 // fill new data >> 148 if (numOfCouples>0) { >> 149 for (G4int i=0; i<numOfCouples; i++) { >> 150 G4double cute = DBL_MAX; >> 151 >> 152 // protection for usage with extrapolator >> 153 if(i < nc) { cute = cuts[i]; } >> 154 >> 155 const G4MaterialCutsCouple* couple = >> 156 theCoupleTable->GetMaterialCutsCouple(i); >> 157 const G4Material* material = couple->GetMaterial(); >> 158 G4DataVector* dv = ComputePartialSumSigma(material,fixedEnergy,cute); >> 159 partialSumSigma.push_back(dv); >> 160 } >> 161 } 158 } 162 } >> 163 >> 164 // define pointer to G4ParticleChange >> 165 if(!fParticleChange) { fParticleChange = GetParticleChangeForLoss(); } 159 } 166 } 160 167 161 //....oooOO0OOooo........oooOO0OOooo........oo 168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 162 169 163 G4double G4MuBremsstrahlungModel::ComputeDEDXP 170 G4double G4MuBremsstrahlungModel::ComputeDEDXPerVolume( 164 << 171 const G4Material* material, 165 172 const G4ParticleDefinition*, 166 173 G4double kineticEnergy, 167 174 G4double cutEnergy) 168 { 175 { 169 G4double dedx = 0.0; 176 G4double dedx = 0.0; 170 if (kineticEnergy <= lowestKinEnergy) { retu << 177 if (kineticEnergy <= lowestKinEnergy) return dedx; 171 178 172 G4double cut = std::max(cutEnergy, minThresh << 179 G4double tmax = kineticEnergy; 173 cut = std::min(cut, kineticEnergy); << 180 G4double cut = std::min(cutEnergy,tmax); >> 181 if(cut < minThreshold) cut = minThreshold; 174 182 175 const G4ElementVector* theElementVector = ma 183 const G4ElementVector* theElementVector = material->GetElementVector(); 176 const G4double* theAtomicNumDensityVector = 184 const G4double* theAtomicNumDensityVector = 177 material->GetAtomicNumDensityVector(); 185 material->GetAtomicNumDensityVector(); 178 186 179 // loop for elements in the material 187 // loop for elements in the material 180 for (size_t i=0; i<material->GetNumberOfElem << 188 for (size_t i=0; i<material->GetNumberOfElements(); i++) { >> 189 181 G4double loss = 190 G4double loss = 182 ComputMuBremLoss((*theElementVector)[i]- 191 ComputMuBremLoss((*theElementVector)[i]->GetZ(), kineticEnergy, cut); >> 192 183 dedx += loss*theAtomicNumDensityVector[i]; 193 dedx += loss*theAtomicNumDensityVector[i]; 184 } 194 } 185 // G4cout << "BR e= " << kineticEnergy << " 195 // G4cout << "BR e= " << kineticEnergy << " dedx= " << dedx << G4endl; 186 dedx = std::max(dedx, 0.); << 196 if(dedx < 0.) dedx = 0.; 187 return dedx; 197 return dedx; 188 } 198 } 189 199 190 //....oooOO0OOooo........oooOO0OOooo........oo 200 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 191 201 192 G4double G4MuBremsstrahlungModel::ComputMuBrem 202 G4double G4MuBremsstrahlungModel::ComputMuBremLoss(G4double Z, 193 203 G4double tkin, G4double cut) 194 { 204 { 195 G4double totalEnergy = mass + tkin; 205 G4double totalEnergy = mass + tkin; 196 static const G4double ak1 = 0.05; << 206 G4double ak1 = 0.05; 197 static const G4int k2 = 5; << 207 G4int k2=5; >> 208 G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623}; >> 209 G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566}; 198 G4double loss = 0.; 210 G4double loss = 0.; 199 211 200 G4double vcut = cut/totalEnergy; 212 G4double vcut = cut/totalEnergy; 201 G4int kkk = (G4int)(vcut/ak1) + k2; << 213 G4double vmax = tkin/totalEnergy; 202 if (kkk > 8) { kkk = 8; } << 214 203 else if (kkk < 1) { kkk = 1; } << 215 G4double aaa = 0.; 204 G4double hhh = vcut/(G4double)(kkk); << 216 G4double bbb = vcut; 205 << 217 if(vcut>vmax) bbb=vmax ; 206 G4double aa = 0.; << 218 G4int kkk = (G4int)((bbb-aaa)/ak1)+k2 ; 207 for(G4int l=0; l<kkk; ++l) { << 219 G4double hhh=(bbb-aaa)/float(kkk) ; 208 for(G4int i=0; i<6; ++i) { << 220 >> 221 G4double aa = aaa; >> 222 for(G4int l=0; l<kkk; l++) >> 223 { >> 224 for(G4int i=0; i<6; i++) >> 225 { 209 G4double ep = (aa + xgi[i]*hhh)*totalEne 226 G4double ep = (aa + xgi[i]*hhh)*totalEnergy; 210 loss += ep*wgi[i]*ComputeDMicroscopicCro 227 loss += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, ep); 211 } 228 } 212 aa += hhh; 229 aa += hhh; 213 } 230 } 214 231 215 loss *= hhh*totalEnergy; << 232 loss *=hhh*totalEnergy ; >> 233 216 return loss; 234 return loss; 217 } 235 } 218 236 219 //....oooOO0OOooo........oooOO0OOooo........oo 237 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 220 238 221 G4double G4MuBremsstrahlungModel::ComputeMicro 239 G4double G4MuBremsstrahlungModel::ComputeMicroscopicCrossSection( 222 G4d 240 G4double tkin, 223 G4d 241 G4double Z, 224 G4d 242 G4double cut) 225 { 243 { 226 G4double totalEnergy = tkin + mass; 244 G4double totalEnergy = tkin + mass; 227 static const G4double ak1 = 2.3; << 245 G4double ak1 = 2.3; 228 static const G4int k2 = 4; << 246 G4int k2 = 4; >> 247 G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623}; >> 248 G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566}; 229 G4double cross = 0.; 249 G4double cross = 0.; 230 250 231 if(cut >= tkin) return cross; 251 if(cut >= tkin) return cross; 232 252 233 G4double vcut = cut/totalEnergy; 253 G4double vcut = cut/totalEnergy; 234 G4double vmax = tkin/totalEnergy; 254 G4double vmax = tkin/totalEnergy; 235 255 236 G4double aaa = G4Log(vcut); << 256 G4double aaa = log(vcut); 237 G4double bbb = G4Log(vmax); << 257 G4double bbb = log(vmax); 238 G4int kkk = (G4int)((bbb-aaa)/ak1) + k2 ; << 258 G4int kkk = (G4int)((bbb-aaa)/ak1)+k2 ; 239 if(kkk > 8) { kkk = 8; } << 259 G4double hhh = (bbb-aaa)/G4double(kkk); 240 else if (kkk < 1) { kkk = 1; } << 260 241 G4double hhh = (bbb-aaa)/(G4double)(kkk); << 242 G4double aa = aaa; 261 G4double aa = aaa; 243 262 244 for(G4int l=0; l<kkk; ++l) { << 263 for(G4int l=0; l<kkk; l++) 245 for(G4int i=0; i<6; ++i) { << 264 { 246 G4double ep = G4Exp(aa + xgi[i]*hhh)*tot << 265 for(G4int i=0; i<6; i++) >> 266 { >> 267 G4double ep = exp(aa + xgi[i]*hhh)*totalEnergy; 247 cross += ep*wgi[i]*ComputeDMicroscopicCr 268 cross += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, ep); 248 } 269 } 249 aa += hhh; 270 aa += hhh; 250 } 271 } 251 272 252 cross *= hhh; << 273 cross *=hhh; >> 274 253 //G4cout << "BR e= " << tkin<< " cross= " < 275 //G4cout << "BR e= " << tkin<< " cross= " << cross/barn << G4endl; >> 276 254 return cross; 277 return cross; 255 } 278 } 256 279 257 //....oooOO0OOooo........oooOO0OOooo........oo 280 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 258 281 259 G4double G4MuBremsstrahlungModel::ComputeDMicr 282 G4double G4MuBremsstrahlungModel::ComputeDMicroscopicCrossSection( 260 G4d 283 G4double tkin, 261 G4d 284 G4double Z, 262 G4d 285 G4double gammaEnergy) 263 // differential cross section 286 // differential cross section 264 { 287 { 265 G4double dxsection = 0.; 288 G4double dxsection = 0.; 266 if(gammaEnergy > tkin) { return dxsection; } << 289 >> 290 if( gammaEnergy > tkin) return dxsection ; 267 291 268 G4double E = tkin + mass ; 292 G4double E = tkin + mass ; 269 G4double v = gammaEnergy/E ; 293 G4double v = gammaEnergy/E ; 270 G4double delta = 0.5*mass*mass*v/(E-gammaEne 294 G4double delta = 0.5*mass*mass*v/(E-gammaEnergy) ; 271 G4double rab0 = delta*sqrte ; << 295 G4double rab0=delta*sqrte ; 272 296 273 G4int iz = G4lrint(Z); << 297 G4int iz = G4int(Z); 274 if(iz < 1) { iz = 1; } << 298 if(iz < 1) iz = 1; 275 else if(iz > 92) { iz = 92; } << 276 299 277 G4double z13 = 1.0/nist->GetZ13(iz); 300 G4double z13 = 1.0/nist->GetZ13(iz); 278 G4double dnstar = fDN[iz]; << 301 G4double dn = 1.54*nist->GetA27(iz); 279 302 280 G4double b,b1; << 303 G4double b,b1,dnstar ; 281 if(1 == iz) { << 304 >> 305 if(1 == iz) >> 306 { 282 b = bh; 307 b = bh; 283 b1 = bh1; 308 b1 = bh1; 284 } else { << 309 dnstar = dn; >> 310 } >> 311 else >> 312 { 285 b = btf; 313 b = btf; 286 b1 = btf1; 314 b1 = btf1; >> 315 dnstar = dn/std::pow(dn, 1./Z); 287 } 316 } 288 317 289 // nucleus contribution logarithm 318 // nucleus contribution logarithm 290 G4double rab1 = b*z13; << 319 G4double rab1=b*z13; 291 G4double fn = G4Log(rab1/(dnstar*(CLHEP::ele << 320 G4double fn=log(rab1/(dnstar*(electron_mass_c2+rab0*rab1))* 292 (mass + delta*(dnstar*sqrte-2.))); << 321 (mass+delta*(dnstar*sqrte-2.))) ; 293 fn = std::max(fn, 0.); << 322 if(fn <0.) fn = 0. ; 294 // electron contribution logarithm 323 // electron contribution logarithm 295 G4double epmax1 = E/(1.+0.5*mass*rmass/E); << 324 G4double epmax1=E/(1.+0.5*mass*rmass/E) ; 296 G4double fe = 0.; << 325 G4double fe=0.; 297 if(gammaEnergy < epmax1) { << 326 if(gammaEnergy<epmax1) 298 G4double rab2 = b1*z13*z13; << 327 { 299 fe = G4Log(rab2*mass/((1.+delta*rmass/(CLH << 328 G4double rab2=b1*z13*z13 ; 300 (CLHEP::electron_mass_c2+rab0*rab2))); << 329 fe=log(rab2*mass/((1.+delta*rmass/(electron_mass_c2*sqrte))* 301 fe = std::max(fe, 0.); << 330 (electron_mass_c2+rab0*rab2))) ; >> 331 if(fe<0.) fe=0. ; 302 } 332 } 303 333 304 dxsection = coeff*(1.-v*(1. - 0.75*v))*Z*(fn 334 dxsection = coeff*(1.-v*(1. - 0.75*v))*Z*(fn*Z + fe)/gammaEnergy; 305 dxsection = std::max(dxsection, 0.0); << 335 306 return dxsection; 336 return dxsection; 307 } 337 } 308 338 309 //....oooOO0OOooo........oooOO0OOooo........oo 339 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 310 340 311 G4double G4MuBremsstrahlungModel::ComputeCross 341 G4double G4MuBremsstrahlungModel::ComputeCrossSectionPerAtom( 312 con 342 const G4ParticleDefinition*, 313 343 G4double kineticEnergy, 314 << 344 G4double Z, G4double, 315 345 G4double cutEnergy, 316 346 G4double maxEnergy) 317 { 347 { 318 G4double cross = 0.0; 348 G4double cross = 0.0; 319 if (kineticEnergy <= lowestKinEnergy) return 349 if (kineticEnergy <= lowestKinEnergy) return cross; 320 G4double tmax = std::min(maxEnergy, kineticE 350 G4double tmax = std::min(maxEnergy, kineticEnergy); 321 G4double cut = std::min(cutEnergy, kineticE 351 G4double cut = std::min(cutEnergy, kineticEnergy); 322 if (cut < minThreshold) cut = minThreshold; << 352 if(cut < minThreshold) cut = minThreshold; 323 if (cut >= tmax) return cross; 353 if (cut >= tmax) return cross; 324 354 325 cross = ComputeMicroscopicCrossSection (kine 355 cross = ComputeMicroscopicCrossSection (kineticEnergy, Z, cut); 326 if(tmax < kineticEnergy) { 356 if(tmax < kineticEnergy) { 327 cross -= ComputeMicroscopicCrossSection(ki 357 cross -= ComputeMicroscopicCrossSection(kineticEnergy, Z, tmax); 328 } 358 } 329 return cross; 359 return cross; 330 } 360 } 331 361 332 //....oooOO0OOooo........oooOO0OOooo........oo 362 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 333 363 >> 364 G4DataVector* G4MuBremsstrahlungModel::ComputePartialSumSigma( >> 365 const G4Material* material, >> 366 G4double kineticEnergy, >> 367 G4double cut) >> 368 >> 369 // Build the table of cross section per element. >> 370 // The table is built for material >> 371 // This table is used to select randomly an element in the material. >> 372 { >> 373 G4int nElements = material->GetNumberOfElements(); >> 374 const G4ElementVector* theElementVector = material->GetElementVector(); >> 375 const G4double* theAtomNumDensityVector = >> 376 material->GetAtomicNumDensityVector(); >> 377 >> 378 G4DataVector* dv = new G4DataVector(); >> 379 >> 380 G4double cross = 0.0; >> 381 >> 382 for (G4int i=0; i<nElements; i++ ) { >> 383 cross += theAtomNumDensityVector[i] >> 384 * ComputeMicroscopicCrossSection(kineticEnergy, >> 385 (*theElementVector)[i]->GetZ(), cut); >> 386 dv->push_back(cross); >> 387 } >> 388 return dv; >> 389 } >> 390 >> 391 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 392 334 void G4MuBremsstrahlungModel::SampleSecondarie 393 void G4MuBremsstrahlungModel::SampleSecondaries( 335 std::vector<G4Dy 394 std::vector<G4DynamicParticle*>* vdp, 336 const G4Material << 395 const G4MaterialCutsCouple* couple, 337 const G4DynamicP << 396 const G4DynamicParticle* dp, 338 G4double minEner << 397 G4double minEnergy, 339 G4double maxEner << 398 G4double maxEnergy) 340 { 399 { 341 G4double kineticEnergy = dp->GetKineticEnerg 400 G4double kineticEnergy = dp->GetKineticEnergy(); 342 // check against insufficient energy 401 // check against insufficient energy 343 G4double tmax = std::min(kineticEnergy, maxE 402 G4double tmax = std::min(kineticEnergy, maxEnergy); 344 G4double tmin = std::min(kineticEnergy, minE 403 G4double tmin = std::min(kineticEnergy, minEnergy); 345 tmin = std::max(tmin, minThreshold); << 404 if(tmin < minThreshold) tmin = minThreshold; 346 if(tmin >= tmax) return; 405 if(tmin >= tmax) return; 347 406 348 // ===== sampling of energy transfer ====== 407 // ===== sampling of energy transfer ====== 349 408 350 G4ParticleMomentum partDirection = dp->GetMo 409 G4ParticleMomentum partDirection = dp->GetMomentumDirection(); 351 410 352 // select randomly one element constituing t 411 // select randomly one element constituing the material 353 const G4Element* anElement = SelectRandomAto << 412 const G4Element* anElement = SelectRandomAtom(couple); 354 G4double Z = anElement->GetZ(); 413 G4double Z = anElement->GetZ(); >> 414 >> 415 G4double totalEnergy = kineticEnergy + mass; >> 416 G4double totalMomentum = sqrt(kineticEnergy*(kineticEnergy + 2.0*mass)); >> 417 355 G4double func1 = tmin* 418 G4double func1 = tmin* 356 ComputeDMicroscopicCrossSection(kineticEne << 419 ComputeDMicroscopicCrossSection(kineticEnergy,Z,tmin); 357 420 358 G4double gEnergy; << 421 G4double lnepksi, epksi; 359 G4double func2; 422 G4double func2; 360 423 361 G4double xmin = G4Log(tmin/minThreshold); << 362 G4double xmax = G4Log(tmax/tmin); << 363 << 364 do { 424 do { 365 gEnergy = minThreshold*G4Exp(xmin + G4Unif << 425 lnepksi = log(tmin) + G4UniformRand()*log(kineticEnergy/tmin); 366 func2 = gEnergy*ComputeDMicroscopicCrossSe << 426 epksi = exp(lnepksi); 367 << 427 func2 = epksi*ComputeDMicroscopicCrossSection(kineticEnergy,Z,epksi); 368 // Loop checking, 03-Aug-2015, Vladimir Iv << 428 369 } while(func2 < func1*G4UniformRand()); 429 } while(func2 < func1*G4UniformRand()); 370 430 371 // angles of the emitted gamma using general << 431 G4double gEnergy = epksi; 372 G4ThreeVector gamDir = << 432 373 GetAngularDistribution()->SampleDirection( << 433 // ===== sample angle ===== 374 << 434 375 // create G4DynamicParticle object for the G << 435 G4double gam = totalEnergy/mass; 376 G4DynamicParticle* gamma = new G4DynamicPart << 436 G4double rmax = gam*std::min(1.0, totalEnergy/gEnergy - 1.0); 377 vdp->push_back(gamma); << 437 G4double rmax2= rmax*rmax; 378 << 438 G4double x = G4UniformRand()*rmax2/(1.0 + rmax2); 379 // compute post-interaction kinematics of pr << 439 380 // energy-momentum conservation << 440 G4double theta = sqrt(x/(1.0 - x))/gam; 381 const G4double totMomentum = << 441 G4double sint = sin(theta); 382 std::sqrt(kineticEnergy*(kineticEnergy + 2 << 442 G4double phi = twopi * G4UniformRand() ; 383 G4ThreeVector dir = << 443 G4double dirx = sint*cos(phi), diry = sint*sin(phi), dirz = cos(theta) ; 384 (totMomentum*dp->GetMomentumDirection() - << 444 385 const G4double finalE = kineticEnergy - gEne << 445 G4ThreeVector gDirection(dirx, diry, dirz); 386 << 446 gDirection.rotateUz(partDirection); 387 // if secondary gamma energy is higher than << 447 388 // then stop tracking the primary particle a << 448 partDirection *= totalMomentum; 389 // instead of the primary one << 449 partDirection -= gEnergy*gDirection; 390 if (gEnergy > SecondaryThreshold()) { << 450 partDirection = partDirection.unit(); 391 fParticleChange->ProposeTrackStatus(fStopA << 451 392 fParticleChange->SetProposedKineticEnergy( << 452 // primary change 393 G4DynamicParticle* newdp = new G4DynamicPa << 453 kineticEnergy -= gEnergy; 394 vdp->push_back(newdp); << 454 fParticleChange->SetProposedKineticEnergy(kineticEnergy); 395 } else { << 455 fParticleChange->SetProposedMomentumDirection(partDirection); 396 // continue tracking the primary e-/e+ oth << 456 397 fParticleChange->SetProposedMomentumDirect << 457 // save secondary 398 fParticleChange->SetProposedKineticEnergy( << 458 G4DynamicParticle* aGamma = >> 459 new G4DynamicParticle(theGamma,gDirection,gEnergy); >> 460 vdp->push_back(aGamma); >> 461 } >> 462 >> 463 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 464 >> 465 const G4Element* G4MuBremsstrahlungModel::SelectRandomAtom( >> 466 const G4MaterialCutsCouple* couple) const >> 467 { >> 468 // select randomly 1 element within the material >> 469 >> 470 const G4Material* material = couple->GetMaterial(); >> 471 G4int nElements = material->GetNumberOfElements(); >> 472 const G4ElementVector* theElementVector = material->GetElementVector(); >> 473 if(1 == nElements) { return (*theElementVector)[0]; } >> 474 else if(1 > nElements) { return 0; } >> 475 >> 476 G4DataVector* dv = partialSumSigma[couple->GetIndex()]; >> 477 G4double rval = G4UniformRand()*((*dv)[nElements-1]); >> 478 for (G4int i=0; i<nElements; i++) { >> 479 if (rval <= (*dv)[i]) { return (*theElementVector)[i]; } 399 } 480 } >> 481 return (*theElementVector)[nElements-1]; 400 } 482 } 401 483 402 //....oooOO0OOooo........oooOO0OOooo........oo 484 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 403 485