1 | <!-- ******************************************************** --> |
---|
2 | <!-- --> |
---|
3 | <!-- [History] --> |
---|
4 | <!-- Changed by: Katsuya Amako, 9-Jul-1998 --> |
---|
5 | <!-- Changed by: Katsuya Amako, 4-Aug-1998 --> |
---|
6 | <!-- Changed by: John Allison, 4-Aug-1998 --> |
---|
7 | <!-- Changed by: Katsuya Amako, 30-Nov-1998 --> |
---|
8 | <!-- Changed by: Dennis Wright, 29-Nov-2001 --> |
---|
9 | <!-- Changed by: Makoto Asai, 22-Apr-2003 --> |
---|
10 | <!-- Proof read by: Joe Chuma, 2-Jul-1999 --> |
---|
11 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 --> |
---|
12 | <!-- --> |
---|
13 | <!-- ******************************************************** --> |
---|
14 | |
---|
15 | |
---|
16 | <!-- ******************* Section (Level#1) ****************** --> |
---|
17 | <sect1 id="sect.ManUAct"> |
---|
18 | <title> |
---|
19 | Mandatory User Actions and Initializations |
---|
20 | </title> |
---|
21 | |
---|
22 | <para> |
---|
23 | Geant4 has three virtual classes whose methods the user must |
---|
24 | override in order to implement a simulation. They require the user |
---|
25 | to define the detector, specify the physics to be used, and |
---|
26 | describe how initial particles are to be generated. |
---|
27 | </para> |
---|
28 | |
---|
29 | <!-- ******* Bridgehead ******* --> |
---|
30 | <bridgehead renderas='sect4'> |
---|
31 | <literal>G4VUserDetectorConstruction</literal> |
---|
32 | </bridgehead> |
---|
33 | |
---|
34 | <para> |
---|
35 | <example id="programlist_ManUAct_1"> |
---|
36 | <title> |
---|
37 | <literal>G4VUserDetectorConstruction</literal> |
---|
38 | </title> |
---|
39 | |
---|
40 | <programlisting> |
---|
41 | class G4VUserDetectorConstruction |
---|
42 | { |
---|
43 | public: |
---|
44 | G4VUserDetectorConstruction(); |
---|
45 | virtual ~G4VUserDetectorConstruction(); |
---|
46 | |
---|
47 | public: |
---|
48 | virtual G4VPhysicalVolume* Construct() = 0; |
---|
49 | }; |
---|
50 | </programlisting> |
---|
51 | </example> |
---|
52 | </para> |
---|
53 | |
---|
54 | |
---|
55 | <!-- ******* Bridgehead ******* --> |
---|
56 | <bridgehead renderas='sect4'> |
---|
57 | <literal>G4VUserPhysicsList</literal> |
---|
58 | </bridgehead> |
---|
59 | |
---|
60 | <para> |
---|
61 | This is an abstract class for constructing particles and |
---|
62 | processes. The user must derive a concrete class from it and |
---|
63 | implement three virtual methods: |
---|
64 | |
---|
65 | <itemizedlist spacing="compact"> |
---|
66 | <listitem><para> |
---|
67 | <literal>ConstructParticle()</literal> to instantiate each requested |
---|
68 | particle type, |
---|
69 | </para></listitem> |
---|
70 | <listitem><para> |
---|
71 | <literal>ConstructPhysics()</literal> to instantiate the desired physics |
---|
72 | processes and register each of them with the process managers of |
---|
73 | the appropriate particles, and |
---|
74 | </para></listitem> |
---|
75 | <listitem><para> |
---|
76 | <literal>SetCuts(G4double aValue)</literal> to set a cut value in range |
---|
77 | for all particles in the particle table, which invokes the |
---|
78 | rebuilding of the physics table. |
---|
79 | </para></listitem> |
---|
80 | </itemizedlist> |
---|
81 | </para> |
---|
82 | |
---|
83 | <para> |
---|
84 | When called, the <literal>Construct()</literal> method of |
---|
85 | <emphasis>G4VUserPhysicsList</emphasis> first invokes |
---|
86 | <literal>ConstructParticle()</literal> and then <literal>ConstructProcess()</literal>. |
---|
87 | The <literal>ConstructProcess()</literal> method must always invoke the |
---|
88 | <literal>AddTransportation()</literal> method in order to insure particle |
---|
89 | transportation. <literal>AddTransportation()</literal> must never be |
---|
90 | overridden. |
---|
91 | </para> |
---|
92 | |
---|
93 | <para> |
---|
94 | <emphasis>G4VUserPhysicsList</emphasis> provides several utility methods for |
---|
95 | the implementation of the above virtual methods. They are presented |
---|
96 | with comments in the class declaration in <xref linkend="programlist_ManUAct_2" |
---|
97 | />. |
---|
98 | |
---|
99 | <example id="programlist_ManUAct_2"> |
---|
100 | <title> |
---|
101 | <literal>G4VUserPhysicsList</literal> |
---|
102 | </title> |
---|
103 | |
---|
104 | <programlisting> |
---|
105 | class G4VUserPhysicsList |
---|
106 | { |
---|
107 | public: |
---|
108 | G4VUserPhysicsList(); |
---|
109 | virtual ~G4VUserPhysicsList(); |
---|
110 | |
---|
111 | public: // with description |
---|
112 | // By calling the "Construct" method, |
---|
113 | // particles and processes are created |
---|
114 | void Construct(); |
---|
115 | |
---|
116 | protected: // with description |
---|
117 | // These two methods of ConstructParticle() and ConstructProcess() |
---|
118 | // will be invoked in the Construct() method. |
---|
119 | |
---|
120 | // each particle type will be instantiated |
---|
121 | virtual void ConstructParticle() = 0; |
---|
122 | |
---|
123 | // each physics process will be instantiated and |
---|
124 | // registered to the process manager of each particle type |
---|
125 | virtual void ConstructProcess() = 0; |
---|
126 | |
---|
127 | protected: // with description |
---|
128 | // User must invoke this method in his ConstructProcess() |
---|
129 | // implementation in order to insures particle transportation. |
---|
130 | // !! Caution: this class must not be overriden !! |
---|
131 | void AddTransportation(); |
---|
132 | |
---|
133 | ///////////////////////////////////////////////////////////////// |
---|
134 | public: // with description |
---|
135 | // "SetCuts" method sets a cut value for all particle types |
---|
136 | // in the particle table |
---|
137 | virtual void SetCuts() = 0; |
---|
138 | |
---|
139 | public: // with description |
---|
140 | // set/get the default cut value |
---|
141 | // Calling SetDefaultCutValue causes re-calcuration of cut values |
---|
142 | // and physics tables just before the next event loop |
---|
143 | void SetDefaultCutValue(G4double newCutValue); |
---|
144 | G4double GetDefaultCutValue() const; |
---|
145 | </programlisting> |
---|
146 | </example> |
---|
147 | <informalexample> |
---|
148 | <programlisting> |
---|
149 | ///////////////////////////////////////////////////////////////////// |
---|
150 | public: // with description |
---|
151 | // Invoke BuildPhysicsTable for all processes for all particles |
---|
152 | // In case of "Retrieve" flag is ON, PhysicsTable will be |
---|
153 | // retrieved from files |
---|
154 | void BuildPhysicsTable(); |
---|
155 | |
---|
156 | // do BuildPhysicsTable for specified particle type |
---|
157 | void BuildPhysicsTable(G4ParticleDefinition* ); |
---|
158 | |
---|
159 | // Store PhysicsTable together with both material and cut value |
---|
160 | // information in files under the specified directory. |
---|
161 | // (return true if files are sucessfully created) |
---|
162 | G4bool StorePhysicsTable(const G4String& directory = "."); |
---|
163 | |
---|
164 | // Return true if "Retrieve" flag is ON. |
---|
165 | // (i.e. PhysicsTable will be retrieved from files) |
---|
166 | G4bool IsPhysicsTableRetrieved() const; |
---|
167 | G4bool IsStoredInAscii() const; |
---|
168 | |
---|
169 | // Get directory path for physics table files. |
---|
170 | const G4String& GetPhysicsTableDirectory() const; |
---|
171 | |
---|
172 | // Set "Retrieve" flag |
---|
173 | // Directory path can be set together. |
---|
174 | // Null string (default) means directory is not changed |
---|
175 | // from the current value |
---|
176 | void SetPhysicsTableRetrieved(const G4String& directory = ""); |
---|
177 | void SetStoredInAscii(); |
---|
178 | |
---|
179 | // Reset "Retrieve" flag |
---|
180 | void ResetPhysicsTableRetrieved(); |
---|
181 | void ResetStoredInAscii(); |
---|
182 | |
---|
183 | /////////////////////////////////////////////////////////////////////// |
---|
184 | public: // with description |
---|
185 | // Print out the List of registered particles types |
---|
186 | void DumpList() const; |
---|
187 | |
---|
188 | public: // with description |
---|
189 | // Request to print out information of cut values |
---|
190 | // Printing will be performed when all tables are made |
---|
191 | void DumpCutValuesTable(G4int nParticles=3); |
---|
192 | |
---|
193 | // The following method actually trigger the print-out requested |
---|
194 | // by the above method. This method must be invoked by RunManager |
---|
195 | // at the proper moment. |
---|
196 | void DumpCutValuesTableIfRequested(); |
---|
197 | |
---|
198 | public: // with description |
---|
199 | void SetVerboseLevel(G4int value); |
---|
200 | G4int GetVerboseLevel() const; |
---|
201 | // set/get controle flag for output message |
---|
202 | // 0: Silent |
---|
203 | // 1: Warning message |
---|
204 | // 2: More |
---|
205 | </programlisting> |
---|
206 | </informalexample> |
---|
207 | <informalexample> |
---|
208 | <programlisting> |
---|
209 | /////////////////////////////////////////////////////////////////////////// |
---|
210 | public: // with description |
---|
211 | // "SetCutsWithDefault" method sets the default cut value |
---|
212 | // for all particles for the default region. |
---|
213 | void SetCutsWithDefault(); |
---|
214 | |
---|
215 | // Following are utility methods for SetCuts |
---|
216 | |
---|
217 | // SetCutValue sets a cut value for a particle type for the default region |
---|
218 | void SetCutValue(G4double aCut, const G4String& pname); |
---|
219 | |
---|
220 | // SetCutValue sets a cut value for a particle type for a region |
---|
221 | void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname); |
---|
222 | |
---|
223 | // Invoke SetCuts for specified particle for a region |
---|
224 | // If the pointer to the region is NULL, the default region is used |
---|
225 | // In case of "Retrieve" flag is ON, |
---|
226 | // Cut values will be retrieved from files |
---|
227 | void SetParticleCuts(G4double cut,G4ParticleDefinition* particle,G4Region* region=0); |
---|
228 | |
---|
229 | // Invoke SetCuts for all particles in a region |
---|
230 | void SetCutsForRegion(G4double aCut, const G4String& rname); |
---|
231 | |
---|
232 | // Following are utility methods are obsolete |
---|
233 | void ResetCuts(); |
---|
234 | |
---|
235 | /////////////////////////////////////////////////////////////////// |
---|
236 | public: |
---|
237 | // Get/SetApplyCuts gets/sets the flag for ApplyCuts |
---|
238 | void SetApplyCuts(G4bool value, const G4String& name); |
---|
239 | G4bool GetApplyCuts(const G4String& name) const; |
---|
240 | |
---|
241 | /////////////////////////////////////////////////////////////////////////////// |
---|
242 | protected: |
---|
243 | // do BuildPhysicsTable for make the integral schema |
---|
244 | void BuildIntegralPhysicsTable(G4VProcess* ,G4ParticleDefinition* ); |
---|
245 | |
---|
246 | |
---|
247 | protected: |
---|
248 | // Retrieve PhysicsTable from files for proccess belongng the particle. |
---|
249 | // Normal BuildPhysics procedure of processes will be invoked, |
---|
250 | // if it fails (in case of Process's RetrievePhysicsTable returns false) |
---|
251 | virtual void RetrievePhysicsTable(G4ParticleDefinition* , |
---|
252 | const G4String& directory, |
---|
253 | G4bool ascii = false); |
---|
254 | |
---|
255 | ///////////////////////////////////////////////////////////////// |
---|
256 | protected: |
---|
257 | // adds new ProcessManager to all particles in the Particle Table |
---|
258 | // this routine is used in Construct() |
---|
259 | void InitializeProcessManager(); |
---|
260 | |
---|
261 | public: // with description |
---|
262 | // remove and delete ProcessManagers for all particles in tha Particle Table |
---|
263 | // this routine is invoked from RunManager |
---|
264 | void RemoveProcessManager(); |
---|
265 | |
---|
266 | public: // with description |
---|
267 | // add process manager for particles created on-the-fly |
---|
268 | void AddProcessManager(G4ParticleDefinition* newParticle, |
---|
269 | G4ProcessManager* newManager = 0 ); |
---|
270 | |
---|
271 | }; |
---|
272 | </programlisting> |
---|
273 | </informalexample> |
---|
274 | </para> |
---|
275 | |
---|
276 | |
---|
277 | <!-- ******* Bridgehead ******* --> |
---|
278 | <bridgehead renderas='sect4'> |
---|
279 | <literal>G4VUserPrimaryGeneratorAction</literal> |
---|
280 | </bridgehead> |
---|
281 | |
---|
282 | <para> |
---|
283 | <example id="programlist_ManUAct_3"> |
---|
284 | <title> |
---|
285 | <literal>G4VUserPrimaryGeneratorAction</literal> |
---|
286 | </title> |
---|
287 | |
---|
288 | <programlisting> |
---|
289 | class G4VUserPrimaryGeneratorAction |
---|
290 | { |
---|
291 | public: |
---|
292 | G4VUserPrimaryGeneratorAction(); |
---|
293 | virtual ~G4VUserPrimaryGeneratorAction(); |
---|
294 | |
---|
295 | public: |
---|
296 | virtual void GeneratePrimaries(G4Event* anEvent) = 0; |
---|
297 | }; |
---|
298 | </programlisting> |
---|
299 | </example> |
---|
300 | </para> |
---|
301 | |
---|
302 | |
---|
303 | </sect1> |
---|