54 if (!fHasReacted) fHasReacted =
new std::map<const G4Track*, G4bool>;
60 fCurrentModel.assign(
G4ITType::size(), std::vector<G4VITStepModel*>());
66 fUserMinTimeStep = -1.;
73 fCurrentModel.clear();
74 fReactionInfo.clear();
86 fUserMinTimeStep = -1.;
92 if (
this == &rhs)
return *
this;
99 fpModelHandler->Initialize();
108 if (fpModelHandler == 0)
112 <<
"No G4ITModelHandler was passed to the modelProcessor.";
113 G4Exception(
"G4ITModelProcessor::InitializeStepper",
"ITModelProcessor002",
116 const std::vector<std::vector<G4ITModelManager*> >* modelManager =
117 fpModelHandler->GetAllModelManager();
119 if (modelManager == 0)
123 <<
"No G4ITModelManager was register to G4ITModelHandler.";
124 G4Exception(
"G4ITModelProcessor::InitializeStepper",
"ITModelProcessor003",
128 int nbModels1 = modelManager->size();
139 for (
int i = 0; i < nbModels1; i++)
141 nbModels2 = (*modelManager)[i].size();
143 for (
int j = 0; j <= i; j++)
145 modman = (*modelManager)[i][j];
147 if (modman == 0)
continue;
149 model = modman->
GetModel(currentGlobalTime);
152 #if defined (DEBUG_MEM)
153 MemStat mem_first, mem_second, mem_diff;
156 #if defined (DEBUG_MEM)
163 #if defined (DEBUG_MEM)
165 mem_diff = mem_second-mem_first;
166 G4cout <<
"\t || MEM || G4ITModelProcessor::InitializeStepper || After computing stepper -> Prepare(), diff is : " << mem_diff <<
G4endl;
168 fCurrentModel[i][j] = model;
172 if (nbModels1 == 1 && nbModels2 == 1)
174 fpModelManager = modman;
190 exceptionDescription <<
"No track was passed to the method (track == 0).";
191 G4Exception(
"G4ITModelProcessor::CalculateStep",
"ITModelProcessor004",
195 fUserMinTimeStep = userMinTimeStep;
205 fpModel->GetTimeStepper()->CalculateStep(*fpTrack, fUserMinTimeStep);
209 std::vector<G4VITStepModel*>& model = fCurrentModel[
GetIT(fpTrack)
212 for (
int i = 0; i < (int) model.size(); i++)
214 if (model[i] == 0)
continue;
215 model[i]->GetTimeStepper()->CalculateStep(*fpTrack, fUserMinTimeStep);
222 const double currentStepTime,
223 const double previousStepTime,
224 const bool reachedUserStepTimeLimit)
228 if (tracks == 0)
return;
230 if (fpModelHandler->GetAllModelManager()->empty())
return;
232 std::map<G4Track*, G4TrackVectorHandle>::iterator tracks_i = tracks->begin();
236 for (tracks_i = tracks->begin(); tracks_i != tracks->end(); tracks_i++)
239 G4Track* trackA = tracks_i->first;
241 if (trackA == 0)
continue;
245 std::map<const G4Track*, G4bool>::iterator it_hasReacted =
246 fHasReacted->find(trackA);
247 if (it_hasReacted != fHasReacted->end())
continue;
253 const std::vector<G4VITStepModel*> model = fCurrentModel[ITypeA];
256 std::vector<G4Track*>::iterator trackB_i = trackB_vector->begin();
263 for (; trackB_i != trackB_vector->end(); trackB_i++)
267 if (trackB == 0)
continue;
268 it_hasReacted = fHasReacted->find(trackB);
269 if (it_hasReacted != fHasReacted->end())
continue;
279 if (trackB == trackA)
283 <<
"The IT reaction process sent back a reaction between trackA and trackB. ";
284 exceptionDescription <<
"The problem is trackA == trackB";
285 G4Exception(
"G4ITModelProcessor::FindReaction",
"ITModelProcessor005",
292 if (ITypeB != ITypeBtmp)
296 if (model[ITypeB]) process = model[ITypeB]->GetReactionProcess();
302 reachedUserStepTimeLimit))
309 (*fHasReacted)[trackA] =
true;
310 (*fHasReacted)[trackB] =
true;
314 fReactionInfo.push_back(changes);
330 fHasReacted->clear();
virtual G4bool TestReactibility(const G4Track &, const G4Track &, const double, const double, bool)=0
Similar to G4ParticleChange, but deal with two tracks rather than one.
const G4Track * GetTrackA()
The G4ITModelProcessor will call the two processes defined in G4VITModel.
static G4ThreadLocal std::map< const G4Track *, G4bool > * fHasReacted
std::ostringstream G4ExceptionDescription
Define what to do before stepping and after stepping.
G4TrackStatus GetTrackStatus() const
void CalculateTimeStep(const G4Track *, const G4double)
G4VITReactionProcess defines the reaction between two G4IT.
Tag the G4IT Should be automatically setup by G4IT using : ITDef(MyIT) and ITImp(MyIT) ...
CLHEP::shared_ptr< std::vector< G4Track * > > G4TrackVectorHandle
static void SetTimes(const G4double &, const G4double &)
G4IT * GetIT(const G4Track *track)
G4GLOB_DLL std::ostream G4cout
virtual ~G4ITModelProcessor()
G4VITTimeStepComputer * GetTimeStepper()
const G4Track * GetTrackB()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
G4ITModelProcessor & operator=(const G4ITModelProcessor &other)
Assignment operator.
virtual const G4ITType GetITType() const =0
void FindReaction(std::map< G4Track *, G4TrackVectorHandle > *, const double currentStepTime, const double previousStepTime, const bool reachedUserStepTimeLimit)
void InitializeStepper(const G4double ¤tGlobalTime, const G4double &userMinTime)
G4VITStepModel * GetModel(const G4double globalTime)
virtual G4ITReactionChange * MakeReaction(const G4Track &, const G4Track &)=0
Before stepping all tracks G4Scheduler calls all the G4VITModel which may contain a G4VITTimeStepper ...
G4ITModelManager chooses which model to use according to the global simulation time.