G4ElementSelector.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // $Id$
00027 //
00028 // File: G4ElementSelector
00029 //
00030 // Author:        V.Ivanchenko (Vladimir.Ivanchenko@cern.ch)
00031 // 
00032 // Creation date: 2 April 2000
00033 //
00034 // Modifications: 
00035 // 18/08/2000  V.Ivanchenko Update description
00036 // 17/05/2006  V.Ivanchenko Cleanup
00037 // 02/10/2007  V.Ivanchenko Fixed typo in computation of Lambda-factor
00038 //                          proposed by Victor Pec 
00039 //
00040 //---------------------------------------------------------------------
00041 
00042 #include "G4ElementSelector.hh"
00043 #include "Randomize.hh" 
00044 #include "G4Material.hh"
00045 #include "G4Nucleus.hh"
00046 
00047 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00048 
00049 G4ElementSelector::G4ElementSelector()
00050 {}
00051 
00052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00053 
00054 G4ElementSelector::~G4ElementSelector()
00055 {}
00056 
00057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
00058 
00059 G4Element* 
00060 G4ElementSelector::SelectZandA(const G4Track& track, G4Nucleus* target)
00061 {
00062   // Fermi-Teller Z-low of mu- capture and exceptions 
00063   // for halogens and oxigen.
00064   // N.C.Mukhopadhyay Phys. Rep. 30 (1977) 1.
00065 
00066   size_t i = 0;
00067   const G4Material* mat = track.GetMaterial();
00068   size_t numberOfElements = mat->GetNumberOfElements();
00069   const G4ElementVector* theElementVector = mat->GetElementVector();
00070 
00071   if(1 < numberOfElements) {
00072     if(numberOfElements > prob.size()) { prob.resize(numberOfElements, 0.0); }
00073     
00074     const G4double* theAtomNumDensity = mat->GetAtomicNumDensityVector();
00075 
00076     G4double sum = 0.0;
00077     for (i=0; i < numberOfElements; ++i) {
00078 
00079       G4int Z = G4lrint((*theElementVector)[i]->GetZ()); 
00080 
00081       // Halogens
00082       if( (9 == Z) || (17 == Z) || (35 == Z) || (53 == Z) || (85 == Z) ) {
00083         sum += 0.66 * Z * theAtomNumDensity[i]; 
00084 
00085         // Oxigen
00086       } else if( 8 == Z ) {
00087         sum += 0.56 * Z * theAtomNumDensity[i]; 
00088 
00089         // Others
00090       } else {
00091         sum += Z * theAtomNumDensity[i]; 
00092       }
00093       prob[i] = sum;
00094     }
00095  
00096     sum *= G4UniformRand();
00097     for (i=0; i < numberOfElements; ++i) {
00098       if(sum <= prob[i]) { break; }
00099     }
00100   }
00101   
00102   G4Element* elm = (*theElementVector)[i];
00103   G4int Z = G4lrint(elm->GetZ());
00104 
00105   // select isotope
00106   const G4IsotopeVector* isv = elm->GetIsotopeVector();
00107   size_t ni = isv->size();
00108   i = 0;
00109 
00110   if(1 < ni) {
00111 
00112     const G4double* ab = elm->GetRelativeAbundanceVector();
00113     G4double y = G4UniformRand();
00114     for(i=0; i<ni; ++i) {
00115       y -= ab[i];
00116       if(y <= 0.0) { break; }
00117     }
00118   }
00119 
00120   G4int A = elm->GetIsotope(i)->GetN();
00121   target->SetParameters(A, Z);
00122 
00123   return elm;
00124 }
00125 

Generated on Mon May 27 17:48:07 2013 for Geant4 by  doxygen 1.4.7