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: G4HadronicInteraction.cc,v 1.6 2009/08/30 16:12:34 vnivanch Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
28 | // |
---|
29 | // Hadronic Interaction base class |
---|
30 | // original by H.P. Wellisch |
---|
31 | // modified by J.L. Chuma, TRIUMF, 21-Mar-1997 |
---|
32 | // Last modified: 04-Apr-1997 |
---|
33 | // reimplemented 1.11.2003 JPW. |
---|
34 | // 23-Jan-2009 V.Ivanchenko move constructor and destructor to the body |
---|
35 | |
---|
36 | #include "G4HadronicInteraction.hh" |
---|
37 | #include "G4HadronicInteractionRegistry.hh" |
---|
38 | #include "G4HadronicException.hh" |
---|
39 | |
---|
40 | G4HadronicInteraction::G4HadronicInteraction(const G4String& modelName) : |
---|
41 | verboseLevel(0), theMinEnergy(0.0), theMaxEnergy(25.0*GeV), |
---|
42 | isBlocked(false), recoilEnergyThreshold(0.0), theModelName(modelName) |
---|
43 | { |
---|
44 | G4HadronicInteractionRegistry::Instance()->RegisterMe(this); |
---|
45 | } |
---|
46 | |
---|
47 | G4HadronicInteraction::~G4HadronicInteraction() |
---|
48 | { |
---|
49 | G4HadronicInteractionRegistry::Instance()->RemoveMe(this); |
---|
50 | } |
---|
51 | |
---|
52 | G4double |
---|
53 | G4HadronicInteraction::SampleInvariantT(const G4ParticleDefinition*, |
---|
54 | G4double, G4int, G4int) |
---|
55 | { |
---|
56 | return 0.0; |
---|
57 | } |
---|
58 | |
---|
59 | G4double G4HadronicInteraction::GetMinEnergy( |
---|
60 | const G4Material *aMaterial, const G4Element *anElement ) const |
---|
61 | { |
---|
62 | size_t i; |
---|
63 | if( IsBlocked(aMaterial) )return 0.*GeV; |
---|
64 | if( IsBlocked(anElement) )return 0.*GeV; |
---|
65 | for( i=0; i<theMinEnergyListElements.size(); ++i ) |
---|
66 | { |
---|
67 | if( anElement == theMinEnergyListElements[i].second ) |
---|
68 | return theMinEnergyListElements[i].first; |
---|
69 | } |
---|
70 | for( i=0; i<theMinEnergyList.size(); ++i ) |
---|
71 | { |
---|
72 | if( aMaterial == theMinEnergyList[i].second ) |
---|
73 | return theMinEnergyList[i].first; |
---|
74 | } |
---|
75 | if(IsBlocked()) return 0.*GeV; |
---|
76 | if( verboseLevel > 0 ) |
---|
77 | G4cout << "*** Warning from HadronicInteraction::GetMinEnergy" << G4endl |
---|
78 | << " material " << aMaterial->GetName() |
---|
79 | << " not found in min energy List" << G4endl; |
---|
80 | return theMinEnergy; |
---|
81 | } |
---|
82 | |
---|
83 | void G4HadronicInteraction::SetMinEnergy(G4double anEnergy, |
---|
84 | const G4Element *anElement ) |
---|
85 | { |
---|
86 | if( IsBlocked(anElement) ) |
---|
87 | G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl |
---|
88 | << " The model is not active for the Element " |
---|
89 | << anElement->GetName() << "." << G4endl; |
---|
90 | |
---|
91 | for( size_t i=0; i<theMinEnergyListElements.size(); ++i ) |
---|
92 | { |
---|
93 | if( anElement == theMinEnergyListElements[i].second ) |
---|
94 | { |
---|
95 | theMinEnergyListElements[i].first = anEnergy; |
---|
96 | return; |
---|
97 | } |
---|
98 | } |
---|
99 | theMinEnergyListElements.push_back(std::pair<G4double, const G4Element *>(anEnergy, anElement)); |
---|
100 | } |
---|
101 | |
---|
102 | void G4HadronicInteraction::SetMinEnergy(G4double anEnergy, |
---|
103 | const G4Material *aMaterial ) |
---|
104 | { |
---|
105 | if( IsBlocked(aMaterial) ) |
---|
106 | G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << G4endl |
---|
107 | << " The model is not active for the Material " |
---|
108 | << aMaterial->GetName() << "." << G4endl; |
---|
109 | |
---|
110 | for( size_t i=0; i<theMinEnergyList.size(); ++i ) |
---|
111 | { |
---|
112 | if( aMaterial == theMinEnergyList[i].second ) |
---|
113 | { |
---|
114 | theMinEnergyList[i].first = anEnergy; |
---|
115 | return; |
---|
116 | } |
---|
117 | } |
---|
118 | theMinEnergyList.push_back(std::pair<G4double, const G4Material *>(anEnergy, aMaterial)); |
---|
119 | } |
---|
120 | |
---|
121 | G4double G4HadronicInteraction::GetMaxEnergy(const G4Material *aMaterial, |
---|
122 | const G4Element *anElement ) const |
---|
123 | { |
---|
124 | size_t i; |
---|
125 | if( IsBlocked(aMaterial) )return 0.0; |
---|
126 | if( IsBlocked(anElement) )return 0.0; |
---|
127 | for( i=0; i<theMaxEnergyListElements.size(); ++i ) |
---|
128 | { |
---|
129 | if( anElement == theMaxEnergyListElements[i].second ) |
---|
130 | return theMaxEnergyListElements[i].first; |
---|
131 | } |
---|
132 | for( i=0; i<theMaxEnergyList.size(); ++i ) |
---|
133 | { |
---|
134 | if( aMaterial == theMaxEnergyList[i].second ) |
---|
135 | return theMaxEnergyList[i].first; |
---|
136 | } |
---|
137 | if(IsBlocked()) return 0.*GeV; |
---|
138 | if( verboseLevel > 0 ) { |
---|
139 | G4cout << "*** Warning from HadronicInteraction::GetMaxEnergy" << G4endl |
---|
140 | << " material " << aMaterial->GetName() |
---|
141 | << " not found in min energy List" << G4endl; |
---|
142 | } |
---|
143 | return theMaxEnergy; |
---|
144 | } |
---|
145 | |
---|
146 | void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy, |
---|
147 | const G4Element *anElement ) |
---|
148 | { |
---|
149 | if( IsBlocked(anElement) ) { |
---|
150 | G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl |
---|
151 | << "Warning: The model is not active for the Element " |
---|
152 | << anElement->GetName() << "." << G4endl; |
---|
153 | } |
---|
154 | for( size_t i=0; i<theMaxEnergyListElements.size(); ++i ) |
---|
155 | { |
---|
156 | if( anElement == theMaxEnergyListElements[i].second ) |
---|
157 | { |
---|
158 | theMaxEnergyListElements[i].first = anEnergy; |
---|
159 | return; |
---|
160 | } |
---|
161 | } |
---|
162 | theMaxEnergyListElements.push_back(std::pair<G4double, const G4Element *>(anEnergy, anElement)); |
---|
163 | } |
---|
164 | |
---|
165 | void G4HadronicInteraction::SetMaxEnergy(G4double anEnergy, |
---|
166 | const G4Material *aMaterial ) |
---|
167 | { |
---|
168 | if( IsBlocked(aMaterial) ) { |
---|
169 | G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << G4endl |
---|
170 | << "Warning: The model is not active for the Material " |
---|
171 | << aMaterial->GetName() << "." << G4endl; |
---|
172 | } |
---|
173 | for( size_t i=0; i<theMaxEnergyList.size(); ++i ) |
---|
174 | { |
---|
175 | if( aMaterial == theMaxEnergyList[i].second ) |
---|
176 | { |
---|
177 | theMaxEnergyList[i].first = anEnergy; |
---|
178 | return; |
---|
179 | } |
---|
180 | } |
---|
181 | theMaxEnergyList.push_back(std::pair<G4double, const G4Material *>(anEnergy, aMaterial)); |
---|
182 | } |
---|
183 | |
---|
184 | void G4HadronicInteraction::DeActivateFor( const G4Material *aMaterial ) |
---|
185 | { |
---|
186 | theBlockedList.push_back(aMaterial); |
---|
187 | } |
---|
188 | |
---|
189 | void G4HadronicInteraction::DeActivateFor( const G4Element *anElement ) |
---|
190 | { |
---|
191 | theBlockedListElements.push_back(anElement); |
---|
192 | } |
---|
193 | |
---|
194 | G4bool G4HadronicInteraction::IsBlocked( const G4Material *aMaterial ) const |
---|
195 | { |
---|
196 | for( size_t i=0; i<theBlockedList.size(); ++i ) |
---|
197 | { |
---|
198 | if( aMaterial == theBlockedList[i] ) |
---|
199 | { |
---|
200 | return true; |
---|
201 | } |
---|
202 | } |
---|
203 | return false; |
---|
204 | } |
---|
205 | |
---|
206 | G4bool G4HadronicInteraction::IsBlocked( const G4Element *anElement ) const |
---|
207 | { |
---|
208 | for( size_t i=0; i<theBlockedListElements.size(); ++i ) |
---|
209 | { |
---|
210 | if( anElement == theBlockedListElements[i] ) |
---|
211 | { |
---|
212 | return true; |
---|
213 | } |
---|
214 | } |
---|
215 | return false; |
---|
216 | } |
---|
217 | |
---|
218 | G4HadronicInteraction::G4HadronicInteraction(const G4HadronicInteraction &right ) |
---|
219 | { |
---|
220 | *this = right; |
---|
221 | } |
---|
222 | |
---|
223 | const G4HadronicInteraction& |
---|
224 | G4HadronicInteraction::operator=(const G4HadronicInteraction &right ) |
---|
225 | { |
---|
226 | G4String text = "unintended use of G4HadronicInteraction::operator="; |
---|
227 | throw G4HadronicException(__FILE__, __LINE__, text); |
---|
228 | return right; |
---|
229 | } |
---|
230 | |
---|
231 | /* end of file */ |
---|
232 | |
---|