Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4ParticleHPManager.cc
이 파일의 문서화 페이지로 가기
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 "G4ParticleHPManager.hh"
34 #include "G4ParticleHPMessenger.hh"
35 #include "G4HadronicException.hh"
36 
37 //G4ThreadLocal G4ParticleHPManager* G4ParticleHPManager::instance = NULL;
39 
41 :/*RWB(NULL),*/
42  verboseLevel(1)
43 ,USE_ONLY_PHOTONEVAPORATION(false)
44 ,SKIP_MISSING_ISOTOPES(false)
45 ,NEGLECT_DOPPLER(false)
46 ,DO_NOT_ADJUST_FINAL_STATE(false)
47 ,PRODUCE_FISSION_FRAGMENTS(false)
48 ,USE_NRESP71_MODEL(false)
49 ,theElasticCrossSections(NULL)
50 ,theCaptureCrossSections(NULL)
51 //,theInelasticCrossSections(NULL)
52 ,theFissionCrossSections(NULL)
53 ,theElasticFSs(NULL)
54 //,theInelasticFSs(NULL)
55 ,theCaptureFSs(NULL)
56 ,theFissionFSs(NULL)
57 ,theTSCoherentCrossSections(NULL)
58 ,theTSIncoherentCrossSections(NULL)
59 ,theTSInelasticCrossSections(NULL)
60 ,theTSCoherentFinalStates(NULL)
61 ,theTSIncoherentFinalStates(NULL)
62 ,theTSInelasticFinalStates(NULL)
63 {
64  messenger = new G4ParticleHPMessenger( this );
65  if ( getenv( "G4NEUTRONHP_DO_NOT_ADJUST_FINAL_STATE" ) || getenv("G4PHP_DO_NOT_ADJUST_FINAL_STATE") ) DO_NOT_ADJUST_FINAL_STATE = true;
66  if ( getenv( "G4NEUTRONHP_USE_ONLY_PHOTONEVAPORATION" ) ) USE_ONLY_PHOTONEVAPORATION = true;
67  if ( getenv( "G4NEUTRONHP_NEGLECT_DOPPLER" ) || getenv("G4PHP_NEGLECT_DOPPLER") ) NEGLECT_DOPPLER = true;
68  if ( getenv( "G4NEUTRONHP_SKIP_MISSING_ISOTOPES" ) ) SKIP_MISSING_ISOTOPES = true;
69  if ( getenv( "G4NEUTRONHP_PRODUCE_FISSION_FRAGMENTS" ) ) PRODUCE_FISSION_FRAGMENTS = true;
70  if ( getenv( "G4PHP_USE_NRESP71_MODEL" ) ) USE_NRESP71_MODEL = true;
71 }
73 {
74  delete messenger;
75 }
77 {
78 // if ( RWB != NULL ) {
79 // G4cout << "Warning: G4ParticleHPReactionWhiteBoard is tried doubly opening" << G4endl;
80 // RWB = new G4ParticleHPReactionWhiteBoard();
81 // }
82 //
83 // RWB = new G4ParticleHPReactionWhiteBoard();
85 }
87 {
88 // if ( RWB == NULL ) {
89 // G4cout << "Warning: try to access G4ParticleHPReactionWhiteBoard before opening" << G4endl;
90 // RWB = new G4ParticleHPReactionWhiteBoard();
91 // }
92 // return RWB;
94 }
96 {
98 }
99 
100 #include "zlib.h"
101 #include <fstream>
102 void G4ParticleHPManager::GetDataStream( G4String filename , std::istringstream& iss )
103 {
104  //if ( getenv( "TEST04" ) && filename != "INVALID" ) G4cout << "Reading " << filename << G4endl;
105  G4String* data=NULL;
106  G4String compfilename(filename);
107  compfilename += ".z";
108  std::ifstream* in = new std::ifstream ( compfilename , std::ios::binary | std::ios::ate );
109  if ( in->good() )
110  {
111 // Use the compressed file
112  G4int file_size = in->tellg();
113  in->seekg( 0 , std::ios::beg );
114  Bytef* compdata = new Bytef[ file_size ];
115 
116  while ( *in ) { // Loop checking, 11.05.2015, T. Koi
117  in->read( (char*)compdata , file_size );
118  }
119 
120  uLongf complen = (uLongf) ( file_size*4 );
121  Bytef* uncompdata = new Bytef[complen];
122 
123  while ( Z_OK != uncompress ( uncompdata , &complen , compdata , file_size ) ) { // Loop checking, 11.05.2015, T. Koi
124  //G4cout << "Too small, retry 2 times bigger size." << G4endl;
125  delete[] uncompdata;
126  complen *= 2;
127  uncompdata = new Bytef[complen];
128  }
129  delete [] compdata;
130  // Now "complen" has uncomplessed size
131  data = new G4String ( (char*)uncompdata , (G4long)complen );
132  delete [] uncompdata;
133  } else {
134 // Use regular text file
135  std::ifstream thefData( filename , std::ios::in | std::ios::ate );
136  if ( thefData.good() ) {
137  G4int file_size = thefData.tellg();
138  thefData.seekg( 0 , std::ios::beg );
139  char* filedata = new char[ file_size ];
140  while ( thefData ) { // 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  } else {
147 // found no data file
148 // set error bit to the stream
149  iss.setstate( std::ios::badbit );
150  }
151  }
152  if ( data != NULL ) {
153  iss.str(*data);
154  G4String id;
155  iss >> id;
156  if ( id == "G4NDL" ) {
157  //Register information of file
158  G4String source;
159  iss >> source;
160  register_data_file(filename,source);
161  } else {
162  iss.seekg( 0 , std::ios::beg );
163  }
164  }
165  //G4cout << iss.rdbuf()->in_avail() << G4endl;
166  in->close(); delete in;
167  delete data;
168 }
169 // Checking existance of data file
170 void G4ParticleHPManager::GetDataStream2( G4String filename , std::istringstream& iss )
171 {
172  G4String compfilename(filename);
173  compfilename += ".z";
174  std::ifstream* in = new std::ifstream ( compfilename , std::ios::binary | std::ios::ate );
175  if ( in->good() )
176  {
177 // Compressed file is exist
178  in->close();
179  } else {
180  std::ifstream thefData( filename , std::ios::in | std::ios::ate );
181  if ( thefData.good() ) {
182 // Regular text file is exist
183  thefData.close();
184  } else {
185 // found no data file
186 // set error bit to the stream
187  iss.setstate( std::ios::badbit );
188  }
189  }
190  delete in;
191 }
192 
194 {
195  G4cout << "You are setting a new verbose level for Particle HP package." << G4endl;
196  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;
197  verboseLevel = newValue;
198 }
199 
201 {
202  mDataEvaluation.insert( std::pair < G4String , G4String > ( filename , source ) );
203 }
204 
206 {
207 
208  G4cout << "Data source of this Partile HP calculation are " << G4endl;
209  for ( std::map< G4String , G4String >::iterator
210  it = mDataEvaluation.begin() ; it != mDataEvaluation.end() ; it++ ) {
211  G4cout << it->first << " " << it->second << G4endl;
212  }
213  G4cout << G4endl;
214 }
215 
217  if ( theInelasticCrossSections.end() != theInelasticCrossSections.find( particle ) )
218  return theInelasticCrossSections.find( particle )->second;
219  else
220  return NULL;
221 }
222 
224  theInelasticCrossSections.insert( std::pair<const G4ParticleDefinition* , G4PhysicsTable* >( particle , val ) );
225 }
226 
227 std::vector<G4ParticleHPChannelList*>* G4ParticleHPManager::GetInelasticFinalStates(const G4ParticleDefinition* particle) {
228  if ( theInelasticFSs.end() != theInelasticFSs.find( particle ) )
229  return theInelasticFSs.find( particle )->second;
230  else
231  return NULL;
232 }
233 
234 void G4ParticleHPManager::RegisterInelasticFinalStates( const G4ParticleDefinition* particle , std::vector<G4ParticleHPChannelList*>* val ) {
235  theInelasticFSs.insert ( std::pair<const G4ParticleDefinition*,std::vector<G4ParticleHPChannelList*>*>( particle , val ) );
236 }
static G4ParticleHPManager * instance
void register_data_file(G4String, G4String)
static G4ParticleHPManager * GetInstance()
#define G4endl
Definition: G4ios.hh:61
std::map< const G4ParticleDefinition *, std::vector< G4ParticleHPChannelList * > * > theInelasticFSs
G4PhysicsTable * GetInelasticCrossSections(const G4ParticleDefinition *)
static G4ParticleHPThreadLocalManager * GetInstance()
const XML_Char const XML_Char * data
Definition: expat.h:268
void GetDataStream(G4String, std::istringstream &iss)
std::map< G4String, G4String > mDataEvaluation
G4ParticleHPReactionWhiteBoard * GetReactionWhiteBoard()
long G4long
Definition: G4Types.hh:80
G4ParticleHPReactionWhiteBoard * GetReactionWhiteBoard()
void RegisterInelasticCrossSections(const G4ParticleDefinition *, G4PhysicsTable *)
G4ParticleHPMessenger * messenger
int G4int
Definition: G4Types.hh:78
ifstream in
Definition: comparison.C:7
std::vector< G4ParticleHPChannelList * > * GetInelasticFinalStates(const G4ParticleDefinition *)
G4GLOB_DLL std::ostream G4cout
#define Z_OK
Definition: zlib.h:177
std::map< const G4ParticleDefinition *, G4PhysicsTable * > theInelasticCrossSections
void RegisterInelasticFinalStates(const G4ParticleDefinition *, std::vector< G4ParticleHPChannelList * > *)
void GetDataStream2(G4String, std::istringstream &iss)