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.21 2006/06/29 19:49:42 gunter Exp $ >> 27 // GEANT4 tag $Name: geant4-08-03-patch-01 $ 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.Ivantchenko) 47 // 03-08-05 Angular correlations according to << 49 // 03-08-05 Angular correlations according to PRM (V.Ivantchenko) 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 // 51 // 28-02-08 Use precomputed Z^1/3 and Log(A) ( << 53 52 // 31-05-13 Use element selectors instead of l << 54 // >> 55 // Class Description: >> 56 // 53 // 57 // 54 // ------------------------------------------- 58 // ------------------------------------------------------------------- 55 // 59 // 56 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 //....oooOO0OOooo........oooOO0OOooo........oo 61 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 62 59 #include "G4MuBremsstrahlungModel.hh" 63 #include "G4MuBremsstrahlungModel.hh" 60 #include "G4PhysicalConstants.hh" << 61 #include "G4SystemOfUnits.hh" << 62 #include "G4Gamma.hh" 64 #include "G4Gamma.hh" 63 #include "G4MuonMinus.hh" 65 #include "G4MuonMinus.hh" 64 #include "G4MuonPlus.hh" 66 #include "G4MuonPlus.hh" 65 #include "Randomize.hh" 67 #include "Randomize.hh" 66 #include "G4Material.hh" 68 #include "G4Material.hh" 67 #include "G4Element.hh" 69 #include "G4Element.hh" 68 #include "G4ElementVector.hh" 70 #include "G4ElementVector.hh" 69 #include "G4ProductionCutsTable.hh" 71 #include "G4ProductionCutsTable.hh" 70 #include "G4ModifiedMephi.hh" << 71 #include "G4ParticleChangeForLoss.hh" 72 #include "G4ParticleChangeForLoss.hh" 72 #include "G4Log.hh" << 73 73 74 //....oooOO0OOooo........oooOO0OOooo........oo 74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 75 >> 76 // static members >> 77 // >> 78 G4double G4MuBremsstrahlungModel::zdat[]={1., 4., 13., 29., 92.}; >> 79 G4double G4MuBremsstrahlungModel::adat[]={1.01, 9.01, 26.98, 63.55, 238.03}; >> 80 G4double G4MuBremsstrahlungModel::tdat[]={1.e3, 1.e4, 1.e5, 1.e6, 1.e7, 1.e8, >> 81 1.e9, 1.e10}; >> 82 75 //....oooOO0OOooo........oooOO0OOooo........oo 83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 76 84 77 const G4double G4MuBremsstrahlungModel::xgi[] << 85 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 86 83 G4MuBremsstrahlungModel::G4MuBremsstrahlungMod 87 G4MuBremsstrahlungModel::G4MuBremsstrahlungModel(const G4ParticleDefinition* p, 84 88 const G4String& nam) 85 : G4VEmModel(nam), 89 : G4VEmModel(nam), 86 sqrte(std::sqrt(G4Exp(1.))), << 90 particle(0), 87 lowestKinEnergy(0.1*CLHEP::GeV), << 91 lowestKinEnergy(1.0*GeV), 88 minThreshold(0.9*CLHEP::keV) << 92 minThreshold(1.0*keV), >> 93 nzdat(5), >> 94 ntdat(8), >> 95 NBIN(1000), >> 96 cutFixed(0.98*keV), >> 97 samplingTablesAreFilled(false) 89 { 98 { 90 theGamma = G4Gamma::Gamma(); 99 theGamma = G4Gamma::Gamma(); 91 nist = G4NistManager::Instance(); << 92 100 93 SetAngularDistribution(new G4ModifiedMephi() << 101 if(p) SetParticle(p); >> 102 } 94 103 95 if (nullptr != p) { SetParticle(p); } << 104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 96 if (0.0 == fDN[1]) { << 105 97 for (G4int i=1; i<93; ++i) { << 106 G4MuBremsstrahlungModel::~G4MuBremsstrahlungModel() 98 G4double dn = 1.54*nist->GetA27(i); << 107 { 99 fDN[i] = dn; << 108 size_t n = partialSumSigma.size(); 100 if(1 < i) { << 109 if(n > 0) { 101 fDN[i] /= std::pow(dn, 1./G4double(i)); << 110 for(size_t i=0; i<n; i++) { 102 } << 111 delete partialSumSigma[i]; 103 } 112 } 104 } 113 } 105 } 114 } 106 115 107 //....oooOO0OOooo........oooOO0OOooo........oo 116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 108 117 109 G4double G4MuBremsstrahlungModel::MinEnergyCut 118 G4double G4MuBremsstrahlungModel::MinEnergyCut(const G4ParticleDefinition*, 110 119 const G4MaterialCutsCouple*) 111 { 120 { 112 return minThreshold; 121 return minThreshold; 113 } 122 } 114 123 115 //....oooOO0OOooo........oooOO0OOooo........oo 124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 116 125 117 G4double G4MuBremsstrahlungModel::MinPrimaryEn << 118 << 119 << 120 { << 121 return std::max(lowestKinEnergy, cut); << 122 } << 123 << 124 //....oooOO0OOooo........oooOO0OOooo........oo << 125 << 126 void G4MuBremsstrahlungModel::SetParticle(cons 126 void G4MuBremsstrahlungModel::SetParticle(const G4ParticleDefinition* p) 127 { 127 { 128 if(nullptr == particle) { << 128 if(!particle) { 129 particle = p; 129 particle = p; 130 mass = particle->GetPDGMass(); 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 } 131 } 135 } 132 } 136 133 137 //....oooOO0OOooo........oooOO0OOooo........oo 134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 138 135 139 void G4MuBremsstrahlungModel::Initialise(const 136 void G4MuBremsstrahlungModel::Initialise(const G4ParticleDefinition* p, 140 const 137 const G4DataVector& cuts) 141 { 138 { 142 SetParticle(p); << 139 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 140 151 //....oooOO0OOooo........oooOO0OOooo........oo << 141 highKinEnergy = HighEnergyLimit(); 152 142 153 void G4MuBremsstrahlungModel::InitialiseLocal( << 143 G4double fixedEnergy = 0.5*highKinEnergy; 154 << 144 // G4double fixedEnergy = 500000.*TeV; 155 { << 145 156 if(p == particle && lowestKinEnergy < HighEn << 146 const G4ProductionCutsTable* theCoupleTable= 157 SetElementSelectors(masterModel->GetElemen << 147 G4ProductionCutsTable::GetProductionCutsTable(); >> 148 if(theCoupleTable) { >> 149 G4int numOfCouples = theCoupleTable->GetTableSize(); >> 150 >> 151 G4int nn = partialSumSigma.size(); >> 152 G4int nc = cuts.size(); >> 153 if(nn > 0) { >> 154 for (G4int ii=0; ii<nn; ii++){ >> 155 G4DataVector* a=partialSumSigma[ii]; >> 156 if ( a ) delete a; >> 157 } >> 158 partialSumSigma.clear(); >> 159 } >> 160 if (numOfCouples>0) { >> 161 for (G4int i=0; i<numOfCouples; i++) { >> 162 G4double cute = DBL_MAX; >> 163 if(i < nc) cute = cuts[i]; >> 164 const G4MaterialCutsCouple* couple = >> 165 theCoupleTable->GetMaterialCutsCouple(i); >> 166 const G4Material* material = couple->GetMaterial(); >> 167 G4DataVector* dv = ComputePartialSumSigma(material,fixedEnergy,cute); >> 168 partialSumSigma.push_back(dv); >> 169 } >> 170 } 158 } 171 } >> 172 if(!samplingTablesAreFilled) MakeSamplingTables(); >> 173 if(pParticleChange) >> 174 fParticleChange = reinterpret_cast<G4ParticleChangeForLoss*> >> 175 (pParticleChange); >> 176 else >> 177 fParticleChange = new G4ParticleChangeForLoss(); 159 } 178 } 160 179 161 //....oooOO0OOooo........oooOO0OOooo........oo 180 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 162 181 163 G4double G4MuBremsstrahlungModel::ComputeDEDXP 182 G4double G4MuBremsstrahlungModel::ComputeDEDXPerVolume( 164 << 183 const G4Material* material, 165 184 const G4ParticleDefinition*, 166 185 G4double kineticEnergy, 167 186 G4double cutEnergy) 168 { 187 { 169 G4double dedx = 0.0; 188 G4double dedx = 0.0; 170 if (kineticEnergy <= lowestKinEnergy) { retu << 189 if (kineticEnergy <= lowestKinEnergy) return dedx; 171 190 172 G4double cut = std::max(cutEnergy, minThresh << 191 G4double tmax = kineticEnergy; 173 cut = std::min(cut, kineticEnergy); << 192 G4double cut = min(cutEnergy,tmax); 174 193 175 const G4ElementVector* theElementVector = ma 194 const G4ElementVector* theElementVector = material->GetElementVector(); 176 const G4double* theAtomicNumDensityVector = 195 const G4double* theAtomicNumDensityVector = 177 material->GetAtomicNumDensityVector(); << 196 material->GetAtomicNumDensityVector(); 178 197 179 // loop for elements in the material 198 // loop for elements in the material 180 for (size_t i=0; i<material->GetNumberOfElem << 199 for (size_t i=0; i<material->GetNumberOfElements(); i++) { 181 G4double loss = << 200 182 ComputMuBremLoss((*theElementVector)[i]- << 201 G4double Z = (*theElementVector)[i]->GetZ(); >> 202 G4double A = (*theElementVector)[i]->GetA()/(g/mole) ; >> 203 >> 204 G4double loss = ComputMuBremLoss(Z, A, kineticEnergy, cut); >> 205 183 dedx += loss*theAtomicNumDensityVector[i]; 206 dedx += loss*theAtomicNumDensityVector[i]; 184 } 207 } 185 // G4cout << "BR e= " << kineticEnergy << " << 208 if(dedx < 0.) dedx = 0.; 186 dedx = std::max(dedx, 0.); << 187 return dedx; 209 return dedx; 188 } 210 } 189 211 190 //....oooOO0OOooo........oooOO0OOooo........oo 212 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 191 213 192 G4double G4MuBremsstrahlungModel::ComputMuBrem << 214 G4double G4MuBremsstrahlungModel::ComputMuBremLoss(G4double Z, G4double A, 193 215 G4double tkin, G4double cut) 194 { 216 { 195 G4double totalEnergy = mass + tkin; 217 G4double totalEnergy = mass + tkin; 196 static const G4double ak1 = 0.05; << 218 G4double ak1 = 0.05; 197 static const G4int k2 = 5; << 219 G4int k2=5; >> 220 G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623}; >> 221 G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566}; 198 G4double loss = 0.; 222 G4double loss = 0.; 199 223 200 G4double vcut = cut/totalEnergy; 224 G4double vcut = cut/totalEnergy; 201 G4int kkk = (G4int)(vcut/ak1) + k2; << 225 G4double vmax = tkin/totalEnergy; 202 if (kkk > 8) { kkk = 8; } << 226 203 else if (kkk < 1) { kkk = 1; } << 227 G4double aaa = 0.; 204 G4double hhh = vcut/(G4double)(kkk); << 228 G4double bbb = vcut; 205 << 229 if(vcut>vmax) bbb=vmax ; 206 G4double aa = 0.; << 230 G4int kkk = (G4int)((bbb-aaa)/ak1)+k2 ; 207 for(G4int l=0; l<kkk; ++l) { << 231 G4double hhh=(bbb-aaa)/float(kkk) ; 208 for(G4int i=0; i<6; ++i) { << 232 >> 233 G4double aa = aaa; >> 234 for(G4int l=0; l<kkk; l++) >> 235 { >> 236 for(G4int i=0; i<6; i++) >> 237 { 209 G4double ep = (aa + xgi[i]*hhh)*totalEne 238 G4double ep = (aa + xgi[i]*hhh)*totalEnergy; 210 loss += ep*wgi[i]*ComputeDMicroscopicCro << 239 loss += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, A, ep); 211 } 240 } 212 aa += hhh; 241 aa += hhh; 213 } 242 } 214 243 215 loss *= hhh*totalEnergy; << 244 loss *=hhh*totalEnergy ; >> 245 216 return loss; 246 return loss; 217 } 247 } 218 248 219 //....oooOO0OOooo........oooOO0OOooo........oo 249 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 220 250 221 G4double G4MuBremsstrahlungModel::ComputeMicro 251 G4double G4MuBremsstrahlungModel::ComputeMicroscopicCrossSection( 222 G4d 252 G4double tkin, 223 G4d 253 G4double Z, >> 254 G4double A, 224 G4d 255 G4double cut) 225 { 256 { 226 G4double totalEnergy = tkin + mass; 257 G4double totalEnergy = tkin + mass; 227 static const G4double ak1 = 2.3; << 258 G4double ak1 = 2.3; 228 static const G4int k2 = 4; << 259 G4int k2 = 4; >> 260 G4double xgi[]={0.03377,0.16940,0.38069,0.61931,0.83060,0.96623}; >> 261 G4double wgi[]={0.08566,0.18038,0.23396,0.23396,0.18038,0.08566}; 229 G4double cross = 0.; 262 G4double cross = 0.; 230 263 231 if(cut >= tkin) return cross; 264 if(cut >= tkin) return cross; 232 265 233 G4double vcut = cut/totalEnergy; 266 G4double vcut = cut/totalEnergy; 234 G4double vmax = tkin/totalEnergy; 267 G4double vmax = tkin/totalEnergy; 235 268 236 G4double aaa = G4Log(vcut); << 269 G4double aaa = log(vcut); 237 G4double bbb = G4Log(vmax); << 270 G4double bbb = log(vmax); 238 G4int kkk = (G4int)((bbb-aaa)/ak1) + k2 ; << 271 G4int kkk = (G4int)((bbb-aaa)/ak1)+k2 ; 239 if(kkk > 8) { kkk = 8; } << 272 G4double hhh = (bbb-aaa)/float(kkk); 240 else if (kkk < 1) { kkk = 1; } << 273 241 G4double hhh = (bbb-aaa)/(G4double)(kkk); << 242 G4double aa = aaa; 274 G4double aa = aaa; 243 275 244 for(G4int l=0; l<kkk; ++l) { << 276 for(G4int l=0; l<kkk; l++) 245 for(G4int i=0; i<6; ++i) { << 277 { 246 G4double ep = G4Exp(aa + xgi[i]*hhh)*tot << 278 for(G4int i=0; i<6; i++) 247 cross += ep*wgi[i]*ComputeDMicroscopicCr << 279 { >> 280 G4double ep = exp(aa + xgi[i]*hhh)*totalEnergy; >> 281 cross += ep*wgi[i]*ComputeDMicroscopicCrossSection(tkin, Z, A, ep); 248 } 282 } 249 aa += hhh; 283 aa += hhh; 250 } 284 } 251 285 252 cross *= hhh; << 286 cross *=hhh; 253 //G4cout << "BR e= " << tkin<< " cross= " < << 287 254 return cross; 288 return cross; 255 } 289 } 256 290 257 //....oooOO0OOooo........oooOO0OOooo........oo 291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 258 292 259 G4double G4MuBremsstrahlungModel::ComputeDMicr 293 G4double G4MuBremsstrahlungModel::ComputeDMicroscopicCrossSection( 260 G4d 294 G4double tkin, 261 G4d 295 G4double Z, >> 296 G4double A, 262 G4d 297 G4double gammaEnergy) 263 // differential cross section 298 // differential cross section 264 { 299 { >> 300 static const G4double sqrte=sqrt(exp(1.)) ; >> 301 static const G4double bh=202.4,bh1=446.,btf=183.,btf1=1429. ; >> 302 static const G4double rmass=mass/electron_mass_c2 ; >> 303 static const G4double cc=classic_electr_radius/rmass ; >> 304 static const G4double coeff= 16.*fine_structure_const*cc*cc/3. ; >> 305 265 G4double dxsection = 0.; 306 G4double dxsection = 0.; 266 if(gammaEnergy > tkin) { return dxsection; } << 307 >> 308 if( gammaEnergy > tkin) return dxsection ; 267 309 268 G4double E = tkin + mass ; 310 G4double E = tkin + mass ; 269 G4double v = gammaEnergy/E ; 311 G4double v = gammaEnergy/E ; 270 G4double delta = 0.5*mass*mass*v/(E-gammaEne 312 G4double delta = 0.5*mass*mass*v/(E-gammaEnergy) ; 271 G4double rab0 = delta*sqrte ; << 313 G4double rab0=delta*sqrte ; >> 314 >> 315 G4double z13 = exp(-log(Z)/3.) ; >> 316 G4double dn = 1.54*exp(0.27*log(A)) ; 272 317 273 G4int iz = G4lrint(Z); << 318 G4double b,b1,dnstar ; 274 if(iz < 1) { iz = 1; } << 319 275 else if(iz > 92) { iz = 92; } << 320 if(Z<1.5) 276 << 321 { 277 G4double z13 = 1.0/nist->GetZ13(iz); << 322 b=bh; 278 G4double dnstar = fDN[iz]; << 323 b1=bh1; 279 << 324 dnstar=dn ; 280 G4double b,b1; << 325 } 281 if(1 == iz) { << 326 else 282 b = bh; << 327 { 283 b1 = bh1; << 328 b=btf; 284 } else { << 329 b1=btf1; 285 b = btf; << 330 dnstar = exp((1.-1./Z)*log(dn)) ; 286 b1 = btf1; << 287 } 331 } 288 332 289 // nucleus contribution logarithm 333 // nucleus contribution logarithm 290 G4double rab1 = b*z13; << 334 G4double rab1=b*z13; 291 G4double fn = G4Log(rab1/(dnstar*(CLHEP::ele << 335 G4double fn=log(rab1/(dnstar*(electron_mass_c2+rab0*rab1))* 292 (mass + delta*(dnstar*sqrte-2.))); << 336 (mass+delta*(dnstar*sqrte-2.))) ; 293 fn = std::max(fn, 0.); << 337 if(fn <0.) fn = 0. ; 294 // electron contribution logarithm 338 // electron contribution logarithm 295 G4double epmax1 = E/(1.+0.5*mass*rmass/E); << 339 G4double epmax1=E/(1.+0.5*mass*rmass/E) ; 296 G4double fe = 0.; << 340 G4double fe=0.; 297 if(gammaEnergy < epmax1) { << 341 if(gammaEnergy<epmax1) 298 G4double rab2 = b1*z13*z13; << 342 { 299 fe = G4Log(rab2*mass/((1.+delta*rmass/(CLH << 343 G4double rab2=b1*z13*z13 ; 300 (CLHEP::electron_mass_c2+rab0*rab2))); << 344 fe=log(rab2*mass/((1.+delta*rmass/(electron_mass_c2*sqrte))* 301 fe = std::max(fe, 0.); << 345 (electron_mass_c2+rab0*rab2))) ; >> 346 if(fe<0.) fe=0. ; 302 } 347 } 303 348 304 dxsection = coeff*(1.-v*(1. - 0.75*v))*Z*(fn 349 dxsection = coeff*(1.-v*(1. - 0.75*v))*Z*(fn*Z + fe)/gammaEnergy; 305 dxsection = std::max(dxsection, 0.0); << 350 306 return dxsection; 351 return dxsection; 307 } 352 } 308 353 309 //....oooOO0OOooo........oooOO0OOooo........oo 354 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 310 355 311 G4double G4MuBremsstrahlungModel::ComputeCross 356 G4double G4MuBremsstrahlungModel::ComputeCrossSectionPerAtom( 312 con 357 const G4ParticleDefinition*, 313 358 G4double kineticEnergy, 314 << 359 G4double Z, G4double A, 315 360 G4double cutEnergy, 316 << 361 G4double) >> 362 { >> 363 G4double cross = ComputeMicroscopicCrossSection (kineticEnergy, >> 364 Z, A/(g/mole), cutEnergy); >> 365 return cross; >> 366 } >> 367 >> 368 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 369 >> 370 G4double G4MuBremsstrahlungModel::CrossSectionPerVolume( >> 371 const G4Material* material, >> 372 const G4ParticleDefinition*, >> 373 G4double kineticEnergy, >> 374 G4double cutEnergy, >> 375 G4double maxEnergy) 317 { 376 { 318 G4double cross = 0.0; 377 G4double cross = 0.0; 319 if (kineticEnergy <= lowestKinEnergy) return << 378 if (cutEnergy >= maxEnergy || kineticEnergy <= lowestKinEnergy) return cross; 320 G4double tmax = std::min(maxEnergy, kineticE << 379 321 G4double cut = std::min(cutEnergy, kineticE << 380 G4double tmax = min(maxEnergy, kineticEnergy); 322 if (cut < minThreshold) cut = minThreshold; << 381 G4double cut = min(cutEnergy, tmax); 323 if (cut >= tmax) return cross; << 382 324 << 383 const G4ElementVector* theElementVector = material->GetElementVector(); 325 cross = ComputeMicroscopicCrossSection (kine << 384 const G4double* theAtomNumDensityVector = 326 if(tmax < kineticEnergy) { << 385 material->GetAtomicNumDensityVector(); 327 cross -= ComputeMicroscopicCrossSection(ki << 386 >> 387 for (size_t i=0; i<material->GetNumberOfElements(); i++) { >> 388 >> 389 G4double Z = (*theElementVector)[i]->GetZ(); >> 390 G4double A = (*theElementVector)[i]->GetA()/(g/mole); >> 391 >> 392 G4double cr = ComputeMicroscopicCrossSection(kineticEnergy, Z, A, cut); >> 393 >> 394 if(tmax < kineticEnergy) { >> 395 cr -= ComputeMicroscopicCrossSection(kineticEnergy, Z, A, tmax); >> 396 } >> 397 cross += theAtomNumDensityVector[i] * cr; 328 } 398 } >> 399 329 return cross; 400 return cross; 330 } 401 } 331 402 332 //....oooOO0OOooo........oooOO0OOooo........oo 403 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 333 404 334 void G4MuBremsstrahlungModel::SampleSecondarie << 405 G4DataVector* G4MuBremsstrahlungModel::ComputePartialSumSigma( 335 std::vector<G4Dy << 406 const G4Material* material, 336 const G4Material << 407 G4double kineticEnergy, 337 const G4DynamicP << 408 G4double cut) 338 G4double minEner << 409 339 G4double maxEner << 410 // Build the table of cross section per element. The table is built for MATERIAL >> 411 // This table is used by DoIt to select randomly an element in the material. >> 412 { >> 413 G4int nElements = material->GetNumberOfElements(); >> 414 const G4ElementVector* theElementVector = material->GetElementVector(); >> 415 const G4double* theAtomNumDensityVector = >> 416 material->GetAtomicNumDensityVector(); >> 417 >> 418 G4DataVector* dv = new G4DataVector(); >> 419 >> 420 G4double cross = 0.0; >> 421 >> 422 for (G4int i=0; i<nElements; i++ ) { >> 423 >> 424 G4double Z = (*theElementVector)[i]->GetZ(); >> 425 G4double A = (*theElementVector)[i]->GetA()/(g/mole) ; >> 426 cross += theAtomNumDensityVector[i] >> 427 * ComputeMicroscopicCrossSection(kineticEnergy, Z, A, cut); >> 428 dv->push_back(cross); >> 429 } >> 430 return dv; >> 431 } >> 432 >> 433 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 434 >> 435 void G4MuBremsstrahlungModel::MakeSamplingTables() >> 436 { >> 437 >> 438 G4double AtomicNumber,AtomicWeight,KineticEnergy, >> 439 TotalEnergy,Maxep; >> 440 >> 441 for (G4int iz=0; iz<nzdat; iz++) >> 442 { >> 443 AtomicNumber = zdat[iz]; >> 444 AtomicWeight = adat[iz]*g/mole ; >> 445 >> 446 for (G4int it=0; it<ntdat; it++) >> 447 { >> 448 KineticEnergy = tdat[it]; >> 449 TotalEnergy = KineticEnergy + mass; >> 450 Maxep = KineticEnergy ; >> 451 >> 452 G4double CrossSection = 0.0 ; >> 453 >> 454 // calculate the differential cross section >> 455 // numerical integration in >> 456 // log ............... >> 457 G4double c = log(Maxep/cutFixed) ; >> 458 G4double ymin = -5. ; >> 459 G4double ymax = 0. ; >> 460 G4double dy = (ymax-ymin)/NBIN ; >> 461 >> 462 G4double y = ymin - 0.5*dy ; >> 463 G4double yy = ymin - dy ; >> 464 G4double x = exp(y); >> 465 G4double fac = exp(dy); >> 466 G4double dx = exp(yy)*(fac - 1.0); >> 467 >> 468 for (G4int i=0 ; i<NBIN; i++) >> 469 { >> 470 y += dy ; >> 471 x *= fac; >> 472 dx*= fac; >> 473 G4double ep = cutFixed*exp(c*x) ; >> 474 >> 475 CrossSection += ep*dx*ComputeDMicroscopicCrossSection( >> 476 KineticEnergy,AtomicNumber, >> 477 AtomicWeight,ep) ; >> 478 ya[i]=y ; >> 479 proba[iz][it][i] = CrossSection ; >> 480 >> 481 } >> 482 >> 483 proba[iz][it][NBIN] = CrossSection ; >> 484 ya[NBIN] = 0. ; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! >> 485 >> 486 if(CrossSection > 0.) >> 487 { >> 488 for(G4int ib=0; ib<=NBIN; ib++) >> 489 { >> 490 proba[iz][it][ib] /= CrossSection ; >> 491 } >> 492 } >> 493 } >> 494 } >> 495 samplingTablesAreFilled = true; >> 496 } >> 497 >> 498 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 499 >> 500 vector<G4DynamicParticle*>* G4MuBremsstrahlungModel::SampleSecondaries( >> 501 const G4MaterialCutsCouple* couple, >> 502 const G4DynamicParticle* dp, >> 503 G4double tmin, >> 504 G4double maxEnergy) 340 { 505 { >> 506 341 G4double kineticEnergy = dp->GetKineticEnerg 507 G4double kineticEnergy = dp->GetKineticEnergy(); 342 // check against insufficient energy 508 // check against insufficient energy 343 G4double tmax = std::min(kineticEnergy, maxE << 509 G4double tmax = min(kineticEnergy, maxEnergy); 344 G4double tmin = std::min(kineticEnergy, minE << 510 if(tmin >= tmax) return 0; 345 tmin = std::max(tmin, minThreshold); << 346 if(tmin >= tmax) return; << 347 511 348 // ===== sampling of energy transfer ====== << 512 static const G4double ysmall = -100. ; >> 513 static const G4double ytablelow = -5. ; 349 514 350 G4ParticleMomentum partDirection = dp->GetMo 515 G4ParticleMomentum partDirection = dp->GetMomentumDirection(); 351 516 352 // select randomly one element constituing t 517 // select randomly one element constituing the material 353 const G4Element* anElement = SelectRandomAto << 518 const G4Element* anElement = SelectRandomAtom(couple); 354 G4double Z = anElement->GetZ(); << 519 355 G4double func1 = tmin* << 520 G4double totalEnergy = kineticEnergy + mass; 356 ComputeDMicroscopicCrossSection(kineticEne << 521 G4double totalMomentum = sqrt(kineticEnergy*(kineticEnergy + 2.0*mass)); 357 522 358 G4double gEnergy; << 523 G4double dy = 5./G4float(NBIN); 359 G4double func2; << 360 524 361 G4double xmin = G4Log(tmin/minThreshold); << 525 // This sampling should be checked!!! VI 362 G4double xmax = G4Log(tmax/tmin); << 526 G4double ymin=log(log(tmin/cutFixed)/log(tmax/cutFixed)); >> 527 >> 528 if(ymin < ysmall) return 0; >> 529 >> 530 // sampling using tables >> 531 >> 532 G4double v,x,y ; >> 533 G4int iy; >> 534 // select sampling table ; >> 535 G4double lnZ = log(anElement->GetZ()) ; >> 536 G4double delmin = 1.e10 ; >> 537 G4double del ; >> 538 G4int izz = 0; >> 539 G4int itt = 0; >> 540 G4int NBINminus1; >> 541 NBINminus1 = NBIN-1 ; >> 542 for (G4int iz=0; iz<nzdat; iz++) >> 543 { >> 544 del = std::abs(lnZ-log(zdat[iz])) ; >> 545 if(del<delmin) >> 546 { >> 547 delmin=del ; >> 548 izz=iz ; >> 549 } >> 550 } >> 551 >> 552 delmin = 1.e10 ; >> 553 for (G4int it=0; it<ntdat; it++) >> 554 { >> 555 del = std::abs(log(tmax)-log(tdat[it])) ; >> 556 if(del<delmin) >> 557 { >> 558 delmin=del; >> 559 itt=it ; >> 560 } >> 561 } >> 562 G4int iymin = G4int((ymin+5.)/dy+0.5) ; 363 563 364 do { 564 do { 365 gEnergy = minThreshold*G4Exp(xmin + G4Unif << 565 if(ymin < ytablelow) 366 func2 = gEnergy*ComputeDMicroscopicCrossSe << 566 { 367 << 567 y = ymin + G4UniformRand()*(ytablelow-ymin) ; 368 // Loop checking, 03-Aug-2015, Vladimir Iv << 568 } 369 } while(func2 < func1*G4UniformRand()); << 569 else >> 570 { >> 571 G4double r = G4UniformRand() ; >> 572 >> 573 iy = iymin-1 ; >> 574 delmin = proba[izz][itt][NBINminus1]-proba[izz][itt][iymin] ; >> 575 do { >> 576 iy += 1 ; >> 577 } while ((r > (proba[izz][itt][iy]-proba[izz][itt][iymin])/delmin) >> 578 &&(iy < NBINminus1)) ; >> 579 >> 580 //sampling is Done uniformly in y in the bin >> 581 y = ya[iy] + G4UniformRand() * ( ya[iy+1] - ya[iy] ) ; >> 582 } >> 583 >> 584 x = exp(y) ; >> 585 >> 586 v = cutFixed*exp(x*log(tmax/cutFixed)) ; >> 587 >> 588 } while ( v <= 0.); 370 589 371 // angles of the emitted gamma using general << 372 G4ThreeVector gamDir = << 373 GetAngularDistribution()->SampleDirection( << 374 << 375 // create G4DynamicParticle object for the G 590 // create G4DynamicParticle object for the Gamma 376 G4DynamicParticle* gamma = new G4DynamicPart << 591 G4double gEnergy = v; 377 vdp->push_back(gamma); << 592 >> 593 // sample angle >> 594 G4double gam = totalEnergy/mass; >> 595 G4double rmax = gam*min(1.0, totalEnergy/gEnergy - 1.0); >> 596 rmax *= rmax; >> 597 x = G4UniformRand()*rmax/(1.0 + rmax); >> 598 >> 599 G4double theta = sqrt(x/(1.0 - x))/gam; >> 600 G4double sint = sin(theta); >> 601 G4double phi = twopi * G4UniformRand() ; >> 602 G4double dirx = sint*cos(phi), diry = sint*sin(phi), dirz = cos(theta) ; >> 603 >> 604 G4ThreeVector gDirection(dirx, diry, dirz); >> 605 gDirection.rotateUz(partDirection); >> 606 >> 607 partDirection *= totalMomentum; >> 608 partDirection -= gEnergy*gDirection; >> 609 partDirection = partDirection.unit(); >> 610 >> 611 // primary change >> 612 kineticEnergy -= gEnergy; >> 613 fParticleChange->SetProposedKineticEnergy(kineticEnergy); >> 614 fParticleChange->SetProposedMomentumDirection(partDirection); >> 615 >> 616 // save secondary >> 617 G4DynamicParticle* aGamma = new G4DynamicParticle(theGamma,gDirection,gEnergy); >> 618 vector<G4DynamicParticle*>* vdp = new vector<G4DynamicParticle*>; >> 619 vdp->push_back(aGamma); >> 620 >> 621 return vdp; >> 622 } >> 623 >> 624 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 625 >> 626 const G4Element* G4MuBremsstrahlungModel::SelectRandomAtom( >> 627 const G4MaterialCutsCouple* couple) const >> 628 { >> 629 // select randomly 1 element within the material >> 630 >> 631 const G4Material* material = couple->GetMaterial(); >> 632 G4int nElements = material->GetNumberOfElements(); >> 633 const G4ElementVector* theElementVector = material->GetElementVector(); >> 634 if(1 == nElements) return (*theElementVector)[0]; >> 635 else if(1 > nElements) return 0; 378 636 379 // compute post-interaction kinematics of pr << 637 G4DataVector* dv = partialSumSigma[couple->GetIndex()]; 380 // energy-momentum conservation << 638 G4double rval = G4UniformRand()*((*dv)[nElements-1]); 381 const G4double totMomentum = << 639 for (G4int i=0; i<nElements; i++) { 382 std::sqrt(kineticEnergy*(kineticEnergy + 2 << 640 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 } 641 } >> 642 return (*theElementVector)[nElements-1]; 400 } 643 } 401 644 402 //....oooOO0OOooo........oooOO0OOooo........oo 645 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 403 646