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 10.4.p3 ] [ 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/G4ParticleHPProbabilityTablesStore.cc (Version 11.3.0) and /processes/hadronic/models/particle_hp/src/G4ParticleHPProbabilityTablesStore.cc (Version 10.0.p1)


  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 //                                                
 27 // -------------------------------------------    
 28 //                                                
 29 //      Geant4 source file                        
 30 //                                                
 31 //      File name: G4ParticleHPProbabilityTabl    
 32 //                                                
 33 //      Authors: Marek Zmeskal (CTU, Czech Tec    
 34 //               Loic Thulliez (CEA France)       
 35 //                                                
 36 //      Creation date: 4 June 2024                
 37 //                                                
 38 //      Description: Class to store all probab    
 39 //                   different isotopes and in    
 40 //                   different temperatures.      
 41 //                                                
 42 //      Modifications:                            
 43 //                                                
 44 // -------------------------------------------    
 45 //                                                
 46 //                                                
 47                                                   
 48 #include "G4ParticleHPProbabilityTablesStore.h    
 49 #include "G4SystemOfUnits.hh"                     
 50 #include "G4ParticleHPVector.hh"                  
 51 #include "G4ParticleHPManager.hh"                 
 52 #include "G4HadronicParameters.hh"                
 53 #include "G4Material.hh"                          
 54 #include "G4Element.hh"                           
 55 #include "G4Isotope.hh"                           
 56 #include "G4DynamicParticle.hh"                   
 57 #include "G4Exception.hh"                         
 58 #include "G4ParticleHPIsoProbabilityTable.hh"     
 59 #include "G4ParticleHPIsoProbabilityTable_NJOY    
 60 #include "G4ParticleHPIsoProbabilityTable_CALE    
 61 #include <string>                                 
 62 #include <sstream>                                
 63                                                   
 64 G4ParticleHPProbabilityTablesStore* G4Particle    
 65                                                   
 66 ///-------------------------------------------    
 67 G4ParticleHPProbabilityTablesStore::G4Particle    
 68   Temperatures(0), ProbabilityTables(0), URRli    
 69   if ( G4FindDataDir( "G4URRPTDATA" ) != nullp    
 70     dirName = G4FindDataDir( "G4URRPTDATA" );     
 71   } else {                                        
 72     G4Exception( "G4ParticleHPProbabilityTable    
 73        FatalException, "Please setenv G4URRPTD    
 74   }                                               
 75   if ( G4HadronicParameters::Instance()->GetTy    
 76     dirName += "/njoy/";                          
 77     usedNjoy = true;                              
 78   } else if ( G4HadronicParameters::Instance()    
 79     dirName += "/calendf/";                       
 80     usedCalendf = true;                           
 81   } else {                                        
 82     G4Exception( "G4ParticleHPProbabilityTable    
 83        FatalException, "The format of probabil    
 84        "please set it with G4HadronicParameter    
 85   }                                               
 86   numIso = (G4int)G4Isotope::GetNumberOfIsotop    
 87   // find all possible temperatures for all is    
 88   G4Material* theMaterial;                        
 89   G4int Temp;                                     
 90   Temperatures = new std::vector< std::vector<    
 91   for ( G4int i = 0; i < numIso; ++i ) {          
 92     std::vector< G4int > isotemperatures;         
 93     std::map< std::thread::id, G4double > simp    
 94     std::map< std::thread::id, G4double > simp    
 95     Temperatures->push_back( std::move(isotemp    
 96     energy_cache.push_back( std::move(simpleMa    
 97     random_number_cache.push_back( std::move(s    
 98   }                                               
 99   for ( std::size_t im = 0; im < G4Material::G    
100     std::vector< G4bool > isoinmat( numIso, fa    
101     theMaterial = G4Material::GetMaterialTable    
102     Temp = (G4int)theMaterial->GetTemperature(    
103     for ( G4int e = 0; e < (G4int)theMaterial-    
104       for ( G4int i = 0; i < (G4int)theMateria    
105       std::size_t indexI = theMaterial->GetEle    
106       std::vector< G4int > isotemperatures = (    
107       if ( std::find( isotemperatures.begin(),    
108         (*Temperatures)[indexI].push_back( Tem    
109         isoinmat[indexI] = true;                  
110       } else {                                    
111         if ( isoinmat[indexI] ) {                 
112           G4ExceptionDescription message;         
113           message << "The isotope Z=" << theMa    
114                     << " and A=" << theMateria    
115                     << " is more times in mate    
116             << "This may cause bias in selecti    
117             << "Please make materials only wit    
118           G4Exception( "G4ParticleHPProbabilit    
119         }                                         
120       }                                           
121       }  // end of cycle over isotopes            
122     }  // end of cycle over elements              
123   }  // end of cycle over materials               
124 }                                                 
125                                                   
126 ///-------------------------------------------    
127 G4ParticleHPProbabilityTablesStore::~G4Particl    
128   for ( G4int i = 0; i < numIso; i++ ) {          
129     for ( std::map< G4int, G4ParticleHPIsoProb    
130           it != (*ProbabilityTables)[i].end();    
131       delete it->second;                          
132     }                                             
133   }                                               
134   delete ProbabilityTables;                       
135   delete URRlimits;                               
136   delete Temperatures;                            
137 }                                                 
138                                                   
139 ///-------------------------------------------    
140 G4ParticleHPProbabilityTablesStore* G4Particle    
141   if ( instance == nullptr ) instance = new G4    
142   return instance;                                
143 }                                                 
144                                                   
145 ///-------------------------------------------    
146 G4double G4ParticleHPProbabilityTablesStore::G    
147   const G4Isotope* iso, const G4Element* ele,     
148   G4double kineticEnergy = dp->GetKineticEnerg    
149   std::size_t indexI = iso->GetIndex();           
150   G4int T = (G4int)( mat->GetTemperature() );     
151   std::thread::id id = std::this_thread::get_i    
152   if ( energy_cache[indexI][id] == kineticEner    
153     return (*ProbabilityTables)[indexI][T]->Ge    
154   } else {                                        
155     energy_cache[indexI][id] = kineticEnergy;     
156     return (*ProbabilityTables)[iso->GetIndex(    
157   }                                               
158 }                                                 
159                                                   
160 ///-------------------------------------------    
161 void G4ParticleHPProbabilityTablesStore::Init(    
162   ProbabilityTables = new std::vector< std::ma    
163   for ( G4int i = 0; i < numIso; i++ ) {          
164     G4int Z = (*(G4Isotope::GetIsotopeTable())    
165     G4int A = (*(G4Isotope::GetIsotopeTable())    
166     G4int meso = (*(G4Isotope::GetIsotopeTable    
167     std::map< G4int, G4ParticleHPIsoProbabilit    
168     for ( G4int T : (*Temperatures)[i] ) {  //    
169       if ( usedNjoy ) {                           
170     tempPTmap.insert( { T, new G4ParticleHPIso    
171       } else if ( usedCalendf ) {                 
172     tempPTmap.insert( { T, new G4ParticleHPIso    
173       }                                           
174       tempPTmap[T]->Init( Z, A, meso, T, dirNa    
175     }                                             
176     ProbabilityTables->push_back( std::move(te    
177   }                                               
178 }                                                 
179                                                   
180 ///-------------------------------------------    
181 void G4ParticleHPProbabilityTablesStore::InitU    
182   URRlimits = new std::vector< std::pair< G4do    
183   // Find energy limits of the URR for each el    
184   std::vector< G4bool > wasnotprintedyet( numI    
185   for ( std::size_t i = 0; i < G4Element::GetN    
186     G4double minE = DBL_MAX;                      
187     G4double maxE = 0.0;                          
188     for ( G4int ii = 0; ii < (G4int)(*(G4Eleme    
189       G4int Z = (*(G4Element::GetElementTable(    
190       G4int A = (*(G4Element::GetElementTable(    
191       G4int meso = (*(G4Element::GetElementTab    
192       std::size_t indexI = (*(G4Element::GetEl    
193       filename = std::to_string(Z) + "_" + std    
194       if ( meso != 0 ) filename += "_m" + std:    
195       G4double emin = DBL_MAX;                    
196       G4double emax = 0.0;                        
197       G4double emin2 = DBL_MAX;                   
198       G4double emax2 = 0.0;                       
199       G4bool hasalreadyPT = false;                
200       G4bool doesnothavePTyet = false;            
201       for ( G4int T : (*Temperatures)[indexI]     
202         G4String fullPathFileName = dirName +     
203         std::istringstream theData( std::ios::    
204         G4ParticleHPManager::GetInstance()->Ge    
205         if ( theData.good() &&  hasalreadyPT )    
206       theData >> emin2 >> emax2;                  
207       if ( emin2 != emin  ||  emax2 != emax )     
208         G4ExceptionDescription message;           
209         message << "There is mismatch between     
210           << "with Z=" << Z << " and A=" << A     
211                     << "The broadest limits wi    
212         G4Exception( "G4ParticleHPProbabilityT    
213         G4cout << "Temperature T= " << T << "     
214         if ( emin < minE ) minE = emin;           
215         if ( emax > maxE ) maxE = emax;           
216       }                                           
217         } else if ( theData.good() ) {            
218       theData >> emin >> emax;                    
219       if ( emin < minE ) minE = emin;             
220       if ( emax > maxE ) maxE = emax;             
221       hasalreadyPT = true;                        
222       if ( doesnothavePTyet  &&  wasnotprinted    
223         G4ExceptionDescription message;           
224         message << "There are probability tabl    
225                     << "Smooth cross section w    
226         G4Exception( "G4ParticleHPProbabilityT    
227         wasnotprintedyet[indexI] = false;         
228       }                                           
229     } else if ( hasalreadyPT  &&  wasnotprinte    
230       G4ExceptionDescription message;             
231       message << "There are probability tables    
232                   << "Smooth cross section wil    
233       G4Exception( "G4ParticleHPProbabilityTab    
234       wasnotprintedyet[indexI] = false;           
235     } else {                                      
236       doesnothavePTyet = true;                    
237     }                                             
238       }                                           
239     }                                             
240     std::pair< G4double, G4double > simplepair    
241     URRlimits->push_back( simplepair );           
242   }                                               
243   // Find absolute energy limits of the URR an    
244   G4double absminE = (*URRlimits)[0].first;       
245   G4double absmaxE = (*URRlimits)[0].second;      
246   for ( auto iterator : (*URRlimits) ) {          
247     if ( iterator.first < absminE )  absminE =    
248     if ( iterator.second > absmaxE ) absmaxE =    
249   }                                               
250   std::pair< G4double, G4double > minmaxpair(     
251   URRlimits->push_back( minmaxpair );             
252 }                                                 
253