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 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 /run/include/G4VUserPhysicsList.hh (Version 11.3.0) and /run/include/G4VUserPhysicsList.hh (Version ReleaseNotes)


** Warning: Cannot open xref database.

  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 // G4VUserPhysicsList                             
 27 //                                                
 28 // Class description:                             
 29 //                                                
 30 // This class is an abstract class for constru    
 31 // User must implement the following two pure     
 32 // class derived from this class:                 
 33 // - G4VUserPhysicsList::ConstructParticle()      
 34 //     Construct particles                        
 35 // - G4VUserPhysicsList::ConstructProcess()       
 36 //     Construct procesess and register them t    
 37                                                   
 38 // Original author: H.Kurashige (Kobe Universi    
 39 // -------------------------------------------    
 40 #ifndef G4VUserPhysicsList_hh                     
 41 #define G4VUserPhysicsList_hh 1                   
 42                                                   
 43 #include "G4ParticleDefinition.hh"                
 44 #include "G4ParticleTable.hh"                     
 45 #include "G4PhysicsModelCatalog.hh"               
 46 #include "G4ProductionCutsTable.hh"               
 47 #include "G4Threading.hh"                         
 48 #include "G4VUPLSplitter.hh"                      
 49 #include "G4ios.hh"                               
 50 #include "globals.hh"                             
 51                                                   
 52 #include "rundefs.hh"                             
 53 #include "tls.hh"                                 
 54                                                   
 55 class G4UserPhysicsListMessenger;                 
 56 class G4PhysicsListHelper;                        
 57 class G4VProcess;                                 
 58                                                   
 59 // Encapsulate the fields of class G4VUserPhys    
 60 class G4VUPLData                                  
 61 {                                                 
 62   public:                                         
 63     void initialize();                            
 64                                                   
 65     G4ParticleTable::G4PTblDicIterator* _thePa    
 66     G4UserPhysicsListMessenger* _theMessenger     
 67     G4PhysicsListHelper* _thePLHelper = nullpt    
 68     G4bool _fIsPhysicsTableBuilt = false;         
 69     G4int _fDisplayThreshold = 0;                 
 70 };                                                
 71                                                   
 72 // The type G4VUPLManager is introduced to enc    
 73 // both the master thread and worker threads t    
 74 // the fields encapsulated by the class G4VUPL    
 75 // changes the value for these fields, it refe    
 76 // definition defined below. For every G4VUser    
 77 // there is a corresponding G4VUPLData instanc    
 78 // are organized by the class G4VUPLManager as    
 79 // The field "int g4vuplInstanceID" is added t    
 80 // The value of this field in each G4VUserPhys    
 81 // subscript of the corresponding G44VUPLData     
 82 // In order to use the class G44VUPLManager, w    
 83 // G4VUserPhysicsList as follows: "static G4VU    
 84 // Both the master thread and worker threads c    
 85 // for G44VUPLData instances mutually along wi    
 86 // instances are created. For each worker thre    
 87 // Consider any thread A, if there is any othe    
 88 // This ion is shared by the thread A. So the     
 89 // in the array of G4PDefData instances for th    
 90 //                                                
 91 // Important Note: you may wonder why we are i    
 92 //                 since there is only one PL     
 93 //                 This is true, in the sense     
 94 //                 to be associated to a G4Run    
 95 //                 instantiate as many PLs are    
 96 //                 of the PLs to be used we th    
 97 //                 guarantee that the system w    
 98 //                 this (unusual) case. This m    
 99 //                                                
100 using G4VUPLManager = G4VUPLSplitter<G4VUPLDat    
101 using G4VUserPhysicsListSubInstanceManager = G    
102                                                   
103 class G4VUserPhysicsList                          
104 {                                                 
105   public:                                         
106     G4VUserPhysicsList();                         
107     virtual ~G4VUserPhysicsList();                
108     G4VUserPhysicsList(const G4VUserPhysicsLis    
109     G4VUserPhysicsList& operator=(const G4VUse    
110                                                   
111     // Each particle type will be instantiated    
112     // This method is invoked by the RunManger    
113     virtual void ConstructParticle() = 0;         
114                                                   
115     // By calling the "Construct" method,         
116     // process manager and processes are creat    
117     void Construct();                             
118                                                   
119     // Each physics process will be instantiat    
120     // registered to the process manager of ea    
121     // Invoked in the Construct() method.         
122     virtual void ConstructProcess() = 0;          
123                                                   
124     // Sets a cut value for all particle types    
125     virtual void SetCuts();                       
126                                                   
127     // Set/get the default cut value. Calling     
128     // re-calcuration of cut values and physic    
129     // next event loop.                           
130     void SetDefaultCutValue(G4double newCutVal    
131     G4double GetDefaultCutValue() const;          
132                                                   
133     // Invoke BuildPhysicsTable for all proces    
134     // In case of "Retrieve" flag is ON, Physi    
135     // retrieved from files.                      
136     void BuildPhysicsTable();                     
137                                                   
138     // Prepare the PhysicsTable for specified     
139     void PreparePhysicsTable(G4ParticleDefinit    
140                                                   
141     // Build the PhysicsTable for specified pa    
142     void BuildPhysicsTable(G4ParticleDefinitio    
143                                                   
144     // Store PhysicsTable together with both m    
145     // information in files under the specifie    
146     // Returns "true" if files are successfull    
147     G4bool StorePhysicsTable(const G4String& d    
148                                                   
149     // Return true if "Retrieve" flag is ON.      
150     // (i.e. PhysicsTable will be retrieved fr    
151     G4bool IsPhysicsTableRetrieved() const;       
152     G4bool IsStoredInAscii() const;               
153                                                   
154     // Get directory path for physics table fi    
155     const G4String& GetPhysicsTableDirectory()    
156                                                   
157     // Set "Retrieve" flag. Directory path can    
158     // Null string (default) means directory i    
159     // from the current value.                    
160     void SetPhysicsTableRetrieved(const G4Stri    
161     void SetStoredInAscii();                      
162                                                   
163     // Reset "Retrieve" flag.                     
164     void ResetPhysicsTableRetrieved();            
165     void ResetStoredInAscii();                    
166                                                   
167     // Print out the List of registered partic    
168     void DumpList() const;                        
169                                                   
170     // Request to print out information of cut    
171     // Printing will be performed when all tab    
172     void DumpCutValuesTable(G4int flag = 1);      
173                                                   
174     // Triggers the print-out requested by the    
175     // This method must be invoked by RunManag    
176     void DumpCutValuesTableIfRequested();         
177                                                   
178     // Set/get control flag for output message    
179     //  0: Silent                                 
180     //  1: Warning message                        
181     //  2: More                                   
182     void SetVerboseLevel(G4int value);            
183     G4int GetVerboseLevel() const;                
184                                                   
185     void UseCoupledTransportation(G4bool vl =     
186                                                   
187     // Invokes default SetCuts() method.          
188     // Note: cut values will not be overwritte    
189     // Use of default SetCuts() method is reco    
190     void SetCutsWithDefault();                    
191                                                   
192     // Sets a cut value for a particle type fo    
193     void SetCutValue(G4double aCut, const G4St    
194                                                   
195     // Gets a cut value for a particle type fo    
196     G4double GetCutValue(const G4String& pname    
197                                                   
198     // Sets a cut value for a particle type fo    
199     void SetCutValue(G4double aCut, const G4St    
200                                                   
201     // Invoke SetCuts for specified particle f    
202     // If the pointer to the region is NULL, t    
203     // In case of "Retrieve" flag is ON, cut v    
204     // from files.                                
205     void SetParticleCuts(G4double cut, G4Parti    
206     void SetParticleCuts(G4double cut, const G    
207                                                   
208     // Invoke SetCuts() for all particles in a    
209     void SetCutsForRegion(G4double aCut, const    
210                                                   
211     // Gets/sets the flag for ApplyCuts().        
212     void SetApplyCuts(G4bool value, const G4St    
213     G4bool GetApplyCuts(const G4String& name)     
214                                                   
215     // Remove and delete ProcessManagers for a    
216     // Particle Table.                            
217     void RemoveProcessManager();                  
218                                                   
219     // Remove and delete TrackingManagers for     
220     // Particle Table.                            
221     void RemoveTrackingManager();                 
222                                                   
223     // Add process manager for particles creat    
224     void AddProcessManager(G4ParticleDefinitio    
225                            G4ProcessManager* n    
226                                                   
227     // Check consistencies of list of particle    
228     void CheckParticleList();                     
229                                                   
230     void DisableCheckParticleList();              
231                                                   
232     inline G4int GetInstanceID() const;           
233     static const G4VUPLManager& GetSubInstance    
234                                                   
235     // Used by Worker threads on the shared in    
236     // to initialise workers. Derived class re    
237     // must also call this base class method.     
238     virtual void InitializeWorker();              
239                                                   
240     // Destroy thread-local data. Note that de    
241     // implementing this method should still c    
242     virtual void TerminateWorker();               
243                                                   
244   protected:                                      
245     // User must invoke this method in his Con    
246     // implementation in order to enable parti    
247     void AddTransportation();                     
248                                                   
249     // Register a process to the particle type    
250     // according to the ordering parameter tab    
251     // 'true' is returned if the process is re    
252     G4bool RegisterProcess(G4VProcess* process    
253                                                   
254     // Build PhysicsTable for making the integ    
255     void BuildIntegralPhysicsTable(G4VProcess*    
256                                                   
257     // Retrieve PhysicsTable from files for pr    
258     // Normal BuildPhysics procedure of proces    
259     // fails (in case of process's RetrievePhy    
260     virtual void RetrievePhysicsTable(G4Partic    
261                                       G4bool a    
262                                                   
263     // Adds new ProcessManager to all particle    
264     // This function is used in Construct().      
265     void InitializeProcessManager();              
266                                                   
267     G4ParticleTable::G4PTblDicIterator* GetPar    
268                                                   
269   protected:                                      
270     // The particle table has the complete Lis    
271     G4ParticleTable* theParticleTable = nullpt    
272                                                   
273     G4int verboseLevel = 1;                       
274                                                   
275     // Default cut value for all particles        
276     G4double defaultCutValue = 1.0;               
277     G4bool isSetDefaultCutValue = false;          
278                                                   
279     // Pointer to ProductionCutsTable.            
280     G4ProductionCutsTable* fCutsTable = nullpt    
281                                                   
282     // Flag to determine if physics table will    
283     G4bool fRetrievePhysicsTable = false;         
284     G4bool fStoredInAscii = true;                 
285                                                   
286     G4bool fIsCheckedForRetrievePhysicsTable =    
287     G4bool fIsRestoredCutValues = false;          
288                                                   
289     // Directory name for physics table files.    
290     G4String directoryPhysicsTable = ".";         
291                                                   
292     // Flag for CheckParticleList().              
293     G4bool fDisableCheckParticleList = false;     
294                                                   
295     // MT data                                    
296     G4int g4vuplInstanceID = 0;                   
297     G4RUN_DLL static G4VUPLManager subInstance    
298 };                                                
299                                                   
300 // Inline methods implementations                 
301                                                   
302 inline void G4VUserPhysicsList::Construct()       
303 {                                                 
304 #ifdef G4VERBOSE                                  
305   if (verboseLevel > 1) G4cout << "G4VUserPhys    
306 #endif                                            
307                                                   
308   if (G4Threading::IsMasterThread()) G4Physics    
309                                                   
310   InitializeProcessManager();                     
311                                                   
312 #ifdef G4VERBOSE                                  
313   if (verboseLevel > 1) G4cout << "Construct p    
314 #endif                                            
315   ConstructProcess();                             
316 }                                                 
317                                                   
318 inline G4double G4VUserPhysicsList::GetDefault    
319 {                                                 
320   return defaultCutValue;                         
321 }                                                 
322                                                   
323 inline G4int G4VUserPhysicsList::GetVerboseLev    
324 {                                                 
325   return verboseLevel;                            
326 }                                                 
327                                                   
328 inline G4bool G4VUserPhysicsList::IsPhysicsTab    
329 {                                                 
330   return fRetrievePhysicsTable;                   
331 }                                                 
332                                                   
333 inline G4bool G4VUserPhysicsList::IsStoredInAs    
334 {                                                 
335   return fStoredInAscii;                          
336 }                                                 
337                                                   
338 inline const G4String& G4VUserPhysicsList::Get    
339 {                                                 
340   return directoryPhysicsTable;                   
341 }                                                 
342                                                   
343 inline void G4VUserPhysicsList::SetStoredInAsc    
344 {                                                 
345   fStoredInAscii = true;                          
346 }                                                 
347                                                   
348 inline void G4VUserPhysicsList::ResetPhysicsTa    
349 {                                                 
350   fRetrievePhysicsTable = false;                  
351   fIsRestoredCutValues = false;                   
352   fIsCheckedForRetrievePhysicsTable = false;      
353 }                                                 
354                                                   
355 inline void G4VUserPhysicsList::ResetStoredInA    
356 {                                                 
357   fStoredInAscii = false;                         
358 }                                                 
359                                                   
360 inline void G4VUserPhysicsList::DisableCheckPa    
361 {                                                 
362   fDisableCheckParticleList = true;               
363 }                                                 
364                                                   
365 inline G4int G4VUserPhysicsList::GetInstanceID    
366 {                                                 
367   return g4vuplInstanceID;                        
368 }                                                 
369                                                   
370 inline const G4VUPLManager& G4VUserPhysicsList    
371 {                                                 
372   return subInstanceManager;                      
373 }                                                 
374                                                   
375 #endif                                            
376