Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: G4ComponentSAIDTotalXS.cc 76889 2013-11-18 13:01:55Z gcosmo $
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"
42 #include "G4LPhysicsFreeVector.hh"
43 
44 const G4String G4ComponentSAIDTotalXS::fnames[13] = {
45  "","pp","np","pip","pim",
46  "pin","pie",
47  "gp_pi0p","gp_pi+n","gn_pi-p","gn_pi0n","gp_etap","gp_etapp"
48 };
49 
51  : G4VComponentCrossSection("xsSAID")
52 {
53  for(G4int i=0; i<numberOfSaidXS; ++i) {
54  elastdata[i] = 0;
55  inelastdata[i] = 0;
56  }
57 }
58 
60 {
61  /*
62  for(G4int i=0; i<numberOfSaidXS; ++i) {
63  if(elastdata[i]) {
64  delete elastdata[i];
65  elastdata[i] = 0;
66  }
67  if(inelastdata[i]) {
68  delete inelastdata[i];
69  inelastdata[i] = 0;
70  }
71  }
72  */
73 }
74 
75 G4double
77  const G4ParticleDefinition* part,
79 {
80  PrintWarning(part,0,Z,G4lrint(N),
81  "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
82  "Method is not implemented");
83  return 0.0;
84 }
85 
86 G4double
88  const G4ParticleDefinition* part,
89  G4double kinEnergy, G4int Z, G4int N)
90 {
91  return GetInelasticIsotopeCrossSection(part,kinEnergy,Z,N)
92  + GetElasticIsotopeCrossSection(part,kinEnergy,Z,N);
93 }
94 
95 G4double
97  const G4ParticleDefinition* part,
99 {
100  PrintWarning(part,0,Z,G4lrint(N),
101  "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
102  "Method is not implemented");
103  return 0.0;
104 }
105 
106 G4double
108  const G4ParticleDefinition* part,
109  G4double kinEnergy, G4int Z, G4int N)
110 {
111  G4double cross = 0.0;
112  G4SAIDCrossSectionType tp = GetType(part,0,Z,N);
113  if(saidUnknown != tp) {
114  G4int idx = G4int(tp);
115  if(!inelastdata[idx]) { Initialise(tp); }
116  if(inelastdata[idx]) {
117  cross = (inelastdata[idx])->Value(kinEnergy);
118  }
119  }
120  return cross;
121 }
122 
123 G4double
125  const G4ParticleDefinition* part,
126  G4double, G4int Z, G4double N)
127 {
128  PrintWarning(part,0,Z,G4lrint(N),
129  "G4ComponentSAIDTotalXS::GetTotalElementCrossSection",
130  "Method is not implemented");
131  return 0.0;
132 }
133 
134 G4double
136  const G4ParticleDefinition* part,
137  G4double kinEnergy, G4int Z, G4int N)
138 {
139  G4double cross = 0.0;
140  G4SAIDCrossSectionType tp = GetType(part,0,Z,N);
141  if(saidUnknown != tp) {
142  G4int idx = G4int(tp);
143  if(!elastdata[idx]) { Initialise(tp); }
144  if(elastdata[idx]) {
145  cross = (elastdata[idx])->Value(kinEnergy);
146  }
147  }
148  return cross;
149 }
150 
151 G4double
153  const G4ParticleDefinition* prim,
154  const G4ParticleDefinition* sec,
155  G4double kinEnergy, G4int Z, G4int N)
156 {
157  G4double cross = 0.0;
158  G4SAIDCrossSectionType tp = GetType(prim,sec,Z,N);
159  if(saidUnknown != tp) {
160  G4int idx = G4int(tp);
161  if(!inelastdata[idx]) { Initialise(tp); }
162  if(inelastdata[idx]) {
163  cross = (inelastdata[idx])->Value(kinEnergy);
164  }
165  }
166  return cross;
167 }
168 
169 void
171 {
172 }
173 
175 G4ComponentSAIDTotalXS::GetType(const G4ParticleDefinition* prim,
176  const G4ParticleDefinition* sec,
177  G4int Z, G4int N)
178 {
180  if(1 == N && prim) {
181  G4int code = prim->GetPDGEncoding();
182 
183  // only gamma + N x-sections available
184  if(0 == Z && sec && 22 == code) {
185  G4int code1 = sec->GetPDGEncoding();
186  if(-211 == code1) { type = saidGN_PINP; }
187  else if(111 == code1) { type = saidGN_PI0N; }
188 
189  // x-sections off proton
190  } else if(1 == Z) {
191  if(sec) {
192  G4int code1 = sec->GetPDGEncoding();
193  if(-211 == code) {
194  if(111 == code1) { type = saidPINP_PI0N; }
195  else if(221 == code1) { type = saidPINP_ETAN; }
196 
197  } else if(22 == code) {
198  if(111 == code1) { type = saidGP_PI0P; }
199  else if(211 == code1) { type = saidGP_PIPN; }
200  else if(221 == code1) { type = saidGP_ETAP; }
201  else if(331 == code1) { type = saidGP_ETAPP; }
202  }
203  } else {
204  if(2212 == code) { type = saidPP; }
205  else if(2112 == code) { type = saidNP; }
206  else if(211 == code) { type = saidPIPP; }
207  else if(-211 == code) { type = saidPINP; }
208  }
209  }
210  }
211  //G4cout << "G4ComponentSAIDTotalXS::Type= " << type << G4endl;
212  return type;
213 }
214 
215 void G4ComponentSAIDTotalXS::Initialise(G4SAIDCrossSectionType tp)
216 {
217  G4int idx = G4int(tp);
218  // check environment variable
219  // Build the complete string identifying the file with the data set
220  char* path = getenv("G4SAIDXSDATA");
221  if (!path){
222  G4Exception("G4ComponentSAIDTotalXS::Initialise(..)","had013",
224  "Environment variable G4SAIDXSDATA is not defined");
225  return;
226  }
227  if(idx <= 4) {
228  elastdata[idx] = new G4LPhysicsFreeVector();
229  inelastdata[idx] = new G4LPhysicsFreeVector();
230  ReadData(idx,elastdata[idx],path,"_el.dat");
231  ReadData(idx,inelastdata[idx],path,"_in.dat");
232  } else {
233  inelastdata[idx] = new G4LPhysicsFreeVector();
234  ReadData(idx,inelastdata[idx],path,".dat");
235  }
236 }
237 
238 void G4ComponentSAIDTotalXS::ReadData(G4int index,
240  const G4String& ss1,
241  const G4String& ss2)
242 {
243  std::ostringstream ost;
244  ost << ss1 << "/" << fnames[index] << ss2;
245  std::ifstream filein(ost.str().c_str());
246  if (!(filein)) {
248  ed << "Data file <" << ost.str().c_str()
249  << "> is not opened!";
250  G4Exception("G4ComponentSAIDTotalXS::ReadData(..)","had014",
251  FatalException, ed, "Check G4SAIDXSDATA");
252  } else {
253  if(GetVerboseLevel() > 1) {
254  G4cout << "File " << ost.str()
255  << " is opened by G4ComponentSAIDTotalXS" << G4endl;
256  }
257  // retrieve data from DB
258  v->Retrieve(filein, true);
259  v->ScaleVector(CLHEP::MeV,CLHEP::millibarn);
260  v->SetSpline(true);
261  }
262 }
263 
264 void
265 G4ComponentSAIDTotalXS::PrintWarning(const G4ParticleDefinition* prim,
266  const G4ParticleDefinition* sec,
267  G4int Z, G4int N,
268  const G4String& ss1,
269  const G4String& ss2)
270 {
271  G4cout << ss1 << ": " << ss2 << G4endl;
272  G4cout << "For Z= " << Z << " N= " << N << " of ";
273  if(prim) { G4cout << prim->GetParticleName() << " "; }
274  if(sec) { G4cout << " x-section to " << sec->GetParticleName(); }
275  G4cout << G4endl;
276 }
virtual G4double GetTotalElementCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4double)
virtual G4double GetInelasticIsotopeCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4int)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4SAIDCrossSectionType
virtual G4double GetElasticIsotopeCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4int)
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
virtual void Description() const
virtual G4double GetInelasticElementCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4double)
void SetSpline(G4bool)
G4GLOB_DLL std::ostream G4cout
virtual void ScaleVector(G4double factorE, G4double factorV)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4double GetTotalIsotopeCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4int)
Definition: inftrees.h:24
int G4lrint(double ad)
Definition: templates.hh:163
virtual G4bool Retrieve(std::ifstream &fIn, G4bool ascii=false)
#define G4endl
Definition: G4ios.hh:61
**D E S C R I P T I O N
virtual G4double GetElasticElementCrossSection(const G4ParticleDefinition *, G4double kinEnergy, G4int, G4double)
double G4double
Definition: G4Types.hh:76
G4double GetChargeExchangeCrossSection(const G4ParticleDefinition *prim, const G4ParticleDefinition *sec, G4double kinEnergy, G4int, G4int)