[819] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // $Id: G4PenelopeBremsstrahlungContinuous.cc,v 1.9 2006/06/29 19:40:39 gunter Exp $ |
---|
| 27 | // GEANT4 tag $Name: $ |
---|
| 28 | // |
---|
| 29 | // -------------------------------------------------------------- |
---|
| 30 | // |
---|
| 31 | // File name: G4PenelopeBremsstrahlungContinuous |
---|
| 32 | // |
---|
| 33 | // Author: Luciano Pandola |
---|
| 34 | // |
---|
| 35 | // Creation date: February 2003 |
---|
| 36 | // History: |
---|
| 37 | // ----------- |
---|
| 38 | // 20 Feb 2003 L. Pandola 1st implementation |
---|
| 39 | // 17 Mar 2003 L. Pandola Added the correction for positrons |
---|
| 40 | // 19 Mar 2003 L. Pandola Bugs fixed |
---|
| 41 | // 17 Mar 2004 L. Pandola Removed unnecessary calls to std::pow(a,b) |
---|
| 42 | //---------------------------------------------------------------- |
---|
| 43 | |
---|
| 44 | #include "G4PenelopeBremsstrahlungContinuous.hh" |
---|
| 45 | #include "G4PenelopeInterpolator.hh" |
---|
| 46 | #include "G4Electron.hh" |
---|
| 47 | #include "G4Positron.hh" |
---|
| 48 | #include "Randomize.hh" |
---|
| 49 | #include "G4ParticleDefinition.hh" |
---|
| 50 | #include "globals.hh" |
---|
| 51 | #include <sstream> |
---|
| 52 | |
---|
| 53 | G4PenelopeBremsstrahlungContinuous::G4PenelopeBremsstrahlungContinuous (G4int Zed,G4double taglio,G4double e1, |
---|
| 54 | G4double e2, |
---|
| 55 | const G4String name) : |
---|
| 56 | Zmat(Zed),tCut(taglio),MinE(e1),MaxE(e2),partName(name) |
---|
| 57 | { |
---|
| 58 | //Construct extended energy table |
---|
| 59 | //200 bins between MinE and MaxE (logarithmic) |
---|
| 60 | G4double EL=0.99999*MinE; |
---|
| 61 | G4double EU=1.00001*MaxE; |
---|
| 62 | DLFC=std::log(EU/EL)/((G4double) (NumberofExtendedEGrid-1)); |
---|
| 63 | ExtendedLogEnergy[0]=std::log(EL); |
---|
| 64 | for (size_t i=1;i<NumberofExtendedEGrid;i++){ |
---|
| 65 | ExtendedLogEnergy[i]=ExtendedLogEnergy[i-1]+DLFC; |
---|
| 66 | } |
---|
| 67 | DLFC=1.0/DLFC; |
---|
| 68 | |
---|
| 69 | LoadFromFile(); |
---|
| 70 | PrepareInterpolationTable(); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | G4PenelopeBremsstrahlungContinuous::~G4PenelopeBremsstrahlungContinuous() |
---|
| 75 | { |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | void G4PenelopeBremsstrahlungContinuous::LoadFromFile() |
---|
| 79 | { |
---|
| 80 | //Read information from DataBase File |
---|
| 81 | char* path = getenv("G4LEDATA"); |
---|
| 82 | if (!path) |
---|
| 83 | { |
---|
| 84 | G4String excep = "G4PenelopeBremsstrahlungContinuous - G4LEDATA environment variable not set!"; |
---|
| 85 | G4Exception(excep); |
---|
| 86 | } |
---|
| 87 | G4String pathString(path); |
---|
| 88 | G4String filename = "br-pen-cont-"; |
---|
| 89 | std::ostringstream ost; |
---|
| 90 | ost << filename << Zmat << ".dat"; |
---|
| 91 | G4String name(ost.str()); |
---|
| 92 | G4String dirFile = pathString + "/penelope/" + name; |
---|
| 93 | std::ifstream file(dirFile); |
---|
| 94 | std::filebuf* lsdp = file.rdbuf(); |
---|
| 95 | if (!(lsdp->is_open())) |
---|
| 96 | { |
---|
| 97 | G4String excep = "G4PenelopeBremsstrahlungContinuous - data file " + name + " not found!"; |
---|
| 98 | G4Exception(excep); |
---|
| 99 | } |
---|
| 100 | G4double a1; |
---|
| 101 | for (size_t i=0;i<NumberofEPoints;i++){ |
---|
| 102 | file >> a1; |
---|
| 103 | Energies[i]=a1; |
---|
| 104 | for (size_t j=0;j<NumberofKPoints;j++){ |
---|
| 105 | file >> a1; |
---|
| 106 | ReducedCS[i][j]=a1/millibarn; //coversion present in Penelope source |
---|
| 107 | } |
---|
| 108 | file >> a1; |
---|
| 109 | TotalCS[i]=a1/millibarn; //conversion present in Penelope source |
---|
| 110 | file >> a1; |
---|
| 111 | if (a1 != ((G4double) -1)){ |
---|
| 112 | G4String excep = "G4PenelopeBremsstrahlungContinuous - Check the bremms data file "+ name; |
---|
| 113 | G4Exception(excep); |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | file.close(); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | void G4PenelopeBremsstrahlungContinuous::PrepareInterpolationTable() |
---|
| 121 | { |
---|
| 122 | //The energy-loss spectrum is re-normalized to reproduce the |
---|
| 123 | //total scaled cross-section of Berger and Seltzer |
---|
| 124 | |
---|
| 125 | G4double pK[NumberofKPoints] = {1.0e-12,0.05,0.075,0.1,0.125,0.15,0.2,0.25, |
---|
| 126 | 0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7, |
---|
| 127 | 0.75,0.8,0.85,0.9,0.925,0.95,0.97,0.99, |
---|
| 128 | 0.995,0.999,0.9995,0.9999,0.99995,0.99999,1.0}; |
---|
| 129 | G4double pY[NumberofKPoints]; |
---|
| 130 | |
---|
| 131 | size_t i=0,j=0; |
---|
| 132 | for (i=0;i<NumberofEPoints;i++){ |
---|
| 133 | for (j=0;j<NumberofKPoints;j++){ |
---|
| 134 | pY[j]= ReducedCS[i][j]; |
---|
| 135 | } |
---|
| 136 | G4PenelopeInterpolator* interpolator = new G4PenelopeInterpolator(pK,pY,NumberofKPoints); |
---|
| 137 | G4double Rsum = interpolator->CalculateMomentum(1.0,0); |
---|
| 138 | |
---|
| 139 | delete interpolator; |
---|
| 140 | G4double Fact = (millibarn/cm2)*(Energies[i]+electron_mass_c2)*(1.0/fine_structure_const)/ |
---|
| 141 | (classic_electr_radius*classic_electr_radius*(Energies[i]+2.0*electron_mass_c2)); |
---|
| 142 | G4double Normalization = TotalCS[i]/(Rsum*Fact); |
---|
| 143 | G4double TST = std::abs(Normalization-100.0); |
---|
| 144 | if (TST > 1.0) { |
---|
| 145 | G4String excep = "G4PenelopeBremsstrahlungContinuous - Check the bremms data file"; |
---|
| 146 | G4Exception(excep); |
---|
| 147 | } |
---|
| 148 | for (j=0;j<NumberofKPoints;j++){ |
---|
| 149 | ReducedCS[i][j] = ReducedCS[i][j]*Normalization; |
---|
| 150 | } |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | //Compute the scaled energy loss distribution and sampling parameters |
---|
| 154 | // for the energies in the simulation grid |
---|
| 155 | |
---|
| 156 | // Interpolation in E |
---|
| 157 | G4double pX[NumberofEPoints]; |
---|
| 158 | G4double pYY[NumberofEPoints]; |
---|
| 159 | for (i=0;i<NumberofEPoints;i++){ |
---|
| 160 | pX[i] = std::log(Energies[i]); |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | for (j=0;j<NumberofKPoints;j++){ |
---|
| 164 | for (i=0;i<NumberofEPoints;i++){ |
---|
| 165 | pYY[i] = std::log(ReducedCS[i][j]); |
---|
| 166 | } |
---|
| 167 | G4PenelopeInterpolator* interpolator2 = new G4PenelopeInterpolator(pX,pYY,NumberofEPoints); |
---|
| 168 | for (i=0;i<NumberofExtendedEGrid;i++){ |
---|
| 169 | G4double ELL = ExtendedLogEnergy[i]; |
---|
| 170 | if (ELL >= pX[0]) { |
---|
| 171 | p0[i][j] = std::exp(interpolator2->CubicSplineInterpolation(ELL)); |
---|
| 172 | } |
---|
| 173 | else |
---|
| 174 | { |
---|
| 175 | G4double F1=interpolator2->CubicSplineInterpolation(pX[0]); |
---|
| 176 | G4double FP1 = interpolator2->FirstDerivative(pX[0]); |
---|
| 177 | p0[i][j] = std::exp(F1+FP1*(ELL-pX[0])); |
---|
| 178 | } |
---|
| 179 | } |
---|
| 180 | delete interpolator2; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | //Forse questa roba (e Pbcut come membro privato) non serve |
---|
| 184 | // G4double PDF[NumberofKPoints]; |
---|
| 185 | |
---|
| 186 | // for (i=0;i<NumberofExtendedEGrid;i++){ |
---|
| 187 | // for (j=0;j<NumberofKPoints;j++){ |
---|
| 188 | // PDF[j]=p0[i][j]; |
---|
| 189 | // } |
---|
| 190 | // G4double Xc=0; |
---|
| 191 | // if (i<(NumberofExtendedEGrid-1)){ |
---|
| 192 | // Xc=tCut/std::exp(ExtendedLogEnergy[i+1]); |
---|
| 193 | // } |
---|
| 194 | // else |
---|
| 195 | // { |
---|
| 196 | // Xc=tCut/std::exp(ExtendedLogEnergy[NumberofExtendedEGrid-1]); |
---|
| 197 | // } |
---|
| 198 | |
---|
| 199 | // G4PenelopeInterpolator* interpolator3 = new G4PenelopeInterpolator(pK,PDF,NumberofKPoints); |
---|
| 200 | // Pbcut[i]=interpolator3->CalculateMomentum(Xc,-1); |
---|
| 201 | // delete interpolator3; |
---|
| 202 | // } |
---|
| 203 | |
---|
| 204 | } |
---|
| 205 | |
---|
| 206 | G4double G4PenelopeBremsstrahlungContinuous::CalculateStopping(G4double e1) |
---|
| 207 | //Stopping power expressed in MeV/mm*2 |
---|
| 208 | { |
---|
| 209 | G4double Xel=std::max(std::log(e1),ExtendedLogEnergy[0]); |
---|
| 210 | G4double Xe=1.0+(Xel-ExtendedLogEnergy[0])*DLFC; |
---|
| 211 | G4int Ke = (G4int) Xe; |
---|
| 212 | G4double Xek = Xe-Ke; |
---|
| 213 | |
---|
| 214 | //Global x-section factor |
---|
| 215 | G4double Fact=Zmat*Zmat*(e1+electron_mass_c2)*(e1+electron_mass_c2)/(e1*(e1+2.0*electron_mass_c2)) |
---|
| 216 | *(millibarn/cm2); |
---|
| 217 | Fact=Fact*PositronCorrection(e1); |
---|
| 218 | |
---|
| 219 | //Moments of the scaled bremss x-section |
---|
| 220 | G4double wcre = tCut/e1; |
---|
| 221 | G4double pY[NumberofKPoints]; |
---|
| 222 | G4double pK[NumberofKPoints] = {1.0e-12,0.05,0.075,0.1,0.125,0.15,0.2,0.25, |
---|
| 223 | 0.3,0.35,0.4,0.45,0.5,0.55,0.6,0.65,0.7, |
---|
| 224 | 0.75,0.8,0.85,0.9,0.925,0.95,0.97,0.99, |
---|
| 225 | 0.995,0.999,0.9995,0.9999,0.99995,0.99999,1.0}; |
---|
| 226 | |
---|
| 227 | for (size_t i=0;i<NumberofKPoints;i++){ |
---|
| 228 | pY[i] = p0[Ke][i]; |
---|
| 229 | } |
---|
| 230 | G4PenelopeInterpolator* interpolator1 = new G4PenelopeInterpolator(pK,pY,NumberofKPoints); |
---|
| 231 | G4double XS1A = interpolator1->CalculateMomentum(wcre,0); |
---|
| 232 | G4double XS2A = interpolator1->CalculateMomentum(wcre,1); |
---|
| 233 | delete interpolator1; |
---|
| 234 | for (size_t k=0;k<NumberofKPoints;k++){ |
---|
| 235 | pY[k] = p0[std::min(Ke+1,(G4int) NumberofExtendedEGrid-1)][k]; |
---|
| 236 | } |
---|
| 237 | G4PenelopeInterpolator* interpolator2 = new G4PenelopeInterpolator (pK,pY,NumberofKPoints); |
---|
| 238 | G4double XS1B = interpolator2->CalculateMomentum(wcre,0); |
---|
| 239 | G4double XS2B = interpolator2->CalculateMomentum(wcre,1); |
---|
| 240 | delete interpolator2; |
---|
| 241 | |
---|
| 242 | G4double XS1 = ((1.0-Xek)*XS1A+Xek*XS1B)*Fact*e1; //weighted mean between the energy bin of the grid |
---|
| 243 | G4double XS2 = ((1.0-Xek)*XS2A+Xek*XS2B)*Fact*e1*e1; //straggling cross section (2nd momentum); |
---|
| 244 | //Il secondo momento XS2 potrebbe tornare utile in seguito |
---|
| 245 | |
---|
| 246 | //XS1 is given in MeV*cm2, as in Penelope, but it must be converted in MeV*mm2 |
---|
| 247 | XS1=XS1*cm2/mm2; |
---|
| 248 | //XS2 is given in MeV2*cm2, as in Penelope, but it must be converted in MeV2*mm2 |
---|
| 249 | XS2=XS2*cm2/mm2; |
---|
| 250 | |
---|
| 251 | //Deve includere anche le famose correzioni per tenere conto |
---|
| 252 | //che la sezione d'urto varia sullo step! |
---|
| 253 | //Il valore che tira fuori va nella tabella e non viene piu' modificato |
---|
| 254 | return XS1; |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | G4double G4PenelopeBremsstrahlungContinuous::PositronCorrection(G4double en) |
---|
| 258 | { |
---|
| 259 | const G4double Coeff[7]={-1.2359e-01,6.1274e-2,-3.1516e-2,7.7446e-3,-1.0595e-3, |
---|
| 260 | 7.0568e-5,-1.8080e-6}; |
---|
| 261 | G4double T=0; |
---|
| 262 | G4double correct=0; |
---|
| 263 | if (partName == "e-") { |
---|
| 264 | return 1.0; //no correction for electrons |
---|
| 265 | } |
---|
| 266 | else if (partName == "e+"){ |
---|
| 267 | T=std::log(1+((1e6*en)/(Zmat*Zmat*electron_mass_c2))); |
---|
| 268 | for (G4int i=0;i<7;i++){ |
---|
| 269 | correct += Coeff[i]*std::pow(T,i+1); |
---|
| 270 | } |
---|
| 271 | correct = 1.0-std::exp(correct); |
---|
| 272 | return correct; |
---|
| 273 | } |
---|
| 274 | else //ne' elettroni ne' positroni...exception |
---|
| 275 | { |
---|
| 276 | G4String excep = "G4PenelopeBremmstrahlungContinuous: the particle is not e- nor e+!"; |
---|
| 277 | G4Exception(excep); |
---|
| 278 | return 0; |
---|
| 279 | } |
---|
| 280 | } |
---|