Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4ComponentSAIDTotalXS.cc
Go to the documentation of this file.
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$
27//
28// -------------------------------------------------------------------
29//
30// GEANT4 Class file
31//
32//
33// File name: G4ComponentSAIDTotalXS
34//
35// Authors: G.Folger, V.Ivanchenko, D.Wright
36//
37// Modifications:
38//
39
41#include "G4PhysicsVector.hh"
44
45G4String G4ComponentSAIDTotalXS::fnames[13] = {
46 "","pp","np","pip","pim",
47 "pin","pie",
48 "gp_pi0p","gp_pi+n","gn_pi-p","gn_pi0n","gp_etap","gp_etapp"
49};
50G4PhysicsVector* G4ComponentSAIDTotalXS::elastdata[13] = {0};
51G4PhysicsVector* G4ComponentSAIDTotalXS::inelastdata[13] = {0};
52
54 : G4VComponentCrossSection("xsSAID"),numberOfSaidXS(13)
55{}
56
58{
59 for(G4int i=0; i<numberOfSaidXS; ++i) {
60 if(elastdata[i]) {
61 delete elastdata[i];
62 elastdata[i] = 0;
63 }
64 if(inelastdata[i]) {
65 delete inelastdata[i];
66 inelastdata[i] = 0;
67 }
68 }
69}
70
73 const G4ParticleDefinition* part,
75{
76 PrintWarning(part,0,Z,G4lrint(N),
77 "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
78 "Method is not implemented");
79 return 0.0;
80}
81
84 const G4ParticleDefinition* part,
85 G4double kinEnergy, G4int Z, G4int N)
86{
87 return GetInelasticIsotopeCrossSection(part,kinEnergy,Z,N)
88 + GetElasticIsotopeCrossSection(part,kinEnergy,Z,N);
89}
90
93 const G4ParticleDefinition* part,
95{
96 PrintWarning(part,0,Z,G4lrint(N),
97 "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
98 "Method is not implemented");
99 return 0.0;
100}
101
104 const G4ParticleDefinition* part,
105 G4double kinEnergy, G4int Z, G4int N)
106{
107 G4double cross = 0.0;
108 G4SAIDCrossSectionType tp = GetType(part,0,Z,N);
109 if(saidUnknown != tp) {
110 G4int idx = G4int(tp);
111 if(!inelastdata[idx]) { Initialise(tp); }
112 if(inelastdata[idx]) {
113 cross = (inelastdata[idx])->Value(kinEnergy);
114 }
115 }
116 return cross;
117}
118
121 const G4ParticleDefinition* part,
122 G4double, G4int Z, G4double N)
123{
124 PrintWarning(part,0,Z,G4lrint(N),
125 "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
126 "Method is not implemented");
127 return 0.0;
128}
129
132 const G4ParticleDefinition* part,
133 G4double kinEnergy, G4int Z, G4int N)
134{
135 G4double cross = 0.0;
136 G4SAIDCrossSectionType tp = GetType(part,0,Z,N);
137 if(saidUnknown != tp) {
138 G4int idx = G4int(tp);
139 if(!elastdata[idx]) { Initialise(tp); }
140 if(elastdata[idx]) {
141 cross = (elastdata[idx])->Value(kinEnergy);
142 }
143 }
144 return cross;
145}
146
149 const G4ParticleDefinition* prim,
150 const G4ParticleDefinition* sec,
151 G4double kinEnergy, G4int Z, G4int N)
152{
153 G4double cross = 0.0;
154 G4SAIDCrossSectionType tp = GetType(prim,sec,Z,N);
155 if(saidUnknown != tp) {
156 G4int idx = G4int(tp);
157 if(!inelastdata[idx]) { Initialise(tp); }
158 if(inelastdata[idx]) {
159 cross = (inelastdata[idx])->Value(kinEnergy);
160 }
161 }
162 return cross;
163}
164
165void
167{
168}
169
171G4ComponentSAIDTotalXS::GetType(const G4ParticleDefinition* prim,
172 const G4ParticleDefinition* sec,
173 G4int Z, G4int N)
174{
176 if(1 == N && prim) {
177 G4int code = prim->GetPDGEncoding();
178
179 // only gamma + N x-sections available
180 if(0 == Z && sec && 22 == code) {
181 G4int code1 = sec->GetPDGEncoding();
182 if(-211 == code1) { type = saidGN_PINP; }
183 else if(111 == code1) { type = saidGN_PI0N; }
184
185 // x-sections off proton
186 } else if(1 == Z) {
187 if(sec) {
188 G4int code1 = sec->GetPDGEncoding();
189 if(-211 == code) {
190 if(111 == code1) { type = saidPINP_PI0N; }
191 else if(221 == code1) { type = saidPINP_ETAN; }
192
193 } else if(22 == code) {
194 if(111 == code1) { type = saidGP_PI0P; }
195 else if(211 == code1) { type = saidGP_PIPN; }
196 else if(221 == code1) { type = saidGP_ETAP; }
197 else if(331 == code1) { type = saidGP_ETAPP; }
198 }
199 } else {
200 if(2212 == code) { type = saidPP; }
201 else if(2112 == code) { type = saidNP; }
202 else if(211 == code) { type = saidPIPP; }
203 else if(-211 == code) { type = saidPINP; }
204 }
205 }
206 }
207 //G4cout << "G4ComponentSAIDTotalXS::Type= " << type << G4endl;
208 return type;
209}
210
211void G4ComponentSAIDTotalXS::Initialise(G4SAIDCrossSectionType tp)
212{
213 G4int idx = G4int(tp);
214 // check environment variable
215 // Build the complete string identifying the file with the data set
216 char* path = getenv("G4SAIDXSDATA");
217 if (!path){
218 throw G4HadronicException(__FILE__, __LINE__,
219 "G4SAIDXSDATA environment variable not defined");
220 return;
221 }
222 if(idx <= 4) {
223 elastdata[idx] = new G4LPhysicsFreeVector();
224 inelastdata[idx] = new G4LPhysicsFreeVector();
225 ReadData(idx,elastdata[idx],path,"_el.dat");
226 ReadData(idx,inelastdata[idx],path,"_in.dat");
227 } else {
228 inelastdata[idx] = new G4LPhysicsFreeVector();
229 ReadData(idx,inelastdata[idx],path,".dat");
230 }
231}
232
233void G4ComponentSAIDTotalXS::ReadData(G4int index,
235 const G4String& ss1,
236 const G4String& ss2)
237{
238 std::ostringstream ost;
239 ost << ss1 << "/" << fnames[index] << ss2;
240 std::ifstream filein(ost.str().c_str());
241 if (!(filein)) {
242 G4cout << ost.str() << " is not opened by G4ComponentSAIDTotalXS"
243 << G4endl;
244 G4String sss(ost.str());
245 throw G4HadronicException(__FILE__, __LINE__,
246 "Data file " + sss +
247 " is not opened," +
248 "chech that G4SAIDXSDATA correctly set");
249
250 } else {
251 if(GetVerboseLevel() > 1) {
252 G4cout << "File " << ost.str()
253 << " is opened by G4ComponentSAIDTotalXS" << G4endl;
254 }
255 // retrieve data from DB
256 v->Retrieve(filein, true);
257 v->ScaleVector(CLHEP::MeV,CLHEP::millibarn);
258 v->SetSpline(true);
259 }
260}
261
262void
263G4ComponentSAIDTotalXS::PrintWarning(const G4ParticleDefinition* prim,
264 const G4ParticleDefinition* sec,
265 G4int Z, G4int N,
266 const G4String& ss1,
267 const G4String& ss2)
268{
269 G4cout << ss1 << ": " << ss2 << G4endl;
270 G4cout << "For Z= " << Z << " N= " << N << " of ";
271 if(prim) { G4cout << prim->GetParticleName() << " "; }
272 if(sec) { G4cout << " x-section to " << sec->GetParticleName(); }
273 G4cout << G4endl;
274}
G4SAIDCrossSectionType
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
virtual G4double GetInelasticElementCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4double)
G4double GetChargeExchangeCrossSection(const G4ParticleDefinition *prim, const G4ParticleDefinition *sec, G4double kinEnergy, G4int, G4int)
virtual G4double GetInelasticIsotopeCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4int)
virtual G4double GetElasticElementCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4double)
virtual G4double GetTotalElementCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4double)
virtual void Description() const
virtual G4double GetTotalIsotopeCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4int)
virtual G4double GetElasticIsotopeCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4int)
const G4String & GetParticleName() const
virtual void ScaleVector(G4double factorE, G4double factorV)
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
void SetSpline(G4bool)
int G4lrint(double ad)
Definition: templates.hh:163