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