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: G4VXTRenergyLoss.cc,v 1.44 2007/09/29 17:49:34 vnivanch Exp $ >> 28 // GEANT4 tag $Name: geant4-09-02-patch-04 $ >> 29 // 26 // History: 30 // History: 27 // 2001-2002 R&D by V.Grichine 31 // 2001-2002 R&D by V.Grichine 28 // 19.06.03 V. Grichine, modifications in Buil << 32 // 19.06.03 V. Grichine, modifications in BuildTable for the integration 29 // in respect of angle: 33 // in respect of angle: range is increased, accuracy is 30 // improved 34 // improved 31 // 28.07.05, P.Gumplinger add G4ProcessType to 35 // 28.07.05, P.Gumplinger add G4ProcessType to constructor 32 // 28.09.07, V.Ivanchenko general cleanup with 36 // 28.09.07, V.Ivanchenko general cleanup without change of algorithms 33 // 37 // 34 38 35 #include "G4VXTRenergyLoss.hh" << 39 #include "G4Timer.hh" 36 40 37 #include "G4AffineTransform.hh" << 41 #include "G4VXTRenergyLoss.hh" 38 #include "G4DynamicParticle.hh" << 42 #include "G4Poisson.hh" 39 #include "G4EmProcessSubType.hh" << 40 #include "G4Integrator.hh" << 41 #include "G4MaterialTable.hh" 43 #include "G4MaterialTable.hh" 42 #include "G4ParticleMomentum.hh" << 43 #include "G4PhysicalConstants.hh" << 44 #include "G4PhysicsFreeVector.hh" << 45 #include "G4PhysicsLinearVector.hh" << 46 #include "G4PhysicsLogVector.hh" << 47 #include "G4RotationMatrix.hh" << 48 #include "G4SandiaTable.hh" << 49 #include "G4SystemOfUnits.hh" << 50 #include "G4ThreeVector.hh" << 51 #include "G4Timer.hh" << 52 #include "G4VDiscreteProcess.hh" 44 #include "G4VDiscreteProcess.hh" 53 #include "G4VParticleChange.hh" 45 #include "G4VParticleChange.hh" 54 #include "G4VSolid.hh" 46 #include "G4VSolid.hh" 55 #include "G4PhysicsModelCatalog.hh" << 47 >> 48 #include "G4RotationMatrix.hh" >> 49 #include "G4ThreeVector.hh" >> 50 #include "G4AffineTransform.hh" >> 51 #include "G4SandiaTable.hh" >> 52 >> 53 #include "G4PhysicsVector.hh" >> 54 #include "G4PhysicsFreeVector.hh" >> 55 #include "G4PhysicsLinearVector.hh" >> 56 >> 57 using namespace std; 56 58 57 ////////////////////////////////////////////// 59 //////////////////////////////////////////////////////////////////////////// >> 60 // 58 // Constructor, destructor 61 // Constructor, destructor 59 G4VXTRenergyLoss::G4VXTRenergyLoss(G4LogicalVo << 62 60 G4Material* << 63 G4VXTRenergyLoss::G4VXTRenergyLoss(G4LogicalVolume *anEnvelope, 61 G4double a, << 64 G4Material* foilMat,G4Material* gasMat, 62 const G4Str << 65 G4double a, G4double b, 63 G4ProcessTy << 66 G4int n,const G4String& processName, 64 : G4VDiscreteProcess(processName, type) << 67 G4ProcessType type) : 65 , fGammaCutInKineticEnergy(nullptr) << 68 G4VDiscreteProcess(processName, type), 66 , fAngleDistrTable(nullptr) << 69 fGammaCutInKineticEnergy(0), 67 , fEnergyDistrTable(nullptr) << 70 fGammaTkinCut(0), 68 , fAngleForEnergyTable(nullptr) << 71 fAngleDistrTable(0), 69 , fPlatePhotoAbsCof(nullptr) << 72 fEnergyDistrTable(0), 70 , fGasPhotoAbsCof(nullptr) << 73 fPlatePhotoAbsCof(0), 71 , fGammaTkinCut(0.0) << 74 fGasPhotoAbsCof(0), >> 75 fAngleForEnergyTable(0) 72 { 76 { 73 verboseLevel = 1; 77 verboseLevel = 1; 74 secID = G4PhysicsModelCatalog::GetModelID("m << 75 SetProcessSubType(fTransitionRadiation); << 76 << 77 fPtrGamma = nullptr; << 78 fMinEnergyTR = fMaxEnergyTR = fMaxThetaTR = << 79 fVarAngle = fLambda = fTotalDist = fPlateThi << 80 fAlphaPlate = 100.; << 81 fAlphaGas = 40.; << 82 << 83 fTheMinEnergyTR = CLHEP::keV * 1.; // 1.; / << 84 fTheMaxEnergyTR = CLHEP::keV * 100.; // 40.; << 85 << 86 fTheMinAngle = 1.e-8; // << 87 fTheMaxAngle = 4.e-4; << 88 << 89 fTotBin = 50; // number of bins in log sca << 90 fBinTR = 100; // number of bins in TR vec << 91 fKrange = 229; << 92 // min/max angle2 in log-vectors << 93 78 94 fMinThetaTR = 3.0e-9; << 79 // Initialization of local constants 95 fMaxThetaTR = 1.0e-4; << 80 fTheMinEnergyTR = 1.0*keV; >> 81 fTheMaxEnergyTR = 100.0*keV; >> 82 fTheMaxAngle = 1.0e-3; >> 83 fTheMinAngle = 5.0e-6; >> 84 fBinTR = 50; >> 85 >> 86 fMinProtonTkin = 100.0*GeV; >> 87 fMaxProtonTkin = 100.0*TeV; >> 88 fTotBin = 50; 96 89 97 << 98 // Proton energy vector initialization 90 // Proton energy vector initialization 99 fProtonEnergyVector = << 100 new G4PhysicsLogVector(fMinProtonTkin, fMa << 101 91 102 fXTREnergyVector = << 92 fProtonEnergyVector = new G4PhysicsLogVector(fMinProtonTkin, 103 new G4PhysicsLogVector(fTheMinEnergyTR, fT << 93 fMaxProtonTkin, >> 94 fTotBin ); >> 95 >> 96 fXTREnergyVector = new G4PhysicsLogVector(fTheMinEnergyTR, >> 97 fTheMaxEnergyTR, >> 98 fBinTR ); >> 99 >> 100 fPlasmaCof = 4.0*pi*fine_structure_const*hbarc*hbarc*hbarc/electron_mass_c2; >> 101 >> 102 fCofTR = fine_structure_const/pi; 104 103 105 fEnvelope = anEnvelope; << 104 fEnvelope = anEnvelope ; 106 105 107 fPlateNumber = n; << 106 fPlateNumber = n ; 108 if(verboseLevel > 0) 107 if(verboseLevel > 0) 109 G4cout << "### G4VXTRenergyLoss: the numbe << 108 G4cout<<"### G4VXTRenergyLoss: the number of TR radiator plates = " 110 << fPlateNumber << G4endl; << 109 <<fPlateNumber<<G4endl ; 111 if(fPlateNumber == 0) 110 if(fPlateNumber == 0) 112 { 111 { 113 G4Exception("G4VXTRenergyLoss::G4VXTRenerg << 112 G4Exception("G4VXTRenergyLoss: No plates in X-ray TR radiator") ; 114 FatalException, "No plates in << 115 } 113 } 116 // default is XTR dEdx, not flux after radia 114 // default is XTR dEdx, not flux after radiator >> 115 117 fExitFlux = false; 116 fExitFlux = false; 118 // default angle distribution according nume << 117 fAngleRadDistr = false; 119 fFastAngle = false; // no angle accordin << 120 fAngleRadDistr = true; << 121 fCompton = false; 118 fCompton = false; 122 119 123 fLambda = DBL_MAX; 120 fLambda = DBL_MAX; 124 << 125 // Mean thicknesses of plates and gas gaps 121 // Mean thicknesses of plates and gas gaps 126 fPlateThick = a; << 122 127 fGasThick = b; << 123 fPlateThick = a ; 128 fTotalDist = fPlateNumber * (fPlateThick + << 124 fGasThick = b ; >> 125 fTotalDist = fPlateNumber*(fPlateThick+fGasThick) ; 129 if(verboseLevel > 0) 126 if(verboseLevel > 0) 130 G4cout << "total radiator thickness = " << << 127 G4cout<<"total radiator thickness = "<<fTotalDist/cm<<" cm"<<G4endl ; 131 << G4endl; << 132 128 133 // index of plate material 129 // index of plate material 134 fMatIndex1 = (G4int)foilMat->GetIndex(); << 130 fMatIndex1 = foilMat->GetIndex() ; 135 if(verboseLevel > 0) 131 if(verboseLevel > 0) 136 G4cout << "plate material = " << foilMat-> << 132 G4cout<<"plate material = "<<foilMat->GetName()<<G4endl ; 137 133 138 // index of gas material 134 // index of gas material 139 fMatIndex2 = (G4int)gasMat->GetIndex(); << 135 fMatIndex2 = gasMat->GetIndex() ; 140 if(verboseLevel > 0) 136 if(verboseLevel > 0) 141 G4cout << "gas material = " << gasMat->Get << 137 G4cout<<"gas material = "<<gasMat->GetName()<<G4endl ; 142 138 143 // plasma energy squared for plate material 139 // plasma energy squared for plate material 144 fSigma1 = fPlasmaCof * foilMat->GetElectronD << 140 >> 141 fSigma1 = fPlasmaCof*foilMat->GetElectronDensity() ; >> 142 // fSigma1 = (20.9*eV)*(20.9*eV) ; 145 if(verboseLevel > 0) 143 if(verboseLevel > 0) 146 G4cout << "plate plasma energy = " << std: << 144 G4cout<<"plate plasma energy = "<<sqrt(fSigma1)/eV<<" eV"<<G4endl ; 147 << G4endl; << 148 145 149 // plasma energy squared for gas material 146 // plasma energy squared for gas material 150 fSigma2 = fPlasmaCof * gasMat->GetElectronDe << 147 >> 148 fSigma2 = fPlasmaCof*gasMat->GetElectronDensity() ; 151 if(verboseLevel > 0) 149 if(verboseLevel > 0) 152 G4cout << "gas plasma energy = " << std::s << 150 G4cout<<"gas plasma energy = "<<sqrt(fSigma2)/eV<<" eV"<<G4endl ; 153 << G4endl; << 154 151 155 // Compute cofs for preparation of linear ph 152 // Compute cofs for preparation of linear photo absorption 156 ComputePlatePhotoAbsCof(); << 153 157 ComputeGasPhotoAbsCof(); << 154 ComputePlatePhotoAbsCof() ; >> 155 ComputeGasPhotoAbsCof() ; 158 156 159 pParticleChange = &fParticleChange; 157 pParticleChange = &fParticleChange; >> 158 160 } 159 } 161 160 162 ////////////////////////////////////////////// 161 /////////////////////////////////////////////////////////////////////////// 163 G4VXTRenergyLoss::~G4VXTRenergyLoss() << 164 { << 165 delete fProtonEnergyVector; << 166 delete fXTREnergyVector; << 167 if(fEnergyDistrTable) << 168 { << 169 fEnergyDistrTable->clearAndDestroy(); << 170 delete fEnergyDistrTable; << 171 } << 172 if(fAngleRadDistr) << 173 { << 174 fAngleDistrTable->clearAndDestroy(); << 175 delete fAngleDistrTable; << 176 } << 177 if(fAngleForEnergyTable) << 178 { << 179 fAngleForEnergyTable->clearAndDestroy(); << 180 delete fAngleForEnergyTable; << 181 } << 182 } << 183 162 184 void G4VXTRenergyLoss::ProcessDescription(std: << 163 G4VXTRenergyLoss::~G4VXTRenergyLoss() 185 { 164 { 186 out << "Base class for 'fast' parameterisati << 165 if(fEnvelope) delete fEnvelope; 187 "transition\n" << 188 "radiation. Angular distribution is v << 189 } 166 } 190 167 191 ////////////////////////////////////////////// 168 /////////////////////////////////////////////////////////////////////////////// >> 169 // 192 // Returns condition for application of the mo 170 // Returns condition for application of the model depending on particle type >> 171 >> 172 193 G4bool G4VXTRenergyLoss::IsApplicable(const G4 173 G4bool G4VXTRenergyLoss::IsApplicable(const G4ParticleDefinition& particle) 194 { 174 { 195 return (particle.GetPDGCharge() != 0.0); << 175 return ( particle.GetPDGCharge() != 0.0 ) ; 196 } 176 } 197 177 198 ////////////////////////////////////////////// 178 ///////////////////////////////////////////////////////////////////////////////// >> 179 // 199 // Calculate step size for XTR process inside 180 // Calculate step size for XTR process inside raaditor 200 G4double G4VXTRenergyLoss::GetMeanFreePath(con << 181 201 G4F << 182 G4double G4VXTRenergyLoss::GetMeanFreePath(const G4Track& aTrack, >> 183 G4double, // previousStepSize, >> 184 G4ForceCondition* condition) 202 { 185 { 203 G4int iTkin, iPlace; 186 G4int iTkin, iPlace; 204 G4double lambda, sigma, kinEnergy, mass, gam 187 G4double lambda, sigma, kinEnergy, mass, gamma; 205 G4double charge, chargeSq, massRatio, TkinSc 188 G4double charge, chargeSq, massRatio, TkinScaled; 206 G4double E1, E2, W, W1, W2; << 189 G4double E1,E2,W,W1,W2; 207 190 208 *condition = NotForced; 191 *condition = NotForced; 209 << 192 210 if(aTrack.GetVolume()->GetLogicalVolume() != << 193 if( aTrack.GetVolume()->GetLogicalVolume() != fEnvelope ) lambda = DBL_MAX; 211 lambda = DBL_MAX; << 212 else 194 else 213 { 195 { 214 const G4DynamicParticle* aParticle = aTrac 196 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 215 kinEnergy = aPart << 197 kinEnergy = aParticle->GetKineticEnergy(); 216 mass = aParticle->GetDefinition()->GetPDG << 198 mass = aParticle->GetDefinition()->GetPDGMass(); 217 gamma = 1.0 + kinEnergy / mass; << 199 gamma = 1.0 + kinEnergy/mass; 218 if(verboseLevel > 1) 200 if(verboseLevel > 1) 219 { 201 { 220 G4cout << " gamma = " << gamma << "; f << 202 G4cout<<" gamma = "<<gamma<<"; fGamma = "<<fGamma<<G4endl; 221 } 203 } 222 204 223 if(std::fabs(gamma - fGamma) < 0.05 * gamm << 205 if ( fabs( gamma - fGamma ) < 0.05*gamma ) lambda = fLambda; 224 lambda = fLambda; << 225 else 206 else 226 { 207 { 227 charge = aParticle->GetDefinition()- << 208 charge = aParticle->GetDefinition()->GetPDGCharge(); 228 chargeSq = charge * charge; << 209 chargeSq = charge*charge; 229 massRatio = proton_mass_c2 / mass; << 210 massRatio = proton_mass_c2/mass; 230 TkinScaled = kinEnergy * massRatio; << 211 TkinScaled = kinEnergy*massRatio; 231 212 232 for(iTkin = 0; iTkin < fTotBin; ++iTkin) << 213 for(iTkin = 0; iTkin < fTotBin; iTkin++) 233 { 214 { 234 if(TkinScaled < fProtonEnergyVector->G << 215 if( TkinScaled < fProtonEnergyVector->GetLowEdgeEnergy(iTkin)) break ; 235 break; << 236 } 216 } 237 iPlace = iTkin - 1; << 217 iPlace = iTkin - 1 ; 238 218 239 if(iTkin == 0) << 219 if(iTkin == 0) lambda = DBL_MAX; // Tkin is too small, neglect of TR photon generation 240 lambda = DBL_MAX; // Tkin is too smal << 220 else // general case: Tkin between two vectors of the material 241 else // general case: Tkin between two << 242 { 221 { 243 if(iTkin == fTotBin) << 222 if(iTkin == fTotBin) 244 { 223 { 245 sigma = (*(*fEnergyDistrTable)(iPlac << 224 sigma = (*(*fEnergyDistrTable)(iPlace))(0)*chargeSq; 246 } 225 } 247 else 226 else 248 { 227 { 249 E1 = fProtonEnergyVector->GetLowE << 228 E1 = fProtonEnergyVector->GetLowEdgeEnergy(iTkin - 1) ; 250 E2 = fProtonEnergyVector->GetLowE << 229 E2 = fProtonEnergyVector->GetLowEdgeEnergy(iTkin) ; 251 W = 1.0 / (E2 - E1); << 230 W = 1.0/(E2 - E1) ; 252 W1 = (E2 - TkinScaled) * W; << 231 W1 = (E2 - TkinScaled)*W ; 253 W2 = (TkinScaled - E1) * W; << 232 W2 = (TkinScaled - E1)*W ; 254 sigma = ((*(*fEnergyDistrTable)(iPla << 233 sigma = ( (*(*fEnergyDistrTable)(iPlace ))(0)*W1 + 255 (*(*fEnergyDistrTable)(iPla << 234 (*(*fEnergyDistrTable)(iPlace+1))(0)*W2 )*chargeSq; 256 chargeSq; << 235 257 } 236 } 258 if(sigma < DBL_MIN) << 237 if (sigma < DBL_MIN) lambda = DBL_MAX; 259 lambda = DBL_MAX; << 238 else lambda = 1./sigma; 260 else << 261 lambda = 1. / sigma; << 262 fLambda = lambda; 239 fLambda = lambda; 263 fGamma = gamma; << 240 fGamma = gamma; 264 if(verboseLevel > 1) 241 if(verboseLevel > 1) 265 { 242 { 266 G4cout << " lambda = " << lambda / m << 243 G4cout<<" lambda = "<<lambda/mm<<" mm"<<G4endl; 267 } 244 } 268 } 245 } 269 } 246 } 270 } << 247 } 271 return lambda; 248 return lambda; 272 } 249 } 273 250 274 ////////////////////////////////////////////// 251 ////////////////////////////////////////////////////////////////////////// >> 252 // 275 // Interface for build table from physics list 253 // Interface for build table from physics list >> 254 276 void G4VXTRenergyLoss::BuildPhysicsTable(const 255 void G4VXTRenergyLoss::BuildPhysicsTable(const G4ParticleDefinition& pd) 277 { 256 { 278 if(pd.GetPDGCharge() == 0.) << 257 if(pd.GetPDGCharge() == 0.) 279 { 258 { 280 G4Exception("G4VXTRenergyLoss::BuildPhysic << 259 G4Exception("G4VXTRenergyLoss::BuildPhysicsTable", "Notification", JustWarning, 281 JustWarning, "XTR initialisati << 260 "XTR initialisation for neutral particle ?!" ); 282 } 261 } 283 BuildEnergyTable(); << 262 BuildTable(); 284 << 263 if (fAngleRadDistr) 285 if(fAngleRadDistr) << 286 { 264 { 287 if(verboseLevel > 0) 265 if(verboseLevel > 0) 288 { << 266 G4cout<<"Build angle distribution according the transparent regular radiator" 289 G4cout << 267 <<G4endl; 290 << "Build angle for energy distributio << 268 BuildAngleTable(); 291 << G4endl; << 292 } << 293 BuildAngleForEnergyBank(); << 294 } 269 } 295 } 270 } 296 271 >> 272 297 ////////////////////////////////////////////// 273 ////////////////////////////////////////////////////////////////////////// >> 274 // 298 // Build integral energy distribution of XTR p 275 // Build integral energy distribution of XTR photons 299 void G4VXTRenergyLoss::BuildEnergyTable() << 276 >> 277 void G4VXTRenergyLoss::BuildTable() 300 { 278 { 301 G4int iTkin, iTR, iPlace; 279 G4int iTkin, iTR, iPlace; 302 G4double radiatorCof = 1.0; // for tuning o << 280 G4double radiatorCof = 1.0; // for tuning of XTR yield 303 G4double energySum = 0.0; << 304 281 305 fEnergyDistrTable = new G4PhysicsTable(fTotB 282 fEnergyDistrTable = new G4PhysicsTable(fTotBin); 306 if(fAngleRadDistr) << 307 fAngleDistrTable = new G4PhysicsTable(fTot << 308 283 309 fGammaTkinCut = 0.0; 284 fGammaTkinCut = 0.0; >> 285 >> 286 // setting of min/max TR energies >> 287 >> 288 if(fGammaTkinCut > fTheMinEnergyTR) fMinEnergyTR = fGammaTkinCut ; >> 289 else fMinEnergyTR = fTheMinEnergyTR ; >> 290 >> 291 if(fGammaTkinCut > fTheMaxEnergyTR) fMaxEnergyTR = 2.0*fGammaTkinCut ; >> 292 else fMaxEnergyTR = fTheMaxEnergyTR ; 310 293 311 // setting of min/max TR energies << 294 G4cout.precision(4) ; 312 if(fGammaTkinCut > fTheMinEnergyTR) << 295 G4Timer timer ; 313 fMinEnergyTR = fGammaTkinCut; << 296 timer.Start() ; 314 else << 315 fMinEnergyTR = fTheMinEnergyTR; << 316 << 317 if(fGammaTkinCut > fTheMaxEnergyTR) << 318 fMaxEnergyTR = 2.0 * fGammaTkinCut; << 319 else << 320 fMaxEnergyTR = fTheMaxEnergyTR; << 321 << 322 G4Integrator<G4VXTRenergyLoss, G4double (G4V << 323 integral; << 324 << 325 G4cout.precision(4); << 326 G4Timer timer; << 327 timer.Start(); << 328 297 329 if(verboseLevel > 0) << 298 if(verboseLevel > 0) { 330 { << 299 G4cout<<G4endl; 331 G4cout << G4endl; << 300 G4cout<<"Lorentz Factor"<<"\t"<<"XTR photon number"<<G4endl; 332 G4cout << "Lorentz Factor" << 301 G4cout<<G4endl; 333 << "\t" << 334 << "XTR photon number" << G4endl; << 335 G4cout << G4endl; << 336 } 302 } 337 for(iTkin = 0; iTkin < fTotBin; ++iTkin) // << 303 for( iTkin = 0 ; iTkin < fTotBin ; iTkin++ ) // Lorentz factor loop 338 { 304 { 339 auto energyVector = << 305 G4PhysicsLogVector* energyVector = new G4PhysicsLogVector( fMinEnergyTR, 340 new G4PhysicsLogVector(fMinEnergyTR, fMa << 306 fMaxEnergyTR, >> 307 fBinTR ) ; 341 308 342 fGamma = << 309 fGamma = 1.0 + (fProtonEnergyVector-> 343 1.0 + (fProtonEnergyVector->GetLowEdgeEn << 310 GetLowEdgeEnergy(iTkin)/proton_mass_c2) ; 344 311 345 // if(fMaxThetaTR > fTheMaxAngle) fMax << 312 fMaxThetaTR = 25.0/(fGamma*fGamma) ; // theta^2 346 // else if(fMaxThetaTR < fTheMinAngle) << 347 313 348 energySum = 0.0; << 314 fTheMinAngle = 1.0e-3 ; // was 5.e-6, e-6 !!!, e-5, e-4 >> 315 >> 316 if( fMaxThetaTR > fTheMaxAngle ) fMaxThetaTR = fTheMaxAngle; >> 317 else >> 318 { >> 319 if( fMaxThetaTR < fTheMinAngle ) fMaxThetaTR = fTheMinAngle; >> 320 } >> 321 G4PhysicsLinearVector* angleVector = new G4PhysicsLinearVector(0.0, >> 322 fMaxThetaTR, >> 323 fBinTR ); 349 324 350 energyVector->PutValue(fBinTR - 1, energyS << 325 G4double energySum = 0.0; >> 326 G4double angleSum = 0.0; 351 327 352 for(iTR = fBinTR - 2; iTR >= 0; --iTR) << 328 G4Integrator<G4VXTRenergyLoss,G4double(G4VXTRenergyLoss::*)(G4double)> integral; 353 { << 354 // Legendre96 or Legendre10 << 355 329 356 energySum += radiatorCof * fCofTR * << 330 energyVector->PutValue(fBinTR-1,energySum); 357 << 331 angleVector->PutValue(fBinTR-1,angleSum); 358 // integral.Legendre10(this, &G4VXTRenergyLo << 359 << 360 integral.Legendre96(this, & << 361 << 362 energyV << 363 energyV << 364 332 365 energyVector->PutValue(iTR, energySum / << 333 for( iTR = fBinTR - 2 ; iTR >= 0 ; iTR-- ) 366 } << 334 { 367 iPlace = iTkin; << 335 energySum += radiatorCof*fCofTR*integral.Legendre10( 368 fEnergyDistrTable->insertAt(iPlace, energy << 336 this,&G4VXTRenergyLoss::SpectralXTRdEdx, >> 337 energyVector->GetLowEdgeEnergy(iTR), >> 338 energyVector->GetLowEdgeEnergy(iTR+1) ); >> 339 >> 340 // angleSum += fCofTR*integral.Legendre96( >> 341 // this,&G4VXTRenergyLoss::AngleXTRdEdx, >> 342 // angleVector->GetLowEdgeEnergy(iTR), >> 343 // angleVector->GetLowEdgeEnergy(iTR+1) ); 369 344 >> 345 energyVector->PutValue(iTR,energySum/fTotalDist); >> 346 // angleVector ->PutValue(iTR,angleSum); >> 347 } 370 if(verboseLevel > 0) 348 if(verboseLevel > 0) 371 { << 349 { 372 G4cout << fGamma << "\t" << energySum << << 350 G4cout 373 } << 351 // <<iTkin<<"\t" 374 } << 352 // <<"fGamma = " >> 353 <<fGamma<<"\t" // <<" fMaxThetaTR = "<<fMaxThetaTR >> 354 // <<"sumN = " >> 355 <<energySum // <<" ; sumA = "<<angleSum >> 356 <<G4endl; >> 357 } >> 358 iPlace = iTkin; >> 359 fEnergyDistrTable->insertAt(iPlace,energyVector); >> 360 // fAngleDistrTable->insertAt(iPlace,angleVector); >> 361 } 375 timer.Stop(); 362 timer.Stop(); 376 G4cout.precision(6); 363 G4cout.precision(6); 377 if(verboseLevel > 0) << 364 if(verboseLevel > 0) { 378 { << 365 G4cout<<G4endl; 379 G4cout << G4endl; << 366 G4cout<<"total time for build X-ray TR energy loss tables = " 380 G4cout << "total time for build X-ray TR e << 367 <<timer.GetUserElapsed()<<" s"<<G4endl; 381 << timer.GetUserElapsed() << " s" < << 382 } 368 } 383 fGamma = 0.; 369 fGamma = 0.; 384 return; << 370 return ; 385 } 371 } 386 372 387 ////////////////////////////////////////////// 373 ////////////////////////////////////////////////////////////////////////// 388 // Bank of angle distributions for given energ << 374 // >> 375 // 389 376 390 void G4VXTRenergyLoss::BuildAngleForEnergyBank << 377 void G4VXTRenergyLoss::BuildEnergyTable() 391 { 378 { 392 << 393 if( ( this->GetProcessName() == "TranspRegXT << 394 this->GetProcessName() == "TranspRegXT << 395 this->GetProcessName() == "RegularXTRa << 396 this->GetProcessName() == "RegularXTRmodel" << 397 { << 398 BuildAngleTable(); // by sum of delta-func << 399 return; << 400 } << 401 G4int i, iTkin, iTR; << 402 G4double angleSum = 0.0; << 403 << 404 fGammaTkinCut = 0.0; << 405 << 406 // setting of min/max TR energies << 407 if(fGammaTkinCut > fTheMinEnergyTR) << 408 fMinEnergyTR = fGammaTkinCut; << 409 else << 410 fMinEnergyTR = fTheMinEnergyTR; << 411 << 412 if(fGammaTkinCut > fTheMaxEnergyTR) << 413 fMaxEnergyTR = 2.0 * fGammaTkinCut; << 414 else << 415 fMaxEnergyTR = fTheMaxEnergyTR; << 416 << 417 auto energyVector = << 418 new G4PhysicsLogVector(fMinEnergyTR, fMaxE << 419 << 420 G4Integrator<G4VXTRenergyLoss, G4double (G4V << 421 integral; << 422 << 423 G4cout.precision(4); << 424 G4Timer timer; << 425 timer.Start(); << 426 << 427 for(iTkin = 0; iTkin < fTotBin; ++iTkin) // << 428 { << 429 fGamma = << 430 1.0 + (fProtonEnergyVector->GetLowEdgeEn << 431 << 432 if(fMaxThetaTR > fTheMaxAngle) << 433 fMaxThetaTR = fTheMaxAngle; << 434 else if(fMaxThetaTR < fTheMinAngle) << 435 fMaxThetaTR = fTheMinAngle; << 436 << 437 fAngleForEnergyTable = new G4PhysicsTable( << 438 << 439 for(iTR = 0; iTR < fBinTR; ++iTR) << 440 { << 441 angleSum = 0.0; << 442 fEnergy = energyVector->GetLowEdgeEnerg << 443 << 444 // log-vector to increase number of thin << 445 auto angleVector = new G4PhysicsLogVecto << 446 << 447 << 448 << 449 angleVector->PutValue(fBinTR - 1, angleS << 450 << 451 for(i = fBinTR - 2; i >= 0; --i) << 452 { << 453 // Legendre96 or Legendre10 << 454 << 455 angleSum += << 456 integral.Legendre10(this, &G4VXTRene << 457 angleVector->Get << 458 angleVector->Get << 459 << 460 angleVector->PutValue(i, angleSum); << 461 } << 462 fAngleForEnergyTable->insertAt(iTR, angl << 463 } << 464 fAngleBank.push_back(fAngleForEnergyTable) << 465 } << 466 timer.Stop(); << 467 G4cout.precision(6); << 468 if(verboseLevel > 0) << 469 { << 470 G4cout << G4endl; << 471 G4cout << "total time for build X-ray TR a << 472 << timer.GetUserElapsed() << " s" < << 473 } << 474 fGamma = 0.; << 475 delete energyVector; << 476 } 379 } 477 380 478 ////////////////////////////////////////////// 381 //////////////////////////////////////////////////////////////////////// 479 // Build XTR angular distribution at given ene << 382 // >> 383 // Build XTR angular distribution at given energy based on the model 480 // of transparent regular radiator 384 // of transparent regular radiator >> 385 481 void G4VXTRenergyLoss::BuildAngleTable() 386 void G4VXTRenergyLoss::BuildAngleTable() 482 { 387 { 483 G4int iTkin, iTR; 388 G4int iTkin, iTR; 484 G4double energy; << 389 G4double energy; 485 390 486 fGammaTkinCut = 0.0; 391 fGammaTkinCut = 0.0; 487 << 392 488 // setting of min/max TR energies << 393 // setting of min/max TR energies 489 if(fGammaTkinCut > fTheMinEnergyTR) << 394 490 fMinEnergyTR = fGammaTkinCut; << 395 if(fGammaTkinCut > fTheMinEnergyTR) fMinEnergyTR = fGammaTkinCut; 491 else << 396 else fMinEnergyTR = fTheMinEnergyTR; 492 fMinEnergyTR = fTheMinEnergyTR; << 397 493 << 398 if(fGammaTkinCut > fTheMaxEnergyTR) fMaxEnergyTR = 2.0*fGammaTkinCut; 494 if(fGammaTkinCut > fTheMaxEnergyTR) << 399 else fMaxEnergyTR = fTheMaxEnergyTR; 495 fMaxEnergyTR = 2.0 * fGammaTkinCut; << 496 else << 497 fMaxEnergyTR = fTheMaxEnergyTR; << 498 400 499 G4cout.precision(4); 401 G4cout.precision(4); 500 G4Timer timer; 402 G4Timer timer; 501 timer.Start(); 403 timer.Start(); 502 if(verboseLevel > 0) << 404 if(verboseLevel > 0) { 503 { << 405 G4cout<<G4endl; 504 G4cout << G4endl << "Lorentz Factor" << "\ << 406 G4cout<<"Lorentz Factor"<<"\t"<<"XTR photon number"<<G4endl; 505 << "XTR photon number" << G4endl << << 407 G4cout<<G4endl; 506 } 408 } 507 for(iTkin = 0; iTkin < fTotBin; ++iTkin) // << 409 for( iTkin = 0 ; iTkin < fTotBin ; iTkin++ ) // Lorentz factor loop 508 { 410 { 509 fGamma = << 411 510 1.0 + (fProtonEnergyVector->GetLowEdgeEn << 412 fGamma = 1.0 + (fProtonEnergyVector-> >> 413 GetLowEdgeEnergy(iTkin)/proton_mass_c2) ; 511 414 512 // fMaxThetaTR = 25. * 2500.0 / (fGamma * << 415 fMaxThetaTR = 25.0/(fGamma*fGamma) ; // theta^2 513 416 514 if(fMaxThetaTR > fTheMaxAngle) << 417 fTheMinAngle = 1.0e-3 ; // was 5.e-6, e-6 !!!, e-5, e-4 515 fMaxThetaTR = fTheMaxAngle; << 418 >> 419 if( fMaxThetaTR > fTheMaxAngle ) fMaxThetaTR = fTheMaxAngle; 516 else 420 else 517 { 421 { 518 if(fMaxThetaTR < fTheMinAngle) << 422 if( fMaxThetaTR < fTheMinAngle ) fMaxThetaTR = fTheMinAngle; 519 fMaxThetaTR = fTheMinAngle; << 520 } 423 } 521 424 522 fAngleForEnergyTable = new G4PhysicsTable( 425 fAngleForEnergyTable = new G4PhysicsTable(fBinTR); 523 426 524 for(iTR = 0; iTR < fBinTR; ++iTR) << 427 for( iTR = 0; iTR < fBinTR; iTR++ ) 525 { 428 { >> 429 // energy = fMinEnergyTR*(iTR+1); >> 430 526 energy = fXTREnergyVector->GetLowEdgeEne 431 energy = fXTREnergyVector->GetLowEdgeEnergy(iTR); 527 432 528 G4PhysicsFreeVector* angleVector = GetAn << 433 G4PhysicsFreeVector* angleVector = new G4PhysicsFreeVector(fBinTR); 529 434 530 fAngleForEnergyTable->insertAt(iTR, angl << 435 angleVector = GetAngleVector(energy,fBinTR); >> 436 // G4cout<<G4endl; >> 437 >> 438 fAngleForEnergyTable->insertAt(iTR,angleVector) ; 531 } 439 } 532 fAngleBank.push_back(fAngleForEnergyTable) << 440 533 } << 441 fAngleBank.push_back(fAngleForEnergyTable); >> 442 } 534 timer.Stop(); 443 timer.Stop(); 535 G4cout.precision(6); 444 G4cout.precision(6); 536 if(verboseLevel > 0) << 445 if(verboseLevel > 0) { 537 { << 446 G4cout<<G4endl; 538 G4cout << G4endl; << 447 G4cout<<"total time for build XTR angle for given energy tables = " 539 G4cout << "total time for build XTR angle << 448 <<timer.GetUserElapsed()<<" s"<<G4endl; 540 << timer.GetUserElapsed() << " s" < << 541 } 449 } 542 fGamma = 0.; 450 fGamma = 0.; 543 << 451 544 return; 452 return; 545 } << 453 } 546 454 547 ////////////////////////////////////////////// 455 ///////////////////////////////////////////////////////////////////////// >> 456 // 548 // Vector of angles and angle integral distrib 457 // Vector of angles and angle integral distributions >> 458 549 G4PhysicsFreeVector* G4VXTRenergyLoss::GetAngl 459 G4PhysicsFreeVector* G4VXTRenergyLoss::GetAngleVector(G4double energy, G4int n) 550 { 460 { 551 G4double theta = 0., result, tmp = 0., cof1, << 461 G4double theta=0., result, tmp=0., cof1, cof2, cofMin, cofPHC, angleSum = 0.; 552 angleSum = 0.; << 462 G4int iTheta, k, kMax, kMin; 553 G4int iTheta, k, kMin; << 463 554 << 464 G4PhysicsFreeVector* angleVector = new G4PhysicsFreeVector(n); 555 auto angleVector = new G4PhysicsFreeVector(n << 465 556 << 466 cofPHC = 4*pi*hbarc; 557 cofPHC = 4. * pi * hbarc; << 467 tmp = (fSigma1 - fSigma2)/cofPHC/energy; 558 tmp = (fSigma1 - fSigma2) / cofPHC / ener << 468 cof1 = fPlateThick*tmp; 559 cof1 = fPlateThick * tmp; << 469 cof2 = fGasThick*tmp; 560 cof2 = fGasThick * tmp; << 561 470 562 cofMin = energy * (fPlateThick + fGasThick) << 471 cofMin = energy*(fPlateThick + fGasThick)/fGamma/fGamma; 563 cofMin += (fPlateThick * fSigma1 + fGasThick << 472 cofMin += (fPlateThick*fSigma1 + fGasThick*fSigma2)/energy; 564 cofMin /= cofPHC; 473 cofMin /= cofPHC; 565 474 566 kMin = G4int(cofMin); 475 kMin = G4int(cofMin); 567 if(cofMin > kMin) << 476 if (cofMin > kMin) kMin++; 568 kMin++; << 569 477 >> 478 kMax = kMin + fBinTR -1; 570 if(verboseLevel > 2) 479 if(verboseLevel > 2) 571 { 480 { 572 G4cout << "n-1 = " << n - 1 << 481 G4cout<<"n-1 = "<<n-1<<"; theta = " 573 << "; theta = " << std::sqrt(fMaxTh << 482 <<std::sqrt(fMaxThetaTR)*fGamma<<"; tmp = " 574 << "; tmp = " << 0. << "; angleS << 483 <<0. >> 484 <<"; angleSum = "<<angleSum<<G4endl; 575 } 485 } >> 486 angleVector->PutValue(n-1,fMaxThetaTR, angleSum); 576 487 577 for(iTheta = n - 1; iTheta >= 1; --iTheta) << 488 for( iTheta = n - 2 ; iTheta >= 1 ; iTheta-- ) 578 { 489 { 579 k = iTheta - 1 + kMin; << 580 tmp = pi * fPlateThick * (k + cof2) / ( << 581 result = (k - cof1) * (k - cof1) * (k + co << 582 tmp = std::sin(tmp) * std::sin(tmp) * s << 583 490 584 if(k == kMin && kMin == G4int(cofMin)) << 491 k = iTheta- 1 + kMin; >> 492 >> 493 tmp = pi*fPlateThick*(k + cof2)/(fPlateThick + fGasThick); >> 494 >> 495 result = (k - cof1)*(k - cof1)*(k + cof2)*(k + cof2); >> 496 >> 497 tmp = sin(tmp)*sin(tmp)*abs(k-cofMin)/result; >> 498 >> 499 if( k == kMin && kMin == G4int(cofMin) ) 585 { 500 { 586 // angleSum += 0.5 * tmp; << 501 angleSum += 0.5*tmp; // 0.5*sin(tmp)*sin(tmp)*abs(k-cofMin)/result; 587 angleSum += tmp; // ATLAS TB << 588 } 502 } 589 else if(iTheta == n - 1) << 590 ; << 591 else 503 else 592 { 504 { 593 angleSum += tmp; << 505 angleSum += tmp; // sin(tmp)*sin(tmp)*abs(k-cofMin)/result; 594 } 506 } 595 theta = std::abs(k - cofMin) * cofPHC / en << 507 theta = abs(k-cofMin)*cofPHC/energy/(fPlateThick + fGasThick); 596 << 597 if(verboseLevel > 2) 508 if(verboseLevel > 2) 598 { 509 { 599 G4cout << "iTheta = " << iTheta << "; k << 510 G4cout<<"iTheta = "<<iTheta<<"; k = "<<k<<"; theta = " 600 << "; theta = " << std::sqrt(thet << 511 <<std::sqrt(theta)*fGamma<<"; tmp = " 601 << "; angleSum = " << angleSum << 512 <<tmp // sin(tmp)*sin(tmp)*abs(k-cofMin)/result >> 513 <<"; angleSum = "<<angleSum<<G4endl; 602 } 514 } 603 angleVector->PutValue(iTheta, theta, angle << 515 angleVector->PutValue( iTheta, theta, angleSum ); 604 } 516 } 605 if(theta > 0.) << 517 if (theta > 0.) 606 { 518 { 607 // angleSum += 0.5 * tmp; << 519 angleSum += 0.5*tmp; 608 angleSum += 0.; // ATLAS TB << 520 theta = 0.; 609 theta = 0.; << 610 } 521 } 611 if(verboseLevel > 2) 522 if(verboseLevel > 2) 612 { 523 { 613 G4cout << "iTheta = " << iTheta << "; thet << 524 G4cout<<"iTheta = "<<iTheta<<"; theta = " 614 << "; tmp = " << tmp << "; angle << 525 <<std::sqrt(theta)*fGamma<<"; tmp = " >> 526 <<tmp >> 527 <<"; angleSum = "<<angleSum<<G4endl; 615 } 528 } 616 angleVector->PutValue(iTheta, theta, angleSu << 529 angleVector->PutValue( iTheta, theta, angleSum ); 617 530 618 return angleVector; 531 return angleVector; 619 } 532 } 620 533 621 ////////////////////////////////////////////// 534 //////////////////////////////////////////////////////////////////////// 622 // Build XTR angular distribution based on the << 535 // 623 // radiator << 536 // Build XTR angular distribution based on the model of transparent regular radiator >> 537 624 void G4VXTRenergyLoss::BuildGlobalAngleTable() 538 void G4VXTRenergyLoss::BuildGlobalAngleTable() 625 { 539 { 626 G4int iTkin, iTR, iPlace; 540 G4int iTkin, iTR, iPlace; 627 G4double radiatorCof = 1.0; // for tuning o << 541 G4double radiatorCof = 1.0; // for tuning of XTR yield 628 G4double angleSum; 542 G4double angleSum; 629 fAngleDistrTable = new G4PhysicsTable(fTotBi 543 fAngleDistrTable = new G4PhysicsTable(fTotBin); 630 544 631 fGammaTkinCut = 0.0; 545 fGammaTkinCut = 0.0; >> 546 >> 547 // setting of min/max TR energies >> 548 >> 549 if(fGammaTkinCut > fTheMinEnergyTR) fMinEnergyTR = fGammaTkinCut ; >> 550 else fMinEnergyTR = fTheMinEnergyTR ; >> 551 >> 552 if(fGammaTkinCut > fTheMaxEnergyTR) fMaxEnergyTR = 2.0*fGammaTkinCut ; >> 553 else fMaxEnergyTR = fTheMaxEnergyTR ; 632 554 633 // setting of min/max TR energies << 555 G4cout.precision(4) ; 634 if(fGammaTkinCut > fTheMinEnergyTR) << 556 G4Timer timer ; 635 fMinEnergyTR = fGammaTkinCut; << 557 timer.Start() ; 636 else << 558 if(verboseLevel > 0) { 637 fMinEnergyTR = fTheMinEnergyTR; << 559 G4cout<<G4endl; 638 << 560 G4cout<<"Lorentz Factor"<<"\t"<<"XTR photon number"<<G4endl; 639 if(fGammaTkinCut > fTheMaxEnergyTR) << 561 G4cout<<G4endl; 640 fMaxEnergyTR = 2.0 * fGammaTkinCut; << 562 } 641 else << 563 for( iTkin = 0 ; iTkin < fTotBin ; iTkin++ ) // Lorentz factor loop 642 fMaxEnergyTR = fTheMaxEnergyTR; << 564 { 643 << 565 644 G4cout.precision(4); << 566 fGamma = 1.0 + (fProtonEnergyVector-> 645 G4Timer timer; << 567 GetLowEdgeEnergy(iTkin)/proton_mass_c2) ; 646 timer.Start(); << 647 if(verboseLevel > 0) << 648 { << 649 G4cout << G4endl; << 650 G4cout << "Lorentz Factor" << 651 << "\t" << 652 << "XTR photon number" << G4endl; << 653 G4cout << G4endl; << 654 } << 655 for(iTkin = 0; iTkin < fTotBin; ++iTkin) // << 656 { << 657 fGamma = << 658 1.0 + (fProtonEnergyVector->GetLowEdgeEn << 659 568 660 // fMaxThetaTR = 25.0 / (fGamma * fGamma); << 569 fMaxThetaTR = 25.0/(fGamma*fGamma) ; // theta^2 661 // fMaxThetaTR = 1.e-4; // theta^2 << 662 570 663 if(fMaxThetaTR > fTheMaxAngle) << 571 fTheMinAngle = 1.0e-3 ; // was 5.e-6, e-6 !!!, e-5, e-4 664 fMaxThetaTR = fTheMaxAngle; << 572 >> 573 if( fMaxThetaTR > fTheMaxAngle ) fMaxThetaTR = fTheMaxAngle; 665 else 574 else 666 { 575 { 667 if(fMaxThetaTR < fTheMinAngle) << 576 if( fMaxThetaTR < fTheMinAngle ) fMaxThetaTR = fTheMinAngle; 668 fMaxThetaTR = fTheMinAngle; << 669 } 577 } 670 auto angleVector = << 578 G4PhysicsLinearVector* angleVector = new G4PhysicsLinearVector(0.0, 671 // G4PhysicsLogVector* angleVector = << 579 fMaxThetaTR, 672 new G4PhysicsLinearVector(0.0, fMaxTheta << 580 fBinTR ); 673 // new G4PhysicsLogVector(1.e-8, fMaxThet << 674 581 675 angleSum = 0.0; << 582 angleSum = 0.0; 676 583 677 G4Integrator<G4VXTRenergyLoss, G4double (G << 584 G4Integrator<G4VXTRenergyLoss,G4double(G4VXTRenergyLoss::*)(G4double)> integral; 678 integral; << 679 585 680 angleVector->PutValue(fBinTR - 1, angleSum << 586 >> 587 angleVector->PutValue(fBinTR-1,angleSum); 681 588 682 for(iTR = fBinTR - 2; iTR >= 0; --iTR) << 589 for( iTR = fBinTR - 2 ; iTR >= 0 ; iTR-- ) 683 { 590 { 684 angleSum += radiatorCof * fCofTR * << 685 integral.Legendre96(this, &G << 686 angleVec << 687 angleVec << 688 591 689 angleVector->PutValue(iTR, angleSum); << 592 angleSum += radiatorCof*fCofTR*integral.Legendre96( >> 593 this,&G4VXTRenergyLoss::AngleXTRdEdx, >> 594 angleVector->GetLowEdgeEnergy(iTR), >> 595 angleVector->GetLowEdgeEnergy(iTR+1) ); >> 596 >> 597 angleVector ->PutValue(iTR,angleSum); 690 } 598 } 691 if(verboseLevel > 1) << 599 if(verboseLevel > 1) { 692 { << 600 G4cout 693 G4cout << fGamma << "\t" << angleSum << << 601 // <<iTkin<<"\t" >> 602 // <<"fGamma = " >> 603 <<fGamma<<"\t" // <<" fMaxThetaTR = "<<fMaxThetaTR >> 604 // <<"sumN = "<<energySum // <<" ; sumA = " >> 605 <<angleSum >> 606 <<G4endl; 694 } 607 } 695 iPlace = iTkin; 608 iPlace = iTkin; 696 fAngleDistrTable->insertAt(iPlace, angleVe << 609 fAngleDistrTable->insertAt(iPlace,angleVector); 697 } << 610 } 698 timer.Stop(); 611 timer.Stop(); 699 G4cout.precision(6); 612 G4cout.precision(6); 700 if(verboseLevel > 0) << 613 if(verboseLevel > 0) { 701 { << 614 G4cout<<G4endl; 702 G4cout << G4endl; << 615 G4cout<<"total time for build X-ray TR angle tables = " 703 G4cout << "total time for build X-ray TR a << 616 <<timer.GetUserElapsed()<<" s"<<G4endl; 704 << timer.GetUserElapsed() << " s" < << 705 } 617 } 706 fGamma = 0.; 618 fGamma = 0.; 707 << 619 708 return; 620 return; 709 } << 621 } >> 622 710 623 711 ////////////////////////////////////////////// 624 ////////////////////////////////////////////////////////////////////////////// 712 // The main function which is responsible for << 625 // 713 // passage through G4Envelope with discrete ge << 626 // The main function which is responsible for the treatment of a particle passage 714 G4VParticleChange* G4VXTRenergyLoss::PostStepD << 627 // trough G4Envelope with discrete generation of G4Gamma 715 << 628 >> 629 G4VParticleChange* G4VXTRenergyLoss::PostStepDoIt( const G4Track& aTrack, >> 630 const G4Step& aStep ) 716 { 631 { 717 G4int iTkin; << 632 G4int iTkin, iPlace; 718 G4double energyTR, theta, theta2, phi, dirX, << 633 G4double energyTR, theta,theta2, phi, dirX, dirY, dirZ; >> 634 719 635 720 fParticleChange.Initialize(aTrack); 636 fParticleChange.Initialize(aTrack); 721 637 722 if(verboseLevel > 1) 638 if(verboseLevel > 1) 723 { 639 { 724 G4cout << "Start of G4VXTRenergyLoss::Post << 640 G4cout<<"Start of G4VXTRenergyLoss::PostStepDoIt "<<G4endl ; 725 G4cout << "name of current material = " << 641 G4cout<<"name of current material = " 726 << aTrack.GetVolume()->GetLogicalVo << 642 <<aTrack.GetVolume()->GetLogicalVolume()->GetMaterial()->GetName()<<G4endl ; 727 << G4endl; << 728 } 643 } 729 if(aTrack.GetVolume()->GetLogicalVolume() != << 644 if( aTrack.GetVolume()->GetLogicalVolume() != fEnvelope ) 730 { 645 { 731 if(verboseLevel > 0) 646 if(verboseLevel > 0) 732 { 647 { 733 G4cout << "Go out from G4VXTRenergyLoss: << 648 G4cout<<"Go out from G4VXTRenergyLoss::PostStepDoIt: wrong volume "<<G4endl; 734 << G4endl; << 735 } 649 } 736 return G4VDiscreteProcess::PostStepDoIt(aT 650 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); 737 } 651 } 738 else 652 else 739 { 653 { 740 G4StepPoint* pPostStepPoint = aStep 654 G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint(); 741 const G4DynamicParticle* aParticle = aTrac 655 const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle(); 742 << 656 743 // Now we are ready to Generate one TR pho 657 // Now we are ready to Generate one TR photon 744 G4double kinEnergy = aParticle->GetKinetic << 745 G4double mass = aParticle->GetDefinit << 746 G4double gamma = 1.0 + kinEnergy / mas << 747 658 748 if(verboseLevel > 1) << 659 G4double kinEnergy = aParticle->GetKineticEnergy() ; >> 660 G4double mass = aParticle->GetDefinition()->GetPDGMass() ; >> 661 G4double gamma = 1.0 + kinEnergy/mass ; >> 662 >> 663 if(verboseLevel > 1 ) 749 { 664 { 750 G4cout << "gamma = " << gamma << G4endl; << 665 G4cout<<"gamma = "<<gamma<<G4endl ; 751 } 666 } 752 G4double massRatio = proton_mass << 667 G4double massRatio = proton_mass_c2/mass ; 753 G4double TkinScaled = kinEnergy * << 668 G4double TkinScaled = kinEnergy*massRatio ; 754 G4ThreeVector position = pPostStepPo << 669 G4ThreeVector position = pPostStepPoint->GetPosition(); 755 G4ParticleMomentum direction = aParticle-> 670 G4ParticleMomentum direction = aParticle->GetMomentumDirection(); 756 G4double startTime = pPostStepPo << 671 G4double startTime = pPostStepPoint->GetGlobalTime(); 757 672 758 for(iTkin = 0; iTkin < fTotBin; ++iTkin) << 673 for( iTkin = 0; iTkin < fTotBin; iTkin++ ) 759 { 674 { 760 if(TkinScaled < fProtonEnergyVector->Get << 675 if(TkinScaled < fProtonEnergyVector->GetLowEdgeEnergy(iTkin)) break; 761 break; << 762 } 676 } >> 677 iPlace = iTkin - 1; 763 678 764 if(iTkin == 0) // Tkin is too small, negl << 679 if(iTkin == 0) // Tkin is too small, neglect of TR photon generation 765 { 680 { 766 if(verboseLevel > 0) << 681 if( verboseLevel > 0) 767 { 682 { 768 G4cout << "Go out from G4VXTRenergyLos << 683 G4cout<<"Go out from G4VXTRenergyLoss::PostStepDoIt:iTkin = "<<iTkin<<G4endl; 769 << G4endl; << 770 } 684 } 771 return G4VDiscreteProcess::PostStepDoIt( 685 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); 772 } << 686 } 773 else // general case: Tkin between two ve << 687 else // general case: Tkin between two vectors of the material 774 { 688 { 775 fParticleChange.SetNumberOfSecondaries(1 689 fParticleChange.SetNumberOfSecondaries(1); 776 690 777 energyTR = GetXTRrandomEnergy(TkinScaled << 691 energyTR = GetXTRrandomEnergy(TkinScaled,iTkin); 778 692 779 if(verboseLevel > 1) << 693 if( verboseLevel > 1) 780 { 694 { 781 G4cout << "energyTR = " << energyTR / << 695 G4cout<<"energyTR = "<<energyTR/keV<<" keV"<<G4endl; 782 } 696 } 783 if(fAngleRadDistr) << 697 if (fAngleRadDistr) 784 { 698 { 785 theta2 = GetRandomAngle(energyTR, iTki << 699 // theta = fabs(G4RandGauss::shoot(0.0,pi/gamma)); 786 if(theta2 > 0.) << 700 theta2 = GetRandomAngle(energyTR,iTkin); 787 theta = std::sqrt(theta2); << 701 if(theta2 > 0.) theta = std::sqrt(theta2); 788 else << 702 else theta = theta2; 789 theta = 0.; << 790 } 703 } 791 else << 704 else theta = fabs(G4RandGauss::shoot(0.0,pi/gamma)); 792 theta = std::fabs(G4RandGauss::shoot(0 << 705 >> 706 if( theta >= 0.1 ) theta = 0.1; 793 707 794 if(theta >= 0.1) << 708 // G4cout<<" : theta = "<<theta<<endl ; 795 theta = 0.1; << 796 709 797 phi = twopi * G4UniformRand(); << 710 phi = twopi*G4UniformRand(); 798 711 799 dirX = std::sin(theta) * std::cos(phi); << 712 dirX = sin(theta)*cos(phi); 800 dirY = std::sin(theta) * std::sin(phi); << 713 dirY = sin(theta)*sin(phi); 801 dirZ = std::cos(theta); << 714 dirZ = cos(theta); 802 715 803 G4ThreeVector directionTR(dirX, dirY, di << 716 G4ThreeVector directionTR(dirX,dirY,dirZ); 804 directionTR.rotateUz(direction); 717 directionTR.rotateUz(direction); 805 directionTR.unit(); 718 directionTR.unit(); 806 719 807 auto aPhotonTR = << 720 G4DynamicParticle* aPhotonTR = new G4DynamicParticle(G4Gamma::Gamma(), 808 new G4DynamicParticle(G4Gamma::Gamma() << 721 directionTR, energyTR); 809 722 810 // A XTR photon is set on the particle t << 723 // A XTR photon is set on the particle track inside the radiator 811 // and is moved to the G4Envelope surfac 724 // and is moved to the G4Envelope surface for standard X-ray TR models 812 // only. The case of fExitFlux=true 725 // only. The case of fExitFlux=true 813 726 814 if(fExitFlux) << 727 if( fExitFlux ) 815 { 728 { 816 const G4RotationMatrix* rotM = << 729 const G4RotationMatrix* rotM = pPostStepPoint->GetTouchable()->GetRotation(); 817 pPostStepPoint->GetTouchable()->GetR << 818 G4ThreeVector transl = pPostStepPoint- 730 G4ThreeVector transl = pPostStepPoint->GetTouchable()->GetTranslation(); 819 G4AffineTransform transform = G4Affine << 731 G4AffineTransform transform = G4AffineTransform(rotM,transl); 820 transform.Invert(); 732 transform.Invert(); 821 G4ThreeVector localP = transform.Trans 733 G4ThreeVector localP = transform.TransformPoint(position); 822 G4ThreeVector localV = transform.Trans 734 G4ThreeVector localV = transform.TransformAxis(directionTR); 823 735 824 G4double distance = << 736 G4double distance = fEnvelope->GetSolid()->DistanceToOut(localP, localV); 825 fEnvelope->GetSolid()->DistanceToOut << 826 if(verboseLevel > 1) 737 if(verboseLevel > 1) 827 { 738 { 828 G4cout << "distance to exit = " << d << 739 G4cout<<"distance to exit = "<<distance/mm<<" mm"<<G4endl; 829 } 740 } 830 position += distance * directionTR; << 741 position += distance*directionTR; 831 startTime += distance / c_light; << 742 startTime += distance/c_light; 832 } 743 } 833 G4Track* aSecondaryTrack = new G4Track(a << 744 G4Track* aSecondaryTrack = new G4Track( aPhotonTR, >> 745 startTime, position ); 834 aSecondaryTrack->SetTouchableHandle( 746 aSecondaryTrack->SetTouchableHandle( 835 aStep.GetPostStepPoint()->GetTouchable << 747 aStep.GetPostStepPoint()->GetTouchableHandle()); 836 aSecondaryTrack->SetParentID(aTrack.GetT << 748 aSecondaryTrack->SetParentID( aTrack.GetTrackID() ); 837 749 838 fParticleChange.AddSecondary(aSecondaryT 750 fParticleChange.AddSecondary(aSecondaryTrack); 839 fParticleChange.ProposeEnergy(kinEnergy) << 751 fParticleChange.ProposeEnergy(kinEnergy); 840 } 752 } 841 } 753 } 842 return G4VDiscreteProcess::PostStepDoIt(aTra 754 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep); 843 } 755 } 844 756 845 ////////////////////////////////////////////// 757 /////////////////////////////////////////////////////////////////////// >> 758 // 846 // This function returns the spectral and angl 759 // This function returns the spectral and angle density of TR quanta 847 // in X-ray energy region generated forward wh 760 // in X-ray energy region generated forward when a relativistic 848 // charged particle crosses interface between 761 // charged particle crosses interface between two materials. 849 // The high energy small theta approximation i 762 // The high energy small theta approximation is applied. 850 // (matter1 -> matter2, or 2->1) 763 // (matter1 -> matter2, or 2->1) 851 // varAngle =2* (1 - std::cos(theta)) or appro << 764 // varAngle =2* (1 - cos(theta)) or approximately = theta*theta 852 G4complex G4VXTRenergyLoss::OneInterfaceXTRdEd << 765 // 853 << 766 854 { << 767 G4complex G4VXTRenergyLoss::OneInterfaceXTRdEdx( G4double energy, 855 G4complex Z1 = GetPlateComplexFZ(energy, gam << 768 G4double gamma, 856 G4complex Z2 = GetGasComplexFZ(energy, gamma << 769 G4double varAngle ) >> 770 { >> 771 G4complex Z1 = GetPlateComplexFZ(energy,gamma,varAngle) ; >> 772 G4complex Z2 = GetGasComplexFZ(energy,gamma,varAngle) ; >> 773 >> 774 G4complex zOut = (Z1 - Z2)*(Z1 - Z2) >> 775 * (varAngle*energy/hbarc/hbarc) ; >> 776 return zOut ; 857 777 858 G4complex zOut = (Z1 - Z2) * (Z1 - Z2) * (va << 859 return zOut; << 860 } 778 } 861 779 >> 780 862 ////////////////////////////////////////////// 781 ////////////////////////////////////////////////////////////////////////////// >> 782 // 863 // For photon energy distribution tables. Inte 783 // For photon energy distribution tables. Integrate first over angle >> 784 // >> 785 864 G4double G4VXTRenergyLoss::SpectralAngleXTRdEd 786 G4double G4VXTRenergyLoss::SpectralAngleXTRdEdx(G4double varAngle) 865 { 787 { 866 G4double result = GetStackFactor(fEnergy, fG << 788 G4double result = GetStackFactor(fEnergy,fGamma,varAngle); 867 if(result < 0.0) << 789 if(result < 0.0) result = 0.0; 868 result = 0.0; << 869 return result; 790 return result; 870 } 791 } 871 792 872 ////////////////////////////////////////////// 793 ///////////////////////////////////////////////////////////////////////// >> 794 // 873 // For second integration over energy 795 // For second integration over energy >> 796 874 G4double G4VXTRenergyLoss::SpectralXTRdEdx(G4d 797 G4double G4VXTRenergyLoss::SpectralXTRdEdx(G4double energy) 875 { 798 { 876 G4int i; << 799 G4int i, iMax = 8; 877 static constexpr G4int iMax = 8; << 800 G4double result = 0.0; 878 G4double angleSum = 0.0; << 879 801 880 G4double lim[iMax] = { 0.0, 0.01, 0.02, 0.05 << 802 G4double lim[8] = { 0.0, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0 }; 881 803 882 for(i = 0; i < iMax; ++i) << 804 for( i = 0; i < iMax; i++ ) lim[i] *= fMaxThetaTR; 883 lim[i] *= fMaxThetaTR; << 884 805 885 G4Integrator<G4VXTRenergyLoss, G4double (G4V << 806 G4Integrator<G4VXTRenergyLoss,G4double(G4VXTRenergyLoss::*)(G4double)> integral; 886 integral; << 887 807 888 fEnergy = energy; 808 fEnergy = energy; >> 809 >> 810 for( i = 0; i < iMax-1; i++ ) 889 { 811 { 890 for(i = 0; i < iMax - 1; ++i) << 812 result += integral.Legendre96(this,&G4VXTRenergyLoss::SpectralAngleXTRdEdx, 891 { << 813 lim[i],lim[i+1]); 892 angleSum += integral.Legendre96( << 814 // result += integral.Legendre10(this,&G4VXTRenergyLoss::SpectralAngleXTRdEdx, 893 this, &G4VXTRenergyLoss::SpectralAngle << 815 // lim[i],lim[i+1]); 894 } << 895 } 816 } 896 return angleSum; << 897 } << 898 817 >> 818 return result; >> 819 } >> 820 899 ////////////////////////////////////////////// 821 ////////////////////////////////////////////////////////////////////////// >> 822 // 900 // for photon angle distribution tables 823 // for photon angle distribution tables >> 824 // >> 825 901 G4double G4VXTRenergyLoss::AngleSpectralXTRdEd 826 G4double G4VXTRenergyLoss::AngleSpectralXTRdEdx(G4double energy) 902 { 827 { 903 G4double result = GetStackFactor(energy, fGa << 828 G4double result = GetStackFactor(energy,fGamma,fVarAngle); 904 if(result < 0) << 829 if(result < 0) result = 0.0; 905 result = 0.0; << 906 return result; 830 return result; 907 } << 831 } 908 832 909 ////////////////////////////////////////////// 833 /////////////////////////////////////////////////////////////////////////// >> 834 // 910 // The XTR angular distribution based on trans 835 // The XTR angular distribution based on transparent regular radiator 911 G4double G4VXTRenergyLoss::AngleXTRdEdx(G4doub << 836 >> 837 G4double G4VXTRenergyLoss::AngleXTRdEdx(G4double varAngle) 912 { 838 { >> 839 // G4cout<<"angle2 = "<<varAngle<<"; fGamma = "<<fGamma<<G4endl; >> 840 913 G4double result; 841 G4double result; 914 G4double sum = 0., tmp1, tmp2, tmp = 0., cof << 842 G4double sum = 0., tmp1, tmp2, tmp=0., cof1, cof2, cofMin, cofPHC, energy1, energy2; 915 energy2; << 916 G4int k, kMax, kMin, i; 843 G4int k, kMax, kMin, i; 917 844 918 cofPHC = twopi * hbarc; << 845 cofPHC = twopi*hbarc; 919 846 920 cof1 = (fPlateThick + fGasThick) * (1. / fGa << 847 cof1 = (fPlateThick + fGasThick)*(1./fGamma/fGamma + varAngle); 921 cof2 = fPlateThick * fSigma1 + fGasThick * f << 848 cof2 = fPlateThick*fSigma1 + fGasThick*fSigma2; 922 849 923 cofMin = std::sqrt(cof1 * cof2); << 850 // G4cout<<"cof1 = "<<cof1<<"; cof2 = "<<cof2<<"; cofPHC = "<<cofPHC<<G4endl; >> 851 >> 852 cofMin = sqrt(cof1*cof2); 924 cofMin /= cofPHC; 853 cofMin /= cofPHC; 925 854 926 kMin = G4int(cofMin); 855 kMin = G4int(cofMin); 927 if(cofMin > kMin) << 856 if (cofMin > kMin) kMin++; 928 kMin++; << 857 >> 858 kMax = kMin + 9; // 9; // kMin + G4int(tmp); 929 859 930 kMax = kMin + 9; << 860 // G4cout<<"cofMin = "<<cofMin<<"; kMin = "<<kMin<<"; kMax = "<<kMax<<G4endl; 931 861 932 for(k = kMin; k <= kMax; ++k) << 862 for( k = kMin; k <= kMax; k++ ) 933 { 863 { 934 tmp1 = cofPHC * k; << 864 tmp1 = cofPHC*k; 935 tmp2 = std::sqrt(tmp1 * tmp1 - cof1 * c << 865 tmp2 = sqrt(tmp1*tmp1-cof1*cof2); 936 energy1 = (tmp1 + tmp2) / cof1; << 866 energy1 = (tmp1+tmp2)/cof1; 937 energy2 = (tmp1 - tmp2) / cof1; << 867 energy2 = (tmp1-tmp2)/cof1; 938 868 939 for(i = 0; i < 2; ++i) << 869 for(i = 0; i < 2; i++) 940 { 870 { 941 if(i == 0) << 871 if( i == 0 ) 942 { 872 { 943 if(energy1 > fTheMaxEnergyTR || energy << 873 if (energy1 > fTheMaxEnergyTR || energy1 < fTheMinEnergyTR) continue; 944 continue; << 874 tmp1 = ( energy1*energy1*(1./fGamma/fGamma + varAngle) + fSigma1 ) 945 << 875 * fPlateThick/(4*hbarc*energy1); 946 tmp1 = << 876 tmp2 = sin(tmp1); 947 (energy1 * energy1 * (1. / fGamma / << 877 tmp = energy1*tmp2*tmp2; 948 fPlateThick / (4 * hbarc * energy1); << 878 tmp2 = fPlateThick/(4*tmp1); 949 tmp2 = std::sin(tmp1); << 879 tmp1 = hbarc*energy1/( energy1*energy1*(1./fGamma/fGamma + varAngle) + fSigma2 ); 950 tmp = energy1 * tmp2 * tmp2; << 880 tmp *= (tmp1-tmp2)*(tmp1-tmp2); 951 tmp2 = fPlateThick / (4. * tmp1); << 881 tmp1 = cof1/(4*hbarc) - cof2/(4*hbarc*energy1*energy1); 952 tmp1 = << 882 tmp2 = abs(tmp1); 953 hbarc * energy1 / << 883 if(tmp2 > 0.) tmp /= tmp2; 954 (energy1 * energy1 * (1. / fGamma / << 884 else continue; 955 tmp *= (tmp1 - tmp2) * (tmp1 - tmp2); << 956 tmp1 = cof1 / (4. * hbarc) - cof2 / (4 << 957 tmp2 = std::abs(tmp1); << 958 << 959 if(tmp2 > 0.) << 960 tmp /= tmp2; << 961 else << 962 continue; << 963 } 885 } 964 else 886 else 965 { 887 { 966 if(energy2 > fTheMaxEnergyTR || energy << 888 if (energy2 > fTheMaxEnergyTR || energy2 < fTheMinEnergyTR) continue; 967 continue; << 889 tmp1 = ( energy2*energy2*(1./fGamma/fGamma + varAngle) + fSigma1 ) 968 << 890 * fPlateThick/(4*hbarc*energy2); 969 tmp1 = << 891 tmp2 = sin(tmp1); 970 (energy2 * energy2 * (1. / fGamma / << 892 tmp = energy2*tmp2*tmp2; 971 fPlateThick / (4. * hbarc * energy2) << 893 tmp2 = fPlateThick/(4*tmp1); 972 tmp2 = std::sin(tmp1); << 894 tmp1 = hbarc*energy2/( energy2*energy2*(1./fGamma/fGamma + varAngle) + fSigma2 ); 973 tmp = energy2 * tmp2 * tmp2; << 895 tmp *= (tmp1-tmp2)*(tmp1-tmp2); 974 tmp2 = fPlateThick / (4. * tmp1); << 896 tmp1 = cof1/(4*hbarc) - cof2/(4*hbarc*energy2*energy2); 975 tmp1 = << 897 tmp2 = abs(tmp1); 976 hbarc * energy2 / << 898 if(tmp2 > 0.) tmp /= tmp2; 977 (energy2 * energy2 * (1. / fGamma / << 899 else continue; 978 tmp *= (tmp1 - tmp2) * (tmp1 - tmp2); << 979 tmp1 = cof1 / (4. * hbarc) - cof2 / (4 << 980 tmp2 = std::abs(tmp1); << 981 << 982 if(tmp2 > 0.) << 983 tmp /= tmp2; << 984 else << 985 continue; << 986 } 900 } 987 sum += tmp; 901 sum += tmp; 988 } 902 } >> 903 // G4cout<<"k = "<<k<<"; energy1 = "<<energy1/keV<<" keV; energy2 = "<<energy2/keV >> 904 // <<" keV; tmp = "<<tmp<<"; sum = "<<sum<<G4endl; 989 } 905 } 990 result = 4. * pi * fPlateNumber * sum * varA << 906 result = 4.*pi*fPlateNumber*sum*varAngle; 991 result /= hbarc * hbarc; << 907 result /= hbarc*hbarc; 992 908 >> 909 // old code based on general numeric integration >> 910 // fVarAngle = varAngle; >> 911 // G4Integrator<G4VXTRenergyLoss,G4double(G4VXTRenergyLoss::*)(G4double)> integral; >> 912 // result = integral.Legendre10(this,&G4VXTRenergyLoss::AngleSpectralXTRdEdx, >> 913 // fMinEnergyTR,fMaxEnergyTR); 993 return result; 914 return result; 994 } 915 } 995 916 >> 917 >> 918 ////////////////////////////////////////////////////////////////////// >> 919 ////////////////////////////////////////////////////////////////////// 996 ////////////////////////////////////////////// 920 ////////////////////////////////////////////////////////////////////// >> 921 // 997 // Calculates formation zone for plates. Omega 922 // Calculates formation zone for plates. Omega is energy !!! 998 G4double G4VXTRenergyLoss::GetPlateFormationZo << 923 999 << 924 G4double G4VXTRenergyLoss::GetPlateFormationZone( G4double omega , 1000 { << 925 G4double gamma , 1001 G4double cof, lambda; << 926 G4double varAngle ) 1002 lambda = 1.0 / gamma / gamma + varAngle + f << 927 { 1003 cof = 2.0 * hbarc / omega / lambda; << 928 G4double cof, lambda ; 1004 return cof; << 929 lambda = 1.0/gamma/gamma + varAngle + fSigma1/omega/omega ; >> 930 cof = 2.0*hbarc/omega/lambda ; >> 931 return cof ; 1005 } 932 } 1006 933 1007 ///////////////////////////////////////////// 934 ////////////////////////////////////////////////////////////////////// >> 935 // 1008 // Calculates complex formation zone for plat 936 // Calculates complex formation zone for plates. Omega is energy !!! 1009 G4complex G4VXTRenergyLoss::GetPlateComplexFZ << 937 1010 << 938 G4complex G4VXTRenergyLoss::GetPlateComplexFZ( G4double omega , >> 939 G4double gamma , >> 940 G4double varAngle ) 1011 { 941 { 1012 G4double cof, length, delta, real_v, image_ << 942 G4double cof, length,delta, real, image ; 1013 943 1014 length = 0.5 * GetPlateFormationZone(omega, << 944 length = 0.5*GetPlateFormationZone(omega,gamma,varAngle) ; 1015 delta = length * GetPlateLinearPhotoAbs(om << 945 delta = length*GetPlateLinearPhotoAbs(omega) ; 1016 cof = 1.0 / (1.0 + delta * delta); << 946 cof = 1.0/(1.0 + delta*delta) ; 1017 947 1018 real_v = length * cof; << 948 real = length*cof ; 1019 image_v = real_v * delta; << 949 image = real*delta ; 1020 950 1021 G4complex zone(real_v, image_v); << 951 G4complex zone(real,image); 1022 return zone; << 952 return zone ; 1023 } 953 } 1024 954 1025 ///////////////////////////////////////////// 955 //////////////////////////////////////////////////////////////////////// >> 956 // 1026 // Computes matrix of Sandia photo absorption 957 // Computes matrix of Sandia photo absorption cross section coefficients for 1027 // plate material 958 // plate material 1028 void G4VXTRenergyLoss::ComputePlatePhotoAbsCo << 959 >> 960 void G4VXTRenergyLoss::ComputePlatePhotoAbsCof() 1029 { 961 { 1030 const G4MaterialTable* theMaterialTable = G 962 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); 1031 const G4Material* mat = ( << 963 const G4Material* mat = (*theMaterialTable)[fMatIndex1]; 1032 fPlatePhotoAbsCof = m << 964 fPlatePhotoAbsCof = mat->GetSandiaTable(); 1033 965 1034 return; 966 return; 1035 } 967 } 1036 968 >> 969 >> 970 1037 ///////////////////////////////////////////// 971 ////////////////////////////////////////////////////////////////////// 1038 // Returns the value of linear photo absorpti << 972 // >> 973 // Returns the value of linear photo absorption coefficient (in reciprocal 1039 // length) for plate for given energy of X-ra 974 // length) for plate for given energy of X-ray photon omega 1040 G4double G4VXTRenergyLoss::GetPlateLinearPhot << 1041 { << 1042 G4double omega2, omega3, omega4; << 1043 975 1044 omega2 = omega * omega; << 976 G4double G4VXTRenergyLoss::GetPlateLinearPhotoAbs(G4double omega) 1045 omega3 = omega2 * omega; << 977 { 1046 omega4 = omega2 * omega2; << 978 // G4int i ; >> 979 G4double omega2, omega3, omega4 ; 1047 980 1048 const G4double* SandiaCof = fPlatePhotoAbsC << 981 omega2 = omega*omega ; 1049 G4double cross = SandiaCof[0] / << 982 omega3 = omega2*omega ; 1050 SandiaCof[2] / omega3 + Sa << 983 omega4 = omega2*omega2 ; >> 984 >> 985 G4double* SandiaCof = fPlatePhotoAbsCof->GetSandiaCofForMaterial(omega); >> 986 G4double cross = SandiaCof[0]/omega + SandiaCof[1]/omega2 + >> 987 SandiaCof[2]/omega3 + SandiaCof[3]/omega4; 1051 return cross; 988 return cross; 1052 } 989 } 1053 990 >> 991 1054 ///////////////////////////////////////////// 992 ////////////////////////////////////////////////////////////////////// >> 993 // 1055 // Calculates formation zone for gas. Omega i 994 // Calculates formation zone for gas. Omega is energy !!! 1056 G4double G4VXTRenergyLoss::GetGasFormationZon << 995 1057 << 996 G4double G4VXTRenergyLoss::GetGasFormationZone( G4double omega , 1058 { << 997 G4double gamma , 1059 G4double cof, lambda; << 998 G4double varAngle ) 1060 lambda = 1.0 / gamma / gamma + varAngle + f << 999 { 1061 cof = 2.0 * hbarc / omega / lambda; << 1000 G4double cof, lambda ; 1062 return cof; << 1001 lambda = 1.0/gamma/gamma + varAngle + fSigma2/omega/omega ; >> 1002 cof = 2.0*hbarc/omega/lambda ; >> 1003 return cof ; 1063 } 1004 } 1064 1005 >> 1006 1065 ///////////////////////////////////////////// 1007 ////////////////////////////////////////////////////////////////////// >> 1008 // 1066 // Calculates complex formation zone for gas 1009 // Calculates complex formation zone for gas gaps. Omega is energy !!! 1067 G4complex G4VXTRenergyLoss::GetGasComplexFZ(G << 1010 1068 G << 1011 G4complex G4VXTRenergyLoss::GetGasComplexFZ( G4double omega , >> 1012 G4double gamma , >> 1013 G4double varAngle ) 1069 { 1014 { 1070 G4double cof, length, delta, real_v, image_ << 1015 G4double cof, length,delta, real, image ; 1071 1016 1072 length = 0.5 * GetGasFormationZone(omega, g << 1017 length = 0.5*GetGasFormationZone(omega,gamma,varAngle) ; 1073 delta = length * GetGasLinearPhotoAbs(omeg << 1018 delta = length*GetGasLinearPhotoAbs(omega) ; 1074 cof = 1.0 / (1.0 + delta * delta); << 1019 cof = 1.0/(1.0 + delta*delta) ; 1075 1020 1076 real_v = length * cof; << 1021 real = length*cof ; 1077 image_v = real_v * delta; << 1022 image = real*delta ; 1078 1023 1079 G4complex zone(real_v, image_v); << 1024 G4complex zone(real,image); 1080 return zone; << 1025 return zone ; 1081 } 1026 } 1082 1027 >> 1028 >> 1029 1083 ///////////////////////////////////////////// 1030 //////////////////////////////////////////////////////////////////////// >> 1031 // 1084 // Computes matrix of Sandia photo absorption 1032 // Computes matrix of Sandia photo absorption cross section coefficients for 1085 // gas material 1033 // gas material 1086 void G4VXTRenergyLoss::ComputeGasPhotoAbsCof( << 1034 >> 1035 void G4VXTRenergyLoss::ComputeGasPhotoAbsCof() 1087 { 1036 { 1088 const G4MaterialTable* theMaterialTable = G 1037 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); 1089 const G4Material* mat = ( << 1038 const G4Material* mat = (*theMaterialTable)[fMatIndex2]; 1090 fGasPhotoAbsCof = m << 1039 fGasPhotoAbsCof = mat->GetSandiaTable(); 1091 return; 1040 return; 1092 } 1041 } 1093 1042 1094 ///////////////////////////////////////////// 1043 ////////////////////////////////////////////////////////////////////// 1095 // Returns the value of linear photo absorpti << 1044 // >> 1045 // Returns the value of linear photo absorption coefficient (in reciprocal 1096 // length) for gas 1046 // length) for gas 1097 G4double G4VXTRenergyLoss::GetGasLinearPhotoA << 1047 >> 1048 G4double G4VXTRenergyLoss::GetGasLinearPhotoAbs(G4double omega) 1098 { 1049 { 1099 G4double omega2, omega3, omega4; << 1050 G4double omega2, omega3, omega4 ; 1100 1051 1101 omega2 = omega * omega; << 1052 omega2 = omega*omega ; 1102 omega3 = omega2 * omega; << 1053 omega3 = omega2*omega ; 1103 omega4 = omega2 * omega2; << 1054 omega4 = omega2*omega2 ; 1104 1055 1105 const G4double* SandiaCof = fGasPhotoAbsCof << 1056 G4double* SandiaCof = fGasPhotoAbsCof->GetSandiaCofForMaterial(omega); 1106 G4double cross = SandiaCof[0] / << 1057 G4double cross = SandiaCof[0]/omega + SandiaCof[1]/omega2 + 1107 SandiaCof[2] / omega3 + Sa << 1058 SandiaCof[2]/omega3 + SandiaCof[3]/omega4; 1108 return cross; 1059 return cross; >> 1060 1109 } 1061 } 1110 1062 1111 ///////////////////////////////////////////// 1063 ////////////////////////////////////////////////////////////////////// 1112 // Calculates the product of linear cof by fo << 1064 // >> 1065 // Calculates the product of linear cof by formation zone for plate. 1113 // Omega is energy !!! 1066 // Omega is energy !!! 1114 G4double G4VXTRenergyLoss::GetPlateZmuProduct << 1067 1115 << 1068 G4double G4VXTRenergyLoss::GetPlateZmuProduct( G4double omega , >> 1069 G4double gamma , >> 1070 G4double varAngle ) 1116 { 1071 { 1117 return GetPlateFormationZone(omega, gamma, << 1072 return GetPlateFormationZone(omega,gamma,varAngle) 1118 GetPlateLinearPhotoAbs(omega); << 1073 * GetPlateLinearPhotoAbs(omega) ; 1119 } 1074 } 1120 ///////////////////////////////////////////// 1075 ////////////////////////////////////////////////////////////////////// 1121 // Calculates the product of linear cof by fo << 1076 // >> 1077 // Calculates the product of linear cof by formation zone for plate. 1122 // G4cout and output in file in some energy r 1078 // G4cout and output in file in some energy range. 1123 void G4VXTRenergyLoss::GetPlateZmuProduct() << 1079 >> 1080 void G4VXTRenergyLoss::GetPlateZmuProduct() 1124 { 1081 { 1125 std::ofstream outPlate("plateZmu.dat", std: << 1082 ofstream outPlate("plateZmu.dat", ios::out ) ; 1126 outPlate.setf(std::ios::scientific, std::io << 1083 outPlate.setf( ios::scientific, ios::floatfield ); 1127 1084 1128 G4int i; << 1085 G4int i ; 1129 G4double omega, varAngle, gamma; << 1086 G4double omega, varAngle, gamma ; 1130 gamma = 10000.; << 1087 gamma = 10000. ; 1131 varAngle = 1 / gamma / gamma; << 1088 varAngle = 1/gamma/gamma ; 1132 if(verboseLevel > 0) 1089 if(verboseLevel > 0) 1133 G4cout << "energy, keV" << "\t" << "Zmu f << 1090 G4cout<<"energy, keV"<<"\t"<<"Zmu for plate"<<G4endl ; 1134 for(i = 0; i < 100; ++i) << 1091 for(i=0;i<100;i++) 1135 { 1092 { 1136 omega = (1.0 + i) * keV; << 1093 omega = (1.0 + i)*keV ; 1137 if(verboseLevel > 1) 1094 if(verboseLevel > 1) 1138 G4cout << omega / keV << "\t" << 1095 G4cout<<omega/keV<<"\t"<<GetPlateZmuProduct(omega,gamma,varAngle)<<"\t"; 1139 << GetPlateZmuProduct(omega, gam << 1140 if(verboseLevel > 0) 1096 if(verboseLevel > 0) 1141 outPlate << omega / keV << "\t\t" << 1097 outPlate<<omega/keV<<"\t\t"<<GetPlateZmuProduct(omega,gamma,varAngle)<<G4endl ; 1142 << GetPlateZmuProduct(omega, g << 1143 } 1098 } 1144 return; << 1099 return ; 1145 } 1100 } 1146 1101 1147 ///////////////////////////////////////////// 1102 ////////////////////////////////////////////////////////////////////// 1148 // Calculates the product of linear cof by fo << 1103 // >> 1104 // Calculates the product of linear cof by formation zone for gas. 1149 // Omega is energy !!! 1105 // Omega is energy !!! 1150 G4double G4VXTRenergyLoss::GetGasZmuProduct(G << 1106 1151 G << 1107 G4double G4VXTRenergyLoss::GetGasZmuProduct( G4double omega , >> 1108 G4double gamma , >> 1109 G4double varAngle ) 1152 { 1110 { 1153 return GetGasFormationZone(omega, gamma, va << 1111 return GetGasFormationZone(omega,gamma,varAngle)*GetGasLinearPhotoAbs(omega) ; 1154 GetGasLinearPhotoAbs(omega); << 1155 } 1112 } 1156 << 1157 ///////////////////////////////////////////// 1113 ////////////////////////////////////////////////////////////////////// 1158 // Calculates the product of linear cof by fo << 1114 // >> 1115 // Calculates the product of linear cof byformation zone for gas. 1159 // G4cout and output in file in some energy r 1116 // G4cout and output in file in some energy range. 1160 void G4VXTRenergyLoss::GetGasZmuProduct() << 1117 >> 1118 void G4VXTRenergyLoss::GetGasZmuProduct() 1161 { 1119 { 1162 std::ofstream outGas("gasZmu.dat", std::ios << 1120 ofstream outGas("gasZmu.dat", ios::out ) ; 1163 outGas.setf(std::ios::scientific, std::ios: << 1121 outGas.setf( ios::scientific, ios::floatfield ); 1164 G4int i; << 1122 G4int i ; 1165 G4double omega, varAngle, gamma; << 1123 G4double omega, varAngle, gamma ; 1166 gamma = 10000.; << 1124 gamma = 10000. ; 1167 varAngle = 1 / gamma / gamma; << 1125 varAngle = 1/gamma/gamma ; 1168 if(verboseLevel > 0) 1126 if(verboseLevel > 0) 1169 G4cout << "energy, keV" << "\t" << "Zmu f << 1127 G4cout<<"energy, keV"<<"\t"<<"Zmu for gas"<<G4endl ; 1170 for(i = 0; i < 100; ++i) << 1128 for(i=0;i<100;i++) 1171 { 1129 { 1172 omega = (1.0 + i) * keV; << 1130 omega = (1.0 + i)*keV ; 1173 if(verboseLevel > 1) 1131 if(verboseLevel > 1) 1174 G4cout << omega / keV << "\t" << GetGas << 1132 G4cout<<omega/keV<<"\t"<<GetGasZmuProduct(omega,gamma,varAngle)<<"\t" ; 1175 << "\t"; << 1176 if(verboseLevel > 0) 1133 if(verboseLevel > 0) 1177 outGas << omega / keV << "\t\t" << 1134 outGas<<omega/keV<<"\t\t"<<GetGasZmuProduct(omega,gamma,varAngle)<<G4endl ; 1178 << GetGasZmuProduct(omega, gamma << 1179 } 1135 } 1180 return; << 1136 return ; 1181 } 1137 } 1182 1138 1183 ///////////////////////////////////////////// 1139 //////////////////////////////////////////////////////////////////////// >> 1140 // 1184 // Computes Compton cross section for plate m 1141 // Computes Compton cross section for plate material in 1/mm 1185 G4double G4VXTRenergyLoss::GetPlateCompton(G4 << 1142 >> 1143 G4double G4VXTRenergyLoss::GetPlateCompton(G4double omega) 1186 { 1144 { 1187 G4int i, numberOfElements; 1145 G4int i, numberOfElements; 1188 G4double xSection = 0., nowZ, sumZ = 0.; 1146 G4double xSection = 0., nowZ, sumZ = 0.; 1189 1147 1190 const G4MaterialTable* theMaterialTable = G 1148 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); 1191 numberOfElements = (G4int)(*theMaterialTabl << 1149 numberOfElements = (*theMaterialTable)[fMatIndex1]->GetNumberOfElements() ; 1192 1150 1193 for(i = 0; i < numberOfElements; ++i) << 1151 for( i = 0; i < numberOfElements; i++ ) 1194 { 1152 { 1195 nowZ = (*theMaterialTable)[fMatIndex1]->G << 1153 nowZ = (*theMaterialTable)[fMatIndex1]->GetElement(i)->GetZ(); 1196 sumZ += nowZ; << 1154 sumZ += nowZ; 1197 xSection += GetComptonPerAtom(omega, nowZ << 1155 xSection += GetComptonPerAtom(omega,nowZ); // *nowZ; 1198 } 1156 } 1199 xSection /= sumZ; 1157 xSection /= sumZ; 1200 xSection *= (*theMaterialTable)[fMatIndex1] 1158 xSection *= (*theMaterialTable)[fMatIndex1]->GetElectronDensity(); 1201 return xSection; 1159 return xSection; 1202 } 1160 } 1203 1161 >> 1162 1204 ///////////////////////////////////////////// 1163 //////////////////////////////////////////////////////////////////////// >> 1164 // 1205 // Computes Compton cross section for gas mat 1165 // Computes Compton cross section for gas material in 1/mm 1206 G4double G4VXTRenergyLoss::GetGasCompton(G4do << 1166 >> 1167 G4double G4VXTRenergyLoss::GetGasCompton(G4double omega) 1207 { 1168 { 1208 G4double xSection = 0., sumZ = 0.; << 1169 G4int i, numberOfElements; >> 1170 G4double xSection = 0., nowZ, sumZ = 0.; 1209 1171 1210 const G4MaterialTable* theMaterialTable = G 1172 const G4MaterialTable* theMaterialTable = G4Material::GetMaterialTable(); 1211 G4int numberOfElements = (G4int)(*theMateri << 1173 numberOfElements = (*theMaterialTable)[fMatIndex2]->GetNumberOfElements() ; 1212 1174 1213 for (G4int i = 0; i < numberOfElements; ++i << 1175 for( i = 0; i < numberOfElements; i++ ) 1214 { 1176 { 1215 G4double nowZ = (*theMaterialTable)[fMatI << 1177 nowZ = (*theMaterialTable)[fMatIndex2]->GetElement(i)->GetZ(); 1216 sumZ += nowZ; << 1178 sumZ += nowZ; 1217 xSection += GetComptonPerAtom(omega, nowZ << 1179 xSection += GetComptonPerAtom(omega,nowZ); // *nowZ; 1218 } 1180 } 1219 if (sumZ > 0.0) { xSection /= sumZ; } << 1181 xSection /= sumZ; 1220 xSection *= (*theMaterialTable)[fMatIndex2] 1182 xSection *= (*theMaterialTable)[fMatIndex2]->GetElectronDensity(); 1221 return xSection; 1183 return xSection; 1222 } 1184 } 1223 1185 1224 ///////////////////////////////////////////// 1186 //////////////////////////////////////////////////////////////////////// >> 1187 // 1225 // Computes Compton cross section per atom wi 1188 // Computes Compton cross section per atom with Z electrons for gamma with 1226 // the energy GammaEnergy 1189 // the energy GammaEnergy 1227 G4double G4VXTRenergyLoss::GetComptonPerAtom( << 1190 >> 1191 G4double G4VXTRenergyLoss::GetComptonPerAtom(G4double GammaEnergy, G4double Z) 1228 { 1192 { 1229 G4double CrossSection = 0.0; << 1193 G4double CrossSection = 0.0 ; 1230 if(Z < 0.9999) << 1194 if ( Z < 0.9999 ) return CrossSection; 1231 return CrossSection; << 1195 if ( GammaEnergy < 0.1*keV ) return CrossSection; 1232 if(GammaEnergy < 0.1 * keV) << 1196 if ( GammaEnergy > (100.*GeV/Z) ) return CrossSection; 1233 return CrossSection; << 1197 1234 if(GammaEnergy > (100. * GeV / Z)) << 1198 static const G4double a = 20.0 , b = 230.0 , c = 440.0; 1235 return CrossSection; << 1199 1236 << 1200 static const G4double 1237 static constexpr G4double a = 20.0; << 1201 d1= 2.7965e-1*barn, d2=-1.8300e-1*barn, d3= 6.7527 *barn, d4=-1.9798e+1*barn, 1238 static constexpr G4double b = 230.0; << 1202 e1= 1.9756e-5*barn, e2=-1.0205e-2*barn, e3=-7.3913e-2*barn, e4= 2.7079e-2*barn, 1239 static constexpr G4double c = 440.0; << 1203 f1=-3.9178e-7*barn, f2= 6.8241e-5*barn, f3= 6.0480e-5*barn, f4= 3.0274e-4*barn; 1240 << 1204 1241 static constexpr G4double d1 = 2.7965e-1 * << 1205 G4double p1Z = Z*(d1 + e1*Z + f1*Z*Z), p2Z = Z*(d2 + e2*Z + f2*Z*Z), 1242 d3 = 6.7527 * bar << 1206 p3Z = Z*(d3 + e3*Z + f3*Z*Z), p4Z = Z*(d4 + e4*Z + f4*Z*Z); 1243 e1 = 1.9756e-5 * << 1207 1244 e3 = -7.3913e-2 * << 1208 G4double T0 = 15.0*keV; 1245 f1 = -3.9178e-7 * << 1209 if (Z < 1.5) T0 = 40.0*keV; 1246 f3 = 6.0480e-5 * << 1210 1247 << 1211 G4double X = max(GammaEnergy, T0) / electron_mass_c2; 1248 G4double p1Z = Z * (d1 + e1 * Z + f1 * Z * << 1212 CrossSection = p1Z*std::log(1.+2.*X)/X 1249 G4double p2Z = Z * (d2 + e2 * Z + f2 * Z * << 1213 + (p2Z + p3Z*X + p4Z*X*X)/(1. + a*X + b*X*X + c*X*X*X); 1250 G4double p3Z = Z * (d3 + e3 * Z + f3 * Z * << 1251 G4double p4Z = Z * (d4 + e4 * Z + f4 * Z * << 1252 << 1253 G4double T0 = 15.0 * keV; << 1254 if(Z < 1.5) << 1255 T0 = 40.0 * keV; << 1256 << 1257 G4double X = std::max(GammaEnergy, T0) / el << 1258 CrossSection = << 1259 p1Z * std::log(1. + 2. * X) / X + << 1260 (p2Z + p3Z * X + p4Z * X * X) / (1. + a * << 1261 1214 1262 // modification for low energy. (special c 1215 // modification for low energy. (special case for Hydrogen) 1263 if(GammaEnergy < T0) << 1216 >> 1217 if (GammaEnergy < T0) 1264 { 1218 { 1265 G4double dT0 = 1. * keV; << 1219 G4double dT0 = 1.*keV; 1266 X = (T0 + dT0) / electron_mass << 1220 X = (T0+dT0) / electron_mass_c2 ; 1267 G4double sigma = << 1221 G4double sigma = p1Z*log(1.+2*X)/X 1268 p1Z * std::log(1. + 2. * X) / X + << 1222 + (p2Z + p3Z*X + p4Z*X*X)/(1. + a*X + b*X*X + c*X*X*X); 1269 (p2Z + p3Z * X + p4Z * X * X) / (1. + a << 1223 G4double c1 = -T0*(sigma-CrossSection)/(CrossSection*dT0); 1270 G4double c1 = -T0 * (sigma - CrossSection << 1224 G4double c2 = 0.150; 1271 G4double c2 = 0.150; << 1225 if (Z > 1.5) c2 = 0.375-0.0556*log(Z); 1272 if(Z > 1.5) << 1226 G4double y = log(GammaEnergy/T0); 1273 c2 = 0.375 - 0.0556 * std::log(Z); << 1227 CrossSection *= exp(-y*(c1+c2*y)); 1274 G4double y = std::log(GammaEnergy / T0); << 1275 CrossSection *= std::exp(-y * (c1 + c2 * << 1276 } 1228 } 1277 return CrossSection; << 1229 // G4cout << "e= " << GammaEnergy << " Z= " << Z << " cross= " << CrossSection << G4endl; >> 1230 return CrossSection; 1278 } 1231 } 1279 1232 >> 1233 1280 ///////////////////////////////////////////// 1234 /////////////////////////////////////////////////////////////////////// >> 1235 // 1281 // This function returns the spectral and ang 1236 // This function returns the spectral and angle density of TR quanta 1282 // in X-ray energy region generated forward w 1237 // in X-ray energy region generated forward when a relativistic 1283 // charged particle crosses interface between 1238 // charged particle crosses interface between two materials. 1284 // The high energy small theta approximation 1239 // The high energy small theta approximation is applied. 1285 // (matter1 -> matter2, or 2->1) 1240 // (matter1 -> matter2, or 2->1) 1286 // varAngle =2* (1 - std::cos(theta)) or appr << 1241 // varAngle =2* (1 - cos(theta)) or approximately = theta*theta 1287 G4double G4VXTRenergyLoss::OneBoundaryXTRNden << 1242 // 1288 << 1243 1289 << 1244 G4double 1290 { << 1245 G4VXTRenergyLoss::OneBoundaryXTRNdensity( G4double energy,G4double gamma, 1291 G4double formationLength1, formationLength2 << 1246 G4double varAngle ) const 1292 formationLength1 = << 1247 { 1293 1.0 / (1.0 / (gamma * gamma) + fSigma1 / << 1248 G4double formationLength1, formationLength2 ; 1294 formationLength2 = << 1249 formationLength1 = 1.0/ 1295 1.0 / (1.0 / (gamma * gamma) + fSigma2 / << 1250 (1.0/(gamma*gamma) 1296 return (varAngle / energy) * (formationLeng << 1251 + fSigma1/(energy*energy) 1297 (formationLength1 - formationLength2 << 1252 + varAngle) ; >> 1253 formationLength2 = 1.0/ >> 1254 (1.0/(gamma*gamma) >> 1255 + fSigma2/(energy*energy) >> 1256 + varAngle) ; >> 1257 return (varAngle/energy)*(formationLength1 - formationLength2) >> 1258 *(formationLength1 - formationLength2) ; >> 1259 1298 } 1260 } 1299 1261 1300 G4double G4VXTRenergyLoss::GetStackFactor(G4d << 1262 G4double G4VXTRenergyLoss::GetStackFactor( G4double energy, G4double gamma, 1301 G4d << 1263 G4double varAngle ) 1302 { 1264 { 1303 // return stack factor corresponding to one 1265 // return stack factor corresponding to one interface 1304 return std::real(OneInterfaceXTRdEdx(energy << 1266 >> 1267 return std::real( OneInterfaceXTRdEdx(energy,gamma,varAngle) ); 1305 } 1268 } 1306 1269 1307 ///////////////////////////////////////////// 1270 ////////////////////////////////////////////////////////////////////////////// >> 1271 // 1308 // For photon energy distribution tables. Int 1272 // For photon energy distribution tables. Integrate first over angle >> 1273 // >> 1274 1309 G4double G4VXTRenergyLoss::XTRNSpectralAngleD 1275 G4double G4VXTRenergyLoss::XTRNSpectralAngleDensity(G4double varAngle) 1310 { 1276 { 1311 return OneBoundaryXTRNdensity(fEnergy, fGam << 1277 return OneBoundaryXTRNdensity(fEnergy,fGamma,varAngle)* 1312 GetStackFactor(fEnergy, fGamma, varA << 1278 GetStackFactor(fEnergy,fGamma,varAngle) ; 1313 } 1279 } 1314 1280 1315 ///////////////////////////////////////////// 1281 ///////////////////////////////////////////////////////////////////////// >> 1282 // 1316 // For second integration over energy 1283 // For second integration over energy >> 1284 1317 G4double G4VXTRenergyLoss::XTRNSpectralDensit 1285 G4double G4VXTRenergyLoss::XTRNSpectralDensity(G4double energy) 1318 { 1286 { 1319 fEnergy = energy; << 1287 fEnergy = energy ; 1320 G4Integrator<G4VXTRenergyLoss, G4double (G4 << 1288 G4Integrator<G4VXTRenergyLoss,G4double(G4VXTRenergyLoss::*)(G4double)> integral ; 1321 integral; << 1289 return integral.Legendre96(this,&G4VXTRenergyLoss::XTRNSpectralAngleDensity, 1322 return integral.Legendre96(this, &G4VXTRene << 1290 0.0,0.2*fMaxThetaTR) + 1323 0.0, 0.2 * fMaxT << 1291 integral.Legendre10(this,&G4VXTRenergyLoss::XTRNSpectralAngleDensity, 1324 integral.Legendre10(this, &G4VXTRene << 1292 0.2*fMaxThetaTR,fMaxThetaTR) ; 1325 0.2 * fMaxThetaT << 1293 } 1326 } << 1294 1327 << 1328 ///////////////////////////////////////////// 1295 ////////////////////////////////////////////////////////////////////////// >> 1296 // 1329 // for photon angle distribution tables 1297 // for photon angle distribution tables >> 1298 // >> 1299 1330 G4double G4VXTRenergyLoss::XTRNAngleSpectralD 1300 G4double G4VXTRenergyLoss::XTRNAngleSpectralDensity(G4double energy) 1331 { 1301 { 1332 return OneBoundaryXTRNdensity(energy, fGamm << 1302 return OneBoundaryXTRNdensity(energy,fGamma,fVarAngle)* 1333 GetStackFactor(energy, fGamma, fVarA << 1303 GetStackFactor(energy,fGamma,fVarAngle) ; 1334 } << 1304 } 1335 1305 1336 ///////////////////////////////////////////// 1306 /////////////////////////////////////////////////////////////////////////// 1337 G4double G4VXTRenergyLoss::XTRNAngleDensity(G << 1307 // >> 1308 // >> 1309 >> 1310 G4double G4VXTRenergyLoss::XTRNAngleDensity(G4double varAngle) 1338 { 1311 { 1339 fVarAngle = varAngle; << 1312 fVarAngle = varAngle ; 1340 G4Integrator<G4VXTRenergyLoss, G4double (G4 << 1313 G4Integrator<G4VXTRenergyLoss,G4double(G4VXTRenergyLoss::*)(G4double)> integral ; 1341 integral; << 1314 return integral.Legendre96(this,&G4VXTRenergyLoss::XTRNAngleSpectralDensity, 1342 return integral.Legendre96(this, &G4VXTRene << 1315 fMinEnergyTR,fMaxEnergyTR) ; 1343 fMinEnergyTR, fM << 1344 } 1316 } 1345 1317 1346 ///////////////////////////////////////////// 1318 ////////////////////////////////////////////////////////////////////////////// 1347 // Check number of photons for a range of Lor << 1319 // >> 1320 // Check number of photons for a range of Lorentz factors from both energy 1348 // and angular tables 1321 // and angular tables >> 1322 1349 void G4VXTRenergyLoss::GetNumberOfPhotons() 1323 void G4VXTRenergyLoss::GetNumberOfPhotons() 1350 { 1324 { 1351 G4int iTkin; << 1325 G4int iTkin ; 1352 G4double gamma, numberE; << 1326 G4double gamma, numberE ; 1353 1327 1354 std::ofstream outEn("numberE.dat", std::ios << 1328 ofstream outEn("numberE.dat", ios::out ) ; 1355 outEn.setf(std::ios::scientific, std::ios:: << 1329 outEn.setf( ios::scientific, ios::floatfield ); 1356 1330 1357 std::ofstream outAng("numberAng.dat", std:: << 1331 ofstream outAng("numberAng.dat", ios::out ) ; 1358 outAng.setf(std::ios::scientific, std::ios: << 1332 outAng.setf( ios::scientific, ios::floatfield ); 1359 1333 1360 for(iTkin = 0; iTkin < fTotBin; ++iTkin) / << 1334 for(iTkin=0;iTkin<fTotBin;iTkin++) // Lorentz factor loop 1361 { << 1335 { 1362 gamma = << 1336 gamma = 1.0 + (fProtonEnergyVector-> 1363 1.0 + (fProtonEnergyVector->GetLowEdgeE << 1337 GetLowEdgeEnergy(iTkin)/proton_mass_c2) ; 1364 numberE = (*(*fEnergyDistrTable)(iTkin))( << 1338 numberE = (*(*fEnergyDistrTable)(iTkin))(0) ; 1365 if(verboseLevel > 1) << 1339 // numberA = (*(*fAngleDistrTable)(iTkin))(0) ; 1366 G4cout << gamma << "\t\t" << numberE << << 1340 if(verboseLevel > 1) 1367 if(verboseLevel > 0) << 1341 G4cout<<gamma<<"\t\t"<<numberE<<"\t" // <<numberA 1368 outEn << gamma << "\t\t" << numberE << << 1342 <<G4endl ; >> 1343 if(verboseLevel > 0) >> 1344 outEn<<gamma<<"\t\t"<<numberE<<G4endl ; 1369 } 1345 } 1370 return; << 1346 return ; 1371 } << 1347 } 1372 1348 1373 ///////////////////////////////////////////// 1349 ///////////////////////////////////////////////////////////////////////// 1374 // Returns random energy of a X-ray TR photon << 1350 // >> 1351 // Returns randon energy of a X-ray TR photon for given scaled kinetic energy 1375 // of a charged particle 1352 // of a charged particle 1376 G4double G4VXTRenergyLoss::GetXTRrandomEnergy << 1353 >> 1354 G4double G4VXTRenergyLoss::GetXTRrandomEnergy( G4double scaledTkin, G4int iTkin ) 1377 { 1355 { 1378 G4int iTransfer, iPlace; << 1356 G4int iTransfer, iPlace ; 1379 G4double transfer = 0.0, position, E1, E2, << 1357 G4double transfer = 0.0, position, E1, E2, W1, W2, W ; >> 1358 >> 1359 iPlace = iTkin - 1 ; 1380 1360 1381 iPlace = iTkin - 1; << 1361 // G4cout<<"iPlace = "<<iPlace<<endl ; 1382 1362 1383 if(iTkin == fTotBin) // relativistic plato << 1363 if(iTkin == fTotBin) // relativistic plato, try from left 1384 { 1364 { 1385 position = (*(*fEnergyDistrTable)(iPlace) << 1365 position = (*(*fEnergyDistrTable)(iPlace))(0)*G4UniformRand() ; 1386 1366 1387 for(iTransfer = 0;; ++iTransfer) << 1367 for(iTransfer=0;;iTransfer++) 1388 { << 1368 { 1389 if(position >= (*(*fEnergyDistrTable)(i << 1369 if(position >= (*(*fEnergyDistrTable)(iPlace))(iTransfer)) break ; 1390 break; << 1370 } 1391 } << 1371 transfer = GetXTRenergy(iPlace,position,iTransfer); 1392 transfer = GetXTRenergy(iPlace, position, << 1393 } 1372 } 1394 else 1373 else 1395 { 1374 { 1396 E1 = fProtonEnergyVector->GetLowEdgeEnerg << 1375 E1 = fProtonEnergyVector->GetLowEdgeEnergy(iTkin - 1) ; 1397 E2 = fProtonEnergyVector->GetLowEdgeEnerg << 1376 E2 = fProtonEnergyVector->GetLowEdgeEnergy(iTkin) ; 1398 W = 1.0 / (E2 - E1); << 1377 W = 1.0/(E2 - E1) ; 1399 W1 = (E2 - scaledTkin) * W; << 1378 W1 = (E2 - scaledTkin)*W ; 1400 W2 = (scaledTkin - E1) * W; << 1379 W2 = (scaledTkin - E1)*W ; 1401 << 1380 1402 position = ((*(*fEnergyDistrTable)(iPlace << 1381 position =( (*(*fEnergyDistrTable)(iPlace))(0)*W1 + 1403 (*(*fEnergyDistrTable)(iPlace << 1382 (*(*fEnergyDistrTable)(iPlace+1))(0)*W2 )*G4UniformRand() ; 1404 G4UniformRand(); << 1383 1405 << 1384 // G4cout<<position<<"\t" ; 1406 for(iTransfer = 0;; ++iTransfer) << 1385 1407 { << 1386 for(iTransfer=0;;iTransfer++) 1408 if(position >= ((*(*fEnergyDistrTable)( << 1387 { 1409 (*(*fEnergyDistrTable)( << 1388 if( position >= 1410 break; << 1389 ( (*(*fEnergyDistrTable)(iPlace))(iTransfer)*W1 + 1411 } << 1390 (*(*fEnergyDistrTable)(iPlace+1))(iTransfer)*W2) ) break ; 1412 transfer = GetXTRenergy(iPlace, position, << 1391 } 1413 } << 1392 transfer = GetXTRenergy(iPlace,position,iTransfer); 1414 if(transfer < 0.0) << 1393 1415 transfer = 0.0; << 1394 } 1416 return transfer; << 1395 // G4cout<<"XTR transfer = "<<transfer/keV<<" keV"<<endl ; >> 1396 if(transfer < 0.0 ) transfer = 0.0 ; >> 1397 return transfer ; 1417 } 1398 } 1418 1399 1419 ///////////////////////////////////////////// 1400 //////////////////////////////////////////////////////////////////////// >> 1401 // 1420 // Returns approximate position of X-ray phot 1402 // Returns approximate position of X-ray photon energy during random sampling 1421 // over integral energy distribution 1403 // over integral energy distribution 1422 G4double G4VXTRenergyLoss::GetXTRenergy(G4int << 1404 >> 1405 G4double G4VXTRenergyLoss::GetXTRenergy( G4int iPlace, >> 1406 G4double position, >> 1407 G4int iTransfer ) 1423 { 1408 { 1424 G4double x1, x2, y1, y2, result; << 1409 G4double x1, x2, y1, y2, result ; 1425 1410 1426 if(iTransfer == 0) 1411 if(iTransfer == 0) 1427 { 1412 { 1428 result = (*fEnergyDistrTable)(iPlace)->Ge << 1413 result = (*fEnergyDistrTable)(iPlace)->GetLowEdgeEnergy(iTransfer) ; 1429 } << 1414 } 1430 else 1415 else 1431 { 1416 { 1432 y1 = (*(*fEnergyDistrTable)(iPlace))(iTra << 1417 y1 = (*(*fEnergyDistrTable)(iPlace))(iTransfer-1) ; 1433 y2 = (*(*fEnergyDistrTable)(iPlace))(iTra << 1418 y2 = (*(*fEnergyDistrTable)(iPlace))(iTransfer) ; 1434 1419 1435 x1 = (*fEnergyDistrTable)(iPlace)->GetLow << 1420 x1 = (*fEnergyDistrTable)(iPlace)->GetLowEdgeEnergy(iTransfer-1) ; 1436 x2 = (*fEnergyDistrTable)(iPlace)->GetLow << 1421 x2 = (*fEnergyDistrTable)(iPlace)->GetLowEdgeEnergy(iTransfer) ; 1437 1422 1438 if(x1 == x2) << 1423 if ( x1 == x2 ) result = x2 ; 1439 result = x2; << 1440 else 1424 else 1441 { 1425 { 1442 if(y1 == y2) << 1426 if ( y1 == y2 ) result = x1 + (x2 - x1)*G4UniformRand() ; 1443 result = x1 + (x2 - x1) * G4UniformRa << 1444 else 1427 else 1445 { 1428 { 1446 result = x1 + (x2 - x1) * G4UniformRa << 1429 result = x1 + (position - y1)*(x2 - x1)/(y2 - y1) ; 1447 } 1430 } 1448 } 1431 } 1449 } 1432 } 1450 return result; << 1433 return result ; 1451 } 1434 } 1452 1435 1453 ///////////////////////////////////////////// 1436 ///////////////////////////////////////////////////////////////////////// >> 1437 // 1454 // Get XTR photon angle at given energy and 1438 // Get XTR photon angle at given energy and Tkin 1455 1439 1456 G4double G4VXTRenergyLoss::GetRandomAngle(G4d << 1440 G4double G4VXTRenergyLoss::GetRandomAngle( G4double energyXTR, G4int iTkin ) 1457 { 1441 { 1458 G4int iTR, iAngle; 1442 G4int iTR, iAngle; 1459 G4double position, angle; 1443 G4double position, angle; 1460 1444 1461 if(iTkin == fTotBin) << 1445 if (iTkin == fTotBin) iTkin--; 1462 --iTkin; << 1463 1446 1464 fAngleForEnergyTable = fAngleBank[iTkin]; 1447 fAngleForEnergyTable = fAngleBank[iTkin]; 1465 1448 1466 for(iTR = 0; iTR < fBinTR; ++iTR) << 1449 for( iTR = 0; iTR < fBinTR; iTR++ ) 1467 { 1450 { 1468 if(energyXTR < fXTREnergyVector->GetLowEd << 1451 if( energyXTR < fXTREnergyVector->GetLowEdgeEnergy(iTR) ) break; 1469 break; << 1470 } 1452 } 1471 if(iTR == fBinTR) << 1453 if (iTR == fBinTR) iTR--; 1472 --iTR; << 1454 1473 << 1455 position = (*(*fAngleForEnergyTable)(iTR))(0)*G4UniformRand() ; 1474 position = (*(*fAngleForEnergyTable)(iTR))( << 1475 // position = (*(*fAngleForEnergyTable)(iTR << 1476 1456 1477 for(iAngle = 0;; ++iAngle) << 1457 for(iAngle = 0;;iAngle++) 1478 // for(iAngle = 1;; ++iAngle) // ATLAS TB << 1479 { 1458 { 1480 if(position >= (*(*fAngleForEnergyTable)( << 1459 if(position >= (*(*fAngleForEnergyTable)(iTR))(iAngle)) break ; 1481 break; << 1482 } 1460 } 1483 angle = GetAngleXTR(iTR, position, iAngle); << 1461 angle = GetAngleXTR(iTR,position,iAngle); 1484 return angle; 1462 return angle; 1485 } 1463 } 1486 1464 1487 ///////////////////////////////////////////// 1465 //////////////////////////////////////////////////////////////////////// 1488 // Returns approximate position of X-ray phot << 1466 // 1489 // random sampling over integral energy distr << 1467 // Returns approximate position of X-ray photon angle at given energy during random sampling >> 1468 // over integral energy distribution 1490 1469 1491 G4double G4VXTRenergyLoss::GetAngleXTR(G4int << 1470 G4double G4VXTRenergyLoss::GetAngleXTR( G4int iPlace, 1492 G4int << 1471 G4double position, >> 1472 G4int iTransfer ) 1493 { 1473 { 1494 G4double x1, x2, y1, y2, result; << 1474 G4double x1, x2, y1, y2, result ; 1495 1475 1496 if( iTransfer == 0 ) << 1476 if(iTransfer == 0) 1497 // if( iTransfer == 1 ) // ATLAS TB << 1498 { 1477 { 1499 result = (*fAngleForEnergyTable)(iPlace)- << 1478 result = (*fAngleForEnergyTable)(iPlace)->GetLowEdgeEnergy(iTransfer) ; 1500 } << 1479 } 1501 else 1480 else 1502 { 1481 { 1503 y1 = (*(*fAngleForEnergyTable)(iPlace))(i << 1482 y1 = (*(*fAngleForEnergyTable)(iPlace))(iTransfer-1) ; 1504 y2 = (*(*fAngleForEnergyTable)(iPlace))(i << 1483 y2 = (*(*fAngleForEnergyTable)(iPlace))(iTransfer) ; 1505 1484 1506 x1 = (*fAngleForEnergyTable)(iPlace)->Get << 1485 x1 = (*fAngleForEnergyTable)(iPlace)->GetLowEdgeEnergy(iTransfer-1) ; 1507 x2 = (*fAngleForEnergyTable)(iPlace)->Get << 1486 x2 = (*fAngleForEnergyTable)(iPlace)->GetLowEdgeEnergy(iTransfer) ; 1508 1487 1509 if(x1 == x2) result = x2; << 1488 if ( x1 == x2 ) result = x2 ; 1510 else 1489 else 1511 { 1490 { 1512 if( y1 == y2 ) result = x1 + (x2 - x1) << 1491 if ( y1 == y2 ) result = x1 + (x2 - x1)*G4UniformRand() ; 1513 else 1492 else 1514 { 1493 { 1515 result = x1 + (position - y1) * (x2 - << 1494 result = x1 + (position - y1)*(x2 - x1)/(y2 - y1) ; 1516 // result = x1 + 0.1*(position - y1) << 1517 // result = x1 + 0.05*(position - y1) << 1518 } 1495 } 1519 } 1496 } 1520 } 1497 } 1521 return result; << 1498 return result ; 1522 } 1499 } >> 1500 >> 1501 >> 1502 // >> 1503 // >> 1504 /////////////////////////////////////////////////////////////////////// >> 1505 1523 1506