62 #define DEBUG_MEM_STEPPING
63 #define DEBUG_MEM_DETAILED_STEPPING
68 using namespace G4MemStat;
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 ""
86 #define RESET_COLOR ""
96 return std::numeric_limits<T>::has_infinity
97 && value == std::numeric_limits<T>::infinity();
103 if(fgScheduler == 0) fgScheduler =
new G4Scheduler();
114 G4cout <<
"G4Scheduler received G4State_Quit" <<
G4endl;
324 <<
"You are asking to use user defined steps but you did not give any.";
325 G4Exception(
"G4Scheduler::FindUserPreDefinedTimeStep",
328 exceptionDescription);
382 G4cout <<
"*** G4Scheduler starts processing " <<
G4endl;
384 G4cout <<
"___________________________________________"
385 "___________________________" <<
G4endl;
410 G4bool trackFound =
false;
436 G4cout <<
"G4Scheduler: process time= "<< localtimer <<
G4endl;
460 G4cout <<
"*** G4Scheduler ends at time : "
462 G4cout <<
"___________________________________" <<
G4endl;
466 G4cout <<
"*** G4Scheduler did not start because no "
467 "track was found to be processed"<<
G4endl;
468 G4cout <<
"___________________________________" <<
G4endl;
524 double nextWatchedTime = -1;
540 if(nextWatchedTime >
fEndTime && carryOn)
563 G4cout <<
"G4Scheduler has reached a stage: it might be"
564 " a transition or the end"
567 G4bool normalStop =
false;
571 G4cout <<
"== G4Scheduler: I stop because I reached the stop time : "
577 G4cout <<
"G4Scheduler: I stop because the current main list of tracks "
584 G4cout <<
"G4Scheduler: I stop because I reached the maximum allowed "
591 G4cout <<
"G4Scheduler: It might be that I stop because "
592 "I have been told so. You may check "
593 "member fContinue and usage of the method G4Scheduler::Stop()."
607 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
608 MemStat mem_first, mem_second, mem_diff;
611 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
625 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
627 mem_diff = mem_second-mem_first;
628 G4cout <<
"\t || MEM || After step " <<
fNbSteps <<
", diff is : "
635 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_STEPPING)
637 mem_diff = mem_second-mem_first;
638 G4cout <<
"\t || MEM || After stepping, diff is : " << mem_diff <<
G4endl;
643 G4cout <<
"*** G4Scheduler has finished processing a track list at time : "
677 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
678 MemStat mem_first, mem_second, mem_diff;
681 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
696 <<
" the chosen user time step is : "
716 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
718 mem_diff = mem_second-mem_first;
719 G4cout <<
"|| MEM || After computing TS, diff is : " << mem_diff <<
G4endl;
736 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
750 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
752 mem_diff = mem_second-mem_first;
753 G4cout <<
"|| MEM || After IL, diff is : " << mem_diff <<
G4endl;
762 G4cout <<
"*** The minimum time returned by the processes is : "
770 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
808 exceptionDescription <<
"Too many zero time steps were detected. ";
809 exceptionDescription <<
"The simulation is probably stuck. ";
811 <<
"The maximum number of zero time steps is currently : "
813 exceptionDescription <<
".";
816 "SchedulerNullTimeSteps",
818 exceptionDescription);
834 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
836 mem_diff = mem_second-mem_first;
837 G4cout <<
"|| MEM || After LeadingTracks and UserPreTimeStepAction: "
841 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
864 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
866 mem_diff = mem_second-mem_first;
867 G4cout <<
"|| MEM || After DoIT, diff is : " << mem_diff <<
G4endl;
870 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
892 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
894 mem_diff = mem_second-mem_first;
895 G4cout <<
"|| MEM || After computing reactions + UserPostTimeStepAction, "
896 "diff is : " << mem_diff <<
G4endl;
910 std::stringstream finalOutput;
912 finalOutput <<
"*** End of step N°" <<
fNbSteps
916 <<
"\t " << interactionType
923 finalOutput <<
"It has also reached the user time limit" <<
G4endl;
925 finalOutput <<
"_______________________________________________________________"
929 G4cout << finalOutput.str();
946 map<double, double>::const_iterator it_fpUserTimeSteps_i =
fpUserTimeSteps
948 map<double, double>::const_iterator it_fpUserTimeSteps_low =
fpUserTimeSteps
964 it_fpUserTimeSteps_i--;
972 it_fpUserTimeSteps_i = it_fpUserTimeSteps_low;
973 map<double, double>::const_iterator tmp_it = it_fpUserTimeSteps_low;
984 else if (it_fpUserTimeSteps_i == it_fpUserTimeSteps_low)
993 if(it_fpUserTimeSteps_i !=
fpUserTimeSteps->begin()) it_fpUserTimeSteps_i--;
998 it_fpUserTimeSteps_i = it_fpUserTimeSteps_low;
1001 return it_fpUserTimeSteps_i->second;
1012 exceptionDescription
1013 <<
"You are asking to use user defined steps but you did not give any.";
1014 G4Exception(
"G4Scheduler::FindUserPreDefinedTimeStep",
1017 exceptionDescription);
1020 map<double, double>::iterator fpUserTimeSteps_i =
1037 fpUserTimeSteps_i--;
1044 fpUserTimeSteps_i = fpUserTimeSteps_low;
1046 else if(fpUserTimeSteps_i == fpUserTimeSteps_low)
1049 fpUserTimeSteps_i--;
1053 fpUserTimeSteps_i = fpUserTimeSteps_low;
1066 exceptionDescription
1067 <<
"End tracking is called while G4Scheduler is still running."
1073 exceptionDescription);
1083 for (; it != end; ++
it)
1095 for (; it != end; ++
it)
1151 interactionType =
"eInteractionWithMedium";
1154 interactionType =
"eCollisionBetweenTracks";
1157 interactionType =
"eCollisionBetweenTracks";