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: G4TransitionRadiation.cc,v 1.7 2006/06/29 19:56:19 gunter Exp $ >> 28 // GEANT4 tag $Name: geant4-08-01 $ >> 29 // 26 // G4TransitionRadiation class -- implementati 30 // G4TransitionRadiation class -- implementation file 27 31 28 // GEANT 4 class implementation file --- Copyr 32 // GEANT 4 class implementation file --- Copyright CERN 1995 >> 33 // CERN Geneva Switzerland 29 34 30 // For information related to this code, pleas 35 // For information related to this code, please, contact 31 // CERN, CN Division, ASD Group 36 // CERN, CN Division, ASD Group 32 // History: 37 // History: 33 // 1st version 11.09.97 V. Grichine (Vladimir. 38 // 1st version 11.09.97 V. Grichine (Vladimir.Grichine@cern.ch ) 34 // 2nd version 16.12.97 V. Grichine 39 // 2nd version 16.12.97 V. Grichine 35 // 3rd version 28.07.05, P.Gumplinger add G4Pr 40 // 3rd version 28.07.05, P.Gumplinger add G4ProcessType to constructor 36 41 37 //#include <cmath> << 42 >> 43 #include <cmath> >> 44 // #include "G4ios.hh" >> 45 // #include <fstream.h> >> 46 // #include <stdlib.h> 38 47 39 #include "G4TransitionRadiation.hh" 48 #include "G4TransitionRadiation.hh" >> 49 #include "G4Material.hh" >> 50 >> 51 // Init gamma array >> 52 >> 53 >> 54 // Local constants 40 55 41 #include "G4EmProcessSubType.hh" << 56 const G4int G4TransitionRadiation::fSympsonNumber = 100 ; >> 57 const G4int G4TransitionRadiation::fGammaNumber = 15 ; >> 58 const G4int G4TransitionRadiation::fPointNumber = 100 ; >> 59 >> 60 using namespace std; 42 61 43 ////////////////////////////////////////////// 62 /////////////////////////////////////////////////////////////////////// >> 63 // 44 // Constructor for selected couple of material 64 // Constructor for selected couple of materials 45 G4TransitionRadiation::G4TransitionRadiation(c << 65 // 46 G << 66 >> 67 G4TransitionRadiation:: >> 68 G4TransitionRadiation( const G4String& processName, G4ProcessType type ) 47 : G4VDiscreteProcess(processName, type) 69 : G4VDiscreteProcess(processName, type) 48 { 70 { 49 SetProcessSubType(fTransitionRadiation); << 71 // fMatIndex1 = pMat1->GetIndex() ; 50 fMatIndex1 = fMatIndex2 = 0; << 72 // fMatIndex2 = pMat2->GetIndex() ; 51 << 52 fGamma = fEnergy = fVarAngle = fMinEnergy = << 53 fSigma1 = fSigma2 = 0.0; << 54 } 73 } 55 74 56 ////////////////////////////////////////////// 75 ////////////////////////////////////////////////////////////////////// >> 76 // 57 // Destructor 77 // Destructor 58 G4TransitionRadiation::~G4TransitionRadiation( << 78 // 59 79 60 void G4TransitionRadiation::ProcessDescription << 80 G4TransitionRadiation::~G4TransitionRadiation() 61 { 81 { 62 out << "Base class for simulation of x-ray t << 82 ; 63 } 83 } 64 84 65 G4bool G4TransitionRadiation::IsApplicable( << 66 const G4ParticleDefinition& aParticleType) << 67 { << 68 return (aParticleType.GetPDGCharge() != 0.0) << 69 } << 70 << 71 G4double G4TransitionRadiation::GetMeanFreePat << 72 << 73 { << 74 *condition = Forced; << 75 return DBL_MAX; // so TR doesn't limit mean << 76 } << 77 << 78 G4VParticleChange* G4TransitionRadiation::Post << 79 << 80 { << 81 ClearNumberOfInteractionLengthLeft(); << 82 return &aParticleChange; << 83 } << 84 85 85 ////////////////////////////////////////////// 86 /////////////////////////////////////////////////////////////////// >> 87 // 86 // Sympson integral of TR spectral-angle densi 88 // Sympson integral of TR spectral-angle density over energy between 87 // the limits energy 1 and energy2 at fixed va << 89 // the limits energy 1 and energy2 at fixed varAngle = 1 - cos(Theta) 88 G4double G4TransitionRadiation::IntegralOverEn << 90 89 << 91 G4double 90 << 92 G4TransitionRadiation::IntegralOverEnergy( G4double energy1, 91 { << 93 G4double energy2, 92 G4int i; << 94 G4double varAngle ) const 93 G4double h, sumEven = 0.0, sumOdd = 0.0; << 95 { 94 h = 0.5 * (energy2 - energy1) / fSympsonNumb << 96 G4int i ; 95 for(i = 1; i < fSympsonNumber; i++) << 97 G4double h , sumEven = 0.0 , sumOdd = 0.0 ; >> 98 h = 0.5*(energy2 - energy1)/fSympsonNumber ; >> 99 for(i=1;i<fSympsonNumber;i++) 96 { 100 { 97 sumEven += SpectralAngleTRdensity(energy1 << 101 sumEven += SpectralAngleTRdensity(energy1 + 2*i*h,varAngle) ; 98 sumOdd += SpectralAngleTRdensity(energy1 + << 102 sumOdd += SpectralAngleTRdensity(energy1 + (2*i - 1)*h,varAngle) ; 99 } 103 } 100 sumOdd += << 104 sumOdd += SpectralAngleTRdensity(energy1 + (2*fSympsonNumber - 1)*h,varAngle) ; 101 SpectralAngleTRdensity(energy1 + (2 * fSym << 105 return h*( SpectralAngleTRdensity(energy1,varAngle) 102 return h * << 106 + SpectralAngleTRdensity(energy2,varAngle) 103 (SpectralAngleTRdensity(energy1, varA << 107 + 4.0*sumOdd + 2.0*sumEven )/3.0 ; 104 SpectralAngleTRdensity(energy2, varA << 105 2.0 * sumEven) / << 106 3.0; << 107 } 108 } 108 109 >> 110 >> 111 109 ////////////////////////////////////////////// 112 /////////////////////////////////////////////////////////////////// >> 113 // 110 // Sympson integral of TR spectral-angle densi 114 // Sympson integral of TR spectral-angle density over energy between 111 // the limits varAngle1 and varAngle2 at fixed 115 // the limits varAngle1 and varAngle2 at fixed energy 112 G4double G4TransitionRadiation::IntegralOverAn << 116 113 << 117 G4double 114 << 118 G4TransitionRadiation::IntegralOverAngle( G4double energy, 115 { << 119 G4double varAngle1, 116 G4int i; << 120 G4double varAngle2 ) const 117 G4double h, sumEven = 0.0, sumOdd = 0.0; << 121 { 118 h = 0.5 * (varAngle2 - varAngle1) / fSympson << 122 G4int i ; 119 for(i = 1; i < fSympsonNumber; ++i) << 123 G4double h , sumEven = 0.0 , sumOdd = 0.0 ; >> 124 h = 0.5*(varAngle2 - varAngle1)/fSympsonNumber ; >> 125 for(i=1;i<fSympsonNumber;i++) 120 { 126 { 121 sumEven += SpectralAngleTRdensity(energy, << 127 sumEven += SpectralAngleTRdensity(energy,varAngle1 + 2*i*h) ; 122 sumOdd += SpectralAngleTRdensity(energy, v << 128 sumOdd += SpectralAngleTRdensity(energy,varAngle1 + (2*i - 1)*h) ; 123 } 129 } 124 sumOdd += << 130 sumOdd += SpectralAngleTRdensity(energy,varAngle1 + (2*fSympsonNumber - 1)*h) ; 125 SpectralAngleTRdensity(energy, varAngle1 + << 126 131 127 return h * << 132 return h*( SpectralAngleTRdensity(energy,varAngle1) 128 (SpectralAngleTRdensity(energy, varAn << 133 + SpectralAngleTRdensity(energy,varAngle2) 129 SpectralAngleTRdensity(energy, varAn << 134 + 4.0*sumOdd + 2.0*sumEven )/3.0 ; 130 2.0 * sumEven) / << 131 3.0; << 132 } 135 } 133 136 134 ////////////////////////////////////////////// 137 /////////////////////////////////////////////////////////////////// >> 138 // 135 // The number of transition radiation photons 139 // The number of transition radiation photons generated in the 136 // angle interval between varAngle1 and varAng 140 // angle interval between varAngle1 and varAngle2 137 G4double G4TransitionRadiation::AngleIntegralD << 141 // 138 G4double varAngle1, G4double varAngle2) cons << 142 139 { << 143 G4double G4TransitionRadiation:: 140 G4int i; << 144 AngleIntegralDistribution( G4double varAngle1, 141 G4double h, sumEven = 0.0, sumOdd = 0.0; << 145 G4double varAngle2 ) const 142 h = 0.5 * (varAngle2 - varAngle1) / fSympson << 146 { 143 for(i = 1; i < fSympsonNumber; ++i) << 147 G4int i ; >> 148 G4double h , sumEven = 0.0 , sumOdd = 0.0 ; >> 149 h = 0.5*(varAngle2 - varAngle1)/fSympsonNumber ; >> 150 for(i=1;i<fSympsonNumber;i++) 144 { 151 { 145 sumEven += IntegralOverEnergy(fMinEnergy, << 152 sumEven += IntegralOverEnergy(fMinEnergy, 146 fMinEnergy + << 153 fMinEnergy +0.3*(fMaxEnergy-fMinEnergy), 147 varAngle1 + << 154 varAngle1 + 2*i*h) 148 IntegralOverEnergy(fMinEnergy + << 155 + IntegralOverEnergy(fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), 149 fMaxEnergy, << 156 fMaxEnergy, 150 sumOdd += IntegralOverEnergy(fMinEnergy, << 157 varAngle1 + 2*i*h); 151 fMinEnergy + << 158 sumOdd += IntegralOverEnergy(fMinEnergy, 152 varAngle1 + ( << 159 fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), 153 IntegralOverEnergy(fMinEnergy + << 160 varAngle1 + (2*i - 1)*h) 154 fMaxEnergy, v << 161 + IntegralOverEnergy(fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), >> 162 fMaxEnergy, >> 163 varAngle1 + (2*i - 1)*h) ; 155 } 164 } 156 sumOdd += << 165 sumOdd += IntegralOverEnergy(fMinEnergy, 157 IntegralOverEnergy(fMinEnergy, fMinEnergy << 166 fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), 158 varAngle1 + (2 * fSymps << 167 varAngle1 + (2*fSympsonNumber - 1)*h) 159 IntegralOverEnergy(fMinEnergy + 0.3 * (fMa << 168 + IntegralOverEnergy(fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), 160 varAngle1 + (2 * fSymps << 169 fMaxEnergy, 161 << 170 varAngle1 + (2*fSympsonNumber - 1)*h) ; 162 return h * << 171 163 (IntegralOverEnergy(fMinEnergy, << 172 return h*(IntegralOverEnergy(fMinEnergy, 164 fMinEnergy + 0.3 << 173 fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), 165 varAngle1) + << 174 varAngle1) 166 IntegralOverEnergy(fMinEnergy + 0.3 << 175 + IntegralOverEnergy(fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), 167 fMaxEnergy, varAn << 176 fMaxEnergy, 168 IntegralOverEnergy(fMinEnergy, << 177 varAngle1) 169 fMinEnergy + 0.3 << 178 + IntegralOverEnergy(fMinEnergy, 170 varAngle2) + << 179 fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), 171 IntegralOverEnergy(fMinEnergy + 0.3 << 180 varAngle2) 172 fMaxEnergy, varAn << 181 + IntegralOverEnergy(fMinEnergy + 0.3*(fMaxEnergy - fMinEnergy), 173 4.0 * sumOdd + 2.0 * sumEven) / << 182 fMaxEnergy, 174 3.0; << 183 varAngle2) >> 184 + 4.0*sumOdd + 2.0*sumEven )/3.0 ; 175 } 185 } 176 186 177 ////////////////////////////////////////////// 187 /////////////////////////////////////////////////////////////////// >> 188 // 178 // The number of transition radiation photons, 189 // The number of transition radiation photons, generated in the 179 // energy interval between energy1 and energy2 190 // energy interval between energy1 and energy2 180 G4double G4TransitionRadiation::EnergyIntegral << 191 // 181 G4double energy1, G4double energy2) const << 192 182 { << 193 G4double G4TransitionRadiation:: 183 G4int i; << 194 EnergyIntegralDistribution( G4double energy1, 184 G4double h, sumEven = 0.0, sumOdd = 0.0; << 195 G4double energy2 ) const 185 h = 0.5 * (energy2 - energy1) / fSympsonNumb << 196 { 186 for(i = 1; i < fSympsonNumber; ++i) << 197 G4int i ; >> 198 G4double h , sumEven = 0.0 , sumOdd = 0.0 ; >> 199 h = 0.5*(energy2 - energy1)/fSympsonNumber ; >> 200 for(i=1;i<fSympsonNumber;i++) 187 { 201 { 188 sumEven += << 202 sumEven += IntegralOverAngle(energy1 + 2*i*h,0.0,0.01*fMaxTheta ) 189 IntegralOverAngle(energy1 + 2 * i * h, 0 << 203 + IntegralOverAngle(energy1 + 2*i*h,0.01*fMaxTheta,fMaxTheta); 190 IntegralOverAngle(energy1 + 2 * i * h, 0 << 204 sumOdd += IntegralOverAngle(energy1 + (2*i - 1)*h,0.0,0.01*fMaxTheta) 191 sumOdd += << 205 + IntegralOverAngle(energy1 + (2*i - 1)*h,0.01*fMaxTheta,fMaxTheta) ; 192 IntegralOverAngle(energy1 + (2 * i - 1) << 193 IntegralOverAngle(energy1 + (2 * i - 1) << 194 } 206 } 195 sumOdd += IntegralOverAngle(energy1 + (2 * f << 207 sumOdd += IntegralOverAngle(energy1 + (2*fSympsonNumber - 1)*h, 196 0.01 * fMaxTheta << 208 0.0,0.01*fMaxTheta) 197 IntegralOverAngle(energy1 + (2 * f << 209 + IntegralOverAngle(energy1 + (2*fSympsonNumber - 1)*h, 198 0.01 * fMaxTheta << 210 0.01*fMaxTheta,fMaxTheta) ; 199 << 211 200 return h * << 212 return h*(IntegralOverAngle(energy1,0.0,0.01*fMaxTheta) 201 (IntegralOverAngle(energy1, 0.0, 0.01 << 213 + IntegralOverAngle(energy1,0.01*fMaxTheta,fMaxTheta) 202 IntegralOverAngle(energy1, 0.01 * fM << 214 + IntegralOverAngle(energy2,0.0,0.01*fMaxTheta) 203 IntegralOverAngle(energy2, 0.0, 0.01 << 215 + IntegralOverAngle(energy2,0.01*fMaxTheta,fMaxTheta) 204 IntegralOverAngle(energy2, 0.01 * fM << 216 + 4.0*sumOdd + 2.0*sumEven )/3.0 ; 205 4.0 * sumOdd + 2.0 * sumEven) / << 206 3.0; << 207 } 217 } >> 218 >> 219 >> 220 >> 221 >> 222 // end of G4TransitionRadiation implementation file -------------------------- 208 223