Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4VPhysicsConstructor.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: G4VPhysicsConstructor.hh 103953 2017-05-04 11:27:35Z gcosmo $
28 //
29 //
30 // ------------------------------------------------------------
31 // GEANT 4 class header file
32 // Class Description:
33 // This class is an virtual class for constructing
34 // particles and processes. This class objects will be
35 // registered to G4VPhysicsList.
36 //
37 // User must implement following four virtual methods
38 // in his own concrete class derived from this class.
39 //
40 // all necessary particle type will be instantiated
41 // virtual void ConstructParticle();
42 //
43 // all physics processes will be instantiated and
44 // registered to the process manager of each particle type
45 // virtual void ConstructProcess();
46 //
47 // Only one physics constructor can be registered to
48 // Modular Physics List for each "physics_type".
49 // Physics constructors with same "physics_type" can be
50 // replaced by using the method of
51 // G4VModularPhysicsList::ReplacePhysics()
52 //
53 //
54 // -------------------------------------------
55 // History
56 // first version 12 Nov. 2000 by H.Kurashige
57 // Add physicsType 14 Mar. 2011 by H.Kurashige
58 // Add RegisterProcess 1 May 2011 by H.Kurashige
59 // Add G4PhysicsBuilderInterface 21 Apr 2017 by A.Dotti
60 // ------------------------------------------------------------
61 #ifndef G4VPhysicsConstructor_h
62 #define G4VPhysicsConstructor_h 1
63 
64 #include "globals.hh"
65 #include "rundefs.hh"
66 #include "G4ios.hh"
67 #include "G4ParticleTable.hh"
68 #include "G4PhysicsListHelper.hh"
69 #include "G4VUPLSplitter.hh"
70 #include <vector>
71 
73 
74 class G4VPCData
75 {
76  //Encapsulate the fields of class G4VPhysicsConstructor
77  //that are per-thread.
78 public:
79  using PhysicsBuilders_V=std::vector<G4PhysicsBuilderInterface*>;
80  void initialize();
83 };
84 
85 // The type G4VPCManager is introduced to encapsulate the methods used by
86 // both the master thread and worker threads to allocate memory space for
87 // the fields encapsulated by the class G4VPCData. When each thread
88 // changes the value for these fields, it refers to them using a macro
89 // definition defined below. For every G4VPhysicsConstructor instance,
90 // there is a corresponding G4VPCData instance. All G4VPCData instances
91 // are organized by the class G4VUPLManager as an array.
92 // The field "int g4vuplInstanceID" is added to the class G4VUserPhysicsList.
93 // The value of this field in each G4VUserPhysicsList instance is the
94 // subscript of the corresponding G44VUPLData instance.
95 // In order to use the class G44VUPLManager, we add a static member in the class
96 // G4VUserPhysicsList as follows: "static G4VUPLManager subInstanceManager".
97 // Both the master thread and worker threads change the length of the array
98 // for G44VUPLData instances mutually along with G4VUserPhysicsList
99 // instances are created. For each worker thread, it dynamically creates ions.
100 // Consider any thread A, if there is any other thread which creates an ion.
101 // This ion is shared by the thread A. So the thread A leaves an empty space
102 // in the array of G4PDefData instances for the ion.
103 //
104 // Important Note: you may wonder why we are introducing this mechanism
105 // since there is only one PL for each application.
106 // This is true, in the sense that only one PL is allowed
107 // to be associated to a G4RunManager, however user can instantiate
108 // as many PLs are needed and at run-time select one of the PLs to be used
109 // we thus need this mechanism to guarantee that the system works without
110 // problems in case of this (unusual) case. This may be reviewed in the future
113 
114 // This macros change the references to fields that are now encapsulated
115 // in the class G4VPCData.
116 //
117 // Note1: the use of this-> this is needed to avoid compilation errors
118 // when using templated class with T=G4VUserPhysicsList. Don't know why.
119 // Note2: the name of the first #define is different, because otherwise
120 // we need to change its use in all classes that inherits from
121 // this base class (all examples). However one should note comment
122 // on JIRA task: http://jira-geant4.kek.jp/browse/DEV-27
123 
124 //#define aParticleIterator ((subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator)
125 
127 {
128  public: // with description
129 
130  G4VPhysicsConstructor(const G4String& ="");
131  G4VPhysicsConstructor(const G4String& name, G4int physics_type);
132  virtual ~G4VPhysicsConstructor();
133 
134  virtual void ConstructParticle()=0;
135  // This method will be invoked in the Construct() method.
136  // each particle type will be instantiated
137 
138  virtual void ConstructProcess()=0;
139  // This method will be invoked in the Construct() method.
140  // each physics process will be instantiated and
141  // registered to the process manager of each particle type
142 
143  inline void SetPhysicsName(const G4String& ="");
144  inline const G4String& GetPhysicsName() const;
145 
146  inline void SetPhysicsType(G4int);
147  inline G4int GetPhysicsType() const;
148 
149  inline void SetVerboseLevel(G4int value);
150  inline G4int GetVerboseLevel() const;
151  // set/get controle flag for output message
152  // 0: Silent
153  // 1: Warning message
154  // 2: More
155  // verbose level is set equal to physics list when registered
156 
157  protected:
158 
159  inline G4bool RegisterProcess(G4VProcess* process,
160  G4ParticleDefinition* particle);
161  // Register a process to the particle type
162  // according to the ordering parameter table
163  // 'true' is returned if the process is registerd successfully
164 
165  protected:
169 
175  //This returns a copy of the vector of pointers
178 public:
179  inline G4int GetInstanceID() const;
180  static const G4VPCManager& GetSubInstanceManager();
181 
182  //Method called by kernel to destroy thread-local
183  //data, equivalent to destructor in sequential mode
184  //Derived classes implementing this method, must also call
185  //this base class method.
186  virtual void TerminateWorker();
187 };
188 
189 // Inlined methods
190 
192 {
194 }
195 
197 {
198  return verboseLevel;
199 }
200 
202 {
203  namePhysics = name;
204 }
205 
207 {
208  return namePhysics;
209 }
210 
212 {
213  if (val>0) typePhysics = val;
214 }
215 
217 {
218  return typePhysics;
219 }
220 
221 inline
223  G4ParticleDefinition* particle)
224 {
226  //return aPLHelper->RegisterProcess(process, particle);
227 }
228 
229 inline
231 {
232  return subInstanceManager;
233 }
234 #endif
235 
236 
237 
238 
const XML_Char * name
Definition: expat.h:151
G4VPhysicsConstructor(const G4String &="")
PhysicsBuilders_V * _builders
void SetVerboseLevel(G4int value)
G4VUPLSplitter< G4VPCData > G4VPCManager
#define G4RUN_DLL
Definition: rundefs.hh:48
static G4RUN_DLL G4VPCManager subInstanceManager
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
G4int GetInstanceID() const
void SetPhysicsName(const G4String &="")
static const G4VPCManager & GetSubInstanceManager()
virtual void ConstructParticle()=0
virtual void ConstructProcess()=0
bool G4bool
Definition: G4Types.hh:79
const XML_Char int const XML_Char * value
Definition: expat.h:331
void AddBuilder(G4PhysicsBuilderInterface *bld)
const G4String & GetPhysicsName() const
PhysicsBuilder_V GetBuilders() const
std::vector< G4PhysicsBuilderInterface * > PhysicsBuilders_V
G4VPCManager G4VPhyscicsConstructorManager
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
G4ParticleTable::G4PTblDicIterator * _aParticleIterator
static G4PhysicsListHelper * GetPhysicsListHelper()
int G4int
Definition: G4Types.hh:78
G4ParticleTable * theParticleTable
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
G4VPCData::PhysicsBuilders_V PhysicsBuilder_V