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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/electromagnetic/xrays/src/G4SynchrotronRadiation.cc (Version 11.3.0) and /processes/electromagnetic/xrays/src/G4SynchrotronRadiation.cc (Version 5.0.p1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // -------------------------------------------    
 27 //      GEANT 4 class implementation file         
 28 //                                                
 29 //      History: first implementation,            
 30 //      21-5-98 V.Grichine                        
 31 //      28-05-01, V.Ivanchenko minor changes t    
 32 //      04.03.05, V.Grichine: get local field     
 33 //      18-05-06 H. Burkhardt: Energy spectrum    
 34 //                                                
 35 //////////////////////////////////////////////    
 36                                                   
 37 #include "G4SynchrotronRadiation.hh"              
 38                                                   
 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"                        
 50 #include "G4PhysicsModelCatalog.hh"               
 51                                                   
 52 //////////////////////////////////////////////    
 53 //  Constructor                                   
 54 G4SynchrotronRadiation::G4SynchrotronRadiation    
 55                                                   
 56   : G4VDiscreteProcess(processName, type)         
 57   , theGamma(G4Gamma::Gamma())                    
 58 {                                                 
 59   G4TransportationManager* transportMgr =         
 60     G4TransportationManager::GetTransportation    
 61                                                   
 62   fFieldPropagator = transportMgr->GetPropagat    
 63                                                   
 64   secID = G4PhysicsModelCatalog::GetModelID("m    
 65   SetProcessSubType(fSynchrotronRadiation);       
 66   verboseLevel = 1;                               
 67   FirstTime    = true;                            
 68   FirstTime1   = true;                            
 69   genAngle     = nullptr;                         
 70   SetAngularGenerator(new G4DipBustGenerator()    
 71   theManager = G4LossTableManager::Instance();    
 72   theManager->Register(this);                     
 73 }                                                 
 74                                                   
 75 //////////////////////////////////////////////    
 76 // Destructor                                     
 77 G4SynchrotronRadiation::~G4SynchrotronRadiatio    
 78 {                                                 
 79   delete genAngle;                                
 80   theManager->DeRegister(this);                   
 81 }                                                 
 82                                                   
 83 /////////////////////////////// METHODS //////    
 84                                                   
 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                                                   
100 //////////////////////////////////////////////    
101 // Production of synchrotron X-ray photon         
102 // Geant4 internal units.                         
103 G4double G4SynchrotronRadiation::GetMeanFreePa    
104                                                   
105                                                   
106 {                                                 
107   // gives the MeanFreePath in Geant4 internal    
108   G4double MeanFreePath = DBL_MAX;                
109                                                   
110   const G4DynamicParticle* aDynamicParticle =     
111                                                   
112   *condition = NotForced;                         
113                                                   
114   G4double gamma =                                
115     aDynamicParticle->GetTotalEnergy() / aDyna    
116                                                   
117   G4double particleCharge = aDynamicParticle->    
118                                                   
119   if(gamma < 1.0e3 || 0.0 == particleCharge)      
120   {                                               
121     MeanFreePath = DBL_MAX;                       
122   }                                               
123   else                                            
124   {                                               
125     G4ThreeVector FieldValue;                     
126     const G4Field* pField   = nullptr;            
127     G4bool fieldExertsForce = false;              
128                                                   
129     G4FieldManager* fieldMgr =                    
130       fFieldPropagator->FindAndSetFieldManager    
131                                                   
132     if(fieldMgr != nullptr)                       
133     {                                             
134       // If the field manager has no field, th    
135       fieldExertsForce = (fieldMgr->GetDetecto    
136     }                                             
137                                                   
138     if(fieldExertsForce)                          
139     {                                             
140       pField                     = fieldMgr->G    
141       G4ThreeVector globPosition = trackData.G    
142                                                   
143       G4double globPosVec[4], FieldValueVec[6]    
144                                                   
145       globPosVec[0] = globPosition.x();           
146       globPosVec[1] = globPosition.y();           
147       globPosVec[2] = globPosition.z();           
148       globPosVec[3] = trackData.GetGlobalTime(    
149                                                   
150       pField->GetFieldValue(globPosVec, FieldV    
151                                                   
152       FieldValue =                                
153         G4ThreeVector(FieldValueVec[0], FieldV    
154                                                   
155       G4ThreeVector unitMomentum = aDynamicPar    
156       G4ThreeVector unitMcrossB  = FieldValue.    
157       G4double perpB             = unitMcrossB    
158                                                   
159       static const G4double fLambdaConst =        
160         std::sqrt(3.0) * eplus / (2.5 * fine_s    
161                                                   
162       if(perpB > 0.0)                             
163       {                                           
164         MeanFreePath = fLambdaConst *             
165                        aDynamicParticle->GetDe    
166                        (perpB * particleCharge    
167       }                                           
168       if(verboseLevel > 0 && FirstTime)           
169       {                                           
170         G4cout << "G4SynchrotronRadiation::Get    
171                << " for particle "                
172                << aDynamicParticle->GetDefinit    
173                << '\n'                            
174                << "  MeanFreePath = " << G4Bes    
175                << G4endl;                         
176         if(verboseLevel > 1)                      
177         {                                         
178           G4ThreeVector pvec = aDynamicParticl    
179           G4double Btot      = FieldValue.getR    
180           G4double ptot      = pvec.getR();       
181           G4double rho       = ptot / (MeV * c    
182           // full bending radius                  
183           G4double Theta = unitMomentum.theta(    
184           // angle between particle and field     
185           G4cout << "  B = " << Btot / tesla <    
186                  << "  perpB = " << perpB / te    
187                  << "  Theta = " << Theta         
188                  << " std::sin(Theta)=" << std    
189                  << "  ptot  = " << G4BestUnit    
190                  << "  rho   = " << G4BestUnit    
191         }                                         
192         FirstTime = false;                        
193       }                                           
194     }                                             
195   }                                               
196   return MeanFreePath;                            
197 }                                                 
198                                                   
199 //////////////////////////////////////////////    
200 G4VParticleChange* G4SynchrotronRadiation::Pos    
201   const G4Track& trackData, const G4Step& step    
202                                                   
203 {                                                 
204   aParticleChange.Initialize(trackData);          
205                                                   
206   const G4DynamicParticle* aDynamicParticle =     
207                                                   
208   G4double gamma = aDynamicParticle->GetTotalE    
209                    (aDynamicParticle->GetDefin    
210                                                   
211   G4double particleCharge = aDynamicParticle->    
212   if(gamma <= 1.0e3 || 0.0 == particleCharge)     
213   {                                               
214     return G4VDiscreteProcess::PostStepDoIt(tr    
215   }                                               
216                                                   
217   G4ThreeVector FieldValue;                       
218   const G4Field* pField = nullptr;                
219                                                   
220   G4bool fieldExertsForce = false;                
221   G4FieldManager* fieldMgr =                      
222     fFieldPropagator->FindAndSetFieldManager(t    
223                                                   
224   if(fieldMgr != nullptr)                         
225   {                                               
226     // If the field manager has no field, ther    
227     fieldExertsForce = (fieldMgr->GetDetectorF    
228   }                                               
229                                                   
230   if(fieldExertsForce)                            
231   {                                               
232     pField                     = fieldMgr->Get    
233     G4ThreeVector globPosition = trackData.Get    
234     G4double globPosVec[4], FieldValueVec[6];     
235     globPosVec[0] = globPosition.x();             
236     globPosVec[1] = globPosition.y();             
237     globPosVec[2] = globPosition.z();             
238     globPosVec[3] = trackData.GetGlobalTime();    
239                                                   
240     pField->GetFieldValue(globPosVec, FieldVal    
241     FieldValue =                                  
242       G4ThreeVector(FieldValueVec[0], FieldVal    
243                                                   
244     G4ThreeVector unitMomentum = aDynamicParti    
245     G4ThreeVector unitMcrossB  = FieldValue.cr    
246     G4double perpB             = unitMcrossB.m    
247     if(perpB > 0.0)                               
248     {                                             
249       // M-C of synchrotron photon energy         
250       G4double energyOfSR = GetRandomEnergySR(    
251         gamma, perpB, aDynamicParticle->GetDef    
252                                                   
253       // check against insufficient energy        
254       if(energyOfSR <= 0.0)                       
255       {                                           
256         return G4VDiscreteProcess::PostStepDoI    
257       }                                           
258       G4double kineticEnergy = aDynamicParticl    
259       G4ThreeVector gammaDirection =              
260         genAngle->SampleDirection(aDynamicPart    
261                                                   
262       G4ThreeVector gammaPolarization = FieldV    
263       gammaPolarization               = gammaP    
264                                                   
265       // create G4DynamicParticle object for t    
266       auto aGamma =                               
267         new G4DynamicParticle(theGamma, gammaD    
268       aGamma->SetPolarization(gammaPolarizatio    
269                               gammaPolarizatio    
270                                                   
271       aParticleChange.SetNumberOfSecondaries(1    
272                                                   
273       // Update the incident particle             
274       G4double newKinEnergy = kineticEnergy -     
275                                                   
276       if(newKinEnergy > 0.)                       
277       {                                           
278         aParticleChange.ProposeEnergy(newKinEn    
279       }                                           
280       else                                        
281       {                                           
282         aParticleChange.ProposeEnergy(0.);        
283       }                                           
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     }                                             
293   }                                               
294   return G4VDiscreteProcess::PostStepDoIt(trac    
295 }                                                 
296                                                   
297 //////////////////////////////////////////////    
298 G4double G4SynchrotronRadiation::InvSynFracInt    
299 // direct generation                              
300 {                                                 
301   // from 0 to 0.7                                
302   static constexpr G4double aa1           = 0;    
303   static constexpr G4double aa2           = 0.    
304   static constexpr G4int ncheb1           = 27    
305   static constexpr G4double cheb1[ncheb1] = {     
306     1.22371665676046468821,     0.108956475422    
307     0.0383328524358594396134,   0.007591383693    
308     0.00205712048644963340914,  0.000497810783    
309     0.000130743691810302187818, 0.000033816876    
310     8.97049680900520817728e-6,  2.386854727944    
311     6.41923109149104165049e-7,  1.735498989827    
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             
322   static constexpr G4double aa3           = 0.    
323   static constexpr G4int ncheb2           = 27    
324   static constexpr G4double cheb2[ncheb2] = {     
325     1.1139496701107756,     0.3523967429328067    
326     0.01475818043595387,    0.0033812556373224    
327     0.00020785506681254216, 0.0000539016925370    
328     3.823880733161044e-6,   1.0381966089136036    
329     7.86223332179956e-8,    2.1866609342508474    
330     1.7191233618437565e-9,  4.852755117740807e    
331     3.908961987062447e-11,  1.1146253766895824    
332     9.134319791300977e-13,  2.6211077371181566    
333     2.1528376972619e-14,    6.030906040404772e    
334   };                                              
335   // Chebyshev with exp/log  scale                
336   // a = -Log[1 - SynFracInt[1]]; b = -Log[1 -    
337   static constexpr G4double aa4           = 2.    
338   static constexpr G4double aa5           = 9.    
339   static constexpr G4int ncheb3           = 28    
340   static constexpr G4double cheb3[ncheb3] = {     
341     1.2292683840435586977,        0.1603534492    
342     -0.0353559911947559448721,    0.0077690156    
343     -0.00165886451971685133259,   0.0003357191    
344     -0.0000617184951079161143187, 9.2353403974    
345     -6.06747198795168022842e-7,   -3.079340459    
346     1.98818772614682367781e-7,    -8.139099715    
347     2.84298174969641838618e-8,    -9.128297666    
348     2.77713868004820551077e-9,    -8.130327672    
349     2.31128525568385247392e-10,   -6.417968732    
350     1.74815310473323361543e-11,   -4.686535369    
351     1.24016595805520752748e-12,   -3.248394329    
352     8.44601465226513952994e-14,   -2.186472760    
353     5.65407548745690689978e-15,   -1.465536259    
354     3.82059606377570462276e-16,   -1.004578966    
355   };                                              
356   static constexpr G4double aa6           = 33    
357   static constexpr G4int ncheb4           = 27    
358   static constexpr G4double cheb4[ncheb4] = {     
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   }                                               
384   else                                            
385   {                                               
386     G4double y = -G4Log(1 - x);                   
387     return y * Chebyshev(aa5, aa6, cheb4, nche    
388   }                                               
389 }                                                 
390                                                   
391 G4double G4SynchrotronRadiation::GetRandomEner    
392                                                   
393                                                   
394 {                                                 
395   static const G4double fEnergyConst =            
396     1.5 * c_light * c_light * eplus * hbar_Pla    
397   G4double Ecr = fEnergyConst * gamma * gamma     
398                                                   
399   if(verboseLevel > 0 && FirstTime1)              
400   {                                               
401     // mean and rms of photon energy              
402     G4double Emean = 8. / (15. * std::sqrt(3.)    
403     G4double E_rms = std::sqrt(211. / 675.) *     
404     G4long prec     = G4cout.precision();         
405     G4cout << "G4SynchrotronRadiation::GetRand    
406            << std::setprecision(4) << "  Ecr      
407            << '\n'                                
408            << "  Emean = " << G4BestUnit(Emean    
409            << "  E_rms = " << G4BestUnit(E_rms    
410     FirstTime1 = false;                           
411     G4cout.precision(prec);                       
412   }                                               
413                                                   
414   G4double energySR = Ecr * InvSynFracInt(G4Un    
415   return energySR;                                
416 }                                                 
417                                                   
418 //////////////////////////////////////////////    
419 void G4SynchrotronRadiation::BuildPhysicsTable    
420 {                                                 
421   if(0 < verboseLevel && &part == G4Electron::    
422     ProcessDescription(G4cout);                   
423   // same for all particles, print only for on    
424 }                                                 
425                                                   
426 //////////////////////////////////////////////    
427 void G4SynchrotronRadiation::ProcessDescriptio    
428 {                                                 
429   out << GetProcessName()                         
430       << ":  Incoherent Synchrotron Radiation\    
431          "Good description for long magnets at    
432 }                                                 
433