Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VPhysicsConstructor.hh
Go to the documentation of this file.
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 101155 2016-11-08 08:21:41Z 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 // ------------------------------------------------------------
60 #ifndef G4VPhysicsConstructor_h
61 #define G4VPhysicsConstructor_h 1
62 
63 #include "globals.hh"
64 #include "rundefs.hh"
65 #include "G4ios.hh"
66 #include "G4ParticleTable.hh"
67 #include "G4PhysicsListHelper.hh"
68 #include "G4VUPLSplitter.hh"
69 
70 
71 class G4VPCData
72 {
73  //Encapsulate the fields of class G4VPhysicsConstructor
74  //that are per-thread.
75 public:
76  void initialize();
78 };
79 
80 // The type G4VPCManager is introduced to encapsulate the methods used by
81 // both the master thread and worker threads to allocate memory space for
82 // the fields encapsulated by the class G4VPCData. When each thread
83 // changes the value for these fields, it refers to them using a macro
84 // definition defined below. For every G4VPhysicsConstructor instance,
85 // there is a corresponding G4VPCData instance. All G4VPCData instances
86 // are organized by the class G4VUPLManager as an array.
87 // The field "int g4vuplInstanceID" is added to the class G4VUserPhysicsList.
88 // The value of this field in each G4VUserPhysicsList instance is the
89 // subscript of the corresponding G44VUPLData instance.
90 // In order to use the class G44VUPLManager, we add a static member in the class
91 // G4VUserPhysicsList as follows: "static G4VUPLManager subInstanceManager".
92 // Both the master thread and worker threads change the length of the array
93 // for G44VUPLData instances mutually along with G4VUserPhysicsList
94 // instances are created. For each worker thread, it dynamically creates ions.
95 // Consider any thread A, if there is any other thread which creates an ion.
96 // This ion is shared by the thread A. So the thread A leaves an empty space
97 // in the array of G4PDefData instances for the ion.
98 //
99 // Important Note: you may wonder why we are introducing this mechanism
100 // since there is only one PL for each application.
101 // This is true, in the sense that only one PL is allowed
102 // to be associated to a G4RunManager, however user can instantiate
103 // as many PLs are needed and at run-time select one of the PLs to be used
104 // we thus need this mechanism to guarantee that the system works without
105 // problems in case of this (unusual) case. This may be reviewed in the future
108 
109 // This macros change the references to fields that are now encapsulated
110 // in the class G4VPCData.
111 //
112 // Note1: the use of this-> this is needed to avoid compilation errors
113 // when using templated class with T=G4VUserPhysicsList. Don't know why.
114 // Note2: the name of the first #define is different, because otherwise
115 // we need to change its use in all classes that inherits from
116 // this base class (all examples). However one should note comment
117 // on JIRA task: http://jira-geant4.kek.jp/browse/DEV-27
118 
119 //#define aParticleIterator ((subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator)
120 
122 {
123  public: // with description
124 
125  G4VPhysicsConstructor(const G4String& ="");
126  G4VPhysicsConstructor(const G4String& name, G4int physics_type);
127  virtual ~G4VPhysicsConstructor();
128 
129  virtual void ConstructParticle()=0;
130  // This method will be invoked in the Construct() method.
131  // each particle type will be instantiated
132 
133  virtual void ConstructProcess()=0;
134  // This method will be invoked in the Construct() method.
135  // each physics process will be instantiated and
136  // registered to the process manager of each particle type
137 
138  inline void SetPhysicsName(const G4String& ="");
139  inline const G4String& GetPhysicsName() const;
140 
141  inline void SetPhysicsType(G4int);
142  inline G4int GetPhysicsType() const;
143 
144  inline void SetVerboseLevel(G4int value);
145  inline G4int GetVerboseLevel() const;
146  // set/get controle flag for output message
147  // 0: Silent
148  // 1: Warning message
149  // 2: More
150  // verbose level is set equal to physics list when registered
151 
152  protected:
153 
154  inline G4bool RegisterProcess(G4VProcess* process,
155  G4ParticleDefinition* particle);
156  // Register a process to the particle type
157  // according to the ordering parameter table
158  // 'true' is returned if the process is registerd successfully
159 
160  protected:
164 
169 public:
170  inline G4int GetInstanceID() const;
171  static const G4VPCManager& GetSubInstanceManager();
172  //G4ParticleTable::G4PTblDicIterator* aParticleIterator;
173  // the particle table has the complete List of existing particle types
174 
175  //G4PhysicsListHelper* aPLHelper;
176 };
177 
178 // Inlined methods
179 
181 {
183 }
184 
186 {
187  return verboseLevel;
188 }
189 
191 {
192  namePhysics = name;
193 }
194 
196 {
197  return namePhysics;
198 }
199 
201 {
202  if (val>0) typePhysics = val;
203 }
204 
206 {
207  return typePhysics;
208 }
209 
210 inline
212  G4ParticleDefinition* particle)
213 {
215  //return aPLHelper->RegisterProcess(process, particle);
216 }
217 
218 inline
220 {
221  return subInstanceManager;
222 }
223 #endif
224 
225 
226 
227 
G4int GetInstanceID() const
const XML_Char * name
Definition: expat.h:151
#define G4RUN_DLL
Definition: rundefs.hh:48
int G4int
Definition: G4Types.hh:78
G4ParticleTable::G4PTblDicIterator * _aParticleIterator
G4ParticleTable * theParticleTable
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
G4ParticleTable::G4PTblDicIterator * GetParticleIterator() const
virtual void ConstructParticle()=0
const XML_Char int const XML_Char * value
Definition: expat.h:331
G4VPCManager G4VPhyscicsConstructorManager
bool G4bool
Definition: G4Types.hh:79
G4bool RegisterProcess(G4VProcess *process, G4ParticleDefinition *particle)
static G4RUN_DLL G4VPCManager subInstanceManager
const G4String & GetPhysicsName() const
void SetVerboseLevel(G4int value)
G4VUPLSplitter< G4VPCData > G4VPCManager
void SetPhysicsName(const G4String &="")
static G4PhysicsListHelper * GetPhysicsListHelper()
G4VPhysicsConstructor(const G4String &="")
virtual void ConstructProcess()=0
static const G4VPCManager & GetSubInstanceManager()