1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // $Id: G4EmElementSelector.hh,v 1.2 2008/07/22 15:55:15 vnivanch Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-02 $ |
---|
28 | // |
---|
29 | // ------------------------------------------------------------------- |
---|
30 | // |
---|
31 | // GEANT4 Class header file |
---|
32 | // |
---|
33 | // |
---|
34 | // File name: G4EmElementSelector |
---|
35 | // |
---|
36 | // Author: Vladimir Ivanchenko |
---|
37 | // |
---|
38 | // Creation date: 29.05.2008 |
---|
39 | // |
---|
40 | // Modifications: |
---|
41 | // |
---|
42 | // |
---|
43 | // Class Description: |
---|
44 | // |
---|
45 | // Generic helper class for the random selection of an element |
---|
46 | |
---|
47 | // ------------------------------------------------------------------- |
---|
48 | // |
---|
49 | |
---|
50 | #ifndef G4EmElementSelector_h |
---|
51 | #define G4EmElementSelector_h 1 |
---|
52 | |
---|
53 | #include "globals.hh" |
---|
54 | #include "G4ParticleDefinition.hh" |
---|
55 | #include "G4Material.hh" |
---|
56 | #include "G4Element.hh" |
---|
57 | #include "G4ElementVector.hh" |
---|
58 | #include "G4PhysicsLogVector.hh" |
---|
59 | #include "Randomize.hh" |
---|
60 | #include <vector> |
---|
61 | |
---|
62 | class G4VEmModel; |
---|
63 | |
---|
64 | class G4EmElementSelector |
---|
65 | { |
---|
66 | |
---|
67 | public: |
---|
68 | |
---|
69 | G4EmElementSelector(G4VEmModel*, const G4Material*, G4int bins, |
---|
70 | G4double emin, G4double emax, |
---|
71 | G4bool spline = true); |
---|
72 | |
---|
73 | ~G4EmElementSelector(); |
---|
74 | |
---|
75 | void Initialise(const G4ParticleDefinition*, G4double cut = 0.0); |
---|
76 | |
---|
77 | void Dump(const G4ParticleDefinition* p = 0); |
---|
78 | |
---|
79 | inline const G4Element* SelectRandomAtom(G4double kineticEnergy); |
---|
80 | |
---|
81 | inline const G4Material* GetMaterial() const; |
---|
82 | |
---|
83 | private: |
---|
84 | |
---|
85 | // hide assignment operator |
---|
86 | G4EmElementSelector & operator=(const G4EmElementSelector &right); |
---|
87 | G4EmElementSelector(const G4EmElementSelector&); |
---|
88 | |
---|
89 | G4VEmModel* model; |
---|
90 | const G4Material* material; |
---|
91 | const G4ElementVector* theElementVector; |
---|
92 | |
---|
93 | G4int nElmMinusOne; |
---|
94 | G4int nbins; |
---|
95 | |
---|
96 | G4double cutEnergy; |
---|
97 | G4double lowEnergy; |
---|
98 | G4double highEnergy; |
---|
99 | |
---|
100 | std::vector<G4PhysicsLogVector*> xSections; |
---|
101 | |
---|
102 | }; |
---|
103 | |
---|
104 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... |
---|
105 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... |
---|
106 | |
---|
107 | inline const G4Element* G4EmElementSelector::SelectRandomAtom(G4double e) |
---|
108 | { |
---|
109 | const G4Element* elm = (*theElementVector)[nElmMinusOne]; |
---|
110 | if (nElmMinusOne > 0) { |
---|
111 | G4bool b; |
---|
112 | G4double x = G4UniformRand(); |
---|
113 | for(G4int i=0; i<nElmMinusOne; i++) { |
---|
114 | if (x <= (xSections[i])->GetValue(e,b)) { |
---|
115 | elm = (*theElementVector)[i]; |
---|
116 | break; |
---|
117 | } |
---|
118 | } |
---|
119 | } |
---|
120 | return elm; |
---|
121 | } |
---|
122 | |
---|
123 | inline const G4Material* G4EmElementSelector::GetMaterial() const |
---|
124 | { |
---|
125 | return material; |
---|
126 | } |
---|
127 | |
---|
128 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... |
---|
129 | |
---|
130 | #endif |
---|
131 | |
---|