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 // >> 27 // $Id: G4SynchrotronRadiation.cc,v 1.5 2006/06/29 19:56:15 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-09-03-patch-02 $ >> 29 // 26 // ------------------------------------------- 30 // -------------------------------------------------------------- 27 // GEANT 4 class implementation file 31 // GEANT 4 class implementation file >> 32 // CERN Geneva Switzerland 28 // 33 // 29 // History: first implementation, << 34 // History: first implementation, 30 // 21-5-98 V.Grichine 35 // 21-5-98 V.Grichine 31 // 28-05-01, V.Ivanchenko minor changes t << 36 // 28-05-01, V.Ivanchenko minor changes to provide ANSI -wall compilation 32 // 04.03.05, V.Grichine: get local field << 37 // 04.03.05, V.Grichine: get local field interface 33 // 18-05-06 H. Burkhardt: Energy spectrum 38 // 18-05-06 H. Burkhardt: Energy spectrum from function rather than table >> 39 // >> 40 // >> 41 // 34 // 42 // 35 ////////////////////////////////////////////// 43 /////////////////////////////////////////////////////////////////////////// 36 44 37 #include "G4SynchrotronRadiation.hh" 45 #include "G4SynchrotronRadiation.hh" 38 << 46 // #include "G4Integrator.hh" 39 #include "G4DipBustGenerator.hh" << 40 #include "G4Electron.hh" << 41 #include "G4EmProcessSubType.hh" << 42 #include "G4Log.hh" << 43 #include "G4LossTableManager.hh" << 44 #include "G4Gamma.hh" << 45 #include "G4PhysicalConstants.hh" << 46 #include "G4PropagatorInField.hh" << 47 #include "G4SystemOfUnits.hh" << 48 #include "G4TransportationManager.hh" << 49 #include "G4UnitsTable.hh" 47 #include "G4UnitsTable.hh" 50 #include "G4PhysicsModelCatalog.hh" << 48 >> 49 using namespace std; 51 50 52 ////////////////////////////////////////////// 51 /////////////////////////////////////////////////////////////////////// >> 52 // 53 // Constructor 53 // Constructor >> 54 // >> 55 54 G4SynchrotronRadiation::G4SynchrotronRadiation 56 G4SynchrotronRadiation::G4SynchrotronRadiation(const G4String& processName, 55 << 57 G4ProcessType type):G4VDiscreteProcess (processName, type), 56 : G4VDiscreteProcess(processName, type) << 58 theGamma (G4Gamma::Gamma() ), 57 , theGamma(G4Gamma::Gamma()) << 59 theElectron ( G4Electron::Electron() ), >> 60 thePositron ( G4Positron::Positron() ) 58 { 61 { 59 G4TransportationManager* transportMgr = << 62 G4TransportationManager* transportMgr = 60 G4TransportationManager::GetTransportation 63 G4TransportationManager::GetTransportationManager(); 61 64 62 fFieldPropagator = transportMgr->GetPropagat 65 fFieldPropagator = transportMgr->GetPropagatorInField(); 63 66 64 secID = G4PhysicsModelCatalog::GetModelID("m << 67 fLambdaConst = sqrt(3.0)*electron_mass_c2/ 65 SetProcessSubType(fSynchrotronRadiation); << 68 (2.5*fine_structure_const*eplus*c_light) ; 66 verboseLevel = 1; << 69 fEnergyConst = 1.5*c_light*c_light*eplus*hbar_Planck/electron_mass_c2 ; 67 FirstTime = true; << 70 verboseLevel=1; 68 FirstTime1 = true; << 69 genAngle = nullptr; << 70 SetAngularGenerator(new G4DipBustGenerator() << 71 theManager = G4LossTableManager::Instance(); << 72 theManager->Register(this); << 73 } 71 } 74 72 75 ////////////////////////////////////////////// 73 ///////////////////////////////////////////////////////////////////////// >> 74 // 76 // Destructor 75 // Destructor >> 76 // >> 77 77 G4SynchrotronRadiation::~G4SynchrotronRadiatio 78 G4SynchrotronRadiation::~G4SynchrotronRadiation() 78 { 79 { 79 delete genAngle; << 80 ; 80 theManager->DeRegister(this); << 81 } 81 } 82 82 83 /////////////////////////////// METHODS ////// 83 /////////////////////////////// METHODS ///////////////////////////////// >> 84 // >> 85 // >> 86 // Production of synchrotron X-ray photon >> 87 // GEANT4 internal units. >> 88 // 84 89 85 void G4SynchrotronRadiation::SetAngularGenerat << 86 { << 87 if(p != genAngle) << 88 { << 89 delete genAngle; << 90 genAngle = p; << 91 } << 92 } << 93 << 94 G4bool G4SynchrotronRadiation::IsApplicable( << 95 const G4ParticleDefinition& particle) << 96 { << 97 return (particle.GetPDGCharge() != 0.0 && !p << 98 } << 99 90 100 ////////////////////////////////////////////// << 91 G4double 101 // Production of synchrotron X-ray photon << 92 G4SynchrotronRadiation::GetMeanFreePath( const G4Track& trackData, 102 // Geant4 internal units. << 93 G4double, 103 G4double G4SynchrotronRadiation::GetMeanFreePa << 94 G4ForceCondition* condition) 104 << 105 << 106 { 95 { 107 // gives the MeanFreePath in Geant4 internal << 96 // gives the MeanFreePath in GEANT4 internal units 108 G4double MeanFreePath = DBL_MAX; << 97 G4double MeanFreePath; 109 98 110 const G4DynamicParticle* aDynamicParticle = 99 const G4DynamicParticle* aDynamicParticle = trackData.GetDynamicParticle(); 111 100 112 *condition = NotForced; << 101 *condition = NotForced ; 113 102 114 G4double gamma = << 103 G4double gamma = aDynamicParticle->GetTotalEnergy()/ 115 aDynamicParticle->GetTotalEnergy() / aDyna << 104 aDynamicParticle->GetMass(); 116 105 117 G4double particleCharge = aDynamicParticle-> 106 G4double particleCharge = aDynamicParticle->GetDefinition()->GetPDGCharge(); 118 107 119 if(gamma < 1.0e3 || 0.0 == particleCharge) << 108 if ( gamma < 1.0e3 ) MeanFreePath = DBL_MAX; 120 { << 121 MeanFreePath = DBL_MAX; << 122 } << 123 else 109 else 124 { 110 { 125 G4ThreeVector FieldValue; << 126 const G4Field* pField = nullptr; << 127 G4bool fieldExertsForce = false; << 128 111 129 G4FieldManager* fieldMgr = << 112 G4ThreeVector FieldValue; 130 fFieldPropagator->FindAndSetFieldManager << 113 const G4Field* pField = 0; >> 114 >> 115 G4FieldManager* fieldMgr=0; >> 116 G4bool fieldExertsForce = false; 131 117 132 if(fieldMgr != nullptr) << 118 if( (particleCharge != 0.0) ) 133 { 119 { 134 // If the field manager has no field, th << 120 fieldMgr = fFieldPropagator->FindAndSetFieldManager( trackData.GetVolume() ); 135 fieldExertsForce = (fieldMgr->GetDetecto << 136 } << 137 121 138 if(fieldExertsForce) << 122 if ( fieldMgr != 0 ) >> 123 { >> 124 // If the field manager has no field, there is no field ! >> 125 >> 126 fieldExertsForce = ( fieldMgr->GetDetectorField() != 0 ); >> 127 } >> 128 } >> 129 if ( fieldExertsForce ) 139 { 130 { 140 pField = fieldMgr->G << 131 pField = fieldMgr->GetDetectorField() ; 141 G4ThreeVector globPosition = trackData.G << 132 G4ThreeVector globPosition = trackData.GetPosition(); 142 133 143 G4double globPosVec[4], FieldValueVec[6] << 134 G4double globPosVec[3], FieldValueVec[3]; 144 135 145 globPosVec[0] = globPosition.x(); 136 globPosVec[0] = globPosition.x(); 146 globPosVec[1] = globPosition.y(); 137 globPosVec[1] = globPosition.y(); 147 globPosVec[2] = globPosition.z(); 138 globPosVec[2] = globPosition.z(); 148 globPosVec[3] = trackData.GetGlobalTime( << 149 139 150 pField->GetFieldValue(globPosVec, FieldV << 140 pField->GetFieldValue( globPosVec, FieldValueVec ); >> 141 >> 142 FieldValue = G4ThreeVector( FieldValueVec[0], >> 143 FieldValueVec[1], >> 144 FieldValueVec[2] ); >> 145 151 146 152 FieldValue = << 153 G4ThreeVector(FieldValueVec[0], FieldV << 154 147 155 G4ThreeVector unitMomentum = aDynamicPar 148 G4ThreeVector unitMomentum = aDynamicParticle->GetMomentumDirection(); 156 G4ThreeVector unitMcrossB = FieldValue. << 149 G4ThreeVector unitMcrossB = FieldValue.cross(unitMomentum) ; 157 G4double perpB = unitMcrossB << 150 G4double perpB = unitMcrossB.mag() ; 158 151 159 static const G4double fLambdaConst = << 152 if( perpB > 0.0 ) MeanFreePath = fLambdaConst/perpB; 160 std::sqrt(3.0) * eplus / (2.5 * fine_s << 153 else MeanFreePath = DBL_MAX; 161 154 162 if(perpB > 0.0) << 155 static G4bool FirstTime=true; 163 { << 164 MeanFreePath = fLambdaConst * << 165 aDynamicParticle->GetDe << 166 (perpB * particleCharge << 167 } << 168 if(verboseLevel > 0 && FirstTime) 156 if(verboseLevel > 0 && FirstTime) 169 { 157 { 170 G4cout << "G4SynchrotronRadiation::Get << 158 G4cout << "G4SynchrotronRadiation::GetMeanFreePath :" << '\n' << std::setprecision(4) 171 << " for particle " << 159 << " MeanFreePath = " << G4BestUnit(MeanFreePath, "Length") 172 << aDynamicParticle->GetDefinit << 160 << G4endl; 173 << '\n' << 174 << " MeanFreePath = " << G4Bes << 175 << G4endl; << 176 if(verboseLevel > 1) 161 if(verboseLevel > 1) 177 { 162 { 178 G4ThreeVector pvec = aDynamicParticl << 163 G4ThreeVector pvec=aDynamicParticle->GetMomentum(); 179 G4double Btot = FieldValue.getR << 164 G4double Btot=FieldValue.getR(); 180 G4double ptot = pvec.getR(); << 165 G4double ptot=pvec.getR(); 181 G4double rho = ptot / (MeV * c << 166 G4double rho= ptot / (MeV * c_light * Btot ); // full bending radius 182 // full bending radius << 167 G4double Theta=unitMomentum.theta(FieldValue); // angle between particle and field 183 G4double Theta = unitMomentum.theta( << 168 G4cout 184 // angle between particle and field << 169 << " B = " << Btot/tesla << " Tesla" 185 G4cout << " B = " << Btot / tesla < << 170 << " perpB = " << perpB/tesla << " Tesla" 186 << " perpB = " << perpB / te << 171 << " Theta = " << Theta << " sin(Theta)=" << sin(Theta) << '\n' 187 << " Theta = " << Theta << 172 << " ptot = " << G4BestUnit(ptot,"Energy") 188 << " std::sin(Theta)=" << std << 173 << " rho = " << G4BestUnit(rho,"Length") 189 << " ptot = " << G4BestUnit << 174 << G4endl; 190 << " rho = " << G4BestUnit << 191 } 175 } 192 FirstTime = false; << 176 FirstTime=false; 193 } 177 } 194 } 178 } >> 179 else MeanFreePath = DBL_MAX; >> 180 >> 181 195 } 182 } >> 183 196 return MeanFreePath; 184 return MeanFreePath; 197 } 185 } 198 186 199 ////////////////////////////////////////////// << 187 //////////////////////////////////////////////////////////////////////////////// 200 G4VParticleChange* G4SynchrotronRadiation::Pos << 188 // 201 const G4Track& trackData, const G4Step& step << 189 // >> 190 >> 191 G4VParticleChange* >> 192 G4SynchrotronRadiation::PostStepDoIt(const G4Track& trackData, >> 193 const G4Step& stepData ) 202 194 203 { 195 { 204 aParticleChange.Initialize(trackData); 196 aParticleChange.Initialize(trackData); 205 197 206 const G4DynamicParticle* aDynamicParticle = << 198 const G4DynamicParticle* aDynamicParticle=trackData.GetDynamicParticle(); 207 199 208 G4double gamma = aDynamicParticle->GetTotalE << 200 G4double gamma = aDynamicParticle->GetTotalEnergy()/ 209 (aDynamicParticle->GetDefin << 201 (aDynamicParticle->GetMass() ); 210 202 211 G4double particleCharge = aDynamicParticle-> << 203 if(gamma <= 1.0e3 ) 212 if(gamma <= 1.0e3 || 0.0 == particleCharge) << 213 { 204 { 214 return G4VDiscreteProcess::PostStepDoIt(tr << 205 return G4VDiscreteProcess::PostStepDoIt(trackData,stepData); 215 } 206 } >> 207 G4double particleCharge = aDynamicParticle->GetDefinition()->GetPDGCharge(); 216 208 217 G4ThreeVector FieldValue; << 209 G4ThreeVector FieldValue; 218 const G4Field* pField = nullptr; << 210 const G4Field* pField = 0 ; 219 211 220 G4bool fieldExertsForce = false; << 212 G4FieldManager* fieldMgr=0; 221 G4FieldManager* fieldMgr = << 213 G4bool fieldExertsForce = false; 222 fFieldPropagator->FindAndSetFieldManager(t << 223 214 224 if(fieldMgr != nullptr) << 215 if( (particleCharge != 0.0) ) 225 { 216 { 226 // If the field manager has no field, ther << 217 fieldMgr = fFieldPropagator->FindAndSetFieldManager( trackData.GetVolume() ); 227 fieldExertsForce = (fieldMgr->GetDetectorF << 218 if ( fieldMgr != 0 ) 228 } << 219 { >> 220 // If the field manager has no field, there is no field ! 229 221 230 if(fieldExertsForce) << 222 fieldExertsForce = ( fieldMgr->GetDetectorField() != 0 ); >> 223 } >> 224 } >> 225 if ( fieldExertsForce ) 231 { 226 { 232 pField = fieldMgr->Get << 227 pField = fieldMgr->GetDetectorField() ; 233 G4ThreeVector globPosition = trackData.Get << 228 G4ThreeVector globPosition = trackData.GetPosition() ; 234 G4double globPosVec[4], FieldValueVec[6]; << 229 G4double globPosVec[3], FieldValueVec[3] ; 235 globPosVec[0] = globPosition.x(); << 230 globPosVec[0] = globPosition.x() ; 236 globPosVec[1] = globPosition.y(); << 231 globPosVec[1] = globPosition.y() ; 237 globPosVec[2] = globPosition.z(); << 232 globPosVec[2] = globPosition.z() ; 238 globPosVec[3] = trackData.GetGlobalTime(); << 233 239 << 234 pField->GetFieldValue( globPosVec, FieldValueVec ) ; 240 pField->GetFieldValue(globPosVec, FieldVal << 235 FieldValue = G4ThreeVector( FieldValueVec[0], 241 FieldValue = << 236 FieldValueVec[1], 242 G4ThreeVector(FieldValueVec[0], FieldVal << 237 FieldValueVec[2] ); 243 238 244 G4ThreeVector unitMomentum = aDynamicParti 239 G4ThreeVector unitMomentum = aDynamicParticle->GetMomentumDirection(); 245 G4ThreeVector unitMcrossB = FieldValue.cr << 240 G4ThreeVector unitMcrossB = FieldValue.cross(unitMomentum); 246 G4double perpB = unitMcrossB.m << 241 G4double perpB = unitMcrossB.mag() ; 247 if(perpB > 0.0) 242 if(perpB > 0.0) 248 { 243 { 249 // M-C of synchrotron photon energy 244 // M-C of synchrotron photon energy 250 G4double energyOfSR = GetRandomEnergySR( << 245 251 gamma, perpB, aDynamicParticle->GetDef << 246 G4double energyOfSR = GetRandomEnergySR(gamma,perpB); 252 247 253 // check against insufficient energy 248 // check against insufficient energy 254 if(energyOfSR <= 0.0) << 249 >> 250 if( energyOfSR <= 0.0 ) 255 { 251 { 256 return G4VDiscreteProcess::PostStepDoI << 252 return G4VDiscreteProcess::PostStepDoIt(trackData,stepData); 257 } 253 } 258 G4double kineticEnergy = aDynamicParticl 254 G4double kineticEnergy = aDynamicParticle->GetKineticEnergy(); 259 G4ThreeVector gammaDirection = << 255 G4ParticleMomentum 260 genAngle->SampleDirection(aDynamicPart << 256 particleDirection = aDynamicParticle->GetMomentumDirection(); >> 257 >> 258 // M-C of its direction >> 259 >> 260 G4double Teta = G4UniformRand()/gamma ; // Very roughly >> 261 >> 262 G4double Phi = twopi * G4UniformRand() ; >> 263 >> 264 G4double dirx = sin(Teta)*cos(Phi) , >> 265 diry = sin(Teta)*sin(Phi) , >> 266 dirz = cos(Teta) ; >> 267 >> 268 G4ThreeVector gammaDirection ( dirx, diry, dirz); >> 269 gammaDirection.rotateUz(particleDirection); >> 270 >> 271 // polarization of new gamma >> 272 >> 273 // G4double sx = cos(Teta)*cos(Phi); >> 274 // G4double sy = cos(Teta)*sin(Phi); >> 275 // G4double sz = -sin(Teta); 261 276 262 G4ThreeVector gammaPolarization = FieldV 277 G4ThreeVector gammaPolarization = FieldValue.cross(gammaDirection); 263 gammaPolarization = gammaP << 278 gammaPolarization = gammaPolarization.unit(); >> 279 >> 280 // (sx, sy, sz); >> 281 // gammaPolarization.rotateUz(particleDirection); 264 282 265 // create G4DynamicParticle object for t 283 // create G4DynamicParticle object for the SR photon 266 auto aGamma = << 284 267 new G4DynamicParticle(theGamma, gammaD << 285 G4DynamicParticle* aGamma= new G4DynamicParticle ( theGamma, 268 aGamma->SetPolarization(gammaPolarizatio << 286 gammaDirection, 269 gammaPolarizatio << 287 energyOfSR ); >> 288 aGamma->SetPolarization( gammaPolarization.x(), >> 289 gammaPolarization.y(), >> 290 gammaPolarization.z() ); >> 291 270 292 271 aParticleChange.SetNumberOfSecondaries(1 293 aParticleChange.SetNumberOfSecondaries(1); >> 294 aParticleChange.AddSecondary(aGamma); 272 295 273 // Update the incident particle 296 // Update the incident particle 274 G4double newKinEnergy = kineticEnergy - << 275 297 276 if(newKinEnergy > 0.) << 298 G4double newKinEnergy = kineticEnergy - energyOfSR ; >> 299 aParticleChange.ProposeLocalEnergyDeposit (0.); >> 300 >> 301 if (newKinEnergy > 0.) 277 { 302 { 278 aParticleChange.ProposeEnergy(newKinEn << 303 aParticleChange.ProposeMomentumDirection( particleDirection ); >> 304 aParticleChange.ProposeEnergy( newKinEnergy ); 279 } 305 } 280 else 306 else 281 { 307 { 282 aParticleChange.ProposeEnergy(0.); << 308 aParticleChange.ProposeEnergy( 0. ); 283 } 309 } 284 << 285 // Create the G4Track << 286 G4Track* aSecondaryTrack = new G4Track(a << 287 aSecondaryTrack->SetTouchableHandle(step << 288 aSecondaryTrack->SetParentID(trackData.G << 289 aSecondaryTrack->SetCreatorModelID(secID << 290 aParticleChange.AddSecondary(aSecondaryT << 291 << 292 } 310 } 293 } 311 } 294 return G4VDiscreteProcess::PostStepDoIt(trac << 312 return G4VDiscreteProcess::PostStepDoIt(trackData,stepData); 295 } 313 } 296 314 297 ////////////////////////////////////////////// << 315 >> 316 ///////////////////////////////////////////////////////////////////////////////// >> 317 // >> 318 // >> 319 298 G4double G4SynchrotronRadiation::InvSynFracInt 320 G4double G4SynchrotronRadiation::InvSynFracInt(G4double x) 299 // direct generation 321 // direct generation 300 { 322 { 301 // from 0 to 0.7 323 // from 0 to 0.7 302 static constexpr G4double aa1 = 0; << 324 const G4double aa1=0 ,aa2=0.7; 303 static constexpr G4double aa2 = 0. << 325 const G4int ncheb1=27; 304 static constexpr G4int ncheb1 = 27 << 326 static const G4double cheb1[] = 305 static constexpr G4double cheb1[ncheb1] = { << 327 { 1.22371665676046468821,0.108956475422163837267,0.0383328524358594396134,0.00759138369340257753721, 306 1.22371665676046468821, 0.108956475422 << 328 0.00205712048644963340914,0.000497810783280019308661,0.000130743691810302187818,0.0000338168760220395409734, 307 0.0383328524358594396134, 0.007591383693 << 329 8.97049680900520817728e-6,2.38685472794452241466e-6,6.41923109149104165049e-7,1.73549898982749277843e-7, 308 0.00205712048644963340914, 0.000497810783 << 330 4.72145949240790029153e-8,1.29039866111999149636e-8,3.5422080787089834182e-9,9.7594757336403784905e-10, 309 0.000130743691810302187818, 0.000033816876 << 331 2.6979510184976065731e-10,7.480422622550977077e-11,2.079598176402699913e-11,5.79533622220841193e-12, 310 8.97049680900520817728e-6, 2.386854727944 << 332 1.61856011449276096e-12,4.529450993473807e-13,1.2698603951096606e-13,3.566117394511206e-14,1.00301587494091e-14, 311 6.41923109149104165049e-7, 1.735498989827 << 333 2.82515346447219e-15,7.9680747949792e-16}; 312 4.72145949240790029153e-8, 1.290398661119 << 313 3.5422080787089834182e-9, 9.759475733640 << 314 2.6979510184976065731e-10, 7.480422622550 << 315 2.079598176402699913e-11, 5.795336222208 << 316 1.61856011449276096e-12, 4.529450993473 << 317 1.2698603951096606e-13, 3.566117394511 << 318 1.00301587494091e-14, 2.825153464472 << 319 7.9680747949792e-16 << 320 }; << 321 // from 0.7 to 0.9132260271183847 334 // from 0.7 to 0.9132260271183847 322 static constexpr G4double aa3 = 0. << 335 const G4double aa3=0.9132260271183847; 323 static constexpr G4int ncheb2 = 27 << 336 const G4int ncheb2=27; 324 static constexpr G4double cheb2[ncheb2] = { << 337 static const G4double cheb2[] = 325 1.1139496701107756, 0.3523967429328067 << 338 { 1.1139496701107756,0.3523967429328067,0.0713849171926623,0.01475818043595387,0.003381255637322462, 326 0.01475818043595387, 0.0033812556373224 << 339 0.0008228057599452224,0.00020785506681254216,0.00005390169253706556,0.000014250571923902464,3.823880733161044e-6, 327 0.00020785506681254216, 0.0000539016925370 << 340 1.0381966089136036e-6,2.8457557457837253e-7,7.86223332179956e-8,2.1866609342508474e-8,6.116186259857143e-9, 328 3.823880733161044e-6, 1.0381966089136036 << 341 1.7191233618437565e-9,4.852755117740807e-10,1.3749966961763457e-10,3.908961987062447e-11,1.1146253766895824e-11, 329 7.86223332179956e-8, 2.1866609342508474 << 342 3.1868887323415814e-12,9.134319791300977e-13,2.6211077371181566e-13,7.588643377757906e-14,2.1528376972619e-14, 330 1.7191233618437565e-9, 4.852755117740807e << 343 6.030906040404772e-15,1.9549163926819867e-15}; 331 3.908961987062447e-11, 1.1146253766895824 << 344 // Chebyshev with exp/log scale 332 9.134319791300977e-13, 2.6211077371181566 << 345 // a = -Log[1 - SynFracInt[1]]; b = -Log[1 - SynFracInt[7]]; 333 2.1528376972619e-14, 6.030906040404772e << 346 const G4double aa4=2.4444485538746025480,aa5=9.3830728608909477079; 334 }; << 347 const G4int ncheb3=28; 335 // Chebyshev with exp/log scale << 348 static const G4double cheb3[] = 336 // a = -Log[1 - SynFracInt[1]]; b = -Log[1 - << 349 { 1.2292683840435586977,0.160353449247864455879,-0.0353559911947559448721,0.00776901561223573936985, 337 static constexpr G4double aa4 = 2. << 350 -0.00165886451971685133259,0.000335719118906954279467,-0.0000617184951079161143187,9.23534039743246708256e-6, 338 static constexpr G4double aa5 = 9. << 351 -6.06747198795168022842e-7,-3.07934045961999778094e-7,1.98818772614682367781e-7,-8.13909971567720135413e-8, 339 static constexpr G4int ncheb3 = 28 << 352 2.84298174969641838618e-8,-9.12829766621316063548e-9,2.77713868004820551077e-9,-8.13032767247834023165e-10, 340 static constexpr G4double cheb3[ncheb3] = { << 353 2.31128525568385247392e-10,-6.41796873254200220876e-11,1.74815310473323361543e-11,-4.68653536933392363045e-12, 341 1.2292683840435586977, 0.1603534492 << 354 1.24016595805520752748e-12,-3.24839432979935522159e-13,8.44601465226513952994e-14,-2.18647276044246803998e-14, 342 -0.0353559911947559448721, 0.0077690156 << 355 5.65407548745690689978e-15,-1.46553625917463067508e-15,3.82059606377570462276e-16,-1.00457896653436912508e-16}; 343 -0.00165886451971685133259, 0.0003357191 << 356 const G4double aa6=33.122936966163038145; 344 -0.0000617184951079161143187, 9.2353403974 << 357 const G4int ncheb4=27; 345 -6.06747198795168022842e-7, -3.079340459 << 358 static const G4double cheb4[] = 346 1.98818772614682367781e-7, -8.139099715 << 359 {1.69342658227676741765,0.0742766400841232319225,-0.019337880608635717358,0.00516065527473364110491, 347 2.84298174969641838618e-8, -9.128297666 << 360 -0.00139342012990307729473,0.000378549864052022522193,-0.000103167085583785340215,0.0000281543441271412178337, 348 2.77713868004820551077e-9, -8.130327672 << 361 -7.68409742018258198651e-6,2.09543221890204537392e-6,-5.70493140367526282946e-7,1.54961164548564906446e-7, 349 2.31128525568385247392e-10, -6.417968732 << 362 -4.19665599629607704794e-8,1.13239680054166507038e-8,-3.04223563379021441863e-9,8.13073745977562957997e-10, 350 1.74815310473323361543e-11, -4.686535369 << 363 -2.15969415476814981374e-10,5.69472105972525594811e-11,-1.48844799572430829499e-11,3.84901514438304484973e-12, 351 1.24016595805520752748e-12, -3.248394329 << 364 -9.82222575944247161834e-13,2.46468329208292208183e-13,-6.04953826265982691612e-14,1.44055805710671611984e-14, 352 8.44601465226513952994e-14, -2.186472760 << 365 -3.28200813577388740722e-15,6.96566359173765367675e-16,-1.294122794852896275e-16}; 353 5.65407548745690689978e-15, -1.465536259 << 366 354 3.82059606377570462276e-16, -1.004578966 << 367 if(x<aa2) return x*x*x*Chebyshev(aa1,aa2,cheb1,ncheb1,x); 355 }; << 368 else if(x<aa3) return Chebyshev(aa2,aa3,cheb2,ncheb2,x); 356 static constexpr G4double aa6 = 33 << 369 else if(x<1-0.0000841363) 357 static constexpr G4int ncheb4 = 27 << 370 { G4double y=-log(1-x); 358 static constexpr G4double cheb4[ncheb4] = { << 371 return y*Chebyshev(aa4,aa5,cheb3,ncheb3,y); 359 1.69342658227676741765, 0.07427664008 << 360 -0.019337880608635717358, 0.00516065527 << 361 -0.00139342012990307729473, 0.00037854986 << 362 -0.000103167085583785340215, 0.00002815434 << 363 -7.68409742018258198651e-6, 2.09543221890 << 364 -5.70493140367526282946e-7, 1.54961164548 << 365 -4.19665599629607704794e-8, 1.13239680054 << 366 -3.04223563379021441863e-9, 8.13073745977 << 367 -2.15969415476814981374e-10, 5.69472105972 << 368 -1.48844799572430829499e-11, 3.84901514438 << 369 -9.82222575944247161834e-13, 2.46468329208 << 370 -6.04953826265982691612e-14, 1.44055805710 << 371 -3.28200813577388740722e-15, 6.96566359173 << 372 -1.294122794852896275e-16 << 373 }; << 374 << 375 if(x < aa2) << 376 return x * x * x * Chebyshev(aa1, aa2, che << 377 else if(x < aa3) << 378 return Chebyshev(aa2, aa3, cheb2, ncheb2, << 379 else if(x < 1 - 0.0000841363) << 380 { << 381 G4double y = -G4Log(1 - x); << 382 return y * Chebyshev(aa4, aa5, cheb3, nche << 383 } 372 } 384 else 373 else 385 { << 374 { G4double y=-log(1-x); 386 G4double y = -G4Log(1 - x); << 375 return y*Chebyshev(aa5,aa6,cheb4,ncheb4,y); 387 return y * Chebyshev(aa5, aa6, cheb4, nche << 388 } 376 } 389 } 377 } 390 378 391 G4double G4SynchrotronRadiation::GetRandomEner << 379 G4double G4SynchrotronRadiation::GetRandomEnergySR(G4double gamma, G4double perpB) 392 << 393 << 394 { 380 { 395 static const G4double fEnergyConst = << 396 1.5 * c_light * c_light * eplus * hbar_Pla << 397 G4double Ecr = fEnergyConst * gamma * gamma << 398 381 399 if(verboseLevel > 0 && FirstTime1) << 382 G4double Ecr=fEnergyConst*gamma*gamma*perpB; 400 { << 383 401 // mean and rms of photon energy << 384 static G4bool FirstTime=true; 402 G4double Emean = 8. / (15. * std::sqrt(3.) << 385 if(verboseLevel > 0 && FirstTime) 403 G4double E_rms = std::sqrt(211. / 675.) * << 386 { G4double Emean=8./(15.*sqrt(3.))*Ecr; // mean photon energy 404 G4long prec = G4cout.precision(); << 387 G4double E_rms=sqrt(211./675.)*Ecr; // rms of photon energy distribution 405 G4cout << "G4SynchrotronRadiation::GetRand << 388 G4cout << "G4SynchrotronRadiation::GetRandomEnergySR :" << '\n' << std::setprecision(4) 406 << std::setprecision(4) << " Ecr << 389 << " Ecr = " << G4BestUnit(Ecr,"Energy") << '\n' 407 << '\n' << 390 << " Emean = " << G4BestUnit(Emean,"Energy") << '\n' 408 << " Emean = " << G4BestUnit(Emean << 391 << " E_rms = " << G4BestUnit(E_rms,"Energy") << G4endl; 409 << " E_rms = " << G4BestUnit(E_rms << 392 FirstTime=false; 410 FirstTime1 = false; << 411 G4cout.precision(prec); << 412 } 393 } 413 394 414 G4double energySR = Ecr * InvSynFracInt(G4Un << 395 G4double energySR=Ecr*InvSynFracInt(G4UniformRand()); 415 return energySR; 396 return energySR; 416 } 397 } 417 398 418 ////////////////////////////////////////////// << 399 419 void G4SynchrotronRadiation::BuildPhysicsTable 400 void G4SynchrotronRadiation::BuildPhysicsTable(const G4ParticleDefinition& part) 420 { 401 { 421 if(0 < verboseLevel && &part == G4Electron:: << 402 if(0 < verboseLevel && &part==theElectron ) PrintInfoDefinition(); 422 ProcessDescription(G4cout); << 423 // same for all particles, print only for on << 424 } 403 } 425 404 426 ////////////////////////////////////////////// << 405 void G4SynchrotronRadiation::PrintInfoDefinition() // not yet called, usually called from BuildPhysicsTable 427 void G4SynchrotronRadiation::ProcessDescriptio << 428 { 406 { 429 out << GetProcessName() << 407 G4String comments ="Incoherent Synchrotron Radiation\n"; 430 << ": Incoherent Synchrotron Radiation\ << 408 G4cout << G4endl << GetProcessName() << ": " << comments 431 "Good description for long magnets at << 409 << " good description for long magnets at all energies" << G4endl; 432 } 410 } >> 411 >> 412 ///////////////////// end of G4SynchrotronRadiation.cc 433 413