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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/electromagnetic/utils/src/G4EmDataHandler.cc (Version 11.3.0) and /processes/electromagnetic/utils/src/G4EmDataHandler.cc (Version 5.1.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 Class file                              
 30 //                                                
 31 // File name:     G4EmDataHandler                 
 32 //                                                
 33 // Author:        V. Ivanchenko                   
 34 //                                                
 35 // Creation date: 16 August 2017                  
 36 //                                                
 37 // Modifications:                                 
 38 //                                                
 39 // -------------------------------------------    
 40 //                                                
 41 //                                                
 42                                                   
 43 #include "G4EmDataHandler.hh"                     
 44 #include "G4EmDataRegistry.hh"                    
 45 #include "G4ParticleDefinition.hh"                
 46 #include "G4EmParameters.hh"                      
 47 #include "G4PhysicsTableHelper.hh"                
 48 #include "G4VEmProcess.hh"                        
 49 #include "G4VEnergyLossProcess.hh"                
 50                                                   
 51 //....oooOO0OOooo........oooOO0OOooo........oo    
 52                                                   
 53 G4EmDataHandler::G4EmDataHandler(std::size_t n    
 54   : tLength(n), fName(nam)                        
 55 {                                                 
 56   data.resize(n, nullptr);                        
 57   fMaxXS = new std::vector<G4double>;             
 58   fXSpeaks = new std::vector<G4TwoPeaksXS*>;      
 59   G4EmDataRegistry::Instance()->Register(this)    
 60 }                                                 
 61                                                   
 62 //....oooOO0OOooo........oooOO0OOooo........oo    
 63                                                   
 64 G4EmDataHandler::~G4EmDataHandler()               
 65 {                                                 
 66   if (!fUseBaseParticleTable) {                   
 67     for (std::size_t i=0; i<tLength; ++i) {       
 68       CleanTable(i);                              
 69     }                                             
 70     delete fMaxXS;                                
 71     delete fXSpeaks;                              
 72   }                                               
 73   if (!fElemSelectors.empty()) {                  
 74     for (auto const & ptr : fElemSelectors) {     
 75       if (nullptr != ptr) {                       
 76   for (auto const & p : *ptr) { delete p; }       
 77       }                                           
 78     }                                             
 79   }                                               
 80                                                   
 81 }                                                 
 82                                                   
 83 //....oooOO0OOooo........oooOO0OOooo........oo    
 84                                                   
 85 std::size_t G4EmDataHandler::SetTable(G4Physic    
 86 {                                                 
 87   for (std::size_t i=0; i<tLength; ++i) {         
 88     if (ptr == data[i]) { return i; }             
 89   }                                               
 90   data.push_back(ptr);                            
 91   ++tLength;                                      
 92   return tLength-1;                               
 93 }                                                 
 94                                                   
 95 //....oooOO0OOooo........oooOO0OOooo........oo    
 96                                                   
 97 void G4EmDataHandler::UpdateTable(G4PhysicsTab    
 98 {                                                 
 99   // update table pointer but not delete previ    
100   if (idx < tLength) {                            
101     if (ptr != data[idx]) { data[idx] = ptr; }    
102     data[idx] = G4PhysicsTableHelper::PrepareP    
103   } else {                                        
104     G4cout << "### G4EmDataHandler::UpdateTabl    
105            << " length=" << tLength << G4endl;    
106   }                                               
107 }                                                 
108                                                   
109 //....oooOO0OOooo........oooOO0OOooo........oo    
110                                                   
111 void G4EmDataHandler::SaveTable(G4PhysicsTable    
112 {                                                 
113   if (idx < tLength) {                            
114     data[idx] = ptr;                              
115   }                                               
116 }                                                 
117                                                   
118 //....oooOO0OOooo........oooOO0OOooo........oo    
119                                                   
120 G4PhysicsTable* G4EmDataHandler::MakeTable(std    
121 {                                                 
122   std::size_t idx = i;                            
123   if (idx >= tLength) {                           
124     data.push_back(nullptr);                      
125     idx = tLength;                                
126     ++tLength;                                    
127   }                                               
128   data[idx] = G4PhysicsTableHelper::PreparePhy    
129   return data[idx];                               
130 }                                                 
131                                                   
132 //....oooOO0OOooo........oooOO0OOooo........oo    
133                                                   
134 G4PhysicsTable* G4EmDataHandler::MakeTable(G4P    
135 {                                                 
136   std::size_t idx = i;                            
137   // create new table only if index correspond    
138   // position in the vector                       
139   if (idx < tLength) {                            
140     if (ptr != data[idx]) {                       
141       CleanTable(idx);                            
142       data[idx] = ptr;                            
143     }                                             
144   } else {                                        
145     data.push_back(ptr);                          
146     idx = tLength;                                
147     ++tLength;                                    
148   }                                               
149   data[idx] = G4PhysicsTableHelper::PreparePhy    
150   return data[idx];                               
151 }                                                 
152                                                   
153 //....oooOO0OOooo........oooOO0OOooo........oo    
154                                                   
155 void G4EmDataHandler::CleanTable(std::size_t i    
156 {                                                 
157   if (i < tLength && nullptr != data[i]) {        
158     auto ptr = data[i];                           
159     ptr->clearAndDestroy();                       
160     delete ptr;                                   
161     for (std::size_t j=0; j<tLength; ++j) {       
162       if (ptr == data[j]) { data[j] = nullptr;    
163     }                                             
164   }                                               
165 }                                                 
166                                                   
167 //....oooOO0OOooo........oooOO0OOooo........oo    
168                                                   
169 G4bool G4EmDataHandler::StorePhysicsTable(std:    
170                            const G4ParticleDef    
171          const G4String& fname,                   
172          G4bool ascii)                            
173 {                                                 
174   G4bool yes = true;                              
175   if(nullptr != data[idx]) {                      
176     yes = data[idx]->StorePhysicsTable(fname,     
177                                                   
178     if ( yes ) {                                  
179       G4cout << "### Physics table is stored f    
180        << part->GetParticleName()                 
181              << " <" << fname << "> " << G4end    
182     } else {                                      
183       G4cout << "### Fail to store Physics Tab    
184              << part->GetParticleName()           
185              << " <" << fname << "> " << G4end    
186     }                                             
187   }                                               
188   return yes;                                     
189 }                                                 
190                                                   
191 //....oooOO0OOooo........oooOO0OOooo........oo    
192                                                   
193 G4bool G4EmDataHandler::RetrievePhysicsTable(s    
194                            const G4ParticleDef    
195          const G4String& fname,                   
196          G4bool ascii, G4bool spline)             
197 {                                                 
198   G4PhysicsTable* table = Table(idx);             
199   G4bool yes = G4PhysicsTableHelper::RetrieveP    
200   G4EmParameters* param = G4EmParameters::Inst    
201   if ( yes ) {                                    
202     if (0 < param->Verbose()) {                   
203       G4cout << "### Physics table " << idx <<    
204        << part->GetParticleName()                 
205        << " is retrieved from <" << fname << "    
206        << G4endl;                                 
207     }                                             
208   } else if (1 < param->Verbose()) {              
209     G4cout << "### Fail to retrieve physics ta    
210      << part->GetParticleName() << " from <"      
211      << fname << ">" << G4endl;                   
212   }                                               
213   return yes;                                     
214 }                                                 
215                                                   
216 //....oooOO0OOooo........oooOO0OOooo........oo    
217                                                   
218 void G4EmDataHandler::SetMasterProcess(const G    
219 {                                                 
220   masterProcess.push_back(ptr);                   
221 }                                                 
222                                                   
223 //....oooOO0OOooo........oooOO0OOooo........oo    
224                                                   
225 const G4VEmProcess* G4EmDataHandler::GetMaster    
226 {                                                 
227   return (idx < masterProcess.size()) ? master    
228 }                                                 
229                                                   
230 //....oooOO0OOooo........oooOO0OOooo........oo    
231                                                   
232 void G4EmDataHandler::SetElementSelectors(std:    
233             std::size_t i)                        
234 {                                                 
235   if (i < eLength) {                              
236     if (fElemSelectors[i] != p) {                 
237       delete fElemSelectors[i];                   
238     }                                             
239     fElemSelectors[i] = p;                        
240   } else {                                        
241     fElemSelectors.push_back(p);                  
242     ++eLength;                                    
243   }                                               
244 }                                                 
245                                                   
246 //....oooOO0OOooo........oooOO0OOooo........oo    
247