53 using namespace G4MemStat;
62 fCurrentModel.assign(
G4ITType::size(), std::vector<G4VITStepModel*>());
68 fUserMinTimeStep = -1.;
70 fpTrackingManager = 0;
74 fComputeTimeStep =
false;
75 fComputeReaction =
false;
82 fCurrentModel.clear();
83 fReactionInfo.clear();
95 fUserMinTimeStep = -1.;
97 fpTrackingManager = 0;
100 fComputeTimeStep =
false;
101 fComputeReaction =
false;
106 fpModelHandler->RegisterModel(model, time);
112 if(
this == &rhs)
return *
this;
119 fpModelHandler->Initialize();
123 fComputeTimeStep =
false;
124 fComputeReaction =
false;
125 if(fpModelHandler->GetTimeStepComputerFlag()) fComputeTimeStep =
true;
126 if(fpModelHandler->GetReactionProcessFlag()) fComputeReaction =
true;
135 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
136 MemStat mem_first, mem_second, mem_diff;
139 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
145 InitializeStepper(currentGlobalTime, definedMinTimeStep);
149 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
151 mem_diff = mem_second-mem_first;
152 G4cout <<
"\t || MEM || G4Scheduler::CalculateMinTimeStep || After "
153 "computing fpModelProcessor -> InitializeStepper, diff is : "
164 for (; it != end; ++it)
171 exceptionDescription <<
"No track found.";
172 G4Exception(
"G4Scheduler::CalculateMinStep",
"ITScheduler006",
193 CalculateTimeStep(track, definedMinTimeStep);
196 ExtractTimeStepperData();
199 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
201 mem_diff = mem_second-mem_first;
202 G4cout <<
"\t || MEM || G4Scheduler::CalculateMinTimeStep || "
203 "After looping on tracks, diff is : " << mem_diff <<
G4endl;
218 const std::vector<std::vector<G4VITStepModel*> >*
model = GetCurrentModel();
220 for(
unsigned i = 0; i < model->size(); ++i)
222 for(
unsigned j = 0; j < (*model)[i].size(); ++j)
233 G4double sampledMinTimeStep(stepper->GetSampledMinTimeStep());
236 if(sampledMinTimeStep < fTSTimeStep)
250 fTSTimeStep = sampledMinTimeStep;
253 fReactionSet->CleanAllReaction();
263 fReactionSet->AddReactions(fTSTimeStep,
264 const_cast<G4Track*>(fpTrack),
269 else if(fTSTimeStep == sampledMinTimeStep)
294 fReactionSet->AddReactions(fTSTimeStep,
295 const_cast<G4Track*>(fpTrack),
297 stepper->ResetReactants();
304 stepper->ResetReactants();
319 if(fpModelHandler == 0)
323 <<
"No G4ITModelHandler was passed to the modelProcessor.";
324 G4Exception(
"G4ITModelProcessor::InitializeStepper",
325 "ITModelProcessor002",
327 exceptionDescription);
329 const std::vector<std::vector<G4ITModelManager*> >* modelManager =
330 fpModelHandler->GetAllModelManager();
332 if(modelManager == 0)
336 <<
"No G4ITModelManager was register to G4ITModelHandler.";
337 G4Exception(
"G4ITModelProcessor::InitializeStepper",
338 "ITModelProcessor003",
340 exceptionDescription);
343 int nbModels1 = modelManager->size();
354 for(
int i = 0; i < nbModels1; i++)
356 nbModels2 = (*modelManager)[i].size();
358 for(
int j = 0; j <= i; j++)
360 modman = (*modelManager)[i][j];
362 if(modman == 0)
continue;
364 model = modman->
GetModel(currentGlobalTime);
367 #if defined (DEBUG_MEM)
368 MemStat mem_first, mem_second, mem_diff;
371 #if defined (DEBUG_MEM)
378 #if defined (DEBUG_MEM)
380 mem_diff = mem_second-mem_first;
381 G4cout <<
"\t || MEM || G4ITModelProcessor::InitializeStepper || After computing stepper -> Prepare(), diff is : " << mem_diff <<
G4endl;
383 fCurrentModel[i][j] =
model;
387 if(nbModels1 == 1 && nbModels2 == 1)
389 fpModelManager = modman;
405 exceptionDescription <<
"No track was passed to the method (track == 0).";
407 "ITModelProcessor004",
409 exceptionDescription);
412 fUserMinTimeStep = userMinTimeStep;
422 fpModel->GetTimeStepper()->CalculateStep(*fpTrack, fUserMinTimeStep);
426 std::vector<G4VITStepModel*>&
model = fCurrentModel[
GetIT(fpTrack)
429 for(
int i = 0; i < (
int) model.size(); i++)
431 if(model[i] == 0)
continue;
432 model[i]->GetTimeStepper()->CalculateStep(*fpTrack, fUserMinTimeStep);
443 G4bool reachedUserTimeLimit,
453 if(fReactionSet->Empty())
462 FindReaction(fReactionSet,
465 reachedUserTimeLimit);
470 std::vector<G4ITReactionChange*> * reactionInfo_v = GetReactionInfo();
471 std::vector<G4ITReactionChange*>::iterator reactionInfo_i = reactionInfo_v
474 for(; reactionInfo_i != reactionInfo_v->end(); ++reactionInfo_i)
484 const vector<G4Track*>* productsVector = changes->
GetfSecondary();
486 if(fpUserTimeStepAction)
503 if(nbSecondaries > 0)
505 for(
int i = 0; i < nbSecondaries; ++i)
508 if(fVerbose && i != 0)
G4cout <<
" + ";
511 G4Track* secondary = (*productsVector)[i];
512 fpTrackContainer->_PushTrack(secondary);
516 if(secondary->
GetGlobalTime() - fGlobalTime > fTimeTolerance)
519 exceptionDescription <<
"The time of the secondary should not be bigger than the"
520 " current global time."
521 <<
" This may cause synchronization problem. If the process you"
522 " are using required "
523 <<
"such feature please contact the developpers." <<
G4endl<<
"The global time in the step manager : "
526 <<
"The global time of the track : "
530 G4Exception(
"G4Scheduler::ComputeInteractionBetweenTracks",
533 exceptionDescription);
546 if(fVerbose)
G4cout <<
"No product";
560 <<
"The problem was found for the reaction between tracks :"
568 exceptionDescription <<
"Also no step was found"
569 <<
" ie track->GetStep() == 0 \n";
572 exceptionDescription <<
"Parent ID of trackA : "
574 exceptionDescription <<
"Parent ID of trackB : "
578 <<
"The ID of one of the reaction track was not setup.";
579 G4Exception(
"G4Scheduler::ComputeInteractionBetweenTracks",
582 exceptionDescription);
599 fpTrackingManager->EndTracking(trackA);
600 fpTrackingManager->EndTracking(trackB);
606 reactionInfo_v->clear();
615 fReactionSet->CleanAllReaction();
617 fpTrackContainer->MergeSecondariesWithMainList();
618 fpTrackContainer->KillTracks();
623 const double currentStepTime,
624 const double previousStepTime,
625 const bool reachedUserStepTimeLimit)
630 if(reactionSet == 0)
return;
631 if(fpModelHandler->GetAllModelManager()->empty())
return;
635 std::map<G4Track*, G4ITReactionPerTrackPtr, compTrackPerID>::iterator tracks_i =
636 reactionPerTrackMap.begin();
643 for(tracks_i = reactionPerTrackMap.begin();
644 tracks_i != reactionPerTrackMap.end();
645 tracks_i = reactionPerTrackMap.begin())
648 G4Track* trackA = tracks_i->first;
661 const std::vector<G4VITStepModel*>
model = fCurrentModel[ITypeA];
668 assert(reactionList.begin() != reactionList.end());
670 for(G4ITReactionList::iterator it = reactionList.begin();
671 it != reactionList.end(); it = reactionList.begin())
674 trackB = reaction->GetReactant(trackA);
685 <<
"The IT reaction process sent back a reaction between trackA and trackB. ";
686 exceptionDescription <<
"The problem is trackA == trackB";
688 "ITModelProcessor005",
690 exceptionDescription);
696 if(ITypeB != ITypeBtmp)
700 if(model[ITypeB]) process = model[ITypeB]->GetReactionProcess();
709 reachedUserStepTimeLimit))
716 fReactionInfo.push_back(changes);
void SetParentID(int, int)
static G4ITReactionSet * Instance()
G4int GetNumberOfSecondaries() const
std::ostringstream G4ExceptionDescription
G4VITStepModel * GetModel(const G4double globalTime)
virtual ~G4ITModelProcessor()
G4ITModelProcessor & operator=(const G4ITModelProcessor &other)
const G4String & GetParticleName() const
void CalculateTimeStep(const G4Track *, const G4double)
const G4ParticleDefinition * GetParticleDefinition() const
G4shared_ptr< G4ITReactionPerTrack > G4ITReactionPerTrackPtr
G4shared_ptr< G4ITReaction > G4ITReactionPtr
void FindReaction(G4ITReactionSet *reactionSet, const double currentStepTime, const double previousStepTime, const bool reachedUserStepTimeLimit)
void ComputeTrackReaction(G4ITStepStatus fITStepStatus, G4double fGlobalTime, G4double currentTimeStep, G4double previousTimeStep, G4bool reachedUserTimeLimit, G4double fTimeTolerance, G4UserTimeStepAction *fpUserTimeStepAction, G4int fVerbose)
G4bool WereParentsKilled() const
void RegisterModel(double time, G4VITStepModel *)
virtual G4ITReactionChange * MakeReaction(const G4Track &, const G4Track &)=0
virtual G4bool TestReactibility(const G4Track &, const G4Track &, const double, const double, bool)=0
const G4Track * GetTrackA()
G4ITReactionPerTrackMap & GetReactionMap()
std::map< G4Track *, G4ITReactionPerTrackPtr, compTrackPerID > G4ITReactionPerTrackMap
G4double GetGlobalTime() const
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
void SelectThisReaction(G4ITReactionPtr reaction)
const G4Step * GetStep() const
virtual void UserReactionAction(const G4Track &, const G4Track &, const std::vector< G4Track * > *)
std::list< G4ITReactionPtr > G4ITReactionList
std::vector< G4Track * > * GetfSecondary()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4double CalculateMinTimeStep(G4double currentGlobalTime, G4double definedMinTimeStep)
static void SetTimes(const G4double &, const G4double &)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
virtual const G4ITType GetITType() const =0
G4VITTimeStepComputer * GetTimeStepper()
void ExtractTimeStepperData()
G4GLOB_DLL std::ostream G4cout
void InitializeStepper(G4double currentGlobalTime, G4double userMinTime)
const G4Track * GetTrackB()
void SetTrackStatus(const G4TrackStatus aTrackStatus)
G4TrackStatus GetTrackStatus() const
static G4ITTrackHolder * Instance()
G4shared_ptr< std::vector< G4Track * > > G4TrackVectorHandle
const XML_Char XML_Content * model
virtual void ResetReactants()
G4IT * GetIT(const G4Track *track)
virtual const G4String & GetName() const =0
G4int GetParentID() const