Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VUserPhysicsList.hh
이 파일의 문서화 페이지로 가기
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 //
27 // $Id: G4VUserPhysicsList.hh 103803 2017-04-27 14:03:05Z gcosmo $
28 //
29 //
30 // ------------------------------------------------------------
31 // GEANT 4 class header file
32 // Class Description:
33 // This class is an abstract class for
34 // constructing particles and processes.
35 // User must implement following three virtual methods
36 // in his/her own concrete class derived from this class.
37 // G4VUserPhysicsList::ConstructParticle()
38 // Construct particles
39 // G4VUserPhysicsList::ConstructProcess()
40 // Construct procesess and register them to particles
41 //
42 // -------------------------------------------
43 // History
44 // first version 09 Jan. 1998 by H.Kurashige
45 // modified 24 Jan. 1998 by H.Kurashige
46 // rename DumpCutValues/DumpCutValuesTable
47 // change SetCuts method
48 // add SetCutsWithDefault method
49 // modified 06 June 1998 by H.Kurashige
50 // add AddProcessManager
51 // add BuildPhysicsTable
52 // modified 29 June 1998 by H.Kurashige
53 // add AddProcessManager
54 // modified 05 Dec. 1998 by H.Kurashige
55 // add ConstructAllParticles()
56 // modified 14, Apr 1999 by H.Kurashige
57 // change BuildPhysicsTable as public
58 // removed ConstructAllParticles() and related methods
59 // changed SetCuts method argument
60 // modified 08, Nov 2000 by H.Kurashige
61 // added Retrieve/StorePhysicsTable and related methods
62 // modified 08, Mar 2001 by H.Kurashige
63 // added binary mode for Retrieve/StorePhysicsTable
64 // added RetrieveCutValues and related
65 // added Set/ResetStoredInAscii() to switch on ascii mode
66 // for Retrieve/StorePhysicsTable
67 // modified for CUTS per REGION 10, Oct 2002 by H.Kurashige
68 // removed following methods
69 // void ReCalcCutValue()
70 // void SetCutValueForOthers()
71 // void SetCutValueForOtherThan()
72 // void ReCalcCutValueForOthers()
73 // virtual G4bool StoreMaterialInfo()
74 // virtual G4bool StoreCutValues()
75 // virtual G4bool RetrieveCutValues()
76 // virtual G4bool CheckForRetrievePhysicsTable()
77 // virtual G4bool CheckMaterialInfo()
78 // added void BuildPhysicsTable()
79 // Added PhysicsListHelper 29 Apr. 2011 H.Kurashige
80 // Added default impelmentation of SetCuts 10 June 2011 H.Kurashige
81 // SetCuts is not 'pure virtual' any more
82 // Trasnformations for multi-threading 26 Mar. 2013 A. Dotti
83 // Added destructions 21 Apr 2017 A. Dotti
84 // ------------------------------------------------------------
85 #ifndef G4VUserPhysicsList_h
86 #define G4VUserPhysicsList_h 1
87 
88 #include "globals.hh"
89 #include "tls.hh"
90 #include "rundefs.hh"
91 #include "G4ios.hh"
92 
93 #include "G4ParticleTable.hh"
94 #include "G4ParticleDefinition.hh"
95 #include "G4ProductionCutsTable.hh"
96 #include "G4VUPLSplitter.hh"
97 
98 #include "G4Threading.hh"
99 
101 class G4PhysicsListHelper;
102 class G4VProcess;
103 
105 {
106  //Encapsulate the fields of class G4VUserPhysicsList
107  //that are per-thread.
108 public:
109  void initialize();
115 };
116 // The type G4VUPLManager is introduced to encapsulate the methods used by
117 // both the master thread and worker threads to allocate memory space for
118 // the fields encapsulated by the class G4VUPLData. When each thread
119 // changes the value for these fields, it refers to them using a macro
120 // definition defined below. For every G4VUserPhysicsList instance,
121 // there is a corresponding G4VUPLData instance. All G4VUPLData instances
122 // are organized by the class G4VUPLManager as an array.
123 // The field "int g4vuplInstanceID" is added to the class G4VUserPhysicsList.
124 // The value of this field in each G4VUserPhysicsList instance is the
125 // subscript of the corresponding G44VUPLData instance.
126 // In order to use the class G44VUPLManager, we add a static member in the class
127 // G4VUserPhysicsList as follows: "static G4VUPLManager subInstanceManager".
128 // Both the master thread and worker threads change the length of the array
129 // for G44VUPLData instances mutually along with G4VUserPhysicsList
130 // instances are created. For each worker thread, it dynamically creates ions.
131 // Consider any thread A, if there is any other thread which creates an ion.
132 // This ion is shared by the thread A. So the thread A leaves an empty space
133 // in the array of G4PDefData instances for the ion.
134 //
135 // Important Note: you may wonder why we are introducing this mechanism
136 // since there is only one PL for each application.
137 // This is true, in the sense that only one PL is allowed
138 // to be associated to a G4RunManager, however user can instantiate
139 // as many PLs are needed and at run-time select one of the PLs to be used
140 // we thus need this mechanism to guarantee that the system works without
141 // problems in case of this (unusual) case. This may be reviewed in the future
144 
145 // This macros change the references to fields that are now encapsulated
146 // in the class G4VUPLData.
147 //
148 // Note1: the use of this-> this is needed to avoid compilation errors
149 // when using templated class with T=G4VUserPhysicsList. Don't know why.
150 // Note2: the name of the first #define is different, because otherwise
151 // we need to change its use in all classes that inherits from
152 // this base class (all examples). However one should note comment
153 // on JIRA task: http://jira-geant4.kek.jp/browse/DEV-27
154 //#define theParticleIterator ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theParticleIterator)
155 
157 {
158  public:
160  virtual ~G4VUserPhysicsList();
161 
162  // copy constructor and assignment operator
165 
166  public: // with description
167  // Each particle type will be instantiated
168  // This method is invoked by the RunManger
169  virtual void ConstructParticle() = 0;
170 
171  // By calling the "Construct" method,
172  // process manager and processes are created.
173  void Construct();
174 
175  // Each physics process will be instantiated and
176  // registered to the process manager of each particle type
177  // This method is invoked in Construct method
178  virtual void ConstructProcess() = 0;
179 
180  protected: // with description
181  // User must invoke this method in his ConstructProcess()
182  // implementation in order to insures particle transportation.
183  void AddTransportation();
184 
185  //Register a process to the particle type
186  // according to the ordering parameter table
187  // 'true' is returned if the process is registerd successfully
189  G4ParticleDefinition* particle);
190 
191 
192  public:
193  void UseCoupledTransportation(G4bool vl=true);
194 
196  public: // with description
197  // "SetCuts" method sets a cut value for all particle types
198  // in the particle table
199  virtual void SetCuts();
200 
201  public: // with description
202  // set/get the default cut value
203  // Calling SetDefaultCutValue causes re-calcuration of cut values
204  // and physics tables just before the next event loop
205  void SetDefaultCutValue(G4double newCutValue);
207 
209  public: // with description
210  // Invoke BuildPhysicsTable for all processes for all particles
211  // In case of "Retrieve" flag is ON, PhysicsTable will be
212  // retrieved from files
213  void BuildPhysicsTable();
214 
215  // do PreparePhysicsTable for specified particle type
217 
218  // do BuildPhysicsTable for specified particle type
220 
221  // Store PhysicsTable together with both material and cut value
222  // information in files under the specified directory.
223  // (return true if files are sucessfully created)
224  G4bool StorePhysicsTable(const G4String& directory = ".");
225 
226  // Return true if "Retrieve" flag is ON.
227  // (i.e. PhysicsTable will be retrieved from files)
229  G4bool IsStoredInAscii() const;
230 
231  // Get directory path for physics table files.
232  const G4String& GetPhysicsTableDirectory() const;
233 
234  // Set "Retrieve" flag
235  // Directory path can be set together.
236  // Null string (default) means directory is not changed
237  // from the current value
238  void SetPhysicsTableRetrieved(const G4String& directory = "");
239  void SetStoredInAscii();
240 
241  // Reset "Retrieve" flag
243  void ResetStoredInAscii();
244 
246  public: // with description
247  // Print out the List of registered particles types
248  void DumpList() const;
249 
250  public: // with description
251  // Request to print out information of cut values
252  // Printing will be performed when all tables are made
253  void DumpCutValuesTable(G4int flag =1);
254 
255  // The following method actually trigger the print-out requested
256  // by the above method. This method must be invoked by RunManager
257  // at the proper moment.
259 
260  public: // with description
262  G4int GetVerboseLevel() const;
263  // set/get controle flag for output message
264  // 0: Silent
265  // 1: Warning message
266  // 2: More
267 
269  public: // with description
270  // "SetCutsWithDefault" method invokes default SetCuts method
271  // Note: Cut values will not be overwriten with this method
272  // Using default SetCuts method is recommended
273  // (i.e You do not need to implement SetCuts method)
274  void SetCutsWithDefault();
275 
276  // Following are utility methods for SetCuts
277 
278  // SetCutValue sets a cut value for a particle type for the default region
279  void SetCutValue(G4double aCut, const G4String& pname);
280 
281  // GetCutValue sets a cut value for a particle type for the default region
282  G4double GetCutValue(const G4String& pname) const;
283 
284  // SetCutValue sets a cut value for a particle type for a region
285  void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname);
286 
287  // Invoke SetCuts for specified particle for a region
288  // If the pointer to the region is NULL, the default region is used
289  // In case of "Retrieve" flag is ON,
290  // Cut values will be retrieved from files
291  void SetParticleCuts(G4double cut,G4ParticleDefinition* particle,G4Region* region=0);
292  void SetParticleCuts( G4double cut, const G4String& particleName, G4Region* region=0);
293 
294  // Invoke SetCuts for all particles in a region
295  void SetCutsForRegion(G4double aCut, const G4String& rname);
296 
297  // Following are utility methods are obsolete
298  void ResetCuts();
299 
301  public:
302  // Get/SetApplyCuts gets/sets the flag for ApplyCuts
303  void SetApplyCuts(G4bool value, const G4String& name);
304  G4bool GetApplyCuts(const G4String& name) const;
305 
307  protected:
308  // do BuildPhysicsTable for make the integral schema
310 
311 
312  protected:
313  // Retrieve PhysicsTable from files for proccess belongng the particle.
314  // Normal BuildPhysics procedure of processes will be invoked,
315  // if it fails (in case of Process's RetrievePhysicsTable returns false)
317  const G4String& directory,
318  G4bool ascii = false);
319 
321  protected:
322  // adds new ProcessManager to all particles in the Particle Table
323  // this routine is used in Construct()
325 
326  public: // with description
327  // remove and delete ProcessManagers for all particles in tha Particle Table
328  // this routine is invoked from RunManager
329  void RemoveProcessManager();
330 
331  public: // with description
332  // add process manager for particles created on-the-fly
333  void AddProcessManager(G4ParticleDefinition* newParticle,
334  G4ProcessManager* newManager = 0 );
335 
337  public:
338  // check consistencies of list of particles
339 
340  void CheckParticleList();
341 
343 
345  protected:
346  // the particle table has the complete List of existing particle types
348  //G4ParticleTable::G4PTblDicIterator* theParticleIterator; //AND
349 
350  protected:
351  // pointer to G4UserPhysicsListMessenger
352  //G4UserPhysicsListMessenger* theMessenger;
353 
354  protected:
356 
357  protected:
358  // this is the default cut value for all particles
361 
362  protected:
363  // pointer to ProductionCutsTable
365 
366  // flag to determine physics table will be build from file or not
369 
372 
373  // directory name for physics table files
375 
376  // flag for displaying the range cuts & energy thresholds
377  //G4int fDisplayThreshold;
378 
379  // flag for Physics Table has been built
380  //G4bool fIsPhysicsTableBuilt;
381 
382  // flag for CheckParticleList
384 
385  // PhysicsListHelper
386  //G4PhysicsListHelper* thePLHelper;
387 
388  private:
390 
391  //Changes for MT
392  protected:
396  public:
397  inline G4int GetInstanceID() const;
398  static const G4VUPLManager& GetSubInstanceManager();
399  //Used by Worker threads on the shared instance of
400  // PL to initialize workers. Derived class re-implementing this method
401  // must also call this base class method
402  virtual void InitializeWorker();
403  //Destroy thread-local data. Note that derived classes
404  //implementing this method should still call this base class one
405  virtual void TerminateWorker();
406 };
407 
409 {
410 #ifdef G4VERBOSE
411  if (verboseLevel >1) G4cout << "G4VUserPhysicsList::Construct()" << G4endl;
412 #endif
413 
415 
416 #ifdef G4VERBOSE
417  if (verboseLevel >1) G4cout << "Construct processes " << G4endl;
418 #endif
420 
421 }
422 
424 {
425  return defaultCutValue;
426 }
427 
428 
430 {
431  return verboseLevel;
432 }
433 
434 inline
436 {
437  return fRetrievePhysicsTable;
438 }
439 
440 inline
442 {
443  return fStoredInAscii;
444 }
445 
446 inline
448 {
449  return directoryPhysicsTable;
450 }
451 
452 inline
454 {
455  fStoredInAscii = true;
456 }
457 
458 
459 inline
461 {
462  fRetrievePhysicsTable = false;
463  fIsRestoredCutValues = false;
465 }
466 
467 
468 inline
470 {
471  fStoredInAscii = false;
472 }
473 
474 inline
476 {
478 }
479 
480 inline
482 {
483  return g4vuplInstanceID;
484 }
485 
486 inline
488 {
489  return subInstanceManager;
490 }
491 #endif
492 
void SetCutsForRegion(G4double aCut, const G4String &rname)
const XML_Char * name
Definition: expat.h:151
G4ParticleTable::G4PTblDicIterator * _theParticleIterator
void SetPhysicsTableRetrieved(const G4String &directory="")
void AddProcessManager(G4ParticleDefinition *newParticle, G4ProcessManager *newManager=0)
G4double GetDefaultCutValue() const
#define G4endl
Definition: G4ios.hh:61
#define G4RUN_DLL
Definition: rundefs.hh:48
G4bool IsStoredInAscii() const
const G4String & GetPhysicsTableDirectory() const
static G4RUN_DLL G4VUPLManager subInstanceManager
G4bool IsPhysicsTableRetrieved() const
void BuildIntegralPhysicsTable(G4VProcess *, G4ParticleDefinition *)
G4PhysicsListHelper * _thePLHelper
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
G4int GetVerboseLevel() const
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
void SetParticleCuts(G4double cut, G4ParticleDefinition *particle, G4Region *region=0)
const XML_Char int const XML_Char * value
Definition: expat.h:331
void ResetCuts()
obsolete methods
void PreparePhysicsTable(G4ParticleDefinition *)
G4bool GetApplyCuts(const G4String &name) const
G4ParticleTable * theParticleTable
void UseCoupledTransportation(G4bool vl=true)
G4ProductionCutsTable * fCutsTable
G4bool fIsCheckedForRetrievePhysicsTable
virtual void ConstructParticle()=0
void SetDefaultCutValue(G4double newCutValue)
int G4int
Definition: G4Types.hh:78
static const G4VUPLManager & GetSubInstanceManager()
void SetApplyCuts(G4bool value, const G4String &name)
G4int GetInstanceID() const
virtual void RetrievePhysicsTable(G4ParticleDefinition *, const G4String &directory, G4bool ascii=false)
G4bool StorePhysicsTable(const G4String &directory=".")
G4GLOB_DLL std::ostream G4cout
G4VUPLSplitter< G4VUPLData > G4VUPLManager
G4bool _fIsPhysicsTableBuilt
G4double GetCutValue(const G4String &pname) const
virtual void TerminateWorker()
void SetCutValue(G4double aCut, const G4String &pname)
void SetVerboseLevel(G4int value)
void DumpCutValuesTable(G4int flag=1)
virtual void InitializeWorker()
G4VUserPhysicsList & operator=(const G4VUserPhysicsList &)
G4VUPLManager G4VUserPhysicsListSubInstanceManager
virtual void ConstructProcess()=0
G4UserPhysicsListMessenger * _theMessenger