62#define DEBUG_MEM_STEPPING
63#define DEBUG_MEM_DETAILED_STEPPING
76#define RED "\033[0;31m"
77#define LIGHT_RED "\33[1;31m"
78#define GREEN "\033[32;40m"
79#define GREEN_ON_BLUE "\033[1;32;44m"
80#define RESET_COLOR "\033[0m"
85#define GREEN_ON_BLUE ""
96 return std::numeric_limits<T>::has_infinity
97 && value == std::numeric_limits<T>::infinity();
114 G4cout <<
"G4Scheduler received G4State_Quit" <<
G4endl;
327 <<
"You are asking to use user defined steps but you did not give any.";
328 G4Exception(
"G4Scheduler::FindUserPreDefinedTimeStep",
331 exceptionDescription);
385 G4cout <<
"*** G4Scheduler starts processing " <<
G4endl;
387 G4cout <<
"___________________________________________"
388 "___________________________" <<
G4endl;
424 G4bool trackFound =
false;
450 G4cout <<
"G4Scheduler: process time= "<< localtimer <<
G4endl;
474 G4cout <<
"*** G4Scheduler ends at time : "
476 G4cout <<
"___________________________________" <<
G4endl;
480 G4cout <<
"*** G4Scheduler did not start because no "
481 "track was found to be processed"<<
G4endl;
482 G4cout <<
"___________________________________" <<
G4endl;
554 if(nextWatchedTime >
fEndTime && carryOn)
577 G4cout <<
"G4Scheduler has reached a stage: it might be"
578 " a transition or the end"
581 G4bool normalStop =
false;
585 G4cout <<
"== G4Scheduler: I stop because I reached the stop time : "
591 G4cout <<
"G4Scheduler: I stop because the current main list of tracks "
598 G4cout <<
"G4Scheduler: I stop because I reached the maximum allowed "
605 G4cout <<
"G4Scheduler: It might be that I stop because "
606 "I have been told so. You may check "
607 "member fContinue and usage of the method G4Scheduler::Stop()."
621#if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
622 MemStat mem_first, mem_second, mem_diff;
625#if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
639#if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
641 mem_diff = mem_second-mem_first;
642 G4cout <<
"\t || MEM || After step " <<
fNbSteps <<
", diff is : "
649#if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
651 mem_diff = mem_second-mem_first;
652 G4cout <<
"\t || MEM || After stepping, diff is : " << mem_diff <<
G4endl;
657 G4cout <<
"*** G4Scheduler has finished processing a track list at time : "
691#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
692 MemStat mem_first, mem_second, mem_diff;
695#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
710 <<
" the chosen user time step is : "
730#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
732 mem_diff = mem_second-mem_first;
733 G4cout <<
"|| MEM || After computing TS, diff is : " << mem_diff <<
G4endl;
750#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
763#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
765 mem_diff = mem_second-mem_first;
766 G4cout <<
"|| MEM || After IL, diff is : " << mem_diff <<
G4endl;
775 G4cout <<
"*** The minimum time returned by the processes is : "
783#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
821 exceptionDescription <<
"Too many zero time steps were detected. ";
822 exceptionDescription <<
"The simulation is probably stuck. ";
824 <<
"The maximum number of zero time steps is currently : "
826 exceptionDescription <<
".";
829 "SchedulerNullTimeSteps",
831 exceptionDescription);
847#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
849 mem_diff = mem_second-mem_first;
850 G4cout <<
"|| MEM || After LeadingTracks and UserPreTimeStepAction: "
854#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
877#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
879 mem_diff = mem_second-mem_first;
880 G4cout <<
"|| MEM || After DoIT, diff is : " << mem_diff <<
G4endl;
883#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
905#if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
907 mem_diff = mem_second-mem_first;
908 G4cout <<
"|| MEM || After computing reactions + UserPostTimeStepAction, "
909 "diff is : " << mem_diff <<
G4endl;
923 std::stringstream finalOutput;
925 finalOutput <<
"*** End of step N°" <<
fNbSteps
929 <<
"\t " << interactionType
936 finalOutput <<
"It has also reached the user time limit" <<
G4endl;
938 finalOutput <<
"_______________________________________________________________"
942 G4cout << finalOutput.str();
959 map<G4double, G4double>::const_iterator it_fpUserTimeSteps_i =
fpUserTimeSteps
961 map<G4double, G4double>::const_iterator it_fpUserTimeSteps_low =
fpUserTimeSteps
977 it_fpUserTimeSteps_i--;
985 it_fpUserTimeSteps_i = it_fpUserTimeSteps_low;
986 map<G4double, G4double>::const_iterator tmp_it = it_fpUserTimeSteps_low;
997 else if (it_fpUserTimeSteps_i == it_fpUserTimeSteps_low)
1006 if(it_fpUserTimeSteps_i !=
fpUserTimeSteps->begin()) it_fpUserTimeSteps_i--;
1011 it_fpUserTimeSteps_i = it_fpUserTimeSteps_low;
1014 return it_fpUserTimeSteps_i->second;
1025 exceptionDescription
1026 <<
"You are asking to use user defined steps but you did not give any.";
1027 G4Exception(
"G4Scheduler::FindUserPreDefinedTimeStep",
1030 exceptionDescription);
1033 map<G4double, G4double>::iterator fpUserTimeSteps_i =
1035 map<G4double, G4double>::iterator fpUserTimeSteps_low =
fpUserTimeSteps
1050 fpUserTimeSteps_i--;
1057 fpUserTimeSteps_i = fpUserTimeSteps_low;
1059 else if(fpUserTimeSteps_i == fpUserTimeSteps_low)
1062 fpUserTimeSteps_i--;
1066 fpUserTimeSteps_i = fpUserTimeSteps_low;
1079 exceptionDescription
1080 <<
"End tracking is called while G4Scheduler is still running."
1086 exceptionDescription);
1096 for (; it != end; ++it)
1108 for (; it != end; ++it)
1164 interactionType =
"eInteractionWithMedium";
1167 interactionType =
"eCollisionBetweenTracks";
1170 interactionType =
"eCollisionBetweenTracks";
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
@ eCollisionBetweenTracks
static constexpr double microsecond
static constexpr double picosecond
G4GLOB_DLL std::ostream G4cout
static void DeleteInstance()
virtual void DefineTracks()
void RegisterModel(G4VITStepModel *pModel, G4double globalTime)
void SetModelHandler(G4ITModelHandler *)
void SetTrackingManager(G4ITTrackingManager *trackingManager)
G4double CalculateMinTimeStep(G4double currentGlobalTime, G4double definedMinTimeStep)
void ComputeTrackReaction(G4ITStepStatus fITStepStatus, G4double fGlobalTime, G4double currentTimeStep, G4double previousTimeStep, G4bool reachedUserTimeLimit, G4double fTimeTolerance, G4UserTimeStepAction *fpUserTimeStepAction, G4int fVerbose)
bool GetComputeTimeStep() const
static G4ITReactionSet * Instance()
void ResetLeadingTracks()
void SetTrackingManager(G4ITTrackingManager *trackMan)
void PrepareLeadingTracks()
G4double ComputeInteractionLength(double previousTimeStep)
void DoIt(double timeStep)
virtual void Initialize()
virtual size_t GetNTracks()
G4TrackList * GetMainList(Key)
void MergeSecondariesWithMainList()
G4TrackManyList * GetSecondariesList()
bool SecondaryListsNOTEmpty()
bool MergeNextTimeToMainList(double &time)
bool DelayListsNOTEmpty()
virtual void Initialize()
void EndTrackingWOKill(G4Track *)
void SetInteractivity(G4ITTrackingInteractivity *)
static G4ITTypeManager * Instance()
static G4ThreadLocal G4Scheduler * fgScheduler
G4ITTrackingManager * fpTrackingManager
G4bool fUsePreDefinedTimeSteps
G4int fMaxNZeroTimeStepsAllowed
virtual G4bool Notify(G4ApplicationState requestedState)
void FindUserPreDefinedTimeStep()
G4Scheduler & operator=(const G4Scheduler &)
void ForceReinitialization()
G4ITTrackHolder & fTrackContainer
virtual void RegisterModel(G4VITStepModel *, G4double)
G4ITStepStatus fITStepStatus
G4double GetNextWatchedTime() const
G4double fUserUpperTimeLimit
std::map< G4double, G4double > * fpUserTimeSteps
G4double fPreviousTimeStep
void SetInteractivity(G4ITTrackingInteractivity *)
std::unique_ptr< G4VScavengerMaterial > fpUserScavenger
G4double GetLimitingTimeStep() const
G4double fDefinedMinTimeStep
static G4Scheduler * Instance()
G4UserTimeStepAction * fpUserTimeStepAction
G4double fDefaultMinTimeStep
G4ITModelHandler * fpModelHandler
std::set< G4double > fWatchedTimes
G4ITModelProcessor * fpModelProcessor
G4SchedulerMessenger * fpMessenger
G4bool fReachedUserTimeLimit
virtual size_t GetNTracks()
void GetCollisionType(G4String &interactionType)
G4bool fUseDefaultTimeSteps
G4ITReactionSet * fReactionSet
G4ITTrackingInteractivity * fpTrackingInteractivity
static void DeleteInstance()
G4ITStepProcessor * fpStepProcessor
virtual void UserPostTimeStepAction()
virtual void StartProcessing()
virtual void EndProcessing()
virtual void UserPreTimeStepAction()
T min(const T t1, const T t2)
brief Return the smallest of the two arguments