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 // $Id: G4GammaConversionToMuons.cc,v 1.7 2008/10/16 14:29:48 vnivanch Exp $ >> 28 // GEANT4 tag $Name: geant4-09-02-patch-04 $ >> 29 // 27 // ------------ G4GammaConversionToMuo 30 // ------------ G4GammaConversionToMuons physics process ------ 28 // by H.Burkhardt, S. Kelner and R. Ko 31 // by H.Burkhardt, S. Kelner and R. Kokoulin, April 2002 29 // 32 // 30 // 33 // 31 // 07-08-02: missprint in OR condition in DoIt 34 // 07-08-02: missprint in OR condition in DoIt : f1<0 || f1>f1_max ..etc ... 32 // 25-10-04: migrade to new interfaces of Part 35 // 25-10-04: migrade to new interfaces of ParticleChange (vi) 33 // ------------------------------------------- 36 // --------------------------------------------------------------------------- 34 37 35 #include "G4GammaConversionToMuons.hh" 38 #include "G4GammaConversionToMuons.hh" 36 << 39 #include "G4EnergyLossTables.hh" 37 #include "G4BetheHeitler5DModel.hh" << 38 #include "G4Electron.hh" << 39 #include "G4EmParameters.hh" << 40 #include "G4EmProcessSubType.hh" << 41 #include "G4Exp.hh" << 42 #include "G4Gamma.hh" << 43 #include "G4Log.hh" << 44 #include "G4LossTableManager.hh" << 45 #include "G4MuonMinus.hh" << 46 #include "G4MuonPlus.hh" << 47 #include "G4NistManager.hh" << 48 #include "G4PhysicalConstants.hh" << 49 #include "G4Positron.hh" << 50 #include "G4ProductionCutsTable.hh" << 51 #include "G4SystemOfUnits.hh" << 52 #include "G4UnitsTable.hh" 40 #include "G4UnitsTable.hh" >> 41 #include "G4MuonPlus.hh" >> 42 #include "G4MuonMinus.hh" 53 43 54 //....oooOO0OOooo........oooOO0OOooo........oo 44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 55 45 56 static const G4double sqrte = std::sqrt(std::e << 46 using namespace std; 57 static const G4double PowSat = -0.88; << 58 47 59 G4GammaConversionToMuons::G4GammaConversionToM 48 G4GammaConversionToMuons::G4GammaConversionToMuons(const G4String& processName, 60 G4ProcessType type) << 49 G4ProcessType type):G4VDiscreteProcess (processName, type), 61 : G4VDiscreteProcess (processName, type), << 50 LowestEnergyLimit (4*G4MuonPlus::MuonPlus()->GetPDGMass()), // 4*Mmuon 62 Mmuon(G4MuonPlus::MuonPlus()->GetPDGMass() << 51 HighestEnergyLimit(1e21*eV), // ok to 1e21eV=1e12GeV, then LPM suppression 63 Rc(CLHEP::elm_coupling / Mmuon), << 52 CrossSecFactor(1.) 64 LimitEnergy(5. * Mmuon), << 53 { 65 LowestEnergyLimit(2. * Mmuon), << 54 SetProcessSubType(15); 66 HighestEnergyLimit(1e12 * CLHEP::GeV), // << 67 theGamma(G4Gamma::Gamma()), << 68 theMuonPlus(G4MuonPlus::MuonPlus()), << 69 theMuonMinus(G4MuonMinus::MuonMinus()) << 70 { << 71 SetProcessSubType(fGammaConversionToMuMu); << 72 fManager = G4LossTableManager::Instance(); << 73 fManager->Register(this); << 74 } 55 } 75 56 76 //....oooOO0OOooo........oooOO0OOooo........oo 57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 77 58 78 G4GammaConversionToMuons::~G4GammaConversionTo << 59 // destructor 79 { << 60 80 fManager->DeRegister(this); << 61 G4GammaConversionToMuons::~G4GammaConversionToMuons() // (empty) destructor 81 } << 62 { } 82 63 83 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 84 65 85 G4bool G4GammaConversionToMuons::IsApplicable( << 66 G4bool G4GammaConversionToMuons::IsApplicable( >> 67 const G4ParticleDefinition& particle) 86 { 68 { 87 return (&part == theGamma); << 69 return ( &particle == G4Gamma::Gamma() ); 88 } 70 } 89 71 90 //....oooOO0OOooo........oooOO0OOooo........oo 72 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 91 73 92 void G4GammaConversionToMuons::BuildPhysicsTab << 74 void G4GammaConversionToMuons::BuildPhysicsTable(const G4ParticleDefinition&) 93 { << 75 // Build cross section and mean free path tables 94 Energy5DLimit = G4EmParameters::Instance()-> << 76 { //here no tables, just calling PrintInfoDefinition 95 << 77 PrintInfoDefinition(); 96 auto table = G4Material::GetMaterialTable(); << 97 std::size_t nelm = 0; << 98 for (auto const& mat : *table) { << 99 std::size_t n = mat->GetNumberOfElements() << 100 nelm = std::max(nelm, n); << 101 } << 102 temp.resize(nelm, 0); << 103 << 104 if (Energy5DLimit > 0.0 && nullptr != f5Dmod << 105 f5Dmodel = new G4BetheHeitler5DModel(); << 106 f5Dmodel->SetLeptonPair(theMuonPlus, theMu << 107 const std::size_t numElems = G4ProductionC << 108 const G4DataVector cuts(numElems); << 109 f5Dmodel->Initialise(&p, cuts); << 110 } << 111 PrintInfoDefinition(); << 112 } 78 } 113 79 114 //....oooOO0OOooo........oooOO0OOooo........oo 80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 115 81 116 G4double G4GammaConversionToMuons::GetMeanFree << 82 G4double G4GammaConversionToMuons::GetMeanFreePath(const G4Track& aTrack, 117 << 83 G4double, G4ForceCondition*) >> 84 118 // returns the photon mean free path in GEANT4 85 // returns the photon mean free path in GEANT4 internal units >> 86 // (MeanFreePath is a private member of the class) >> 87 119 { 88 { 120 const G4DynamicParticle* aDynamicGamma = aTr << 89 const G4DynamicParticle* aDynamicGamma = aTrack.GetDynamicParticle(); 121 G4double GammaEnergy = aDynamicGamma->GetKin << 90 G4double GammaEnergy = aDynamicGamma->GetKineticEnergy(); 122 const G4Material* aMaterial = aTrack.GetMate << 91 G4Material* aMaterial = aTrack.GetMaterial(); 123 return ComputeMeanFreePath(GammaEnergy, aMat << 92 >> 93 if (GammaEnergy < LowestEnergyLimit) >> 94 MeanFreePath = DBL_MAX; >> 95 else >> 96 MeanFreePath = ComputeMeanFreePath(GammaEnergy,aMaterial); >> 97 >> 98 return MeanFreePath; 124 } 99 } 125 100 126 //....oooOO0OOooo........oooOO0OOooo........oo 101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 127 102 128 G4double << 103 G4double G4GammaConversionToMuons::ComputeMeanFreePath(G4double GammaEnergy, 129 G4GammaConversionToMuons::ComputeMeanFreePath( << 104 G4Material* aMaterial) 130 << 131 105 132 // computes and returns the photon mean free p 106 // computes and returns the photon mean free path in GEANT4 internal units 133 { 107 { 134 if(GammaEnergy <= LowestEnergyLimit) { retur << 135 const G4ElementVector* theElementVector = aM 108 const G4ElementVector* theElementVector = aMaterial->GetElementVector(); 136 const G4double* NbOfAtomsPerVolume = aMateri 109 const G4double* NbOfAtomsPerVolume = aMaterial->GetVecNbOfAtomsPerVolume(); 137 110 138 G4double SIGMA = 0.0; << 111 G4double SIGMA = 0 ; 139 G4double fact = 1.0; << 140 G4double e = GammaEnergy; << 141 // low energy approximation as in Bethe-Heit << 142 if(e < LimitEnergy) { << 143 G4double y = (e - LowestEnergyLimit)/(Limi << 144 fact = y*y; << 145 e = LimitEnergy; << 146 } << 147 112 148 for ( std::size_t i=0 ; i < aMaterial->GetNu << 113 for ( size_t i=0 ; i < aMaterial->GetNumberOfElements() ; i++ ) 149 { 114 { 150 SIGMA += NbOfAtomsPerVolume[i] * fact * << 115 G4double AtomicZ = (*theElementVector)[i]->GetZ(); 151 ComputeCrossSectionPerAtom(e, (*theEleme << 116 G4double AtomicA = (*theElementVector)[i]->GetA()/(g/mole); >> 117 SIGMA += NbOfAtomsPerVolume[i] * >> 118 ComputeCrossSectionPerAtom(GammaEnergy,AtomicZ,AtomicA); 152 } 119 } 153 return (SIGMA > 0.0) ? 1./SIGMA : DBL_MAX; << 120 return SIGMA > DBL_MIN ? 1./SIGMA : DBL_MAX; 154 } 121 } 155 122 156 //....oooOO0OOooo........oooOO0OOooo........oo 123 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 157 124 158 G4double G4GammaConversionToMuons::GetCrossSec 125 G4double G4GammaConversionToMuons::GetCrossSectionPerAtom( 159 const G4Dyn 126 const G4DynamicParticle* aDynamicGamma, 160 const G4Ele << 127 G4Element* anElement) 161 128 162 // gives the total cross section per atom in G 129 // gives the total cross section per atom in GEANT4 internal units 163 { 130 { 164 return ComputeCrossSectionPerAtom(aDynamicG << 131 G4double GammaEnergy = aDynamicGamma->GetKineticEnergy(); 165 anElement << 132 G4double AtomicZ = anElement->GetZ(); >> 133 G4double AtomicA = anElement->GetA()/(g/mole); >> 134 G4double crossSection = >> 135 ComputeCrossSectionPerAtom(GammaEnergy,AtomicZ,AtomicA); >> 136 return crossSection; 166 } 137 } 167 138 168 //....oooOO0OOooo........oooOO0OOooo........oo 139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 169 140 170 G4double G4GammaConversionToMuons::ComputeCros 141 G4double G4GammaConversionToMuons::ComputeCrossSectionPerAtom( 171 G4double Egam, G4int << 142 G4double Egam, G4double Z, G4double A) 172 143 173 // Calculates the microscopic cross section in 144 // Calculates the microscopic cross section in GEANT4 internal units. 174 // Total cross section parametrisation from H. 145 // Total cross section parametrisation from H.Burkhardt 175 // It gives a good description at any energy ( 146 // It gives a good description at any energy (from 0 to 10**21 eV) 176 { << 147 { static const G4double Mmuon=G4MuonPlus::MuonPlus()->GetPDGMass(); 177 if(Egam <= LowestEnergyLimit) { return 0.0; << 148 static const G4double Mele=electron_mass_c2; 178 << 149 static const G4double Rc=elm_coupling/Mmuon; // classical particle radius 179 G4NistManager* nist = G4NistManager::Instanc << 150 static const G4double sqrte=sqrt(exp(1.)); >> 151 static const G4double PowSat=-0.88; 180 152 181 G4double PowThres, Ecor, B, Dn, Zthird, Winf << 153 static G4double CrossSection = 0.0 ; 182 154 183 if (Z == 1) { // special case of Hydrogen << 155 if ( A < 1. ) return 0; 184 B = 202.4; << 156 if ( Egam < 4*Mmuon ) return 0 ; // below threshold return 0 185 Dn = 1.49; << 186 } << 187 else { << 188 B = 183.; << 189 Dn = 1.54 * nist->GetA27(Z); << 190 } << 191 Zthird = 1. / nist->GetZ13(Z); // Z**(-1/3) << 192 Winfty = B * Zthird * Mmuon / (Dn * electron << 193 WMedAppr = 1. / (4. * Dn * sqrte * Mmuon); << 194 Wsatur = Winfty / WMedAppr; << 195 sigfac = 4. * fine_structure_const * Z * Z * << 196 PowThres = 1.479 + 0.00799 * Dn; << 197 Ecor = -18. + 4347. / (B * Zthird); << 198 << 199 G4double CorFuc = 1. + .04 * G4Log(1. + Ecor << 200 G4double Eg = << 201 G4Exp(G4Log(1. - 4. * Mmuon / Egam) * PowT << 202 * G4Exp(G4Log(G4Exp(G4Log(Wsatur) * PowSat << 203 157 204 G4double CrossSection = 7. / 9. * sigfac * G << 158 static G4double EgamLast=0,Zlast=0,PowThres,Ecor,B,Dn,Zthird,Winfty,WMedAppr, 205 CrossSection *= CrossSecFactor; // increase << 159 Wsatur,sigfac; >> 160 >> 161 if(Zlast==Z && Egam==EgamLast) return CrossSection; // already calculated >> 162 EgamLast=Egam; >> 163 >> 164 if(Zlast!=Z) // new element >> 165 { Zlast=Z; >> 166 if(Z==1) // special case of Hydrogen >> 167 { B=202.4; >> 168 Dn=1.49; >> 169 } >> 170 else >> 171 { B=183.; >> 172 Dn=1.54*pow(A,0.27); >> 173 } >> 174 Zthird=pow(Z,-1./3.); // Z**(-1/3) >> 175 Winfty=B*Zthird*Mmuon/(Dn*Mele); >> 176 WMedAppr=1./(4.*Dn*sqrte*Mmuon); >> 177 Wsatur=Winfty/WMedAppr; >> 178 sigfac=4.*fine_structure_const*Z*Z*Rc*Rc; >> 179 PowThres=1.479+0.00799*Dn; >> 180 Ecor=-18.+4347./(B*Zthird); >> 181 } >> 182 G4double CorFuc=1.+.04*log(1.+Ecor/Egam); >> 183 G4double Eg=pow(1.-4.*Mmuon/Egam,PowThres)*pow( pow(Wsatur,PowSat)+ >> 184 pow(Egam,PowSat),1./PowSat); // threshold and saturation >> 185 CrossSection=7./9.*sigfac*log(1.+WMedAppr*CorFuc*Eg); >> 186 CrossSection*=CrossSecFactor; // increase the CrossSection by (by default 1) 206 return CrossSection; 187 return CrossSection; 207 } 188 } 208 189 209 //....oooOO0OOooo........oooOO0OOooo........oo 190 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 210 191 211 void G4GammaConversionToMuons::SetCrossSecFact 192 void G4GammaConversionToMuons::SetCrossSecFactor(G4double fac) 212 // Set the factor to artificially increase the 193 // Set the factor to artificially increase the cross section 213 { << 194 { CrossSecFactor=fac; 214 if (fac < 0.0) return; << 195 G4cout << "The cross section for GammaConversionToMuons is artificially " 215 CrossSecFactor = fac; << 196 << "increased by the CrossSecFactor=" << CrossSecFactor << G4endl; 216 if (verboseLevel > 1) { << 217 G4cout << "The cross section for GammaConv << 218 << "increased by the CrossSecFactor << 219 } << 220 } 197 } 221 198 222 //....oooOO0OOooo........oooOO0OOooo........oo 199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 223 200 224 G4VParticleChange* G4GammaConversionToMuons::P 201 G4VParticleChange* G4GammaConversionToMuons::PostStepDoIt( 225 202 const G4Track& aTrack, 226 203 const G4Step& aStep) 227 // 204 // 228 // generation of gamma->mu+mu- 205 // generation of gamma->mu+mu- 229 // 206 // 230 { 207 { 231 aParticleChange.Initialize(aTrack); 208 aParticleChange.Initialize(aTrack); 232 const G4Material* aMaterial = aTrack.GetMate << 209 G4Material* aMaterial = aTrack.GetMaterial(); >> 210 >> 211 static const G4double Mmuon=G4MuonPlus::MuonPlus()->GetPDGMass(); >> 212 static const G4double Mele=electron_mass_c2; >> 213 static const G4double sqrte=sqrt(exp(1.)); 233 214 234 // current Gamma energy and direction, retur 215 // current Gamma energy and direction, return if energy too low 235 const G4DynamicParticle* aDynamicGamma = aTr << 216 const G4DynamicParticle *aDynamicGamma = aTrack.GetDynamicParticle(); 236 G4double Egam = aDynamicGamma->GetKineticEne 217 G4double Egam = aDynamicGamma->GetKineticEnergy(); 237 if (Egam <= LowestEnergyLimit) { << 218 if (Egam < 4*Mmuon) return G4VDiscreteProcess::PostStepDoIt(aTrack,aStep); 238 return G4VDiscreteProcess::PostStepDoIt(aT << 239 } << 240 // << 241 // Kill the incident photon << 242 // << 243 aParticleChange.ProposeMomentumDirection( 0. << 244 aParticleChange.ProposeEnergy( 0. ) ; << 245 aParticleChange.ProposeTrackStatus( fStopAnd << 246 << 247 if (Egam <= Energy5DLimit) { << 248 std::vector<G4DynamicParticle*> fvect; << 249 f5Dmodel->SampleSecondaries(&fvect, aTrack << 250 aTrack.GetDynamicParticle(), 0.0, DBL_ << 251 for(auto dp : fvect) { aParticleChange.Add << 252 return G4VDiscreteProcess::PostStepDoIt(aT << 253 } << 254 << 255 G4ParticleMomentum GammaDirection = aDynamic 219 G4ParticleMomentum GammaDirection = aDynamicGamma->GetMomentumDirection(); 256 220 257 // select randomly one element constituting 221 // select randomly one element constituting the material 258 const G4Element* anElement = SelectRandomAto << 222 const G4Element& anElement = *SelectRandomAtom(aDynamicGamma, aMaterial); 259 G4int Z = anElement->GetZasInt(); << 223 G4double Z = anElement.GetZ(); 260 G4NistManager* nist = G4NistManager::Instanc << 224 G4double A = anElement.GetA()/(g/mole); 261 << 225 262 G4double B, Dn; << 226 static G4double Zlast=0,B,Dn,Zthird,Winfty,A027,C1Num2,C2Term2; 263 G4double A027 = nist->GetA27(Z); << 227 if(Zlast!=Z) // the element has changed 264 << 228 { Zlast=Z; 265 if (Z == 1) { // special case of Hydrogen << 229 if(Z==1) // special case of Hydrogen 266 B = 202.4; << 230 { B=202.4; 267 Dn = 1.49; << 231 Dn=1.49; 268 } << 232 } 269 else { << 233 else 270 B = 183.; << 234 { B=183.; 271 Dn = 1.54 * A027; << 235 Dn=1.54*pow(A,0.27); >> 236 } >> 237 Zthird=pow(Z,-1./3.); // Z**(-1/3) >> 238 Winfty=B*Zthird*Mmuon/(Dn*Mele); >> 239 A027=pow(A,0.27); >> 240 G4double C1Num=0.35*A027; >> 241 C1Num2=C1Num*C1Num; >> 242 C2Term2=Mele/(183.*Zthird*Mmuon); 272 } 243 } 273 G4double Zthird = 1. / nist->GetZ13(Z); // << 274 G4double Winfty = B * Zthird * Mmuon / (Dn * << 275 << 276 G4double C1Num = 0.138 * A027; << 277 G4double C1Num2 = C1Num * C1Num; << 278 G4double C2Term2 = electron_mass_c2 / (183. << 279 244 280 G4double GammaMuonInv = Mmuon / Egam; << 245 G4double GammaMuonInv=Mmuon/Egam; >> 246 G4double sqrtx=sqrt(.25-GammaMuonInv); >> 247 G4double xmax=.5+sqrtx; >> 248 G4double xmin=.5-sqrtx; 281 249 282 // generate xPlus according to the different 250 // generate xPlus according to the differential cross section by rejection 283 G4double xmin = (Egam <= LimitEnergy) ? 0.5 << 251 G4double Ds2=(Dn*sqrte-2.); 284 G4double xmax = 1. - xmin; << 252 G4double sBZ=sqrte*B*Zthird/Mele; 285 << 253 G4double LogWmaxInv=1./log(Winfty*(1.+2.*Ds2*GammaMuonInv) 286 G4double Ds2 = (Dn * sqrte - 2.); << 254 /(1.+2.*sBZ*Mmuon*GammaMuonInv)); 287 G4double sBZ = sqrte * B * Zthird / electron << 255 G4double xPlus,xMinus,xPM,result,W; 288 G4double LogWmaxInv = << 256 do 289 1. / G4Log(Winfty * (1. + 2. * Ds2 * Gamma << 257 { xPlus=xmin+G4UniformRand()*(xmax-xmin); 290 G4double xPlus = 0.5; << 258 xMinus=1.-xPlus; 291 G4double xMinus = 0.5; << 259 xPM=xPlus*xMinus; 292 G4double xPM = 0.25; << 260 G4double del=Mmuon*Mmuon/(2.*Egam*xPM); 293 << 261 W=Winfty*(1.+Ds2*del/Mmuon)/(1.+sBZ*del); 294 G4int nn = 0; << 262 if(W<1.) W=1.; // to avoid negative cross section at xmin 295 const G4int nmax = 1000; << 263 G4double xxp=1.-4./3.*xPM; // the main xPlus dependence 296 << 264 result=xxp*log(W)*LogWmaxInv; 297 // sampling for Egam > LimitEnergy << 265 if(result>1.) { 298 if (xmin < 0.5) { << 266 G4cout << "G4GammaConversionToMuons::PostStepDoIt WARNING:" 299 G4double result, W; << 267 << " in dSigxPlusGen, result=" << result << " > 1" << G4endl; 300 do { << 301 xPlus = xmin + G4UniformRand() * (xmax - << 302 xMinus = 1. - xPlus; << 303 xPM = xPlus * xMinus; << 304 G4double del = Mmuon * Mmuon / (2. * Ega << 305 W = Winfty * (1. + Ds2 * del / Mmuon) / << 306 G4double xxp = 1. - 4. / 3. * xPM; // t << 307 result = (xxp > 0.) ? xxp * G4Log(W) * L << 308 if (result > 1.) { << 309 G4cout << "G4GammaConversionToMuons::P << 310 << " in dSigxPlusGen, result=" << 311 } << 312 ++nn; << 313 if(nn >= nmax) { break; } << 314 } 268 } 315 // Loop checking, 07-Aug-2015, Vladimir Iv << 316 while (G4UniformRand() > result); << 317 } 269 } >> 270 while (G4UniformRand() > result); 318 271 319 // now generate the angular variables via th 272 // now generate the angular variables via the auxilary variables t,psi,rho 320 G4double t; 273 G4double t; 321 G4double psi; 274 G4double psi; 322 G4double rho; 275 G4double rho; 323 276 324 G4double a3 = (GammaMuonInv / (2. * xPM)); << 325 G4double a33 = a3 * a3; << 326 G4double f1; << 327 G4double b1 = 1./(4.*C1Num2); << 328 G4double b3 = b1*b1*b1; << 329 G4double a21 = a33 + b1; << 330 << 331 G4double f1_max=-(1.-xPM)*(2.*b1+(a21+a33)*G << 332 << 333 G4double thetaPlus,thetaMinus,phiHalf; // fi 277 G4double thetaPlus,thetaMinus,phiHalf; // final angular variables 334 nn = 0; << 278 335 // t, psi, rho generation start (while angl << 279 do // t, psi, rho generation start (while angle < pi) 336 do { << 280 { 337 //generate t by the rejection method 281 //generate t by the rejection method 338 do { << 282 G4double C1=C1Num2* GammaMuonInv/xPM; 339 ++nn; << 283 G4double f1_max=(1.-xPM) / (1.+C1); 340 t=G4UniformRand(); << 284 G4double f1; // the probability density 341 G4double a34=a33/(t*t); << 285 do 342 G4double a22 = a34 + b1; << 286 { t=G4UniformRand(); 343 if(std::abs(b1)<0.0001*a34) { << 287 f1=(1.-2.*xPM+4.*xPM*t*(1.-t)) / (1.+C1/(t*t)); 344 // special case of a34=a22 because of << 288 if(f1<0 || f1> f1_max) // should never happend 345 f1=(1.-2.*xPM+4.*xPM*t*(1.-t))/(12.*a3 << 289 { 346 } << 290 G4cout << "G4GammaConversionToMuons::PostStepDoIt WARNING:" 347 else { << 291 << "outside allowed range f1=" << f1 << " is set to zero" 348 f1=-(1.-2.*xPM+4.*xPM*t*(1.-t))*(2.*b1 << 292 << G4endl; 349 } << 293 f1 = 0.0; 350 if (f1 < 0.0 || f1 > f1_max) { // shoul << 294 } 351 G4cout << "G4GammaConversionToMuons::P << 295 } 352 << "outside allowed range f1=" << f1 << 296 while ( G4UniformRand()*f1_max > f1); 353 << " is set to zero, a34 = "<< a34 << << 354 << G4endl; << 355 f1 = 0.0; << 356 } << 357 if(nn > nmax) { break; } << 358 // Loop checking, 07-Aug-2015, Vladimir << 359 } while ( G4UniformRand()*f1_max > f1); << 360 // generate psi by the rejection method 297 // generate psi by the rejection method 361 G4double f2_max=1.-2.*xPM*(1.-4.*t*(1.-t)) 298 G4double f2_max=1.-2.*xPM*(1.-4.*t*(1.-t)); >> 299 362 // long version 300 // long version 363 G4double f2; 301 G4double f2; 364 do { << 302 do 365 ++nn; << 303 { psi=2.*pi*G4UniformRand(); 366 psi=twopi*G4UniformRand(); << 304 f2=1.-2.*xPM+4.*xPM*t*(1.-t)*(1.+cos(2.*psi)); 367 f2=1.-2.*xPM+4.*xPM*t*(1.-t)*(1.+std::co << 305 if(f2<0 || f2> f2_max) // should never happend 368 if(f2<0 || f2> f2_max) { // should never << 306 { 369 G4cout << "G4GammaConversionToMuons::P << 307 G4cout << "G4GammaConversionToMuons::PostStepDoIt WARNING:" 370 << "outside allowed range f2=" << 308 << "outside allowed range f2=" << f2 << " is set to zero" 371 f2 = 0.0; << 309 << G4endl; 372 } << 310 f2 = 0.0; 373 if(nn >= nmax) { break; } << 311 } 374 // Loop checking, 07-Aug-2015, Vladimir << 312 } 375 } while ( G4UniformRand()*f2_max > f2); << 313 while ( G4UniformRand()*f2_max > f2); 376 314 377 // generate rho by direct transformation 315 // generate rho by direct transformation 378 G4double C2Term1=GammaMuonInv/(2.*xPM*t); 316 G4double C2Term1=GammaMuonInv/(2.*xPM*t); 379 G4double C22 = C2Term1*C2Term1+C2Term2*C2T << 317 G4double C2=4./sqrt(xPM)*pow(C2Term1*C2Term1+C2Term2*C2Term2,2.); 380 G4double C2=4.*C22*C22/std::sqrt(xPM); << 318 G4double rhomax=1.9/A027*(1./t-1.); 381 G4double rhomax=(1./t-1.)*1.9/A027; << 319 G4double beta=log( (C2+pow(rhomax,4.))/C2 ); 382 G4double beta=G4Log( (C2+rhomax*rhomax*rho << 320 rho=pow(C2 *( exp(beta*G4UniformRand())-1. ) ,0.25); 383 rho=G4Exp(G4Log(C2 *( G4Exp(beta*G4Uniform << 384 321 385 //now get from t and psi the kinematical v 322 //now get from t and psi the kinematical variables 386 G4double u=std::sqrt(1./t-1.); << 323 G4double u=sqrt(1./t-1.); 387 G4double xiHalf=0.5*rho*std::cos(psi); << 324 G4double xiHalf=0.5*rho*cos(psi); 388 phiHalf=0.5*rho/u*std::sin(psi); << 325 phiHalf=0.5*rho/u*sin(psi); 389 326 390 thetaPlus =GammaMuonInv*(u+xiHalf)/xPlus; 327 thetaPlus =GammaMuonInv*(u+xiHalf)/xPlus; 391 thetaMinus=GammaMuonInv*(u-xiHalf)/xMinus; 328 thetaMinus=GammaMuonInv*(u-xiHalf)/xMinus; 392 329 393 // protection against infinite loop << 394 if(nn > nmax) { << 395 if(std::abs(thetaPlus)>pi) { thetaPlus = << 396 if(std::abs(thetaMinus)>pi) { thetaMinus << 397 } << 398 << 399 // Loop checking, 07-Aug-2015, Vladimir Iv << 400 } while ( std::abs(thetaPlus)>pi || std::abs 330 } while ( std::abs(thetaPlus)>pi || std::abs(thetaMinus) >pi); 401 331 402 // now construct the vectors 332 // now construct the vectors 403 // azimuthal symmetry, take phi0 at random b 333 // azimuthal symmetry, take phi0 at random between 0 and 2 pi 404 G4double phi0=twopi*G4UniformRand(); << 334 G4double phi0=2.*pi*G4UniformRand(); 405 G4double EPlus=xPlus*Egam; 335 G4double EPlus=xPlus*Egam; 406 G4double EMinus=xMinus*Egam; 336 G4double EMinus=xMinus*Egam; 407 337 408 // mu+ mu- directions for gamma in z-directi 338 // mu+ mu- directions for gamma in z-direction 409 G4ThreeVector MuPlusDirection ( std::sin(th << 339 G4ThreeVector MuPlusDirection ( sin(thetaPlus) *cos(phi0+phiHalf), 410 std::sin(thetaPlus) *std:: << 340 sin(thetaPlus) *sin(phi0+phiHalf), cos(thetaPlus) ); 411 G4ThreeVector MuMinusDirection (-std::sin(th << 341 G4ThreeVector MuMinusDirection (-sin(thetaMinus)*cos(phi0-phiHalf), 412 -std::sin(thetaMinus) *std:: << 342 -sin(thetaMinus) *sin(phi0-phiHalf), cos(thetaMinus) ); 413 // rotate to actual gamma direction 343 // rotate to actual gamma direction 414 MuPlusDirection.rotateUz(GammaDirection); 344 MuPlusDirection.rotateUz(GammaDirection); 415 MuMinusDirection.rotateUz(GammaDirection); 345 MuMinusDirection.rotateUz(GammaDirection); 416 << 346 aParticleChange.SetNumberOfSecondaries(2); 417 // create G4DynamicParticle object for the p 347 // create G4DynamicParticle object for the particle1 418 auto aParticle1 = new G4DynamicParticle(theM << 348 G4DynamicParticle* aParticle1= new G4DynamicParticle( >> 349 G4MuonPlus::MuonPlus(),MuPlusDirection,EPlus-Mmuon); 419 aParticleChange.AddSecondary(aParticle1); 350 aParticleChange.AddSecondary(aParticle1); 420 // create G4DynamicParticle object for the p 351 // create G4DynamicParticle object for the particle2 421 auto aParticle2 = new G4DynamicParticle(theM << 352 G4DynamicParticle* aParticle2= new G4DynamicParticle( >> 353 G4MuonMinus::MuonMinus(),MuMinusDirection,EMinus-Mmuon); 422 aParticleChange.AddSecondary(aParticle2); 354 aParticleChange.AddSecondary(aParticle2); >> 355 // >> 356 // Kill the incident photon >> 357 // >> 358 aParticleChange.ProposeMomentumDirection( 0., 0., 0. ) ; >> 359 aParticleChange.ProposeEnergy( 0. ) ; >> 360 aParticleChange.ProposeTrackStatus( fStopAndKill ) ; 423 // Reset NbOfInteractionLengthLeft and retu 361 // Reset NbOfInteractionLengthLeft and return aParticleChange 424 return G4VDiscreteProcess::PostStepDoIt( aTr 362 return G4VDiscreteProcess::PostStepDoIt( aTrack, aStep ); 425 } 363 } 426 364 427 //....oooOO0OOooo........oooOO0OOooo........oo 365 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 428 366 429 const G4Element* G4GammaConversionToMuons::Sel << 367 G4Element* G4GammaConversionToMuons::SelectRandomAtom( 430 const G4DynamicParticle* aDynamicGamma, << 368 const G4DynamicParticle* aDynamicGamma, 431 const G4Material* aMaterial) << 369 G4Material* aMaterial) 432 { 370 { 433 // select randomly 1 element within the mate 371 // select randomly 1 element within the material, invoked by PostStepDoIt 434 372 435 const std::size_t NumberOfElements = aM << 373 const G4int NumberOfElements = aMaterial->GetNumberOfElements(); 436 const G4ElementVector* theElementVector = aM 374 const G4ElementVector* theElementVector = aMaterial->GetElementVector(); 437 const G4Element* elm = (*theElementVector)[0 << 375 if (NumberOfElements == 1) return (*theElementVector)[0]; 438 376 439 if (NumberOfElements > 1) { << 377 const G4double* NbOfAtomsPerVolume = aMaterial->GetVecNbOfAtomsPerVolume(); 440 G4double e = std::max(aDynamicGamma->GetKi << 378 441 const G4double* natom = aMaterial->GetVecN << 379 G4double PartialSumSigma = 0. ; 442 << 380 G4double rval = G4UniformRand()/MeanFreePath; 443 G4double sum = 0.; << 381 444 for (std::size_t i=0; i<NumberOfElements; << 382 445 elm = (*theElementVector)[i]; << 383 for ( G4int i=0 ; i < NumberOfElements ; i++ ) 446 sum += natom[i]*ComputeCrossSectionPerAt << 384 { PartialSumSigma += NbOfAtomsPerVolume[i] * 447 temp[i] = sum; << 385 GetCrossSectionPerAtom(aDynamicGamma, (*theElementVector)[i]); 448 } << 386 if (rval <= PartialSumSigma) return ((*theElementVector)[i]); 449 sum *= G4UniformRand(); << 450 for (std::size_t i=0; i<NumberOfElements; << 451 if(sum <= temp[i]) { << 452 elm = (*theElementVector)[i]; << 453 break; << 454 } 387 } 455 } << 388 G4cout << " WARNING !!! - The Material '"<< aMaterial->GetName() 456 } << 389 << "' has no elements, NULL pointer returned." << G4endl; 457 return elm; << 390 return NULL; 458 } 391 } 459 392 460 //....oooOO0OOooo........oooOO0OOooo........oo 393 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 461 394 462 void G4GammaConversionToMuons::PrintInfoDefini 395 void G4GammaConversionToMuons::PrintInfoDefinition() 463 { 396 { 464 G4String comments = "gamma->mu+mu- Bethe Hei << 397 G4String comments ="gamma->mu+mu- Bethe Heitler process, SubType= "; 465 G4cout << G4endl << GetProcessName() << ": << 398 G4cout << G4endl << GetProcessName() << ": " << comments >> 399 << GetProcessSubType() << G4endl; 466 G4cout << " good cross section parame 400 G4cout << " good cross section parametrization from " 467 << G4BestUnit(LowestEnergyLimit, "Ene << 401 << G4BestUnit(LowestEnergyLimit,"Energy") 468 << " GeV for all Z." << G4endl; << 402 << " to " << HighestEnergyLimit/GeV << " GeV for all Z." << G4endl; 469 G4cout << " cross section factor: " < << 470 } 403 } 471 404 472 //....oooOO0OOooo........oooOO0OOooo........oo 405 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 473 406