1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> |
---|
2 | <HTML> |
---|
3 | <HEAD> |
---|
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 | |
---|
12 | <META NAME="GENERATOR" CONTENT="Mozilla/3.0Gold (X11; I; OSF1 V4.0 alpha) [Netscape]"> |
---|
13 | </HEAD> |
---|
14 | <BODY> |
---|
15 | <TABLE WIDTH="100%" > |
---|
16 | <TR> |
---|
17 | <TD> |
---|
18 | </A> |
---|
19 | <A HREF="index.html"> |
---|
20 | <IMG SRC="../../../../resources/html/IconsGIF/Contents.gif" ALT="Contents" HEIGHT=16 WIDTH=59></A> |
---|
21 | <A> |
---|
22 | <IMG SRC="../../../../resources/html/IconsGIF/PreviousGR.gif" ALT="Previous" HEIGHT=16 WIDTH=59></A> |
---|
23 | <A HREF="OptionalActions.html"> |
---|
24 | <IMG SRC="../../../../resources/html/IconsGIF/Next.gif" ALT="Next" HEIGHT=16 WIDTH=59></A> |
---|
25 | </TD> |
---|
26 | |
---|
27 | <TD ALIGN="Right"> |
---|
28 | <FONT COLOR="#238E23"><FONT SIZE=-1> |
---|
29 | <B>Geant4 User's Guide</B> <BR> |
---|
30 | <B>For Application Developers</B> <BR> |
---|
31 | <B>User Actions</B> </FONT></FONT> |
---|
32 | </TD> |
---|
33 | </TR> |
---|
34 | </TABLE> |
---|
35 | <P><BR> |
---|
36 | |
---|
37 | <CENTER><FONT COLOR="#238E23"><FONT SIZE=+3> |
---|
38 | <B>6.1 Mandatory User Actions and Initializations</B> |
---|
39 | </FONT></FONT> |
---|
40 | <BR><BR> |
---|
41 | </CENTER> |
---|
42 | |
---|
43 | <HR ALIGN="Center" SIZE="7%"> |
---|
44 | <p> |
---|
45 | |
---|
46 | Geant4 has three virtual classes whose methods the user must override in order |
---|
47 | to implement a simulation. They require the user to define the detector, |
---|
48 | specify the physics to be used, and describe how initial particles are to be |
---|
49 | generated. |
---|
50 | <p> |
---|
51 | |
---|
52 | <H3><tt>G4VUserDetectorConstruction</tt></H3> |
---|
53 | <p> |
---|
54 | <center> |
---|
55 | <table border=2 cellpadding=10> |
---|
56 | <tr> |
---|
57 | <td> |
---|
58 | <pre> |
---|
59 | class G4VUserDetectorConstruction |
---|
60 | { |
---|
61 | public: |
---|
62 | G4VUserDetectorConstruction(); |
---|
63 | virtual ~G4VUserDetectorConstruction(); |
---|
64 | |
---|
65 | public: |
---|
66 | virtual G4VPhysicalVolume* Construct() = 0; |
---|
67 | }; |
---|
68 | |
---|
69 | </pre> |
---|
70 | </td> |
---|
71 | </tr> |
---|
72 | <tr> |
---|
73 | <td align=center> |
---|
74 | Source listing 6.1.1<BR> |
---|
75 | <tt>G4VUserDetectorConstruction</tt> |
---|
76 | </td> |
---|
77 | </tr> |
---|
78 | </table></center> |
---|
79 | <p> |
---|
80 | |
---|
81 | <H3><tt>G4VUserPhysicsList</tt></H3> |
---|
82 | <p> |
---|
83 | This is an abstract class for constructing particles and processes. The user |
---|
84 | must derive a concrete class from it and implement three virtual methods: |
---|
85 | <UL> |
---|
86 | <LI><tt>ConstructParticle()</tt> to instantiate each requested particle |
---|
87 | type,</LI> |
---|
88 | <LI><tt>ConstructPhysics()</tt> to instantiate the desired physics processes |
---|
89 | and register each of them with the process managers of the |
---|
90 | appropriate particles, and </LI> |
---|
91 | <LI><tt>SetCuts(G4double aValue)</tt> to set a cut value in range for all |
---|
92 | particles in the particle table, which invokes the rebuilding of the |
---|
93 | physics table.</LI> |
---|
94 | </UL> |
---|
95 | <p> |
---|
96 | When called, the <tt>Construct()</tt> method of <i>G4VUserPhysicsList</i> |
---|
97 | first invokes <tt>ConstructParticle()</tt> and then |
---|
98 | <tt>ConstructProcess()</tt>. The <tt>ConstructProcess()</tt> method must |
---|
99 | always invoke the <tt>AddTransportation()</tt> method in order to insure |
---|
100 | particle transportation. <tt>AddTransportation()</tt> must never be |
---|
101 | overridden.</p> |
---|
102 | <p> |
---|
103 | <i>G4VUserPhysicsList</i> provides several utility methods for the |
---|
104 | implementation of the above virtual methods. They are presented with comments |
---|
105 | in the class declaration in source listing 6.1.2.</p> |
---|
106 | |
---|
107 | <center> |
---|
108 | <table border=2 cellpadding=10> |
---|
109 | <tr> |
---|
110 | <td> |
---|
111 | <pre> |
---|
112 | |
---|
113 | class G4VUserPhysicsList |
---|
114 | { |
---|
115 | public: |
---|
116 | G4VUserPhysicsList(); |
---|
117 | virtual ~G4VUserPhysicsList(); |
---|
118 | |
---|
119 | public: // with description |
---|
120 | // By calling the "Construct" method, |
---|
121 | // particles and processes are created |
---|
122 | void Construct(); |
---|
123 | |
---|
124 | |
---|
125 | protected: // with description |
---|
126 | // These two methods of ConstructParticle() and ConstructProcess() |
---|
127 | // will be invoked in the Construct() method. |
---|
128 | |
---|
129 | // each particle type will be instantiated |
---|
130 | virtual void ConstructParticle() = 0; |
---|
131 | |
---|
132 | // each physics process will be instantiated and |
---|
133 | // registered to the process manager of each particle type |
---|
134 | virtual void ConstructProcess() = 0; |
---|
135 | |
---|
136 | protected: // with description |
---|
137 | // User must invoke this method in his ConstructProcess() |
---|
138 | // implementation in order to insures particle transportation. |
---|
139 | // !! Caution: this class must not be overriden !! |
---|
140 | void AddTransportation(); |
---|
141 | |
---|
142 | ///////////////////////////////////////////////////////////////// |
---|
143 | public: // with description |
---|
144 | // "SetCuts" method sets a cut value for all particle types |
---|
145 | // in the particle table |
---|
146 | virtual void SetCuts() = 0; |
---|
147 | |
---|
148 | public: // with description |
---|
149 | // set/get the default cut value |
---|
150 | // Calling SetDefaultCutValue causes re-calcuration of cut values |
---|
151 | // and physics tables just before the next event loop |
---|
152 | void SetDefaultCutValue(G4double newCutValue); |
---|
153 | G4double GetDefaultCutValue() const; |
---|
154 | |
---|
155 | ///////////////////////////////////////////////////////////////////// |
---|
156 | public: // with description |
---|
157 | // Invoke BuildPhysicsTable for all processes for all particles |
---|
158 | // In case of "Retrieve" flag is ON, PhysicsTable will be |
---|
159 | // retrieved from files |
---|
160 | void BuildPhysicsTable(); |
---|
161 | |
---|
162 | // do BuildPhysicsTable for specified particle type |
---|
163 | void BuildPhysicsTable(G4ParticleDefinition* ); |
---|
164 | |
---|
165 | // Store PhysicsTable together with both material and cut value |
---|
166 | // information in files under the specified directory. |
---|
167 | // (return true if files are sucessfully created) |
---|
168 | G4bool StorePhysicsTable(const G4String& directory = "."); |
---|
169 | |
---|
170 | // Return true if "Retrieve" flag is ON. |
---|
171 | // (i.e. PhysicsTable will be retrieved from files) |
---|
172 | G4bool IsPhysicsTableRetrieved() const; |
---|
173 | G4bool IsStoredInAscii() const; |
---|
174 | |
---|
175 | // Get directory path for physics table files. |
---|
176 | const G4String& GetPhysicsTableDirectory() const; |
---|
177 | |
---|
178 | // Set "Retrieve" flag |
---|
179 | // Directory path can be set together. |
---|
180 | // Null string (default) means directory is not changed |
---|
181 | // from the current value |
---|
182 | void SetPhysicsTableRetrieved(const G4String& directory = ""); |
---|
183 | void SetStoredInAscii(); |
---|
184 | |
---|
185 | // Reset "Retrieve" flag |
---|
186 | void ResetPhysicsTableRetrieved(); |
---|
187 | void ResetStoredInAscii(); |
---|
188 | |
---|
189 | /////////////////////////////////////////////////////////////////////// |
---|
190 | public: // with description |
---|
191 | // Print out the List of registered particles types |
---|
192 | void DumpList() const; |
---|
193 | |
---|
194 | public: // with description |
---|
195 | // Request to print out information of cut values |
---|
196 | // Printing will be performed when all tables are made |
---|
197 | void DumpCutValuesTable(G4int nParticles=3); |
---|
198 | |
---|
199 | // The following method actually trigger the print-out requested |
---|
200 | // by the above method. This method must be invoked by RunManager |
---|
201 | // at the proper moment. |
---|
202 | void DumpCutValuesTableIfRequested(); |
---|
203 | |
---|
204 | public: // with description |
---|
205 | void SetVerboseLevel(G4int value); |
---|
206 | G4int GetVerboseLevel() const; |
---|
207 | // set/get controle flag for output message |
---|
208 | // 0: Silent |
---|
209 | // 1: Warning message |
---|
210 | // 2: More |
---|
211 | |
---|
212 | /////////////////////////////////////////////////////////////////////////// |
---|
213 | public: // with description |
---|
214 | // "SetCutsWithDefault" method sets the default cut value |
---|
215 | // for all particles for the default region. |
---|
216 | void SetCutsWithDefault(); |
---|
217 | |
---|
218 | // Following are utility methods for SetCuts |
---|
219 | |
---|
220 | // SetCutValue sets a cut value for a particle type for the default region |
---|
221 | void SetCutValue(G4double aCut, const G4String& pname); |
---|
222 | |
---|
223 | // SetCutValue sets a cut value for a particle type for a region |
---|
224 | void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname); |
---|
225 | |
---|
226 | // Invoke SetCuts for specified particle for a region |
---|
227 | // If the pointer to the region is NULL, the default region is used |
---|
228 | // In case of "Retrieve" flag is ON, |
---|
229 | // Cut values will be retrieved from files |
---|
230 | void SetParticleCuts(G4double cut,G4ParticleDefinition* particle,G4Region* region=0); |
---|
231 | |
---|
232 | // Invoke SetCuts for all particles in a region |
---|
233 | void SetCutsForRegion(G4double aCut, const G4String& rname); |
---|
234 | |
---|
235 | // Following are utility methods are obsolete |
---|
236 | void ResetCuts(); |
---|
237 | |
---|
238 | /////////////////////////////////////////////////////////////////// |
---|
239 | public: |
---|
240 | // Get/SetApplyCuts gets/sets the flag for ApplyCuts |
---|
241 | void SetApplyCuts(G4bool value, const G4String& name); |
---|
242 | G4bool GetApplyCuts(const G4String& name) const; |
---|
243 | |
---|
244 | /////////////////////////////////////////////////////////////////////////////// |
---|
245 | protected: |
---|
246 | // do BuildPhysicsTable for make the integral schema |
---|
247 | void BuildIntegralPhysicsTable(G4VProcess* ,G4ParticleDefinition* ); |
---|
248 | |
---|
249 | |
---|
250 | protected: |
---|
251 | // Retrieve PhysicsTable from files for proccess belongng the particle. |
---|
252 | // Normal BuildPhysics procedure of processes will be invoked, |
---|
253 | // if it fails (in case of Process's RetrievePhysicsTable returns false) |
---|
254 | virtual void RetrievePhysicsTable(G4ParticleDefinition* , |
---|
255 | const G4String& directory, |
---|
256 | G4bool ascii = false); |
---|
257 | |
---|
258 | ///////////////////////////////////////////////////////////////// |
---|
259 | protected: |
---|
260 | // adds new ProcessManager to all particles in the Particle Table |
---|
261 | // this routine is used in Construct() |
---|
262 | void InitializeProcessManager(); |
---|
263 | |
---|
264 | public: // with description |
---|
265 | // remove and delete ProcessManagers for all particles in tha Particle Table |
---|
266 | // this routine is invoked from RunManager |
---|
267 | void RemoveProcessManager(); |
---|
268 | |
---|
269 | public: // with description |
---|
270 | // add process manager for particles created on-the-fly |
---|
271 | void AddProcessManager(G4ParticleDefinition* newParticle, |
---|
272 | G4ProcessManager* newManager = 0 ); |
---|
273 | |
---|
274 | }; |
---|
275 | |
---|
276 | |
---|
277 | |
---|
278 | </pre> |
---|
279 | </td> |
---|
280 | </tr> |
---|
281 | <tr> |
---|
282 | <td align=center> |
---|
283 | Source listing 6.1.2<BR> |
---|
284 | <tt>G4VUserPhysicsList</tt> |
---|
285 | </td> |
---|
286 | </tr> |
---|
287 | </table></center> |
---|
288 | <p> |
---|
289 | |
---|
290 | <b><tt>G4VUserPrimaryGeneratorAction</tt></b> |
---|
291 | <p> |
---|
292 | <center> |
---|
293 | <table border=2 cellpadding=10> |
---|
294 | <tr> |
---|
295 | <td> |
---|
296 | <pre> |
---|
297 | class G4VUserPrimaryGeneratorAction |
---|
298 | { |
---|
299 | public: |
---|
300 | G4VUserPrimaryGeneratorAction(); |
---|
301 | virtual ~G4VUserPrimaryGeneratorAction(); |
---|
302 | |
---|
303 | public: |
---|
304 | virtual void GeneratePrimaries(G4Event* anEvent) = 0; |
---|
305 | }; |
---|
306 | |
---|
307 | </pre> |
---|
308 | </td> |
---|
309 | </tr> |
---|
310 | <tr> |
---|
311 | <td align=center> |
---|
312 | Source listing 6.1.3<BR> |
---|
313 | <tt>G4VUserPrimaryGeneratorAction</tt> |
---|
314 | </td> |
---|
315 | </tr> |
---|
316 | </table></center> |
---|
317 | <p> |
---|
318 | |
---|
319 | <BR><BR> |
---|
320 | <HR><A HREF="../../../../Authors/html/subjectsToAuthors.html"> |
---|
321 | <I>About the authors</A></I> </P></CENTER> |
---|
322 | |
---|
323 | </BODY> |
---|
324 | </HTML> |
---|