Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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 = 0;
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(0)
53,theCaptureCrossSections(0)
54,theFissionCrossSections(0)
55,theElasticFSs(0)
56,theCaptureFSs(0)
57,theFissionFSs(0)
58,theTSCoherentCrossSections(0)
59,theTSIncoherentCrossSections(0)
60,theTSInelasticCrossSections(0)
61,theTSCoherentFinalStates(0)
62,theTSIncoherentFinalStates(0)
63,theTSInelasticFinalStates(0)
64{
65 messenger = new G4ParticleHPMessenger( this );
66 // The rest of this method will be removed in G4 11.0
67 if ( std::getenv( "G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE" ) ||
68 std::getenv( "G4PHP_DO_NOT_ADJUST_FINAL_STATE" ) ) {
69 DO_NOT_ADJUST_FINAL_STATE = true;
71 ed << "Environmental variables G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE and \n"
72 << "G4PHP_DO_NOT_ADJUST_FINAL_STATE are valid but deprecated and will be replaced \n"
73 << "with the UI command: /process/had/particle_hp/do_not_adjust_final_state \n"
74 << "in the next major release, Geant4 version 11.0";
75 G4Exception( "G4ParticleHPManager ", "HP_MAN_165", JustWarning, ed );
76 }
77 if ( std::getenv( "G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION" ) ) {
78 USE_ONLY_PHOTONEVAPORATION = true;
80 ed << "Environmental variable G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION \n"
81 << "is valid but deprecated and will be replaced with the UI command: \n"
82 << "/process/had/particle_hp/use_photo_evaporation \n"
83 << "in the next major release, Geant4 version 11.0";
84 G4Exception( "G4ParticleHPManager ", "HP_MAN_166", JustWarning, ed );
85 }
86 if ( std::getenv( "G4NEUTRONHP_NEGLECT_DOPPLER" ) ||
87 std::getenv( "G4PHP_NEGLECT_DOPPLER" ) ) {
88 NEGLECT_DOPPLER = true;
90 ed << "Environmental variables G4NEUTRONHP_NEGLECT_DOPPLER and G4PHP_NEGLECT_DOPPLER \n"
91 << "are valid but deprecated and will be replaced with the UI command: \n"
92 << "/process/had/particle_hp/neglect_Doppler_broadening \n"
93 << "in the next major release, Geant4 version 11.0";
94 G4Exception( "G4ParticleHPManager ", "HP_MAN_167", JustWarning, ed );
95 }
96 if ( std::getenv( "G4NEUTRONHP_SKIP_MISSING_ISOTOPES" ) ) {
97 SKIP_MISSING_ISOTOPES = true;
99 ed << "Environmental variable G4NEUTRONHP_SKIP_MISSING_ISOTOPES \n"
100 << "is valid but deprecated and will be replaced with the UI command: \n"
101 << "/process/had/particle_hp/skip_missing_isotopes \n"
102 << "in the next major release, Geant4 version 11.0";
103 G4Exception( "G4ParticleHPManager ", "HP_MAN_168", JustWarning, ed );
104 }
105 if ( std::getenv( "G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS" ) ) {
106 PRODUCE_FISSION_FRAGMENTS = true;
108 ed << "Environmental variable G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS \n"
109 << "is valid but deprecated and will be replaced with the UI command: \n"
110 << "/process/had/particle_hp/produce_fission_fragment \n"
111 << "in the next major release, Geant4 version 11.0";
112 G4Exception( "G4ParticleHPManager ", "HP_MAN_169", JustWarning, ed );
113 }
114 if ( std::getenv( "G4NEUTRON_HP_USE_WENDT_FISSION_MODEL" ) ) {
115 USE_WENDT_FISSION_MODEL = true;
116 // Make sure both fission fragment models are not active at same time
117 PRODUCE_FISSION_FRAGMENTS = false;
119 ed << "Environmental variable G4NEUTRON_HP_USE_WENDT_FISSION_MODEL \n"
120 << "is valid but deprecated and will be replaced with the UI command: \n"
121 << "/process/had/particle_hp/use_Wendt_fission_model \n"
122 << "in the next major release, Geant4 version 11.0";
123 G4Exception( "G4ParticleHPManager ", "HP_MAN_170", JustWarning, ed );
124 }
125 if ( std::getenv( "G4PHP_USE_NRESP71_MODEL" ) ) {
126 USE_NRESP71_MODEL = true;
128 ed << "Environmental variable G4PHP_USE_NRESP71_MODEL is valid but deprecated and \n"
129 << "will be replaced with the UI command: /process/had/particle_hp/use_NRESP71_model \n"
130 << "in the next major release, Geant4 version 11.0";
131 G4Exception( "G4ParticleHPManager ", "HP_MAN_171", JustWarning, ed );
132 }
133}
134
135G4ParticleHPManager::~G4ParticleHPManager()
136{
137 delete messenger;
138}
139
141{
142 static G4ParticleHPManager manager;
143 if (!instance)
144 {
145 instance = &manager;
146 }
147 return instance;
148}
149
151{
153}
154
156{
158}
159
161{
163}
164
165void G4ParticleHPManager::GetDataStream( G4String filename , std::istringstream& iss )
166{
167 G4String* data=0;
168 G4String compfilename(filename);
169 compfilename += ".z";
170 std::ifstream* in = new std::ifstream ( compfilename , std::ios::binary | std::ios::ate );
171 if ( in->good() )
172 {
173 // Use the compressed file
174 G4int file_size = in->tellg();
175 in->seekg( 0 , std::ios::beg );
176 Bytef* compdata = new Bytef[ file_size ];
177
178 while ( *in )
179 { // Loop checking, 11.05.2015, T. Koi
180 in->read( (char*)compdata , file_size );
181 }
182
183 uLongf complen = (uLongf) ( file_size*4 );
184 Bytef* uncompdata = new Bytef[complen];
185
186 while ( Z_OK != uncompress ( uncompdata , &complen , compdata , file_size ) )
187 { // Loop checking, 11.05.2015, T. Koi
188 delete[] uncompdata;
189 complen *= 2;
190 uncompdata = new Bytef[complen];
191 }
192 delete [] compdata;
193 // Now "complen" has uncomplessed size
194 data = new G4String ( (char*)uncompdata , (G4long)complen );
195 delete [] uncompdata;
196 }
197 else
198 {
199 // Use regular text file
200 std::ifstream thefData( filename , std::ios::in | std::ios::ate );
201 if ( thefData.good() )
202 {
203 G4int file_size = thefData.tellg();
204 thefData.seekg( 0 , std::ios::beg );
205 char* filedata = new char[ file_size ];
206 while ( thefData )
207 { // Loop checking, 11.05.2015, T. Koi
208 thefData.read( filedata , file_size );
209 }
210 thefData.close();
211 data = new G4String ( filedata , file_size );
212 delete [] filedata;
213 }
214 else
215 {
216 // found no data file
217 // set error bit to the stream
218 iss.setstate( std::ios::badbit );
219 }
220 }
221 if ( data != 0 )
222 {
223 iss.str(*data);
224 G4String id;
225 iss >> id;
226 if ( id == "G4NDL" )
227 {
228 //Register information of file
229 G4String source;
230 iss >> source;
231 register_data_file(filename,source);
232 }
233 else
234 {
235 iss.seekg( 0 , std::ios::beg );
236 }
237 }
238 in->close(); delete in;
239 delete data;
240}
241
242void G4ParticleHPManager::GetDataStream2( G4String filename , std::istringstream& iss )
243{
244 // Checking existance of data file
245
246 G4String compfilename(filename);
247 compfilename += ".z";
248 std::ifstream* in = new std::ifstream ( compfilename , std::ios::binary | std::ios::ate );
249 if ( in->good() )
250 {
251 // Compressed file is exist
252 in->close();
253 }
254 else
255 {
256 std::ifstream thefData( filename , std::ios::in | std::ios::ate );
257 if ( thefData.good() )
258 {
259 // Regular text file is exist
260 thefData.close();
261 }
262 else
263 {
264 // found no data file
265 // set error bit to the stream
266 iss.setstate( std::ios::badbit );
267 }
268 }
269 delete in;
270}
271
273{
274 G4cout << "You are setting a new verbose level for Particle HP package." << G4endl;
275 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;
276 verboseLevel = newValue;
277}
278
279void G4ParticleHPManager::register_data_file(G4String filename, G4String source)
280{
281 mDataEvaluation.insert( std::pair < G4String , G4String > ( filename , source ) );
282}
283
285{
286
287 G4cout << "Data source of this Partile HP calculation are " << G4endl;
288 for ( std::map< G4String , G4String >::iterator
289 it = mDataEvaluation.begin() ; it != mDataEvaluation.end() ; it++ )
290 {
291 G4cout << it->first << " " << it->second << G4endl;
292 }
293 G4cout << G4endl;
294}
295
297{
298 if ( theInelasticCrossSections.end() != theInelasticCrossSections.find( particle ) )
299 return theInelasticCrossSections.find( particle )->second;
300 else
301 return 0;
302}
303
305{
306 theInelasticCrossSections.insert( std::pair<const G4ParticleDefinition* , G4PhysicsTable* >( particle , val ) );
307}
308
309std::vector<G4ParticleHPChannelList*>* G4ParticleHPManager::GetInelasticFinalStates(const G4ParticleDefinition* particle)
310{
311 if ( theInelasticFSs.end() != theInelasticFSs.find( particle ) )
312 return theInelasticFSs.find( particle )->second;
313 else
314 return 0;
315}
316
317void G4ParticleHPManager::RegisterInelasticFinalStates( const G4ParticleDefinition* particle , std::vector<G4ParticleHPChannelList*>* val )
318{
319 theInelasticFSs.insert ( std::pair<const G4ParticleDefinition*,std::vector<G4ParticleHPChannelList*>*>( particle , val ) );
320}
321
322
324 G4cout << G4endl
325 << "=======================================================" << G4endl
326 << "====== ParticleHP Physics Parameters ========" << G4endl
327 << "=======================================================" << G4endl
328 << " UseOnlyPhotoEvaporation ? " << USE_ONLY_PHOTONEVAPORATION << G4endl
329 << " SkipMissingIsotopes ? " << SKIP_MISSING_ISOTOPES << G4endl
330 << " NeglectDoppler ? " << NEGLECT_DOPPLER << G4endl
331 << " DoNotAdjustFinalState ? " << DO_NOT_ADJUST_FINAL_STATE << G4endl
332 << " ProduceFissionFragments ? " << PRODUCE_FISSION_FRAGMENTS << G4endl
333 << " UseWendtFissionModel ? " << USE_WENDT_FISSION_MODEL << G4endl
334 << " UseNRESP71Model ? " << USE_NRESP71_MODEL << G4endl
335 << "=======================================================" << G4endl
336 << G4endl;
337}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
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