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,v 1.41 2009/08/09 14:31:46 kurasige Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // ------------------------------------------------------------ |
---|
32 | // GEANT 4 class header file |
---|
33 | // Class Description: |
---|
34 | // This class is an abstract class for |
---|
35 | // constructing particles and processes. |
---|
36 | // User must implement following three virtual methods |
---|
37 | // in his/her own concrete class derived from this class. |
---|
38 | // G4VUserPhysicsList::ConstructParticle() |
---|
39 | // Construct particles |
---|
40 | // G4VUserPhysicsList::ConstructProcess() |
---|
41 | // Construct procesess and register them to particles |
---|
42 | // G4VUserPhysicsList::SetCuts() |
---|
43 | // set cut values in range to all particles |
---|
44 | // (and rebuilding physics table will be invoked ) |
---|
45 | // |
---|
46 | // ------------------------------------------- |
---|
47 | // History |
---|
48 | // first version 09 Jan. 1998 by H.Kurashige |
---|
49 | // modified 24 Jan. 1998 by H.Kurashige |
---|
50 | // rename DumpCutValues/DumpCutValuesTable |
---|
51 | // change SetCuts method |
---|
52 | // add SetCutsWithDefault method |
---|
53 | // modified 06 June 1998 by H.Kurashige |
---|
54 | // add AddProcessManager |
---|
55 | // add BuildPhysicsTable |
---|
56 | // modified 29 June 1998 by H.Kurashige |
---|
57 | // add AddProcessManager |
---|
58 | // modified 05 Dec. 1998 by H.Kurashige |
---|
59 | // add ConstructAllParticles() |
---|
60 | // modified 14, Apr 1999 by H.Kurashige |
---|
61 | // change BuildPhysicsTable as public |
---|
62 | // removed ConstructAllParticles() and related methods |
---|
63 | // changed SetCuts method argument |
---|
64 | // modified 08, Nov 2000 by H.Kurashige |
---|
65 | // added Retrieve/StorePhysicsTable and related methods |
---|
66 | // modified 08, Mar 2001 by H.Kurashige |
---|
67 | // added binary mode for Retrieve/StorePhysicsTable |
---|
68 | // added RetrieveCutValues and related |
---|
69 | // added Set/ResetStoredInAscii() to switch on ascii mode |
---|
70 | // for Retrieve/StorePhysicsTable |
---|
71 | // modified for CUTS per REGION 10, Oct 2002 by H.Kurashige |
---|
72 | // removed following methods |
---|
73 | // void ReCalcCutValue() |
---|
74 | // void SetCutValueForOthers() |
---|
75 | // void SetCutValueForOtherThan() |
---|
76 | // void ReCalcCutValueForOthers() |
---|
77 | // virtual G4bool StoreMaterialInfo() |
---|
78 | // virtual G4bool StoreCutValues() |
---|
79 | // virtual G4bool RetrieveCutValues() |
---|
80 | // virtual G4bool CheckForRetrievePhysicsTable() |
---|
81 | // virtual G4bool CheckMaterialInfo() |
---|
82 | // added void BuildPhysicsTable() |
---|
83 | // ------------------------------------------------------------ |
---|
84 | #ifndef G4VUserPhysicsList_h |
---|
85 | #define G4VUserPhysicsList_h 1 |
---|
86 | #include "globals.hh" |
---|
87 | #include "G4ios.hh" |
---|
88 | |
---|
89 | #include "G4ParticleTable.hh" |
---|
90 | #include "G4ParticleDefinition.hh" |
---|
91 | #include "G4ProductionCutsTable.hh" |
---|
92 | |
---|
93 | class G4UserPhysicsListMessenger; |
---|
94 | class G4VProcess; |
---|
95 | |
---|
96 | class G4VUserPhysicsList |
---|
97 | { |
---|
98 | public: |
---|
99 | G4VUserPhysicsList(); |
---|
100 | virtual ~G4VUserPhysicsList(); |
---|
101 | |
---|
102 | public: // with description |
---|
103 | // Each particle type will be instantiated |
---|
104 | // This method is invoked by the RunManger |
---|
105 | virtual void ConstructParticle() = 0; |
---|
106 | |
---|
107 | // By calling the "Construct" method, |
---|
108 | // process manager and processes are created. |
---|
109 | void Construct(); |
---|
110 | |
---|
111 | // Each physics process will be instantiated and |
---|
112 | // registered to the process manager of each particle type |
---|
113 | // This method is invoked in Construct method |
---|
114 | virtual void ConstructProcess() = 0; |
---|
115 | |
---|
116 | protected: // with description |
---|
117 | // User must invoke this method in his ConstructProcess() |
---|
118 | // implementation in order to insures particle transportation. |
---|
119 | // !! Caution: this class must not be overriden !! |
---|
120 | void AddTransportation(); |
---|
121 | |
---|
122 | ///////////////////////////////////////////////////////////////// |
---|
123 | public: // with description |
---|
124 | // "SetCuts" method sets a cut value for all particle types |
---|
125 | // in the particle table |
---|
126 | virtual void SetCuts() = 0; |
---|
127 | |
---|
128 | public: // with description |
---|
129 | // set/get the default cut value |
---|
130 | // Calling SetDefaultCutValue causes re-calcuration of cut values |
---|
131 | // and physics tables just before the next event loop |
---|
132 | void SetDefaultCutValue(G4double newCutValue); |
---|
133 | G4double GetDefaultCutValue() const; |
---|
134 | |
---|
135 | ///////////////////////////////////////////////////////////////////// |
---|
136 | public: // with description |
---|
137 | // Invoke BuildPhysicsTable for all processes for all particles |
---|
138 | // In case of "Retrieve" flag is ON, PhysicsTable will be |
---|
139 | // retrieved from files |
---|
140 | void BuildPhysicsTable(); |
---|
141 | |
---|
142 | // do PreparePhysicsTable for specified particle type |
---|
143 | void PreparePhysicsTable(G4ParticleDefinition* ); |
---|
144 | |
---|
145 | // do BuildPhysicsTable for specified particle type |
---|
146 | void BuildPhysicsTable(G4ParticleDefinition* ); |
---|
147 | |
---|
148 | // Store PhysicsTable together with both material and cut value |
---|
149 | // information in files under the specified directory. |
---|
150 | // (return true if files are sucessfully created) |
---|
151 | G4bool StorePhysicsTable(const G4String& directory = "."); |
---|
152 | |
---|
153 | // Return true if "Retrieve" flag is ON. |
---|
154 | // (i.e. PhysicsTable will be retrieved from files) |
---|
155 | G4bool IsPhysicsTableRetrieved() const; |
---|
156 | G4bool IsStoredInAscii() const; |
---|
157 | |
---|
158 | // Get directory path for physics table files. |
---|
159 | const G4String& GetPhysicsTableDirectory() const; |
---|
160 | |
---|
161 | // Set "Retrieve" flag |
---|
162 | // Directory path can be set together. |
---|
163 | // Null string (default) means directory is not changed |
---|
164 | // from the current value |
---|
165 | void SetPhysicsTableRetrieved(const G4String& directory = ""); |
---|
166 | void SetStoredInAscii(); |
---|
167 | |
---|
168 | // Reset "Retrieve" flag |
---|
169 | void ResetPhysicsTableRetrieved(); |
---|
170 | void ResetStoredInAscii(); |
---|
171 | |
---|
172 | /////////////////////////////////////////////////////////////////////// |
---|
173 | public: // with description |
---|
174 | // Print out the List of registered particles types |
---|
175 | void DumpList() const; |
---|
176 | |
---|
177 | public: // with description |
---|
178 | // Request to print out information of cut values |
---|
179 | // Printing will be performed when all tables are made |
---|
180 | void DumpCutValuesTable(G4int nParticles=4); |
---|
181 | |
---|
182 | // The following method actually trigger the print-out requested |
---|
183 | // by the above method. This method must be invoked by RunManager |
---|
184 | // at the proper moment. |
---|
185 | void DumpCutValuesTableIfRequested(); |
---|
186 | |
---|
187 | void DumpCutValues(const G4String &particle_name = "ALL"); |
---|
188 | void DumpCutValues(G4ParticleDefinition* ); |
---|
189 | |
---|
190 | public: // with description |
---|
191 | void SetVerboseLevel(G4int value); |
---|
192 | G4int GetVerboseLevel() const; |
---|
193 | // set/get controle flag for output message |
---|
194 | // 0: Silent |
---|
195 | // 1: Warning message |
---|
196 | // 2: More |
---|
197 | |
---|
198 | /////////////////////////////////////////////////////////////////////////// |
---|
199 | public: // with description |
---|
200 | // "SetCutsWithDefault" method sets the default cut value |
---|
201 | // for all particles for the default region. |
---|
202 | void SetCutsWithDefault(); |
---|
203 | |
---|
204 | // Following are utility methods for SetCuts |
---|
205 | |
---|
206 | // SetCutValue sets a cut value for a particle type for the default region |
---|
207 | void SetCutValue(G4double aCut, const G4String& pname); |
---|
208 | |
---|
209 | // SetCutValue sets a cut value for a particle type for a region |
---|
210 | void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname); |
---|
211 | |
---|
212 | // Invoke SetCuts for specified particle for a region |
---|
213 | // If the pointer to the region is NULL, the default region is used |
---|
214 | // In case of "Retrieve" flag is ON, |
---|
215 | // Cut values will be retrieved from files |
---|
216 | void SetParticleCuts(G4double cut,G4ParticleDefinition* particle,G4Region* region=0); |
---|
217 | |
---|
218 | // Invoke SetCuts for all particles in a region |
---|
219 | void SetCutsForRegion(G4double aCut, const G4String& rname); |
---|
220 | |
---|
221 | // Following are utility methods are obsolete |
---|
222 | void ResetCuts(); |
---|
223 | |
---|
224 | /////////////////////////////////////////////////////////////////// |
---|
225 | public: |
---|
226 | // Get/SetApplyCuts gets/sets the flag for ApplyCuts |
---|
227 | void SetApplyCuts(G4bool value, const G4String& name); |
---|
228 | G4bool GetApplyCuts(const G4String& name) const; |
---|
229 | |
---|
230 | /////////////////////////////////////////////////////////////////////////////// |
---|
231 | protected: |
---|
232 | // do BuildPhysicsTable for make the integral schema |
---|
233 | void BuildIntegralPhysicsTable(G4VProcess* ,G4ParticleDefinition* ); |
---|
234 | |
---|
235 | |
---|
236 | protected: |
---|
237 | // Retrieve PhysicsTable from files for proccess belongng the particle. |
---|
238 | // Normal BuildPhysics procedure of processes will be invoked, |
---|
239 | // if it fails (in case of Process's RetrievePhysicsTable returns false) |
---|
240 | virtual void RetrievePhysicsTable(G4ParticleDefinition* , |
---|
241 | const G4String& directory, |
---|
242 | G4bool ascii = false); |
---|
243 | |
---|
244 | ///////////////////////////////////////////////////////////////// |
---|
245 | protected: |
---|
246 | // adds new ProcessManager to all particles in the Particle Table |
---|
247 | // this routine is used in Construct() |
---|
248 | void InitializeProcessManager(); |
---|
249 | |
---|
250 | public: // with description |
---|
251 | // remove and delete ProcessManagers for all particles in tha Particle Table |
---|
252 | // this routine is invoked from RunManager |
---|
253 | void RemoveProcessManager(); |
---|
254 | |
---|
255 | public: // with description |
---|
256 | // add process manager for particles created on-the-fly |
---|
257 | void AddProcessManager(G4ParticleDefinition* newParticle, |
---|
258 | G4ProcessManager* newManager = 0 ); |
---|
259 | |
---|
260 | ///////////////////////////////////////////////////////////////// |
---|
261 | public: |
---|
262 | // check consistencies of list of particles |
---|
263 | |
---|
264 | void CheckParticleList(); |
---|
265 | |
---|
266 | void DisableCheckParticleList(); |
---|
267 | |
---|
268 | protected: |
---|
269 | |
---|
270 | bool fDisableCheckParticleList; |
---|
271 | |
---|
272 | //////////////////////////////////////////////////////////////////////// |
---|
273 | protected: |
---|
274 | // the particle table has the complete List of existing particle types |
---|
275 | G4ParticleTable* theParticleTable; |
---|
276 | G4ParticleTable::G4PTblDicIterator* theParticleIterator; |
---|
277 | |
---|
278 | protected: |
---|
279 | // pointer to G4UserPhysicsListMessenger |
---|
280 | G4UserPhysicsListMessenger* theMessenger; |
---|
281 | |
---|
282 | protected: |
---|
283 | G4int verboseLevel; |
---|
284 | |
---|
285 | protected: |
---|
286 | // this is the default cut value for all particles |
---|
287 | G4double defaultCutValue; |
---|
288 | |
---|
289 | protected: |
---|
290 | // pointer to ProductionCutsTable |
---|
291 | G4ProductionCutsTable* fCutsTable; |
---|
292 | |
---|
293 | // flag to determine physics table will be build from file or not |
---|
294 | G4bool fRetrievePhysicsTable; |
---|
295 | G4bool fStoredInAscii; |
---|
296 | |
---|
297 | G4bool fIsCheckedForRetrievePhysicsTable; |
---|
298 | G4bool fIsRestoredCutValues; |
---|
299 | |
---|
300 | // directory name for physics table files |
---|
301 | G4String directoryPhysicsTable; |
---|
302 | |
---|
303 | // flag for displaying the range cuts & energy thresholds |
---|
304 | G4int fDisplayThreshold; |
---|
305 | |
---|
306 | // flag for Physics Table has been built |
---|
307 | G4bool fIsPhysicsTableBuilt; |
---|
308 | |
---|
309 | private: |
---|
310 | enum { FixedStringLengthForStore = 32 }; |
---|
311 | |
---|
312 | |
---|
313 | private: |
---|
314 | G4bool useCoupledTransportation; |
---|
315 | |
---|
316 | public: |
---|
317 | inline void UseCoupledTransportation(G4bool vl=true) |
---|
318 | { useCoupledTransportation = vl; } |
---|
319 | |
---|
320 | //////////////////////////////////////////////////////////////////////////// |
---|
321 | // Following method is for backward compatibility and removed soon |
---|
322 | //////////////////////////////////////////////////////////////////////////// |
---|
323 | protected: |
---|
324 | void SetCutValueForOthers(G4double) const; |
---|
325 | |
---|
326 | }; |
---|
327 | |
---|
328 | inline |
---|
329 | void G4VUserPhysicsList::SetCutValueForOthers(G4double) const |
---|
330 | { |
---|
331 | G4cerr << "WARNING !" << G4endl; |
---|
332 | G4cerr << " SetCutValueForOthers became obsolete." << G4endl; |
---|
333 | G4cerr << " It is harmless to remove this invokation without any side effects." << G4endl; |
---|
334 | G4cerr << " This dummy method implementation will be removed soon." << G4endl; |
---|
335 | } |
---|
336 | |
---|
337 | inline void G4VUserPhysicsList::Construct() |
---|
338 | { |
---|
339 | #ifdef G4VERBOSE |
---|
340 | if (verboseLevel >1) G4cout << "G4VUserPhysicsList::Construct()" << G4endl; |
---|
341 | #endif |
---|
342 | |
---|
343 | InitializeProcessManager(); |
---|
344 | |
---|
345 | #ifdef G4VERBOSE |
---|
346 | if (verboseLevel >1) G4cout << "Construct processes " << G4endl; |
---|
347 | #endif |
---|
348 | ConstructProcess(); |
---|
349 | |
---|
350 | } |
---|
351 | |
---|
352 | inline G4double G4VUserPhysicsList::GetDefaultCutValue() const |
---|
353 | { |
---|
354 | return defaultCutValue; |
---|
355 | } |
---|
356 | |
---|
357 | |
---|
358 | inline G4int G4VUserPhysicsList::GetVerboseLevel() const |
---|
359 | { |
---|
360 | return verboseLevel; |
---|
361 | } |
---|
362 | |
---|
363 | inline |
---|
364 | G4bool G4VUserPhysicsList::IsPhysicsTableRetrieved() const |
---|
365 | { |
---|
366 | return fRetrievePhysicsTable; |
---|
367 | } |
---|
368 | |
---|
369 | inline |
---|
370 | G4bool G4VUserPhysicsList::IsStoredInAscii() const |
---|
371 | { |
---|
372 | return fStoredInAscii; |
---|
373 | } |
---|
374 | |
---|
375 | inline |
---|
376 | const G4String& G4VUserPhysicsList::GetPhysicsTableDirectory() const |
---|
377 | { |
---|
378 | return directoryPhysicsTable; |
---|
379 | } |
---|
380 | |
---|
381 | inline |
---|
382 | void G4VUserPhysicsList::SetStoredInAscii() |
---|
383 | { |
---|
384 | fStoredInAscii = true; |
---|
385 | } |
---|
386 | |
---|
387 | |
---|
388 | inline |
---|
389 | void G4VUserPhysicsList::ResetPhysicsTableRetrieved() |
---|
390 | { |
---|
391 | fRetrievePhysicsTable = false; |
---|
392 | fIsRestoredCutValues = false; |
---|
393 | fIsCheckedForRetrievePhysicsTable=false; |
---|
394 | } |
---|
395 | |
---|
396 | |
---|
397 | inline |
---|
398 | void G4VUserPhysicsList::ResetStoredInAscii() |
---|
399 | { |
---|
400 | fStoredInAscii = false; |
---|
401 | } |
---|
402 | |
---|
403 | inline |
---|
404 | void G4VUserPhysicsList::DisableCheckParticleList() |
---|
405 | { |
---|
406 | fDisableCheckParticleList = true; |
---|
407 | } |
---|
408 | |
---|
409 | |
---|
410 | #endif |
---|
411 | |
---|