Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:08

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 // -------------------------------------------------------------------
0028 //
0029 // GEANT4 Class file
0030 //
0031 //
0032 // File name:     G4RDGenerator2BS
0033 //
0034 // Author:        Andreia Trindade (andreia@lip.pt)
0035 //                Pedro Rodrigues  (psilva@lip.pt)
0036 //                Luis Peralta     (luis@lip.pt)
0037 //
0038 // Creation date: 2 June 2003
0039 //
0040 // Modifications: 
0041 // 02 Jun 2003                    First implementation acording with new design
0042 // 05 Nov 2003  MGP               Fixed std namespace
0043 // 17 Nov 2003  MGP               Fixed compilation problem on Windows                  
0044 //
0045 // Class Description: 
0046 //
0047 // Concrete base class for Bremsstrahlung Angular Distribution Generation - 2BS Distribution
0048 //
0049 // Class Description: End 
0050 //
0051 // -------------------------------------------------------------------
0052 //
0053 //    
0054 
0055 #include "G4RDGenerator2BS.hh"
0056 #include "Randomize.hh"
0057 #include "G4PhysicalConstants.hh"
0058 //    
0059 
0060 G4RDGenerator2BS::G4RDGenerator2BS(const G4String& name):G4RDVBremAngularDistribution(name)
0061 {;}
0062 
0063 //    
0064 
0065 G4RDGenerator2BS::~G4RDGenerator2BS() 
0066 {;}
0067 
0068 //
0069 
0070 G4double G4RDGenerator2BS::PolarAngle(const G4double initial_energy,
0071                     const G4double final_energy,
0072                     const G4int Z)
0073 {
0074 
0075   // Adapted from "Improved bremsstrahlung photon angular sampling in the EGS4 code system"
0076   // by Alex F. Bielajew, Rahde Mohan anc Chen-Shou Chui, PIRS-0203
0077   // Ionizing Radiation Standards
0078   // Institute for National Measurement Standards 
0079   // National Research Council of Canada
0080   // Departement of Medical Physics, Memorial Sloan-Kettering Cancer Center, New York
0081 
0082 
0083   G4double theta = 0;
0084 
0085   G4double initialTotalEnergy = (initial_energy+electron_mass_c2)/electron_mass_c2;
0086   G4double finalTotalEnergy = (final_energy+electron_mass_c2)/electron_mass_c2;
0087   EnergyRatio = finalTotalEnergy/initialTotalEnergy;
0088   G4double gMaxEnergy = (pi*initialTotalEnergy)*(pi*initialTotalEnergy);
0089 
0090   G4double Zeff = std::sqrt(static_cast<G4double>(Z) * (static_cast<G4double>(Z) + 1.0));
0091   z = (0.00008116224*(std::pow(Zeff,0.3333333)));
0092 
0093   // Rejection arguments
0094   rejection_argument1 = (1.0+EnergyRatio*EnergyRatio); 
0095   rejection_argument2 = - 2.0*EnergyRatio + 3.0*rejection_argument1;
0096   rejection_argument3 = ((1-EnergyRatio)/(2.0*initialTotalEnergy*EnergyRatio))*
0097     ((1-EnergyRatio)/(2.0*initialTotalEnergy*EnergyRatio));
0098 
0099   // Calculate rejection function at 0, 1 and Emax
0100   G4double gfunction0 = RejectionFunction(0);
0101   G4double gfunction1 = RejectionFunction(1);
0102   G4double gfunctionEmax = RejectionFunction(gMaxEnergy);
0103 
0104 
0105   // Calculate Maximum value 
0106   G4double gMaximum = std::max(gfunction0,gfunction1);
0107   gMaximum = std::max(gMaximum,gfunctionEmax);
0108 
0109   G4double rand, gfunctionTest, randTest;
0110 
0111   do{
0112     rand = G4UniformRand();
0113     rand = rand/(1-rand+1.0/gMaxEnergy);
0114     gfunctionTest = RejectionFunction(rand);
0115     randTest = G4UniformRand();
0116 
0117   }while(randTest > (gfunctionTest/gMaximum));
0118 
0119   theta = std::sqrt(rand)/initialTotalEnergy;
0120 
0121 
0122   return theta;
0123 }
0124 //
0125 
0126 G4double G4RDGenerator2BS::RejectionFunction(G4double value) const
0127 {
0128 
0129   G4double argument = (1+value)*(1+value);
0130 
0131   G4double gfunction = (4+std::log(rejection_argument3+(z/argument)))*
0132     ((4*EnergyRatio*value/argument)-rejection_argument1)+rejection_argument2;
0133 
0134   return gfunction;
0135 
0136 }
0137 
0138 void G4RDGenerator2BS::PrintGeneratorInformation() const
0139 {
0140   G4cout << "\n" << G4endl;
0141   G4cout << "Bremsstrahlung Angular Generator is 2BS Generator from 2BS Koch & Motz distribution (Rev Mod Phys 31(4), 920 (1959))" << G4endl;
0142   G4cout << "Sampling algorithm adapted from PIRS-0203" << G4endl;
0143   G4cout << "\n" << G4endl;
0144 } 
0145