Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ParticleHPManager.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// Class Description
27// Manager of NetronHP
28//
29// 121031 First implementation done by T. Koi (SLAC/PPA)
30// P. Arce, June-2014 Conversion neutron_hp to particle_hp
31//
32#include <zlib.h>
33#include <fstream>
34
39#include "G4Exception.hh"
40
41G4ParticleHPManager* G4ParticleHPManager::instance = nullptr;
42
43G4ParticleHPManager::G4ParticleHPManager()
44: verboseLevel(1)
45,USE_ONLY_PHOTONEVAPORATION(false)
46,SKIP_MISSING_ISOTOPES(false)
47,NEGLECT_DOPPLER(false)
48,DO_NOT_ADJUST_FINAL_STATE(false)
49,PRODUCE_FISSION_FRAGMENTS(false)
50,USE_WENDT_FISSION_MODEL(false)
51,USE_NRESP71_MODEL(false)
52,theElasticCrossSections(nullptr)
53,theCaptureCrossSections(nullptr)
54,theFissionCrossSections(nullptr)
55,theElasticFSs(nullptr)
56,theCaptureFSs(nullptr)
57,theFissionFSs(nullptr)
58,theTSCoherentCrossSections(nullptr)
59,theTSIncoherentCrossSections(nullptr)
60,theTSInelasticCrossSections(nullptr)
61,theTSCoherentFinalStates(nullptr)
62,theTSIncoherentFinalStates(nullptr)
63,theTSInelasticFinalStates(nullptr)
64{
65 messenger = new G4ParticleHPMessenger( this );
66}
67
68G4ParticleHPManager::~G4ParticleHPManager()
69{
70 delete messenger;
71}
72
74{
75 static G4ParticleHPManager manager;
76 if (instance == nullptr)
77 {
78 instance = &manager;
79 }
80 return instance;
81}
82
84{
86}
87
89{
91}
92
94{
96}
97
98void G4ParticleHPManager::GetDataStream( G4String filename , std::istringstream& iss )
99{
100 G4String* data=0;
101 G4String compfilename(filename);
102 compfilename += ".z";
103 std::ifstream* in = new std::ifstream ( compfilename , std::ios::binary | std::ios::ate );
104 if ( in->good() )
105 {
106 // Use the compressed file
107 std::streamoff file_size = in->tellg();
108 in->seekg( 0 , std::ios::beg );
109 Bytef* compdata = new Bytef[ file_size ];
110
111 while ( *in )
112 { // Loop checking, 11.05.2015, T. Koi
113 in->read( (char*)compdata , file_size );
114 }
115
116 uLongf complen = (uLongf) ( file_size*4 );
117 Bytef* uncompdata = new Bytef[complen];
118
119 while ( Z_OK != uncompress ( uncompdata , &complen , compdata , file_size ) )
120 { // Loop checking, 11.05.2015, T. Koi
121 delete[] uncompdata;
122 complen *= 2;
123 uncompdata = new Bytef[complen];
124 }
125 delete [] compdata;
126 // Now "complen" has uncomplessed size
127 data = new G4String ( (char*)uncompdata , (G4long)complen );
128 delete [] uncompdata;
129 }
130 else
131 {
132 // Use regular text file
133 std::ifstream thefData( filename , std::ios::in | std::ios::ate );
134 if ( thefData.good() )
135 {
136 std::streamoff file_size = thefData.tellg();
137 thefData.seekg( 0 , std::ios::beg );
138 char* filedata = new char[ file_size ];
139 while ( thefData )
140 { // Loop checking, 11.05.2015, T. Koi
141 thefData.read( filedata , file_size );
142 }
143 thefData.close();
144 data = new G4String ( filedata , file_size );
145 delete [] filedata;
146 }
147 else
148 {
149 // found no data file
150 // set error bit to the stream
151 iss.setstate( std::ios::badbit );
152 }
153 }
154 if ( data != 0 )
155 {
156 iss.str(*data);
157 G4String id;
158 iss >> id;
159 if ( id == "G4NDL" )
160 {
161 //Register information of file
162 G4String source;
163 iss >> source;
164 register_data_file(filename,source);
165 }
166 else
167 {
168 iss.seekg( 0 , std::ios::beg );
169 }
170 }
171 in->close(); delete in;
172 delete data;
173}
174
175void G4ParticleHPManager::GetDataStream2( G4String filename , std::istringstream& iss )
176{
177 // Checking existance of data file
178
179 G4String compfilename(filename);
180 compfilename += ".z";
181 std::ifstream* in = new std::ifstream ( compfilename , std::ios::binary | std::ios::ate );
182 if ( in->good() )
183 {
184 // Compressed file is exist
185 in->close();
186 }
187 else
188 {
189 std::ifstream thefData( filename , std::ios::in | std::ios::ate );
190 if ( thefData.good() )
191 {
192 // Regular text file is exist
193 thefData.close();
194 }
195 else
196 {
197 // found no data file
198 // set error bit to the stream
199 iss.setstate( std::ios::badbit );
200 }
201 }
202 delete in;
203}
204
206{
207 G4cout << "You are setting a new verbose level for Particle HP package." << G4endl;
208 G4cout << "the new value will be used in whole of the Particle HP package, i.e., models and cross sections for Capture, Elastic, Fission and Inelastic interaction." << G4endl;
209 verboseLevel = newValue;
210}
211
212void G4ParticleHPManager::register_data_file(G4String filename, G4String source)
213{
214 mDataEvaluation.insert( std::pair < G4String , G4String > ( filename , source ) );
215}
216
218{
219
220 G4cout << "Data source of this Partile HP calculation are " << G4endl;
221 for (auto it = mDataEvaluation.cbegin(); it != mDataEvaluation.cend(); ++it)
222 {
223 G4cout << it->first << " " << it->second << G4endl;
224 }
225 G4cout << G4endl;
226}
227
229{
230 if ( theInelasticCrossSections.end() != theInelasticCrossSections.find( particle ) )
231 return theInelasticCrossSections.find( particle )->second;
232 else
233 return nullptr;
234}
235
237{
238 theInelasticCrossSections.insert( std::pair<const G4ParticleDefinition* , G4PhysicsTable* >( particle , val ) );
239}
240
241std::vector<G4ParticleHPChannelList*>* G4ParticleHPManager::GetInelasticFinalStates(const G4ParticleDefinition* particle)
242{
243 if ( theInelasticFSs.end() != theInelasticFSs.find( particle ) )
244 return theInelasticFSs.find( particle )->second;
245 else
246 return nullptr;
247}
248
249void G4ParticleHPManager::RegisterInelasticFinalStates( const G4ParticleDefinition* particle , std::vector<G4ParticleHPChannelList*>* val )
250{
251 theInelasticFSs.insert ( std::pair<const G4ParticleDefinition*,std::vector<G4ParticleHPChannelList*>*>( particle , val ) );
252}
253
254
256{
257 G4cout << G4endl
258 << "=======================================================" << G4endl
259 << "====== ParticleHP Physics Parameters ========" << G4endl
260 << "=======================================================" << G4endl
261 << " UseOnlyPhotoEvaporation ? " << USE_ONLY_PHOTONEVAPORATION << G4endl
262 << " SkipMissingIsotopes ? " << SKIP_MISSING_ISOTOPES << G4endl
263 << " NeglectDoppler ? " << NEGLECT_DOPPLER << G4endl
264 << " DoNotAdjustFinalState ? " << DO_NOT_ADJUST_FINAL_STATE << G4endl
265 << " ProduceFissionFragments ? " << PRODUCE_FISSION_FRAGMENTS << G4endl
266 << " UseWendtFissionModel ? " << USE_WENDT_FISSION_MODEL << G4endl
267 << " UseNRESP71Model ? " << USE_NRESP71_MODEL << G4endl
268 << "=======================================================" << G4endl
269 << G4endl;
270}
long G4long
Definition: G4Types.hh:87
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void GetDataStream2(G4String, std::istringstream &iss)
std::vector< G4ParticleHPChannelList * > * GetInelasticFinalStates(const G4ParticleDefinition *)
void RegisterInelasticFinalStates(const G4ParticleDefinition *, std::vector< G4ParticleHPChannelList * > *)
G4PhysicsTable * GetInelasticCrossSections(const G4ParticleDefinition *)
void RegisterInelasticCrossSections(const G4ParticleDefinition *, G4PhysicsTable *)
static G4ParticleHPManager * GetInstance()
void GetDataStream(G4String, std::istringstream &iss)
G4ParticleHPReactionWhiteBoard * GetReactionWhiteBoard()
static G4ParticleHPThreadLocalManager * GetInstance()
G4ParticleHPReactionWhiteBoard * GetReactionWhiteBoard()
int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: uncompr.c:85
#define Z_OK
Definition: zlib.h:177