Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/processes/electromagnetic/lowenergy/src/G4LivermoreBremsstrahlungModel.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 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/lowenergy/src/G4LivermoreBremsstrahlungModel.cc (Version 11.3.0) and /processes/electromagnetic/lowenergy/src/G4LivermoreBremsstrahlungModel.cc (Version 10.3)


  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: G4LivermoreBremsstrahlungModel.cc 76220 2013-11-08 10:15:00Z gcosmo $
 26 //                                                 27 //
 27 // -------------------------------------------     28 // -------------------------------------------------------------------
 28 //                                                 29 //
 29 // GEANT4 Class file                               30 // GEANT4 Class file
 30 //                                                 31 //
 31 //                                                 32 //
 32 // File name:     G4LivermoreBremsstrahlungMod     33 // File name:     G4LivermoreBremsstrahlungModel
 33 //                                                 34 //
 34 // Author:        Vladimir Ivanchenko use inhe     35 // Author:        Vladimir Ivanchenko use inheritance from Andreas Schaelicke
 35 //                base class implementing ultr     36 //                base class implementing ultra relativistic bremsstrahlung
 36 //                model                        <<  37 //                model 
 37 //                                                 38 //
 38 // Creation date: 04.10.2011                       39 // Creation date: 04.10.2011
 39 //                                                 40 //
 40 // Modifications:                                  41 // Modifications:
 41 //                                                 42 //
 42 // -------------------------------------------     43 // -------------------------------------------------------------------
 43 //                                                 44 //
 44 //....oooOO0OOooo........oooOO0OOooo........oo     45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 45 //....oooOO0OOooo........oooOO0OOooo........oo     46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 46                                                    47 
 47 #include "G4LivermoreBremsstrahlungModel.hh"       48 #include "G4LivermoreBremsstrahlungModel.hh"
 48 #include "G4PhysicalConstants.hh"                  49 #include "G4PhysicalConstants.hh"
 49 #include "G4SystemOfUnits.hh"                      50 #include "G4SystemOfUnits.hh"
 50 #include "G4Electron.hh"                           51 #include "G4Electron.hh"
 51 #include "G4Positron.hh"                           52 #include "G4Positron.hh"
 52 #include "G4Gamma.hh"                              53 #include "G4Gamma.hh"
 53 #include "Randomize.hh"                            54 #include "Randomize.hh"
 54 #include "G4AutoLock.hh"                       << 
 55 #include "G4Material.hh"                           55 #include "G4Material.hh"
 56 #include "G4Element.hh"                            56 #include "G4Element.hh"
 57 #include "G4ElementVector.hh"                      57 #include "G4ElementVector.hh"
 58 #include "G4ProductionCutsTable.hh"                58 #include "G4ProductionCutsTable.hh"
 59 #include "G4ParticleChangeForLoss.hh"              59 #include "G4ParticleChangeForLoss.hh"
 60 #include "G4Generator2BS.hh"                       60 #include "G4Generator2BS.hh"
 61                                                    61 
 62 #include "G4Physics2DVector.hh"                    62 #include "G4Physics2DVector.hh"
 63 #include "G4Exp.hh"                                63 #include "G4Exp.hh"
 64 #include "G4Log.hh"                                64 #include "G4Log.hh"
 65                                                    65 
 66 #include "G4ios.hh"                                66 #include "G4ios.hh"
 67 #include <fstream>                                 67 #include <fstream>
 68 #include <iomanip>                                 68 #include <iomanip>
 69                                                    69 
 70 //....oooOO0OOooo........oooOO0OOooo........oo     70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 71                                                    71 
 72 namespace { G4Mutex LivermoreBremsstrahlungMod << 
 73 using namespace std;                               72 using namespace std;
 74                                                    73 
 75                                                <<  74 G4Physics2DVector* G4LivermoreBremsstrahlungModel::dataSB[] = {0};
 76 G4Physics2DVector* G4LivermoreBremsstrahlungMo << 
 77 G4double G4LivermoreBremsstrahlungModel::ylimi     75 G4double G4LivermoreBremsstrahlungModel::ylimit[] = {0.0};
 78 G4double G4LivermoreBremsstrahlungModel::expnu     76 G4double G4LivermoreBremsstrahlungModel::expnumlim = -12.;
 79                                                    77 
 80 static const G4double emaxlog = 4*G4Log(10.);      78 static const G4double emaxlog = 4*G4Log(10.);
 81 static const G4double alpha = CLHEP::twopi*CLH <<  79 static const G4double alpha = CLHEP::twopi*CLHEP::fine_structure_const; 
 82 static const G4double epeaklimit= 300*CLHEP::M <<  80 static const G4double epeaklimit= 300*CLHEP::MeV; 
 83 static const G4double elowlimit = 20*CLHEP::ke <<  81 static const G4double elowlimit = 20*CLHEP::keV; 
 84                                                    82 
 85 G4LivermoreBremsstrahlungModel::G4LivermoreBre     83 G4LivermoreBremsstrahlungModel::G4LivermoreBremsstrahlungModel(
 86   const G4ParticleDefinition* p, const G4Strin     84   const G4ParticleDefinition* p, const G4String& nam)
 87   : G4eBremsstrahlungRelModel(p,nam),useBicubi     85   : G4eBremsstrahlungRelModel(p,nam),useBicubicInterpolation(false)
 88 {                                                  86 {
 89   SetLowEnergyLimit(10.0*eV);                      87   SetLowEnergyLimit(10.0*eV);
                                                   >>  88   SetLPMFlag(false);
                                                   >>  89   nwarn = 0;
                                                   >>  90   idx = idy = 0;
 90   SetAngularDistribution(new G4Generator2BS())     91   SetAngularDistribution(new G4Generator2BS());
 91 }                                                  92 }
 92                                                    93 
 93 //....oooOO0OOooo........oooOO0OOooo........oo     94 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 94                                                    95 
 95 G4LivermoreBremsstrahlungModel::~G4LivermoreBr     96 G4LivermoreBremsstrahlungModel::~G4LivermoreBremsstrahlungModel()
 96 {                                                  97 {
 97   if(IsMaster()) {                                 98   if(IsMaster()) {
 98     for(size_t i=0; i<101; ++i) {              <<  99     for(size_t i=0; i<101; ++i) { 
 99       if(dataSB[i]) {                             100       if(dataSB[i]) {
100   delete dataSB[i];                            << 101   delete dataSB[i]; 
101   dataSB[i] = nullptr;                         << 102   dataSB[i] = 0;
102       }                                        << 103       } 
103     }                                             104     }
104   }                                               105   }
105 }                                                 106 }
106                                                   107 
107 //....oooOO0OOooo........oooOO0OOooo........oo    108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
108                                                   109 
109 void G4LivermoreBremsstrahlungModel::Initialis    110 void G4LivermoreBremsstrahlungModel::Initialise(const G4ParticleDefinition* p,
110             const G4DataVector& cuts)             111             const G4DataVector& cuts)
111 {                                                 112 {
112   // Access to elements                           113   // Access to elements
113   if(IsMaster()) {                                114   if(IsMaster()) {
                                                   >> 115 
114     // check environment variable                 116     // check environment variable
115     // Build the complete string identifying t    117     // Build the complete string identifying the file with the data set
116     const char* path = G4FindDataDir("G4LEDATA << 118     char* path = getenv("G4LEDATA");
117                                                   119 
118     const G4ElementTable* theElmTable = G4Elem    120     const G4ElementTable* theElmTable = G4Element::GetElementTable();
119     size_t numOfElm = G4Element::GetNumberOfEl    121     size_t numOfElm = G4Element::GetNumberOfElements();
120     if(numOfElm > 0) {                            122     if(numOfElm > 0) {
121       for(size_t i=0; i<numOfElm; ++i) {          123       for(size_t i=0; i<numOfElm; ++i) {
122   G4int Z = (*theElmTable)[i]->GetZasInt();    << 124   G4int Z = G4int(((*theElmTable)[i])->GetZ());
123   if(Z < 1)        { Z = 1; }                     125   if(Z < 1)        { Z = 1; }
124   else if(Z > 100) { Z = 100; }                   126   else if(Z > 100) { Z = 100; }
125   //G4cout << "Z= " << Z << G4endl;               127   //G4cout << "Z= " << Z << G4endl;
126   // Initialisation                               128   // Initialisation
127   if(!dataSB[Z]) { ReadData(Z, path); }           129   if(!dataSB[Z]) { ReadData(Z, path); }
128       }                                           130       }
129     }                                             131     }
130   }                                               132   }
                                                   >> 133 
131   G4eBremsstrahlungRelModel::Initialise(p, cut    134   G4eBremsstrahlungRelModel::Initialise(p, cuts);
132 }                                                 135 }
133                                                   136 
134 //....oooOO0OOooo........oooOO0OOooo........oo    137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
135                                                   138 
136 G4String G4LivermoreBremsstrahlungModel::Direc    139 G4String G4LivermoreBremsstrahlungModel::DirectoryPath() const
137 {                                                 140 {
138   return "/livermore/brem/br";                    141   return "/livermore/brem/br";
139 }                                                 142 }
140                                                   143 
141 //....oooOO0OOooo........oooOO0OOooo........oo    144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
142                                                   145 
143 void G4LivermoreBremsstrahlungModel::ReadData(    146 void G4LivermoreBremsstrahlungModel::ReadData(G4int Z, const char* path)
144 {                                                 147 {
                                                   >> 148   //  G4cout << "ReadData Z= " << Z << G4endl;
                                                   >> 149   // G4cout << "Status for Z= " << dataSB[Z] << G4endl;
                                                   >> 150   //if(path) { G4cout << path << G4endl; }
145   if(dataSB[Z]) { return; }                       151   if(dataSB[Z]) { return; }
146   const char* datadir = path;                     152   const char* datadir = path;
147                                                   153 
148   if(nullptr == datadir) {                     << 154   if(!datadir) {
149     datadir = G4FindDataDir("G4LEDATA");       << 155     datadir = getenv("G4LEDATA");
150     if(!datadir) {                                156     if(!datadir) {
151       G4Exception("G4LivermoreBremsstrahlungMo    157       G4Exception("G4LivermoreBremsstrahlungModel::ReadData()","em0006",
152       FatalException,"Environment variable G4L    158       FatalException,"Environment variable G4LEDATA not defined");
153       return;                                     159       return;
154     }                                             160     }
155   }                                               161   }
156   std::ostringstream ost;                         162   std::ostringstream ost;
157   ost << datadir << DirectoryPath() << Z;         163   ost << datadir << DirectoryPath() << Z;
158   std::ifstream fin(ost.str().c_str());           164   std::ifstream fin(ost.str().c_str());
159   if( !fin.is_open()) {                           165   if( !fin.is_open()) {
160     G4ExceptionDescription ed;                    166     G4ExceptionDescription ed;
161     ed << "Bremsstrahlung data file <" << ost.    167     ed << "Bremsstrahlung data file <" << ost.str().c_str()
162        << "> is not opened!";                     168        << "> is not opened!";
163     G4Exception("G4LivermoreBremsstrahlungMode    169     G4Exception("G4LivermoreBremsstrahlungModel::ReadData()","em0003",
164     FatalException,ed,                            170     FatalException,ed,
165     "G4LEDATA version should be G4EMLOW8.0 or  << 171     "G4LEDATA version should be G4EMLOW6.23 or later.");
166     return;                                       172     return;
167   }                                            << 173   } 
168   //G4cout << "G4LivermoreBremsstrahlungModel  << 174   //G4cout << "G4LivermoreBremsstrahlungModel read from <" << ost.str().c_str() 
169   //   << ">" << G4endl;                          175   //   << ">" << G4endl;
170   G4Physics2DVector* v = new G4Physics2DVector    176   G4Physics2DVector* v = new G4Physics2DVector();
171   if(v->Retrieve(fin)) {                       << 177   if(v->Retrieve(fin)) { 
172     if(useBicubicInterpolation) { v->SetBicubi    178     if(useBicubicInterpolation) { v->SetBicubicInterpolation(true); }
173     dataSB[Z] = v;                             << 179     dataSB[Z] = v; 
174     ylimit[Z] = v->Value(0.97, emaxlog, idx, i    180     ylimit[Z] = v->Value(0.97, emaxlog, idx, idy);
175   } else {                                        181   } else {
176     G4ExceptionDescription ed;                    182     G4ExceptionDescription ed;
177     ed << "Bremsstrahlung data file <" << ost.    183     ed << "Bremsstrahlung data file <" << ost.str().c_str()
178        << "> is not retrieved!";                  184        << "> is not retrieved!";
179     G4Exception("G4LivermoreBremsstrahlungMode    185     G4Exception("G4LivermoreBremsstrahlungModel::ReadData()","em0005",
180                 FatalException,ed,                186                 FatalException,ed,
181     "G4LEDATA version should be G4EMLOW8.0 or  << 187     "G4LEDATA version should be G4EMLOW6.23 or later.");
182     delete v;                                     188     delete v;
183   }                                               189   }
                                                   >> 190   // G4cout << dataSB[Z] << G4endl;
184 }                                                 191 }
185                                                   192 
186 //....oooOO0OOooo........oooOO0OOooo........oo    193 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
187                                                   194 
188 G4double                                       << 195 G4double 
189 G4LivermoreBremsstrahlungModel::ComputeDXSecti    196 G4LivermoreBremsstrahlungModel::ComputeDXSectionPerAtom(G4double gammaEnergy)
190 {                                                 197 {
191   if(gammaEnergy < 0.0 || fPrimaryKinEnergy <= << 198 
192   G4double x = gammaEnergy/fPrimaryKinEnergy;  << 199   if(gammaEnergy < 0.0 || kinEnergy <= 0.0) { return 0.0; }
193   G4double y = G4Log(fPrimaryKinEnergy/MeV);   << 200   G4double x = gammaEnergy/kinEnergy;
194   G4int Z = fCurrentIZ;                        << 201   G4double y = G4Log(kinEnergy/MeV);
                                                   >> 202   G4int Z = G4lrint(currentZ);
195                                                   203 
196   //G4cout << "G4LivermoreBremsstrahlungModel:    204   //G4cout << "G4LivermoreBremsstrahlungModel::ComputeDXSectionPerAtom Z= " << Z
197   //   << " x= " << x << " y= " << y << " " <<    205   //   << " x= " << x << " y= " << y << " " << dataSB[Z] << G4endl;
198   if(!dataSB[Z]) { InitialiseForElement(0, Z);    206   if(!dataSB[Z]) { InitialiseForElement(0, Z); }
199                                                << 207   /*
200   G4double invb2 = fPrimaryTotalEnergy*fPrimar << 208     G4ExceptionDescription ed;
201                    *(fPrimaryKinEnergy + 2.*fP << 209     ed << "Bremsstrahlung data for Z= " << Z
202   G4double cross = dataSB[Z]->Value(x,y,idx,id << 210        << " are not initialized!";
203                                                << 211     G4Exception("G4LivermoreBremsstrahlungModel::ComputeDXSectionPerAtom()",
204   if(!fIsElectron) {                           << 212                 "em0005", FatalException, ed,
                                                   >> 213     "G4LEDATA version should be G4EMLOW6.23 or later.");
                                                   >> 214   }
                                                   >> 215   */
                                                   >> 216   G4double invb2 = 
                                                   >> 217     totalEnergy*totalEnergy/(kinEnergy*(kinEnergy + 2*particleMass));
                                                   >> 218   G4double cross = dataSB[Z]->Value(x,y,idx,idy)*invb2*millibarn/bremFactor;
                                                   >> 219   
                                                   >> 220   if(!isElectron) {
205     G4double invbeta1 = sqrt(invb2);              221     G4double invbeta1 = sqrt(invb2);
206     G4double e2 = fPrimaryKinEnergy - gammaEne << 222     G4double e2 = kinEnergy - gammaEnergy;
207     if(e2 > 0.0) {                                223     if(e2 > 0.0) {
208       G4double invbeta2 = (e2 + fPrimaryPartic << 224       G4double invbeta2 = (e2 + particleMass)/sqrt(e2*(e2 + 2*particleMass));
209                           /sqrt(e2*(e2 + 2.*fP << 225       G4double xxx = alpha*currentZ*(invbeta1 - invbeta2);
210       G4double xxx = alpha*fCurrentIZ*(invbeta << 
211       if(xxx < expnumlim) { cross = 0.0; }        226       if(xxx < expnumlim) { cross = 0.0; }
212       else { cross *= G4Exp(xxx); }               227       else { cross *= G4Exp(xxx); }
213     } else {                                      228     } else {
214       cross = 0.0;                                229       cross = 0.0;
215     }                                             230     }
216   }                                               231   }
217                                                << 232   
218   return cross;                                   233   return cross;
219 }                                                 234 }
220                                                   235 
221 //....oooOO0OOooo........oooOO0OOooo........oo    236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
222                                                   237 
223 void                                           << 238 void 
224 G4LivermoreBremsstrahlungModel::SampleSecondar    239 G4LivermoreBremsstrahlungModel::SampleSecondaries(
225                                         std::v << 240                                         std::vector<G4DynamicParticle*>* vdp, 
226           const G4MaterialCutsCouple* couple,     241           const G4MaterialCutsCouple* couple,
227           const G4DynamicParticle* dp,            242           const G4DynamicParticle* dp,
228           G4double cutEnergy,                     243           G4double cutEnergy,
229           G4double maxEnergy)                     244           G4double maxEnergy)
230 {                                                 245 {
231   G4double kineticEnergy = dp->GetKineticEnerg    246   G4double kineticEnergy = dp->GetKineticEnergy();
232   G4double cut  = std::min(cutEnergy, kineticE    247   G4double cut  = std::min(cutEnergy, kineticEnergy);
233   G4double emax = std::min(maxEnergy, kineticE    248   G4double emax = std::min(maxEnergy, kineticEnergy);
234   if(cut >= emax) { return; }                     249   if(cut >= emax) { return; }
235   // sets total energy, kinetic energy and den << 
236   SetupForMaterial(fPrimaryParticle, couple->G << 
237                                                   250 
238   const G4Element* elm =                       << 251   SetupForMaterial(particle, couple->GetMaterial(), kineticEnergy);
239     SelectRandomAtom(couple,fPrimaryParticle,k << 
240   fCurrentIZ = elm->GetZasInt();               << 
241   G4int Z = fCurrentIZ;                        << 
242                                                   252 
243   G4double totMomentum = sqrt(kineticEnergy*(f << 253   const G4Element* elm = 
                                                   >> 254     SelectRandomAtom(couple,particle,kineticEnergy,cut,emax);
                                                   >> 255   SetCurrentElement(elm->GetZ());
                                                   >> 256   G4int Z = G4int(currentZ);
                                                   >> 257 
                                                   >> 258   totalEnergy = kineticEnergy + particleMass;
                                                   >> 259   densityCorr = densityFactor*totalEnergy*totalEnergy;
                                                   >> 260   G4double totMomentum = sqrt(kineticEnergy*(totalEnergy + electron_mass_c2));
244   /*                                              261   /*
245   G4cout << "G4LivermoreBremsstrahlungModel::S << 262   G4cout << "G4LivermoreBremsstrahlungModel::SampleSecondaries E(MeV)= " 
246    << kineticEnergy/MeV                           263    << kineticEnergy/MeV
247    << " Z= " << Z << " cut(MeV)= " << cut/MeV  << 264    << " Z= " << Z << " cut(MeV)= " << cut/MeV 
248    << " emax(MeV)= " << emax/MeV << " corr= "  << 265    << " emax(MeV)= " << emax/MeV << " corr= " << densityCorr << G4endl;
249   */                                              266   */
250   G4double xmin = G4Log(cut*cut + fDensityCorr << 267   G4double xmin = G4Log(cut*cut + densityCorr);
251   G4double xmax = G4Log(emax*emax  + fDensityC << 268   G4double xmax = G4Log(emax*emax  + densityCorr);
252   G4double y = G4Log(kineticEnergy/MeV);          269   G4double y = G4Log(kineticEnergy/MeV);
253                                                   270 
254   G4double gammaEnergy, v;                     << 271   G4double gammaEnergy, v; 
255                                                   272 
256   // majoranta                                    273   // majoranta
257   G4double x0 = cut/kineticEnergy;                274   G4double x0 = cut/kineticEnergy;
258   G4double vmax = dataSB[Z]->Value(x0, y, idx,    275   G4double vmax = dataSB[Z]->Value(x0, y, idx, idy)*1.02;
                                                   >> 276   //  G4double invbeta1 = 0;
259                                                   277 
260   // majoranta corrected for e-                   278   // majoranta corrected for e-
261   if(fIsElectron && x0 < 0.97 &&               << 279   if(isElectron && x0 < 0.97 && 
262      ((kineticEnergy > epeaklimit) || (kinetic    280      ((kineticEnergy > epeaklimit) || (kineticEnergy < elowlimit))) {
263     G4double ylim = std::min(ylimit[Z],1.1*dat    281     G4double ylim = std::min(ylimit[Z],1.1*dataSB[Z]->Value(0.97,y,idx,idy));
264     if(ylim > vmax) { vmax = ylim; }              282     if(ylim > vmax) { vmax = ylim; }
265   }                                               283   }
266   if(x0 < 0.05) { vmax *= 1.2; }                  284   if(x0 < 0.05) { vmax *= 1.2; }
267                                                   285 
                                                   >> 286   //G4cout<<"y= "<<y<<" xmin= "<<xmin<<" xmax= "<<xmax
                                                   >> 287   //<<" vmax= "<<vmax<<G4endl;
                                                   >> 288   //  G4int ncount = 0;
268   do {                                            289   do {
269     //++ncount;                                   290     //++ncount;
270     G4double x = G4Exp(xmin + G4UniformRand()* << 291     G4double x = G4Exp(xmin + G4UniformRand()*(xmax - xmin)) - densityCorr;
271     if(x < 0.0) { x = 0.0; }                      292     if(x < 0.0) { x = 0.0; }
272     gammaEnergy = sqrt(x);                        293     gammaEnergy = sqrt(x);
273     G4double x1 = gammaEnergy/kineticEnergy;      294     G4double x1 = gammaEnergy/kineticEnergy;
274     v = dataSB[Z]->Value(x1, y, idx, idy);        295     v = dataSB[Z]->Value(x1, y, idx, idy);
275                                                   296 
276     // correction for positrons                << 297     // correction for positrons        
277     if(!fIsElectron) {                         << 298     if(!isElectron) {
278       G4double e1 = kineticEnergy - cut;          299       G4double e1 = kineticEnergy - cut;
279       G4double invbeta1 = (e1 + fPrimaryPartic << 300       G4double invbeta1 = (e1 + particleMass)/sqrt(e1*(e1 + 2*particleMass));
280                           /sqrt(e1*(e1 + 2*fPr << 
281       G4double e2 = kineticEnergy - gammaEnerg    301       G4double e2 = kineticEnergy - gammaEnergy;
282       G4double invbeta2 = (e2 + fPrimaryPartic << 302       G4double invbeta2 = (e2 + particleMass)/sqrt(e2*(e2 + 2*particleMass));
283                           /sqrt(e2*(e2 + 2*fPr << 303       G4double xxx = twopi*fine_structure_const*currentZ*(invbeta1 - invbeta2);
284       G4double xxx = twopi*fine_structure_cons << 
285                                                   304 
286       if(xxx < expnumlim) { v = 0.0; }            305       if(xxx < expnumlim) { v = 0.0; }
287       else { v *= G4Exp(xxx); }                   306       else { v *= G4Exp(xxx); }
288     }                                             307     }
289                                                << 308    
290     if (v > 1.05*vmax && nwarn < 5) {             309     if (v > 1.05*vmax && nwarn < 5) {
291       ++nwarn;                                    310       ++nwarn;
292       G4ExceptionDescription ed;                  311       G4ExceptionDescription ed;
293       ed << "### G4LivermoreBremsstrahlungMode    312       ed << "### G4LivermoreBremsstrahlungModel Warning: Majoranta exceeded! "
294    << v << " > " << vmax << " by " << v/vmax      313    << v << " > " << vmax << " by " << v/vmax
295    << " Egamma(MeV)= " << gammaEnergy             314    << " Egamma(MeV)= " << gammaEnergy
296    << " Ee(MeV)= " << kineticEnergy               315    << " Ee(MeV)= " << kineticEnergy
297    << " Z= " << Z << "  " << fPrimaryParticle- << 316    << " Z= " << Z << "  " << particle->GetParticleName();
298                                                << 317      
299       if ( 20 == nwarn ) {                        318       if ( 20 == nwarn ) {
300   ed << "\n ### G4LivermoreBremsstrahlungModel    319   ed << "\n ### G4LivermoreBremsstrahlungModel Warnings stopped";
301       }                                           320       }
302       G4Exception("G4LivermoreBremsstrahlungMo    321       G4Exception("G4LivermoreBremsstrahlungModel::SampleScattering","em0044",
303       JustWarning, ed,"");                        322       JustWarning, ed,"");
304                                                   323 
305     }                                             324     }
306   } while (v < vmax*G4UniformRand());             325   } while (v < vmax*G4UniformRand());
307                                                   326 
308   //                                              327   //
309   // angles of the emitted gamma. ( Z - axis a    328   // angles of the emitted gamma. ( Z - axis along the parent particle)
310   // use general interface                        329   // use general interface
311   //                                              330   //
312                                                   331 
313   G4ThreeVector gammaDirection =               << 332   G4ThreeVector gammaDirection = 
314     GetAngularDistribution()->SampleDirection( << 333     GetAngularDistribution()->SampleDirection(dp, totalEnergy-gammaEnergy,
315                 Z, couple->GetMaterial());        334                 Z, couple->GetMaterial());
316                                                   335 
317   // create G4DynamicParticle object for the G    336   // create G4DynamicParticle object for the Gamma
318   G4DynamicParticle* gamma =                   << 337   G4DynamicParticle* gamma = 
319     new G4DynamicParticle(fGammaParticle,gamma << 338     new G4DynamicParticle(theGamma,gammaDirection,gammaEnergy);
320   vdp->push_back(gamma);                          339   vdp->push_back(gamma);
321                                                << 340   
322   G4ThreeVector direction = (totMomentum*dp->G    341   G4ThreeVector direction = (totMomentum*dp->GetMomentumDirection()
323            - gammaEnergy*gammaDirection).unit(    342            - gammaEnergy*gammaDirection).unit();
324                                                   343 
325   /*                                              344   /*
326   G4cout << "### G4SBModel: v= "                  345   G4cout << "### G4SBModel: v= "
327    << " Eg(MeV)= " << gammaEnergy                 346    << " Eg(MeV)= " << gammaEnergy
328    << " Ee(MeV)= " << kineticEnergy               347    << " Ee(MeV)= " << kineticEnergy
329    << " DirE " << direction << " DirG " << gam    348    << " DirE " << direction << " DirG " << gammaDirection
330    << G4endl;                                     349    << G4endl;
331   */                                              350   */
332   // energy of primary                            351   // energy of primary
333   G4double finalE = kineticEnergy - gammaEnerg    352   G4double finalE = kineticEnergy - gammaEnergy;
334                                                   353 
335   // stop tracking and create new secondary in    354   // stop tracking and create new secondary instead of primary
336   if(gammaEnergy > SecondaryThreshold()) {        355   if(gammaEnergy > SecondaryThreshold()) {
337     fParticleChange->ProposeTrackStatus(fStopA    356     fParticleChange->ProposeTrackStatus(fStopAndKill);
338     fParticleChange->SetProposedKineticEnergy(    357     fParticleChange->SetProposedKineticEnergy(0.0);
339     G4DynamicParticle* el =                    << 358     G4DynamicParticle* el = 
340       new G4DynamicParticle(const_cast<G4Parti << 359       new G4DynamicParticle(const_cast<G4ParticleDefinition*>(particle),
341           direction, finalE);                     360           direction, finalE);
342     vdp->push_back(el);                           361     vdp->push_back(el);
343                                                   362 
344     // continue tracking                          363     // continue tracking
345   } else {                                        364   } else {
346     fParticleChange->SetProposedMomentumDirect    365     fParticleChange->SetProposedMomentumDirection(direction);
347     fParticleChange->SetProposedKineticEnergy(    366     fParticleChange->SetProposedKineticEnergy(finalE);
348   }                                               367   }
349 }                                                 368 }
350                                                   369 
351 //....oooOO0OOooo........oooOO0OOooo........oo    370 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
352                                                   371 
                                                   >> 372 #include "G4AutoLock.hh"
                                                   >> 373 namespace { G4Mutex LivermoreBremsstrahlungModelMutex = G4MUTEX_INITIALIZER; }
353 void G4LivermoreBremsstrahlungModel::Initialis    374 void G4LivermoreBremsstrahlungModel::InitialiseForElement(
354                                      const G4P << 375                                      const G4ParticleDefinition*, 
355              G4int Z)                             376              G4int Z)
356 {                                                 377 {
357   G4AutoLock l(&LivermoreBremsstrahlungModelMu    378   G4AutoLock l(&LivermoreBremsstrahlungModelMutex);
                                                   >> 379   //G4cout << "G4LivermoreBremsstrahlungModel::InitialiseForElement Z= " 
                                                   >> 380   //<< Z << G4endl;
358   if(!dataSB[Z]) { ReadData(Z); }                 381   if(!dataSB[Z]) { ReadData(Z); }
359   l.unlock();                                     382   l.unlock();
360 }                                                 383 }
361                                                   384 
362 //....oooOO0OOooo........oooOO0OOooo........oo    385 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 386 
                                                   >> 387 
363                                                   388