Geant4-11
G4Scheduler.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// Author: Mathieu Karamitros
28
29// The code is developed in the framework of the ESA AO7146
30//
31// We would be very happy hearing from you, send us your feedback! :)
32//
33// In order for Geant4-DNA to be maintained and still open-source,
34// article citations are crucial.
35// If you use Geant4-DNA chemistry and you publish papers about your software,
36// in addition to the general paper on Geant4-DNA:
37//
38// Int. J. Model. Simul. Sci. Comput. 1 (2010) 157–178
39//
40// we would be very happy if you could please also cite the following
41// reference papers on chemistry:
42//
43// J. Comput. Phys. 274 (2014) 841-882
44// Prog. Nucl. Sci. Tec. 2 (2011) 503-508
45
46
47
48#ifndef G4Scheduler_h
49#define G4Scheduler_h
50
51#include <G4VScheduler.hh>
52#include <vector>
53#include <map>
54#include <memory>
55
56#include "globals.hh"
57
58#include "G4ITModelHandler.hh"
59#include "G4ITStepStatus.hh"
60#include "G4ITTrackHolder.hh"
61#include "G4VStateDependent.hh"
62#include "G4ITReaction.hh"
64
68class G4Track;
72class G4ITGun;
73
74#ifndef compTrackPerID__
75#define compTrackPerID__
76 struct compTrackPerID
77 {
78 G4bool operator()(G4Track* rhs, G4Track* lhs) const
79 {
80 return rhs->GetTrackID() < lhs->GetTrackID();
81 }
82 };
83#endif
84
89 public G4VScheduler,
91{
92protected:
93 virtual ~G4Scheduler();
94
95public:
96 static G4Scheduler* Instance();
100 static void DeleteInstance();
101 virtual G4bool Notify(G4ApplicationState requestedState);
102
103 virtual void RegisterModel(G4VITStepModel*, G4double);
104
105 void Initialize();
107 inline G4bool IsInitialized();
108 inline G4bool IsRunning(){return fRunning;}
109 void Reset();
110 void Process();
111 void ClearList();
112
113 inline void SetGun(G4ITGun*);
114 inline G4ITGun* GetGun();
115
116 inline void Stop();
117 void Clear();
118
119 // To be called only in UserReactionAction::EndProcessing()
120 // after fRunning flag has been turned off.
121 // This is not done automatically before UserReactionAction::EndProcessing()
122 // is called in case one would like to access some track information
123 void EndTracking();
124
125 void SetEndTime(const G4double);
126
127 /* Two tracks below the time tolerance are supposed to be
128 * in the same time slice
129 */
130 inline void SetTimeTolerance(G4double);
131 inline G4double GetTimeTolerance() const;
132
133 inline void SetMaxZeroTimeAllowed(G4int);
134 inline G4int GetMaxZeroTimeAllowed() const;
135
137
138 inline void SetTimeSteps(std::map<G4double, G4double>*);
139 inline void AddTimeStep(G4double, G4double);
140 inline void SetDefaultTimeStep(G4double);
142 inline G4int GetNbSteps() const;
143 inline void SetMaxNbSteps(G4int);
144 inline G4int GetMaxNbSteps() const;
145 inline G4double GetStartTime() const;
146 inline G4double GetEndTime() const;
147 virtual inline G4double GetTimeStep() const;
148 inline G4double GetPreviousTimeStep() const;
149 inline G4double GetGlobalTime() const;
152
153 // To use with transportation only, no reactions
154 inline void UseDefaultTimeSteps(G4bool);
156
157 inline G4ITStepStatus GetStatus() const;
158
159 /* 1 : Reaction information
160 * 2 : (1) + time step information
161 * 3 : (2) + step info for individual tracks
162 * 4 : (2) + trackList processing info + pushed and killed track info
163 */
164 inline void SetVerbose(G4int);
165
166 inline G4int GetVerbose() const;
167
168 inline void WhyDoYouStop();
169
172
173 virtual size_t GetNTracks();
174
175 void GetCollisionType(G4String& interactionType);
176
178 {
179 fWatchedTimes.insert(time);
180 }
181
183
184 inline void SetMaxTimeStep(G4double maxTimeStep)
185 {
186 fMaxTimeStep = maxTimeStep;
187 }
188
190 {
191 return fMaxTimeStep;
192 }
193
195 {
196 return fpUserScavenger.get();
197 }
198 inline void SetScavengerMaterial(std::unique_ptr<G4VScavengerMaterial> scavengerMaterial)
199 {
200 fpUserScavenger = std::move(scavengerMaterial);
201 }
202
203protected:
204
205 void DoProcess();
206 void SynchronizeTracks();
207 void Stepping();
208
210
212
213 void PrintWhyDoYouStop();
214
215private:
216 G4Scheduler();
217 void Create();
218 G4Scheduler(const G4Scheduler&);
220
222
229
232
234
235 // Time members
246
247 G4double fTimeStep; // The selected minimum time step
249
250 // User steps
253 std::map<G4double, G4double>* fpUserTimeSteps;
254 // One can give time steps in respect to the global time
257 // selected user time step in respect to the global time
258 G4bool fReachedUserTimeLimit; // if fMinTimeStep == the user time step
259
260 std::set<G4double> fWatchedTimes;
261
263
264 std::unique_ptr<G4VScavengerMaterial> fpUserScavenger;
265
266 // ==========================================
267 // TO BE REMOVED
275 // ==========================================
276
278 // Time calculated by the time stepper in CalculateMinTimeStep()
280 // Time calculated by the interaction length methods
281 // in ComputeInteractionLength()
282
284 // Flag : if the step is driven by the interaction with the matter and
285 // NOT by the reaction between tracks
286
288
289 // ==========================================
290 //Hoang
292public:
293 void ResetScavenger(bool);
294};
295
297{
298 return fInitialized;
299}
300
302{
303 return fpModelHandler;
304}
305
306inline void G4Scheduler::SetEndTime(const G4double __endtime)
307{
308 fEndTime = __endtime;
309}
310
311inline
312void G4Scheduler::SetTimeSteps(std::map<G4double, G4double>* steps)
313{
315 fpUserTimeSteps = steps;
316}
317
318inline void G4Scheduler::AddTimeStep(G4double startingTime, G4double timeStep)
319{
320 if (fpUserTimeSteps == 0)
321 {
322 fpUserTimeSteps = new std::map<G4double, G4double>();
324 }
325
326 (*fpUserTimeSteps)[startingTime] = timeStep;
327}
328
330{
331 return fNbSteps;
332}
333
335{
336 fMaxSteps = maxSteps;
337}
338
340{
341 return fMaxSteps;
342}
343
345{
346 return fStartTime;
347}
348
350{
351 return fEndTime;
352}
353
355{
356 return fTimeStep;
357}
358
360{
361 fDefaultMinTimeStep = timeStep;
362}
363
365{
366 return fGlobalTime;
367}
368
369inline
371{
372 fpUserTimeStepAction = userITAction;
373}
374
376{
378}
379
380inline void G4Scheduler::SetVerbose(G4int verbose)
381{
382 fVerbose = verbose;
383}
384
386{
387 return fVerbose;
388}
389
390inline
392{
393 fMaxNZeroTimeStepsAllowed = maxTimeStepAllowed;
394}
395
397{
399}
400
402{
403 fTimeTolerance = time;
404}
405
407{
408 return fTimeTolerance;
409}
410
412{
413 return fPreviousTimeStep;
414}
415
417{
418 return fITStepStatus;
419}
420
421inline void G4Scheduler::Stop()
422{
423 fContinue = false;
424}
425
427{
429}
430
432{
433 fpGun = gun;
434}
435
437{
438 return fpGun;
439}
440
442{
443 fWhyDoYouStop = true;
444}
445
447{
449}
450
452{
453 return (fUseDefaultTimeSteps == false && fUsePreDefinedTimeSteps == false);
454}
455
456inline void G4Scheduler::ResetScavenger(bool value)
457{
458 fResetScavenger = value;
459}
460
461#endif
G4ApplicationState
G4ITStepStatus
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
static G4ThreadLocal G4Scheduler * fgScheduler
Definition: G4Scheduler.hh:223
void Clear()
Definition: G4Scheduler.cc:219
void SynchronizeTracks()
Definition: G4Scheduler.cc:511
G4bool CanICarryOn()
Definition: G4Scheduler.cc:564
G4int fMaxSteps
Definition: G4Scheduler.hh:231
void SetMaxTimeStep(G4double maxTimeStep)
Definition: G4Scheduler.hh:184
G4ITTrackingManager * fpTrackingManager
Definition: G4Scheduler.hh:270
G4double fTimeStep
Definition: G4Scheduler.hh:247
G4bool fUsePreDefinedTimeSteps
Definition: G4Scheduler.hh:251
G4int fMaxNZeroTimeStepsAllowed
Definition: G4Scheduler.hh:245
void AddTimeStep(G4double, G4double)
Definition: G4Scheduler.hh:318
virtual G4bool Notify(G4ApplicationState requestedState)
Definition: G4Scheduler.cc:108
void EndTracking()
G4double fTmpGlobalTime
Definition: G4Scheduler.hh:239
void FindUserPreDefinedTimeStep()
G4int GetMaxZeroTimeAllowed() const
Definition: G4Scheduler.hh:396
G4Scheduler & operator=(const G4Scheduler &)
void ForceReinitialization()
G4ITTrackHolder & fTrackContainer
Definition: G4Scheduler.hh:273
void Create()
Definition: G4Scheduler.cc:139
G4bool fWhyDoYouStop
Definition: G4Scheduler.hh:225
virtual void RegisterModel(G4VITStepModel *, G4double)
Definition: G4Scheduler.cc:277
void SetGun(G4ITGun *)
Definition: G4Scheduler.hh:431
G4ITStepStatus fITStepStatus
Definition: G4Scheduler.hh:233
G4double GetNextWatchedTime() const
Definition: G4Scheduler.cc:502
void Reset()
Definition: G4Scheduler.cc:359
G4double fGlobalTime
Definition: G4Scheduler.hh:238
G4int fNbSteps
Definition: G4Scheduler.hh:230
G4double GetMaxTimeStep() const
Definition: G4Scheduler.hh:189
void SetMaxNbSteps(G4int)
Definition: G4Scheduler.hh:334
G4double fUserUpperTimeLimit
Definition: G4Scheduler.hh:255
G4bool IsRunning()
Definition: G4Scheduler.hh:108
G4bool fInteractionStep
Definition: G4Scheduler.hh:283
G4bool IsInitialized()
Definition: G4Scheduler.hh:296
G4UserTimeStepAction * GetUserTimeStepAction() const
Definition: G4Scheduler.hh:375
G4int GetNbSteps() const
Definition: G4Scheduler.hh:329
std::map< G4double, G4double > * fpUserTimeSteps
Definition: G4Scheduler.hh:253
void SetTimeSteps(std::map< G4double, G4double > *)
Definition: G4Scheduler.hh:312
G4bool fRunning
Definition: G4Scheduler.hh:227
G4double fEndTime
Definition: G4Scheduler.hh:242
G4double fPreviousTimeStep
Definition: G4Scheduler.hh:243
void SetInteractivity(G4ITTrackingInteractivity *)
G4double fStartTime
Definition: G4Scheduler.hh:240
G4double fMaxTimeStep
Definition: G4Scheduler.hh:248
void SetUserAction(G4UserTimeStepAction *)
Definition: G4Scheduler.hh:370
std::unique_ptr< G4VScavengerMaterial > fpUserScavenger
Definition: G4Scheduler.hh:264
G4double GetLimitingTimeStep() const
Definition: G4Scheduler.cc:953
G4int GetMaxNbSteps() const
Definition: G4Scheduler.hh:339
G4double fStopTime
Definition: G4Scheduler.hh:241
void SetVerbose(G4int)
Definition: G4Scheduler.hh:380
void Stepping()
Definition: G4Scheduler.cc:663
bool fResetScavenger
Definition: G4Scheduler.hh:291
G4double fTimeTolerance
Definition: G4Scheduler.hh:237
G4double fDefinedMinTimeStep
Definition: G4Scheduler.hh:256
virtual ~G4Scheduler()
Definition: G4Scheduler.cc:203
static G4Scheduler * Instance()
Definition: G4Scheduler.cc:101
G4UserTimeStepAction * fpUserTimeStepAction
Definition: G4Scheduler.hh:262
G4ITModelHandler * GetModelHandler()
Definition: G4Scheduler.hh:301
G4double fDefaultMinTimeStep
Definition: G4Scheduler.hh:252
G4ITStepStatus GetStatus() const
Definition: G4Scheduler.hh:416
G4ITModelHandler * fpModelHandler
Definition: G4Scheduler.hh:274
std::set< G4double > fWatchedTimes
Definition: G4Scheduler.hh:260
G4ITModelProcessor * fpModelProcessor
Definition: G4Scheduler.hh:269
G4SchedulerMessenger * fpMessenger
Definition: G4Scheduler.hh:221
void Process()
Definition: G4Scheduler.cc:379
G4double GetEndTime() const
Definition: G4Scheduler.hh:349
void ClearList()
Definition: G4Scheduler.cc:267
G4bool AreDefaultTimeStepsUsed()
Definition: G4Scheduler.hh:451
void WhyDoYouStop()
Definition: G4Scheduler.hh:441
G4bool fReachedUserTimeLimit
Definition: G4Scheduler.hh:258
G4double GetPreviousTimeStep() const
Definition: G4Scheduler.hh:411
virtual size_t GetNTracks()
void SetDefaultTimeStep(G4double)
Definition: G4Scheduler.hh:359
void AddWatchedTime(G4double time)
Definition: G4Scheduler.hh:177
G4double GetGlobalTime() const
Definition: G4Scheduler.hh:364
G4ITGun * GetGun()
Definition: G4Scheduler.hh:436
G4ITTrackingInteractivity * GetInteractivity()
Definition: G4Scheduler.hh:426
void Initialize()
Definition: G4Scheduler.cc:284
void SetMaxZeroTimeAllowed(G4int)
Definition: G4Scheduler.hh:391
void SetEndTime(const G4double)
Definition: G4Scheduler.hh:306
G4double GetTimeTolerance() const
Definition: G4Scheduler.hh:406
void SetTimeTolerance(G4double)
Definition: G4Scheduler.hh:401
void GetCollisionType(G4String &interactionType)
void ResetScavenger(bool)
Definition: G4Scheduler.hh:456
void DoProcess()
Definition: G4Scheduler.cc:616
G4bool fContinue
Definition: G4Scheduler.hh:228
void PrintWhyDoYouStop()
Definition: G4Scheduler.cc:572
G4bool fUseDefaultTimeSteps
Definition: G4Scheduler.hh:236
G4int fVerbose
Definition: G4Scheduler.hh:224
G4ITReactionSet * fReactionSet
Definition: G4Scheduler.hh:272
G4int GetVerbose() const
Definition: G4Scheduler.hh:385
G4ITTrackingInteractivity * fpTrackingInteractivity
Definition: G4Scheduler.hh:271
static void DeleteInstance()
Definition: G4Scheduler.cc:123
G4ITGun * fpGun
Definition: G4Scheduler.hh:287
void SetScavengerMaterial(std::unique_ptr< G4VScavengerMaterial > scavengerMaterial)
Definition: G4Scheduler.hh:198
G4double fTSTimeStep
Definition: G4Scheduler.hh:277
G4bool fInitialized
Definition: G4Scheduler.hh:226
G4int fZeroTimeCount
Definition: G4Scheduler.hh:244
G4ITStepProcessor * fpStepProcessor
Definition: G4Scheduler.hh:268
G4double fILTimeStep
Definition: G4Scheduler.hh:279
G4double GetStartTime() const
Definition: G4Scheduler.hh:344
virtual G4double GetTimeStep() const
Definition: G4Scheduler.hh:354
void UseDefaultTimeSteps(G4bool)
Definition: G4Scheduler.hh:446
G4VScavengerMaterial * GetScavengerMaterial() const
Definition: G4Scheduler.hh:194
G4int GetTrackID() const
G4bool operator()(G4Track *rhs, G4Track *lhs) const
Definition: G4ITReaction.hh:50
#define G4ThreadLocal
Definition: tls.hh:77