Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ParticleHPIsoData.cc
Go to the documentation of this file.
1 // ********************************************************************
2 // * License and Disclaimer *
3 // * *
4 // * The Geant4 software is copyright of the Copyright Holders of *
5 // * the Geant4 Collaboration. It is provided under the terms and *
6 // * conditions of the Geant4 Software License, included in the file *
7 // * LICENSE and available at http://cern.ch/geant4/license . These *
8 // * include a list of copyright holders. *
9 // * *
10 // * Neither the authors of this software system, nor their employing *
11 // * institutes,nor the agencies providing financial support for this *
12 // * work make any representation or warranty, express or implied, *
13 // * regarding this software system or assume any liability for its *
14 // * use. Please see the license in the file LICENSE and URL above *
15 // * for the full disclaimer and the limitation of liability. *
16 // * *
17 // * This code implementation is the result of the scientific and *
18 // * technical work of the GEANT4 collaboration. *
19 // * By using, copying, modifying or distributing the software (or *
20 // * any work based on the software) you agree to acknowledge its *
21 // * use in resulting scientific publications, and indicate your *
22 // * acceptance of all terms of the Geant4 Software license. *
23 // ********************************************************************
24 //
25 // particle_hp -- source file
26 // J.P. Wellisch, Nov-1996
27 // A prototype of the low energy neutron transport model.
28 //
29 //080901 Avoiding troubles which caused by G4PhysicsVecotor of length 0 by T. Koi
30 //
31 // P. Arce, June-2014 Conversion neutron_hp to particle_hp
32 //
33 #include "G4ParticleHPIsoData.hh"
34 #include "G4ParticleHPManager.hh"
35 #include "G4ParticleHPDataUsed.hh"
36 #include "G4Neutron.hh"
37 
38  //G4bool G4ParticleHPIsoData::Init(G4int A, G4int Z, G4double abun, G4String dirName, G4String aFSType)
40  {
41  theChannelData = 0;
42  G4double abundance = abun/100.;
43  G4String filename;
44  G4bool result = true;
45  //G4ParticleHPDataUsed aFile = theNames.GetName(A, Z, dirName, aFSType, result);
46  G4ParticleHPDataUsed aFile = theNames.GetName(A, Z, M, dirName, aFSType, result);
47  filename = aFile.GetName();
48 // if(filename=="") return false;
49  //std::ifstream theChannel(filename);
50  std::istringstream theChannel(filename,std::ios::in);
51  G4ParticleHPManager::GetInstance()->GetDataStream(filename,theChannel);
52 
53 #ifdef G4PHPDEBUG
54  if(getenv("G4ParticleHPDebug")) G4cout << "G4ParticleHPIsoData::Init = "<< filename <<" "<< A << " " << Z <<G4endl;
55 #endif
56 
57  if(Z==1 && (aFile.GetZ()!=Z || std::abs(aFile.GetA()-A)>0.0001) )
58  {
59  if(getenv("G4ParticleHPDebug")) G4cout << "Skipped = "<< filename <<" "<<A<<" "<<Z<<G4endl;
60  //080901 TKDB No more necessary below protection, cross sections set to 0 in G4ParticleHPNames
61  //And below two lines causes trouble with G4PhysicsVector
62  //theChannel.close();
63  //return false;
64  }
65  if(!theChannel) {/*theChannel.close()*/; return false;}
66  // accommodating deficiencie of some compilers
67  if(theChannel.eof()) {/*theChannel.close()*/; return false;}
68  if(!theChannel) {/*theChannel.close()*/; return false;}
69  G4int dummy;
70  theChannel >> dummy >> dummy;
71  theChannelData = new G4ParticleHPVector;
72  G4int nData;
73  theChannel >> nData;
74  theChannelData->Init(theChannel, nData, CLHEP::eV, abundance*CLHEP::barn);
75 // G4cout << "Channel Data Statistics: "<<theChannelData->GetVectorLength()<<G4endl;
76 // G4cout << "Channel data"<<G4endl;
77 // G4int hpw;
78 // G4cin >> hpw;
79 // theChannelData->Dump();
80 // theChannel.close();
81  return result;
82  }
83 
84  //void G4ParticleHPIsoData::Init(G4int A, G4int Z, G4double abun) //fill PhysicsVector for this Isotope
85 #include "G4Proton.hh"
86 #include "G4Deuteron.hh"
87 #include "G4Triton.hh"
88 #include "G4He3.hh"
89 #include "G4Alpha.hh"
90 void G4ParticleHPIsoData::Init(G4int A, G4int Z, G4int M,G4double abun, G4ParticleDefinition* projectile, const char* dataDirVariable ) //fill PhysicsVector for this Isotope
91  {
92 
93  G4String particleName;
94  if ( projectile == G4Neutron::Neutron() ) {
95  ;
96  } else if ( projectile == G4Proton::Proton() ) {
97  particleName = "Proton";
98  } else if ( projectile == G4Deuteron::Deuteron() ) {
99  particleName = "Deuteron";
100  } else if ( projectile == G4Triton::Triton() ) {
101  particleName = "Triton";
102  } else if ( projectile == G4He3::He3() ) {
103  particleName = "He3";
104  } else if ( projectile == G4Alpha::Alpha() ) {
105  particleName = "Alpha";
106  } else {
107  G4String message("G4ParticleHPInelastic may only be called for neutron, proton, deuteron, triton, He3 or alpha, while it is called for " + projectile->GetParticleName());
108  throw G4HadronicException(__FILE__, __LINE__,message.c_str());
109  }
110 
111  G4String baseName;
112  if ( getenv( dataDirVariable ) ) {
113  baseName = getenv( dataDirVariable );
114  } else {
115  baseName = getenv( "G4PARTICLEHPDATA" );
116  baseName += "/" + particleName;
117  }
118 
119  // G4String baseName = getenv(dataDirVariable);
120  G4String dirName;
121  if( projectile == G4Neutron::Neutron() ){
122  dirName = baseName+"/Fission";
123  //if(Z>89)
124  if(Z>87) //TK Modifed for ENDF VII.0
125  {
126  //Init(A, Z, abun, dirName, "/CrossSection/");
127  Init(A, Z, M, abun, dirName, "/CrossSection");
128  }
129  else
130  {
131  theChannelData = new G4ParticleHPVector;
132  }
133  theFissionData = theChannelData;
134  theChannelData = 0; // fast fix for double delete; revisit later. @@@@@@@
135 
136  dirName = baseName+"/Capture";
137  //Init(A, Z, abun, dirName, "/CrossSection/");
138  Init(A, Z, M, abun, dirName, "/CrossSection");
139  theCaptureData = theChannelData;
140  theChannelData = 0;
141 
142  dirName = baseName+"/Elastic";
143  //Init(A, Z, abun, dirName, "/CrossSection/");
144  Init(A, Z, M, abun, dirName, "/CrossSection");
145  theElasticData = theChannelData;
146  theChannelData = 0;
147  }
148 
149  dirName = baseName+"/Inelastic";
150  //Init(A, Z, abun, dirName, "/CrossSection/");
151  Init(A, Z, M, abun, dirName, "/CrossSection");
152  theInelasticData = theChannelData;
153  theChannelData = 0;
154 
155 // if(theInelasticData!=0) G4cout << "Inelastic Data Statistics: "<<theInelasticData->GetVectorLength()<<G4endl;
156 // if(theElasticData!=0) G4cout << "Elastic Data Statistics: "<<theElasticData->GetVectorLength()<<G4endl;
157 // if(theCaptureData!=0) G4cout << "Capture Data Statistics: "<<theCaptureData->GetVectorLength()<<G4endl;
158 // if(theFissionData!=0) G4cout << "Fission Data Statistics: "<<theFissionData->GetVectorLength()<<G4endl;
159 // G4cout << "Inelastic data"<<G4endl;
160 // if(theInelasticData!=0) theInelasticData->Dump();
161 // G4cout << "Elastic data"<<G4endl;
162 // if(theElasticData!=0) theElasticData->Dump();
163 // G4cout << "Capture data"<<G4endl;
164 // if(theCaptureData!=0) theCaptureData->Dump();
165 // G4cout << "Fission data"<<G4endl;
166 // if(theFissionData!=0) theFissionData->Dump();
167 
168  }
169 
171  {
172  G4bool dbool;
173  return (theNames.GetName(A, Z, base, rest, dbool)).GetName();
174  }
175 
G4double G4ParticleHPJENDLHEData::G4double result
static G4ParticleHPManager * GetInstance()
void GetDataStream(G4String, std::istringstream &iss)
const XML_Char int const XML_Char int const XML_Char * base
Definition: expat.h:331
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
void Init(std::istream &aDataFile, G4int total, G4double ux=1., G4double uy=1.)
G4GLOB_DLL std::ostream G4cout
double A(double temperature)
static constexpr double barn
Definition: SystemOfUnits.h:85
bool G4bool
Definition: G4Types.hh:79
static G4Triton * Triton()
Definition: G4Triton.cc:95
static G4Proton * Proton()
Definition: G4Proton.cc:93
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
static G4Deuteron * Deuteron()
Definition: G4Deuteron.cc:94
static constexpr double eV
G4String GetName(G4int A, G4int Z, G4String base, G4String rest)
#define G4endl
Definition: G4ios.hh:61
G4ParticleHPDataUsed GetName(G4int A, G4int Z, G4String base, G4String rest, G4bool &active)
G4bool Init(G4int A, G4int Z, G4double abun, G4String dirName, G4String aFSType)
static G4Alpha * Alpha()
Definition: G4Alpha.cc:89
double G4double
Definition: G4Types.hh:76
static G4He3 * He3()
Definition: G4He3.cc:94