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] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/particle_hp/src/G4ParticleHPManager.cc (Version 11.3.0) and /processes/hadronic/models/particle_hp/src/G4ParticleHPManager.cc (Version 6.1)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // Class Description                              
 27 // Manager of NetronHP                            
 28 //                                                
 29 // 121031 First implementation done by T. Koi     
 30 // P. Arce, June-2014 Conversion neutron_hp to    
 31 // V. Ivanchenko, July-2023 Basic revision of     
 32 //                                                
 33 #include "G4ParticleHPManager.hh"                 
 34                                                   
 35 #include "G4Exception.hh"                         
 36 #include "G4HadronicException.hh"                 
 37 #include "G4ParticleHPMessenger.hh"               
 38 #include "G4ParticleDefinition.hh"                
 39 #include "G4HadronicParameters.hh"                
 40 #include "G4ParticleHPThreadLocalManager.hh"      
 41 #include "G4SystemOfUnits.hh"                     
 42                                                   
 43 #include <zlib.h>                                 
 44 #include <fstream>                                
 45                                                   
 46 G4ParticleHPManager* G4ParticleHPManager::inst    
 47                                                   
 48 G4ParticleHPManager::G4ParticleHPManager()        
 49   : theMinEnergyDBRC(0.1 * CLHEP::eV),            
 50     theMaxEnergyDBRC(210. * CLHEP::eV),           
 51     theMaxEnergyDoppler(30. * CLHEP::keV)         
 52 {                                                 
 53   messenger = new G4ParticleHPMessenger(this);    
 54   verboseLevel = G4HadronicParameters::Instanc    
 55   const char* ss = G4FindDataDir("NeutronHPNam    
 56   if (nullptr != ss) { CHECK_HP_NAMES = true;     
 57   ss = G4FindDataDir("G4PHP_DO_NOT_CHECK_DIFF_    
 58   if (nullptr != ss) { PHP_CHECK = false; }       
 59   ss = G4FindDataDir("G4PHP_MULTIPLICITY_METHO    
 60   if (nullptr != ss && "BetweenInts" == G4Stri    
 61   ss = G4FindDataDir("G4ParticleHPDebug");        
 62   if (nullptr != ss) { DEBUG = true; }            
 63                                                   
 64   // identify and check data path once - it sh    
 65   const char* nch = G4FindDataDir("G4NEUTRONHP    
 66   if (nullptr == nch) {                           
 67     G4Exception("G4ParticleHPManager::G4Partic    
 68                 FatalException, "G4NEUTRONXSDA    
 69   } else {                                        
 70     fDataPath[0] = G4String(nch);                 
 71   }                                               
 72   // path may be defined by two environment va    
 73   // it is not mandatory to access PHP data -     
 74   const char* ttp = G4FindDataDir("G4PARTICLEH    
 75   G4String tendl = (nullptr == ttp) ? G4String    
 76   const char* ssp = G4FindDataDir("G4PROTONHPD    
 77   fDataPath[1] = (nullptr == ssp) ? tendl + "/    
 78                                                   
 79   ssp = G4FindDataDir("G4DEUTERONHPDATA");        
 80   fDataPath[2] = (nullptr == ssp) ? tendl + "/    
 81                                                   
 82   ssp = G4FindDataDir("G4TRITONHPDATA");          
 83   fDataPath[3] = (nullptr == ssp) ? tendl + "/    
 84                                                   
 85   ssp = G4FindDataDir("G4HE3HPDATA");             
 86   fDataPath[4] = (nullptr == ssp) ? tendl + "/    
 87                                                   
 88   ssp = G4FindDataDir("G4ALPHAHPDATA");           
 89   fDataPath[5] = (nullptr == ssp) ? tendl + "/    
 90 }                                                 
 91                                                   
 92 G4ParticleHPManager::~G4ParticleHPManager()       
 93 {                                                 
 94   delete messenger;                               
 95 }                                                 
 96                                                   
 97 G4ParticleHPManager* G4ParticleHPManager::GetI    
 98 {                                                 
 99   static G4ParticleHPManager manager;             
100   if (instance == nullptr) {                      
101     instance = &manager;                          
102   }                                               
103   return instance;                                
104 }                                                 
105                                                   
106 G4int G4ParticleHPManager::GetPHPIndex(const G    
107   G4int pdg = part->GetPDGEncoding();             
108   G4int idx;                                      
109   if (pdg == 2112) { idx = 0; }                   
110   else if (pdg == 2212) { idx = 1; }              
111   else if (pdg == 1000010020) { idx = 2; }        
112   else if (pdg == 1000010030) { idx = 3; }        
113   else if (pdg == 1000020030) { idx = 4; }        
114   else if (pdg == 1000020040) { idx = 5; }        
115   else {                                          
116     idx = 0;                                      
117     G4ExceptionDescription ed;                    
118     ed << "Particle " << part->GetParticleName    
119        << " cannot be handled by the ParticleH    
120     G4Exception("G4ParticleHPManager::G4Partic    
121                 FatalException, ed, "");          
122   }                                               
123   return idx;                                     
124 }                                                 
125                                                   
126 const G4String&                                   
127 G4ParticleHPManager::GetParticleHPPath(const G    
128   return fDataPath[GetPHPIndex(part)];            
129 }                                                 
130                                                   
131 void G4ParticleHPManager::OpenReactionWhiteBoa    
132 {                                                 
133   G4ParticleHPThreadLocalManager::GetInstance(    
134 }                                                 
135                                                   
136 G4ParticleHPReactionWhiteBoard* G4ParticleHPMa    
137 {                                                 
138   return G4ParticleHPThreadLocalManager::GetIn    
139 }                                                 
140                                                   
141 void G4ParticleHPManager::CloseReactionWhiteBo    
142 {                                                 
143   G4ParticleHPThreadLocalManager::GetInstance(    
144 }                                                 
145                                                   
146 void G4ParticleHPManager::GetDataStream(const     
147 {                                                 
148   G4String* data = nullptr;                       
149   G4String compfilename(filename);                
150   compfilename += ".z";                           
151   auto in = new std::ifstream(compfilename, st    
152   if (in->good()) {                               
153     // Use the compressed file                    
154     std::streamoff file_size = in->tellg();       
155     in->seekg(0, std::ios::beg);                  
156     auto compdata = new Bytef[file_size];         
157                                                   
158     while (*in) {  // Loop checking, 11.05.201    
159       in->read((char*)compdata, file_size);       
160     }                                             
161                                                   
162     auto complen = (uLongf)(file_size * 4);       
163     auto uncompdata = new Bytef[complen];         
164                                                   
165     while (Z_OK != uncompress(uncompdata, &com    
166     {  // Loop checking, 11.05.2015, T. Koi       
167       delete[] uncompdata;                        
168       complen *= 2;                               
169       uncompdata = new Bytef[complen];            
170     }                                             
171     delete[] compdata;                            
172     // Now "complen" has uncomplessed size        
173     data = new G4String((char*)uncompdata, (G4    
174     delete[] uncompdata;                          
175   }                                               
176   else {                                          
177     // Use regular text file                      
178     std::ifstream thefData(filename, std::ios:    
179     if (thefData.good()) {                        
180       std::streamoff file_size = thefData.tell    
181       thefData.seekg(0, std::ios::beg);           
182       auto filedata = new char[file_size];        
183       while (thefData) {  // Loop checking, 11    
184         thefData.read(filedata, file_size);       
185       }                                           
186       thefData.close();                           
187       data = new G4String(filedata, file_size)    
188       delete[] filedata;                          
189     }                                             
190     else {                                        
191       // found no data file                       
192       // set error bit to the stream              
193       iss.setstate(std::ios::badbit);             
194     }                                             
195   }                                               
196   if (data != nullptr) {                          
197     iss.str(*data);                               
198     G4String id;                                  
199     iss >> id;                                    
200     if (id == "G4NDL") {                          
201       // Register information of file             
202       G4String source;                            
203       iss >> source;                              
204       register_data_file(filename, source);       
205     }                                             
206     else {                                        
207       iss.seekg(0, std::ios::beg);                
208     }                                             
209   }                                               
210   in->close();                                    
211   delete in;                                      
212   delete data;                                    
213 }                                                 
214                                                   
215 void G4ParticleHPManager::GetDataStream2(const    
216 {                                                 
217   // Checking existance of data file              
218                                                   
219   G4String compfilename(filename);                
220   compfilename += ".z";                           
221   auto in = new std::ifstream(compfilename, st    
222   if (in->good()) {                               
223     // Compressed file is exist                   
224     in->close();                                  
225   }                                               
226   else {                                          
227     std::ifstream thefData(filename, std::ios:    
228     if (thefData.good()) {                        
229       // Regular text file is exist               
230       thefData.close();                           
231     }                                             
232     else {                                        
233       // found no data file                       
234       // set error bit to the stream              
235       iss.setstate(std::ios::badbit);             
236     }                                             
237   }                                               
238   delete in;                                      
239 }                                                 
240                                                   
241 void G4ParticleHPManager::SetVerboseLevel(G4in    
242 {                                                 
243   G4cout << "You are setting a new verbose lev    
244   G4cout << "the new value will be used in who    
245             "cross sections for Capture, Elast    
246          << G4endl;                               
247   verboseLevel = newValue;                        
248 }                                                 
249                                                   
250 void G4ParticleHPManager::register_data_file(c    
251 {                                                 
252   mDataEvaluation.insert(std::pair<G4String, G    
253 }                                                 
254                                                   
255 void G4ParticleHPManager::DumpDataSource() con    
256 {                                                 
257   G4cout << "Data source of this Partile HP ca    
258   for (const auto& it : mDataEvaluation) {        
259     G4cout << it.first << " " << it.second <<     
260   }                                               
261   G4cout << G4endl;                               
262 }                                                 
263                                                   
264 void G4ParticleHPManager::DumpSetting()           
265 {                                                 
266   if(isPrinted) { return; }                       
267   G4cout << G4endl                                
268          << "=================================    
269          << "======       ParticleHP Physics P    
270          << "=================================    
271          << " Use only photo-evaporation          
272          << " Skip missing isotopes               
273          << " Neglect Doppler                     
274          << " Do not adjust final state           
275          << " Produce fission fragments           
276          << " Use WendtFissionModel               
277          << " Use NRESP71Model                    
278          << " Use DBRC                            
279          << " PHP use Poisson                     
280          << " PHP check                           
281          << " CHECK HP NAMES                      
282          << " Enable DEBUG                        
283          << " Use probability tables from         
284          << "=================================    
285   isPrinted = true;                               
286 }                                                 
287