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 // ------------------------------------------------------------------- 00029 // 00030 // GEANT4 Class header file 00031 // 00032 // 00033 // File name: G4EmElementSelector 00034 // 00035 // Author: Vladimir Ivanchenko 00036 // 00037 // Creation date: 29.05.2008 00038 // 00039 // Modifications: 00040 // 00041 // 00042 // Class Description: 00043 // 00044 // Generic helper class for the random selection of an element 00045 00046 // ------------------------------------------------------------------- 00047 // 00048 00049 #ifndef G4EmElementSelector_h 00050 #define G4EmElementSelector_h 1 00051 00052 #include "globals.hh" 00053 #include "G4ParticleDefinition.hh" 00054 #include "G4Material.hh" 00055 #include "G4Element.hh" 00056 #include "G4ElementVector.hh" 00057 #include "G4PhysicsLogVector.hh" 00058 #include "Randomize.hh" 00059 #include <vector> 00060 00061 class G4VEmModel; 00062 00063 class G4EmElementSelector 00064 { 00065 00066 public: 00067 00068 G4EmElementSelector(G4VEmModel*, const G4Material*, G4int bins, 00069 G4double emin, G4double emax, 00070 G4bool spline = true); 00071 00072 ~G4EmElementSelector(); 00073 00074 void Initialise(const G4ParticleDefinition*, G4double cut = 0.0); 00075 00076 void Dump(const G4ParticleDefinition* p = 0); 00077 00078 inline const G4Element* SelectRandomAtom(G4double kineticEnergy); 00079 00080 inline const G4Material* GetMaterial() const; 00081 00082 private: 00083 00084 // hide assignment operator 00085 G4EmElementSelector & operator=(const G4EmElementSelector &right); 00086 G4EmElementSelector(const G4EmElementSelector&); 00087 00088 G4VEmModel* model; 00089 const G4Material* material; 00090 const G4Element* element; 00091 const G4ElementVector* theElementVector; 00092 00093 G4int nElmMinusOne; 00094 G4int nbins; 00095 00096 G4double cutEnergy; 00097 G4double lowEnergy; 00098 G4double highEnergy; 00099 00100 std::vector<G4PhysicsLogVector*> xSections; 00101 00102 }; 00103 00104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 00105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 00106 00107 inline const G4Element* G4EmElementSelector::SelectRandomAtom(G4double e) 00108 { 00109 if (nElmMinusOne > 0) { 00110 G4double x = G4UniformRand(); 00111 element = (*theElementVector)[nElmMinusOne]; 00112 for(G4int i=0; i<nElmMinusOne; ++i) { 00113 if (x <= (xSections[i])->Value(e)) { 00114 element = (*theElementVector)[i]; 00115 break; 00116 } 00117 } 00118 } 00119 return element; 00120 } 00121 00122 inline const G4Material* G4EmElementSelector::GetMaterial() const 00123 { 00124 return material; 00125 } 00126 00127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 00128 00129 #endif 00130