Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ITModelProcessor Class Reference

#include <G4ITModelProcessor.hh>

Collaboration diagram for G4ITModelProcessor:

Public Member Functions

 G4ITModelProcessor ()
 
virtual ~G4ITModelProcessor ()
 
void SetModelHandler (G4ITModelHandler *)
 
void Initialize ()
 
void RegisterModel (double time, G4VITStepModel *)
 
void CleanProcessor ()
 
G4double CalculateMinTimeStep (G4double currentGlobalTime, G4double definedMinTimeStep)
 
void ComputeTrackReaction (G4ITStepStatus fITStepStatus, G4double fGlobalTime, G4double currentTimeStep, G4double previousTimeStep, G4bool reachedUserTimeLimit, G4double fTimeTolerance, G4UserTimeStepAction *fpUserTimeStepAction, G4int fVerbose)
 
void InitializeStepper (G4double currentGlobalTime, G4double userMinTime)
 
bool GetComputeTimeStep ()
 
void CalculateTimeStep (const G4Track *, const G4double)
 
void DoCalculateStep ()
 
void FindReaction (G4ITReactionSet *reactionSet, const double currentStepTime, const double previousStepTime, const bool reachedUserStepTimeLimit)
 
const std::vector< std::vector
< G4VITStepModel * > > * 
GetCurrentModel ()
 
std::vector
< G4ITReactionChange * > * 
GetReactionInfo ()
 
const G4TrackGetTrack () const
 
void SetTrackingManager (G4ITTrackingManager *trackingManager)
 

Protected Member Functions

void SetTrack (const G4Track *)
 
void ExtractTimeStepperData ()
 
 G4ITModelProcessor (const G4ITModelProcessor &other)
 
G4ITModelProcessoroperator= (const G4ITModelProcessor &other)
 

Protected Attributes

G4double fTSTimeStep
 
G4ITReactionSetfReactionSet
 
G4ITTrackingManagerfpTrackingManager
 
G4ITTrackHolderfpTrackContainer
 
G4bool fInitialized
 
G4ITModelHandlerfpModelHandler
 
const G4TrackfpTrack
 
G4double fUserMinTimeStep
 
std::vector< std::vector
< G4VITStepModel * > > 
fCurrentModel
 
G4VITStepModelfpModel
 
G4ITModelManagerfpModelManager
 
G4ITType fCurrentType1
 
G4ITType fCurrentType2
 
std::vector< G4ITReactionChange * > fReactionInfo
 
bool fComputeTimeStep
 
bool fComputeReaction
 

Detailed Description

The G4ITModelProcessor will call the two processes defined in G4VITModel. This processes act at the beginning and end of each step. The first one, the TimeStepper will calculate a time step to propagate all the track and eventually it can return some tracks that can likely react at the end of the step. The second one, the ReactionProcess will make the tracks reacting.

Definition at line 83 of file G4ITModelProcessor.hh.

Constructor & Destructor Documentation

G4ITModelProcessor::G4ITModelProcessor ( )

Definition at line 56 of file G4ITModelProcessor.cc.

57 {
58  fpTrack = 0;
59  fpModel = 0;
60  fInitialized = false;
61  fpModelManager = 0;
62  fCurrentModel.assign(G4ITType::size(), std::vector<G4VITStepModel*>());
63 
64  for(int i = 0; i < (int) G4ITType::size(); i++)
65  {
66  fCurrentModel[i].assign(G4ITType::size(), 0);
67  }
68  fUserMinTimeStep = -1.;
71  fReactionSet = 0;
72  fpTrackContainer = 0;
73  fpModelHandler = 0;
74  fComputeTimeStep = false;
75  fComputeReaction = false;
76 }
G4ITTrackingManager * fpTrackingManager
G4VITStepModel * fpModel
std::vector< std::vector< G4VITStepModel * > > fCurrentModel
G4ITReactionSet * fReactionSet
static size_t size()
Definition: G4ITType.cc:46
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
G4ITModelManager * fpModelManager
const G4Track * fpTrack
#define DBL_MAX
Definition: templates.hh:83
G4ITModelHandler * fpModelHandler
G4ITTrackHolder * fpTrackContainer

Here is the call graph for this function:

G4ITModelProcessor::~G4ITModelProcessor ( )
virtual

Definition at line 78 of file G4ITModelProcessor.cc.

79 {
80  //dtor
81  // if(fpModelHandler) delete fpModelHandler; deleted by G4Scheduler
82  fCurrentModel.clear();
83  fReactionInfo.clear();
84 }
std::vector< G4ITReactionChange * > fReactionInfo
std::vector< std::vector< G4VITStepModel * > > fCurrentModel
G4ITModelProcessor::G4ITModelProcessor ( const G4ITModelProcessor other)
protected

Copy constructor

Parameters
otherObject to copy from

Definition at line 87 of file G4ITModelProcessor.cc.

88 {
89  //copy ctorr
90  fpTrack = 0;
91  fpModelHandler = 0;
92  fpModel = 0;
93  fInitialized = false;
94  fpModelManager = 0;
95  fUserMinTimeStep = -1.;
98  fReactionSet = 0;
99  fpTrackContainer = 0;
100  fComputeTimeStep = false;
101  fComputeReaction = false;
102 }
G4ITTrackingManager * fpTrackingManager
G4VITStepModel * fpModel
G4ITReactionSet * fReactionSet
G4ITModelManager * fpModelManager
const G4Track * fpTrack
#define DBL_MAX
Definition: templates.hh:83
G4ITModelHandler * fpModelHandler
G4ITTrackHolder * fpTrackContainer

Member Function Documentation

G4double G4ITModelProcessor::CalculateMinTimeStep ( G4double  currentGlobalTime,
G4double  definedMinTimeStep 
)

Definition at line 131 of file G4ITModelProcessor.cc.

133 {
134 
135 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
136  MemStat mem_first, mem_second, mem_diff;
137 #endif
138 
139 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
140  mem_first = MemoryUsage();
141 #endif
142 
144 
145  InitializeStepper(currentGlobalTime, definedMinTimeStep);
146  // TODO
147  // fpMasterModelProcessor -> InitializeStepper(fGlobalTime, fDefinedMinTimeStep) ;
148 
149 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
150  mem_second = MemoryUsage();
151  mem_diff = mem_second-mem_first;
152  G4cout << "\t || MEM || G4Scheduler::CalculateMinTimeStep || After "
153  "computing fpModelProcessor -> InitializeStepper, diff is : "
154  << mem_diff
155  << G4endl;
156 #endif
157 
158 // G4TrackList::iterator fpMainList_i = fpMainList->begin();
159 
161  G4TrackManyList::iterator it = mainList->begin();
162  G4TrackManyList::iterator end = mainList->end();
163 
164  for (; it != end; ++it)
165  {
166  G4Track * track = *it;
167 
168  if (track == 0)
169  {
170  G4ExceptionDescription exceptionDescription;
171  exceptionDescription << "No track found.";
172  G4Exception("G4Scheduler::CalculateMinStep", "ITScheduler006",
173  FatalErrorInArgument, exceptionDescription);
174  return 0; // makes coverity happy
175  }
176 
177 #ifdef DEBUG
178  G4cout << "*_* " << GetIT(track)->GetName()
179  << " ID: " << track->GetTrackID()
180  << " at time : " << track->GetGlobalTime()
181  << G4endl;
182 #endif
183 
184  G4TrackStatus trackStatus = track->GetTrackStatus();
185  if (trackStatus == fStopAndKill || trackStatus == fStopButAlive)
186  {
187  continue;
188  }
189 
190  // This Extract... was thought for MT mode at the track level
191  //ExtractTimeStepperData(fpModelProcessor) ;
192 
193  CalculateTimeStep(track, definedMinTimeStep);
194 
195  // if MT mode at track level, this command should be displaced
197  }
198 
199 #if defined (DEBUG_MEM) && defined (DEBUG_MEM_DETAILED_STEPPING)
200  mem_second = MemoryUsage();
201  mem_diff = mem_second-mem_first;
202  G4cout << "\t || MEM || G4Scheduler::CalculateMinTimeStep || "
203  "After looping on tracks, diff is : " << mem_diff << G4endl;
204 #endif
205  return fTSTimeStep;
206 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4TrackStatus GetTrackStatus() const
void CalculateTimeStep(const G4Track *, const G4double)
virtual const G4String & GetName() const =0
MemStat MemoryUsage()
Definition: G4MemStat.cc:55
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
G4GLOB_DLL std::ostream G4cout
G4int GetTrackID() const
G4double GetGlobalTime() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void InitializeStepper(G4double currentGlobalTime, G4double userMinTime)
#define G4endl
Definition: G4ios.hh:61
G4TrackList * GetMainList(Key)
#define DBL_MAX
Definition: templates.hh:83
G4TrackStatus
G4ITTrackHolder * fpTrackContainer

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ITModelProcessor::CalculateTimeStep ( const G4Track track,
const G4double  userMinTimeStep 
)

Definition at line 397 of file G4ITModelProcessor.cc.

399 {
400  // G4cout << "G4ITModelProcessor::CalculateStep" << G4endl;
401  CleanProcessor();
402  if(track == 0)
403  {
404  G4ExceptionDescription exceptionDescription;
405  exceptionDescription << "No track was passed to the method (track == 0).";
406  G4Exception("G4ITModelProcessor::CalculateStep",
407  "ITModelProcessor004",
409  exceptionDescription);
410  }
411  SetTrack(track);
412  fUserMinTimeStep = userMinTimeStep;
413 
414  DoCalculateStep();
415 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void SetTrack(const G4Track *)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Here is the call graph for this function:

void G4ITModelProcessor::CleanProcessor ( )
inline

Restore original state of the modelProcessor. This method should be call only by the G4Scheduler

Definition at line 229 of file G4ITModelProcessor.hh.

230 {
231  fpTrack = 0;
232 }
const G4Track * fpTrack
void G4ITModelProcessor::ComputeTrackReaction ( G4ITStepStatus  fITStepStatus,
G4double  fGlobalTime,
G4double  currentTimeStep,
G4double  previousTimeStep,
G4bool  reachedUserTimeLimit,
G4double  fTimeTolerance,
G4UserTimeStepAction fpUserTimeStepAction,
G4int  fVerbose 
)

Definition at line 439 of file G4ITModelProcessor.cc.

451 {
452 // if (fReactingTracks.empty())
453  if(fReactionSet->Empty())
454  {
455  return;
456  }
457 
458  if(fITStepStatus == eCollisionBetweenTracks)
459  // if(fInteractionStep == false)
460  {
461  // TODO
463  currentTimeStep,
464  previousTimeStep,
465  reachedUserTimeLimit);
466  // TODO
467  // A ne faire uniquement si le temps choisis est celui calculé par le time stepper
468  // Sinon utiliser quelque chose comme : fModelProcessor->FindReaction(&fMainList);
469 
470  std::vector<G4ITReactionChange*> * reactionInfo_v = GetReactionInfo();
471  std::vector<G4ITReactionChange*>::iterator reactionInfo_i = reactionInfo_v
472  ->begin();
473 
474  for(; reactionInfo_i != reactionInfo_v->end(); ++reactionInfo_i)
475  {
476  G4ITReactionChange* changes = (*reactionInfo_i);
477  G4Track* trackA = const_cast<G4Track*>(changes->GetTrackA());
478  G4Track* trackB = const_cast<G4Track*>(changes->GetTrackB());
479 
480  if(trackA == 0 || trackB == 0 || trackA->GetTrackStatus() == fStopAndKill
481  || trackB->GetTrackStatus() == fStopAndKill) continue;
482 
483  G4int nbSecondaries = changes->GetNumberOfSecondaries();
484  const vector<G4Track*>* productsVector = changes->GetfSecondary();
485 
486  if(fpUserTimeStepAction)
487  {
488  fpUserTimeStepAction->UserReactionAction(*trackA,
489  *trackB,
490  productsVector);
491  }
492 
493 #ifdef G4VERBOSE
494  if(fVerbose)
495  {
496  G4cout << "At time : " << setw(7) << G4BestUnit(fGlobalTime, "Time")
497  << " Reaction : " << GetIT(trackA)->GetName() << " ("
498  << trackA->GetTrackID() << ") + " << GetIT(trackB)->GetName() << " ("
499  << trackB->GetTrackID() << ") -> ";
500  }
501 #endif
502 
503  if(nbSecondaries > 0)
504  {
505  for(int i = 0; i < nbSecondaries; ++i)
506  {
507 #ifdef G4VERBOSE
508  if(fVerbose && i != 0) G4cout << " + ";
509 #endif
510 
511  G4Track* secondary = (*productsVector)[i]; //changes->GetSecondary(i);
512  fpTrackContainer->_PushTrack(secondary);
513  GetIT(secondary)->SetParentID(trackA->GetTrackID(),
514  trackB->GetTrackID());
515 
516  if(secondary->GetGlobalTime() - fGlobalTime > fTimeTolerance)
517  {
518  G4ExceptionDescription exceptionDescription;
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 : "
524  << G4BestUnit(fGlobalTime,"Time")
525  << G4endl
526  << "The global time of the track : "
527  << G4BestUnit(secondary->GetGlobalTime(),"Time")
528  << G4endl;
529 
530  G4Exception("G4Scheduler::ComputeInteractionBetweenTracks",
531  "ITScheduler010",
533  exceptionDescription);
534  }
535 
536 #ifdef G4VERBOSE
537  if(fVerbose)
538  G4cout << GetIT(secondary)->GetName() << " ("
539  << secondary->GetTrackID() << ")";
540 #endif
541  }
542  }
543  else
544  {
545 #ifdef G4VERBOSE
546  if(fVerbose) G4cout << "No product";
547 #endif
548  }
549 #ifdef G4VERBOSE
550  if(fVerbose) G4cout << G4endl;
551 #endif
552  if(trackA->GetTrackID() == 0 || trackB->GetTrackID() == 0)
553  {
554  G4Track* track = 0;
555  if(trackA->GetTrackID() == 0) track = trackA;
556  else track = trackB;
557 
558  G4ExceptionDescription exceptionDescription;
559  exceptionDescription
560  << "The problem was found for the reaction between tracks :"
561  << trackA->GetParticleDefinition()->GetParticleName() << " ("
562  << trackA->GetTrackID() << ") & "
563  << trackB->GetParticleDefinition()->GetParticleName() << " ("
564  << trackB->GetTrackID() << "). \n";
565 
566  if(track->GetStep() == 0)
567  {
568  exceptionDescription << "Also no step was found"
569  << " ie track->GetStep() == 0 \n";
570  }
571 
572  exceptionDescription << "Parent ID of trackA : "
573  << trackA->GetParentID() << "\n";
574  exceptionDescription << "Parent ID of trackB : "
575  << trackB->GetParentID() << "\n";
576 
577  exceptionDescription
578  << "The ID of one of the reaction track was not setup.";
579  G4Exception("G4Scheduler::ComputeInteractionBetweenTracks",
580  "ITScheduler011",
582  exceptionDescription);
583  }
584 
585  if(changes->WereParentsKilled())
586  {
587  // DEBUG
588  // G4cout << "Erasing tracks : "
589  // << "trackA at time : " << G4BestUnit(trackA->GetGlobalTime() , "Time")
590  // << "\t trackB at time : "<< G4BestUnit(trackB->GetGlobalTime(), "Time")
591  // << "\t GlobalTime : " << G4BestUnit(fGlobalTime, "Time")
592  // << G4endl;
593 
594  trackA->SetTrackStatus(fStopAndKill);
595  trackB->SetTrackStatus(fStopAndKill);
596 
597 // G4TrackList::Pop(trackA);
598 // G4TrackList::Pop(trackB);
601  }
602 
603  delete changes;
604  }
605 
606  reactionInfo_v->clear(); // never null because point to a non-pointer member of ModelProcessor
607  }
608  // DEBUG
609  //else
610  //{
611  // G4cout << "fInteractionStep == true" << G4endl ;
612  //}
613 
614 // fReactingTracks.clear();
616 
619 }
void SetTrackStatus(const G4TrackStatus aTrackStatus)
G4int GetParentID() const
G4ITTrackingManager * fpTrackingManager
void MergeSecondariesWithMainList()
const G4Track * GetTrackA()
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void SetParentID(int, int)
Definition: G4IT.hh:229
G4TrackStatus GetTrackStatus() const
G4int GetNumberOfSecondaries() const
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
virtual const G4String & GetName() const =0
const G4Step * GetStep() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
void EndTracking(G4Track *)
void FindReaction(G4ITReactionSet *reactionSet, const double currentStepTime, const double previousStepTime, const bool reachedUserStepTimeLimit)
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
G4ITReactionSet * fReactionSet
G4GLOB_DLL std::ostream G4cout
void _PushTrack(G4Track *track)
const G4ParticleDefinition * GetParticleDefinition() const
G4int GetTrackID() const
G4double GetGlobalTime() const
const G4Track * GetTrackB()
std::vector< G4ITReactionChange * > * GetReactionInfo()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual void UserReactionAction(const G4Track &, const G4Track &, const std::vector< G4Track * > *)
void CleanAllReaction()
G4bool WereParentsKilled() const
#define G4endl
Definition: G4ios.hh:61
std::vector< G4Track * > * GetfSecondary()
G4ITTrackHolder * fpTrackContainer

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ITModelProcessor::DoCalculateStep ( )

Definition at line 418 of file G4ITModelProcessor.cc.

419 {
420  if(fpModel) // ie only one model has been declared and will be used
421  {
423  }
424  else // ie many models have been declared and will be used
425  {
426  std::vector<G4VITStepModel*>& model = fCurrentModel[GetIT(fpTrack)
427  ->GetITType()];
428 
429  for(int i = 0; i < (int) model.size(); i++)
430  {
431  if(model[i] == 0) continue;
432  model[i]->GetTimeStepper()->CalculateStep(*fpTrack, fUserMinTimeStep);
433  }
434  }
435 }
G4VITStepModel * fpModel
std::vector< std::vector< G4VITStepModel * > > fCurrentModel
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
virtual G4double CalculateStep(const G4Track &, const G4double &)=0
G4VITTimeStepComputer * GetTimeStepper()
virtual const G4ITType GetITType() const =0
const G4Track * fpTrack
const XML_Char XML_Content * model
Definition: expat.h:151

Here is the call graph for this function:

void G4ITModelProcessor::ExtractTimeStepperData ( )
protected

Definition at line 210 of file G4ITModelProcessor.cc.

211 {
212  if(fpTrack == 0)
213  {
214  CleanProcessor();
215  return;
216  }
217 
218  const std::vector<std::vector<G4VITStepModel*> >* model = GetCurrentModel();
219 
220  for(unsigned i = 0; i < model->size(); ++i)
221  {
222  for(unsigned j = 0; j < (*model)[i].size(); ++j)
223  {
224  G4VITStepModel* mod = (*model)[i][j];
225 
226  if(mod == 0)
227  {
228  continue;
229  }
230 
231  G4VITTimeStepComputer* stepper(mod->GetTimeStepper());
232 
233  G4double sampledMinTimeStep(stepper->GetSampledMinTimeStep());
234  G4TrackVectorHandle reactants(stepper->GetReactants());
235 
236  if(sampledMinTimeStep < fTSTimeStep)
237  {
238  /*
239  // DEBUG SPECIAL CASE
240  if(!reactants)
241  {
242  G4ExceptionDescription exceptionDescription ;
243  CalculateMinTimeStep(); // => at least N (N = nb of tracks) loops exceptionDescription << "No reactants were found by the time stepper.";
244  G4Exception("G4Scheduler::ExtractTimeStepperData","ITScheduler007",
245  FatalErrorInArgument,exceptionDescription);
246  continue ;
247  }
248  */
249 
250  fTSTimeStep = sampledMinTimeStep;
251  //fReactingTracks.clear();
252 
254  if(bool(reactants))
255  {
256  // G4cout << "*** (1) G4Scheduler::ExtractTimeStepperData insert
257  // reactants for " << GetIT(track)->GetName() << G4endl;
258  // G4cout << "bool(reactants) = " << bool(reactants) << G4endl;
259  // G4cout << reactants->size() << G4endl;
260  // G4cout << GetIT(reactants->operator[](0))->GetName() << G4endl;
261 
262  // fReactingTracks.insert(make_pair(track, reactants));
264  const_cast<G4Track*>(fpTrack),
265  reactants);
266  stepper->ResetReactants();
267  }
268  }
269  else if(fTSTimeStep == sampledMinTimeStep)
270  {
271  /*
272  // DEBUG SPECIAL CASE
273  if(!reactants)
274  {
275  G4ExceptionDescription exceptionDescription ;
276  exceptionDescription << "No reactants were found by the time stepper.";
277  G4Exception("G4Scheduler::ExtractTimeStepperData","ITScheduler008",
278  FatalErrorInArgument,exceptionDescription);
279  continue ;
280  }
281  */
282  if(bool(reactants))
283  {
284  // G4cout << "*** (2) G4Scheduler::ExtractTimeStepperData insert
285  // reactants for " << GetIT(track)->GetName() << G4endl;
286  // G4cout << "bool(reactants) = " << bool(reactants) << G4endl;
287  // G4cout << "trackA : " << GetIT(track)->GetName()
288  // << " ("<< track->GetTrackID() << ")" << G4endl;
289  // G4cout << reactants->size() << G4endl;
290  // G4cout << GetIT(reactants->operator[](0))->GetName() << G4endl;
291 
292  // fReactingTracks.insert(make_pair(track, reactants));
293 
295  const_cast<G4Track*>(fpTrack),
296  reactants);
297  stepper->ResetReactants();
298  }
299  }
300  else
301  {
302  if(bool(reactants))
303  {
304  stepper->ResetReactants();
305  }
306  }
307  }
308  }
309 
310  CleanProcessor();
311 }
G4shared_ptr< std::vector< G4Track * > > G4TrackVectorHandle
Definition: G4ITReaction.hh:43
void AddReactions(double time, G4Track *trackA, G4TrackVectorHandle reactants)
G4ITReactionSet * fReactionSet
const std::vector< std::vector< G4VITStepModel * > > * GetCurrentModel()
G4VITTimeStepComputer * GetTimeStepper()
void CleanAllReaction()
const G4Track * fpTrack
double G4double
Definition: G4Types.hh:76
const XML_Char XML_Content * model
Definition: expat.h:151

Here is the call graph for this function:

void G4ITModelProcessor::FindReaction ( G4ITReactionSet reactionSet,
const double  currentStepTime,
const double  previousStepTime,
const bool  reachedUserStepTimeLimit 
)

Definition at line 622 of file G4ITModelProcessor.cc.

626 {
627  // DEBUG
628  // G4cout << "G4ITReactionManager::FindReaction" << G4endl;
629  //if (tracks == 0) return;
630  if(reactionSet == 0) return;
631  if(fpModelHandler->GetAllModelManager()->empty()) return;
632 
633  G4ITReactionPerTrackMap& reactionPerTrackMap = reactionSet->GetReactionMap();
634 
635  std::map<G4Track*, G4ITReactionPerTrackPtr, compTrackPerID>::iterator tracks_i =
636  reactionPerTrackMap.begin();
637 
638  //std::map<G4Track*, G4TrackVectorHandle, compTrackPerID>::iterator tracks_i = tracks->begin();
639 
640  // G4cout << "G4ITModelProcessor::FindReaction at step :" << G4ITTimeStepper::Instance()->GetNbSteps() << G4endl;
641 
642  // for (tracks_i = tracks->begin(); tracks_i != tracks->end(); tracks_i++)
643  for(tracks_i = reactionPerTrackMap.begin();
644  tracks_i != reactionPerTrackMap.end();
645  tracks_i = reactionPerTrackMap.begin())
646  {
647  //G4cout << "here" << G4endl;
648  G4Track* trackA = tracks_i->first;
649  if(trackA->GetTrackStatus() == fStopAndKill)
650  {
651  //G4cout << "continue 1" << G4endl;
652  continue;
653  }
654 
655  G4ITReactionPerTrackPtr reactionPerTrack = tracks_i->second;
656  G4ITReactionList& reactionList = reactionPerTrack->GetReactionList();
657 
658  G4IT* ITA = GetIT(trackA);
659  G4ITType ITypeA = ITA->GetITType();
660 
661  const std::vector<G4VITStepModel*> model = fCurrentModel[ITypeA];
662 
663  G4Track* trackB = 0;
664  G4ITType ITypeB(-1);
665  G4VITReactionProcess* process = 0;
666  G4ITReactionChange* changes = 0;
667 
668  assert(reactionList.begin() != reactionList.end());
669 
670  for(G4ITReactionList::iterator it = reactionList.begin();
671  it != reactionList.end(); it = reactionList.begin())
672  {
673  G4ITReactionPtr reaction(*it);
674  trackB = reaction->GetReactant(trackA);
675  if(trackB->GetTrackStatus() == fStopAndKill)
676  {
677  //G4cout << "continue 2" << G4endl;
678  continue;
679  }
680 
681  if(trackB == trackA)
682  {
683  G4ExceptionDescription exceptionDescription;
684  exceptionDescription
685  << "The IT reaction process sent back a reaction between trackA and trackB. ";
686  exceptionDescription << "The problem is trackA == trackB";
687  G4Exception("G4ITModelProcessor::FindReaction",
688  "ITModelProcessor005",
690  exceptionDescription);
691  }
692 
693  G4IT* ITB = GetIT(trackB);
694  G4ITType ITypeBtmp = ITB->GetITType();
695 
696  if(ITypeB != ITypeBtmp)
697  {
698  ITypeB = ITypeBtmp;
699 
700  if(model[ITypeB]) process = model[ITypeB]->GetReactionProcess();
701  }
702 
703  reactionSet->SelectThisReaction(reaction);
704 
705  if(process && process->TestReactibility(*trackA,
706  *trackB,
707  currentStepTime,
708  previousStepTime,
709  reachedUserStepTimeLimit))
710  {
711  changes = process->MakeReaction(*trackA, *trackB);
712  }
713 
714  if(changes)
715  {
716  fReactionInfo.push_back(changes);
717 
718  // G4cout << "pushing reaction for trackA (" << trackA->GetTrackID() << ") and trackB ("
719  // << trackB->GetTrackID() << ")" << G4endl;
720  //
721  // G4cout << "nb of secondaries : " << changes->GetNumberOfSecondaries() << G4endl;
722  // G4cout << "with track 0 = " << changes->GetSecondary(0) << G4endl;
723 
724  process->ResetChanges();
725  changes = 0;
726 
727  break;
728  }
729  }
730  }
731 
732  //assert(G4ITReaction::gAll->empty() == true);
733 }
const std::vector< std::vector< G4ITModelManager * > > * GetAllModelManager()
virtual G4bool TestReactibility(const G4Track &, const G4Track &, const double, const double, bool)=0
Definition: G4IT.hh:88
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
std::vector< G4ITReactionChange * > fReactionInfo
G4TrackStatus GetTrackStatus() const
std::vector< std::vector< G4VITStepModel * > > fCurrentModel
G4shared_ptr< G4ITReaction > G4ITReactionPtr
Definition: G4ITReaction.hh:59
std::map< G4Track *, G4ITReactionPerTrackPtr, compTrackPerID > G4ITReactionPerTrackMap
Definition: G4ITReaction.hh:66
G4ITReactionPerTrackMap & GetReactionMap()
void SelectThisReaction(G4ITReactionPtr reaction)
G4IT * GetIT(const G4Track *track)
Definition: G4IT.cc:49
std::list< G4ITReactionPtr > G4ITReactionList
Definition: G4ITReaction.hh:63
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4shared_ptr< G4ITReactionPerTrack > G4ITReactionPerTrackPtr
Definition: G4ITReaction.hh:61
virtual const G4ITType GetITType() const =0
virtual G4ITReactionChange * MakeReaction(const G4Track &, const G4Track &)=0
const XML_Char XML_Content * model
Definition: expat.h:151
G4ITModelHandler * fpModelHandler

Here is the call graph for this function:

bool G4ITModelProcessor::GetComputeTimeStep ( )
inline

Definition at line 118 of file G4ITModelProcessor.hh.

119  {
120  return fComputeTimeStep;
121  }

Here is the caller graph for this function:

const std::vector< std::vector< G4VITStepModel * > > * G4ITModelProcessor::GetCurrentModel ( )
inline

Definition at line 211 of file G4ITModelProcessor.hh.

212 {
213  return &fCurrentModel;
214 }
std::vector< std::vector< G4VITStepModel * > > fCurrentModel
std::vector<G4ITReactionChange*>* G4ITModelProcessor::GetReactionInfo ( )
inline

Definition at line 142 of file G4ITModelProcessor.hh.

143  {
144  return &fReactionInfo;
145  }
std::vector< G4ITReactionChange * > fReactionInfo
const G4Track* G4ITModelProcessor::GetTrack ( ) const
inline

Definition at line 147 of file G4ITModelProcessor.hh.

148  {
149  return fpTrack;
150  }
const G4Track * fpTrack
void G4ITModelProcessor::Initialize ( )

Definition at line 117 of file G4ITModelProcessor.cc.

118 {
122  fInitialized = true;
123  fComputeTimeStep = false;
124  fComputeReaction = false;
127 }
static G4ITReactionSet * Instance()
G4ITReactionSet * fReactionSet
static G4ITTrackHolder * Instance()
G4ITModelHandler * fpModelHandler
bool GetTimeStepComputerFlag()
G4ITTrackHolder * fpTrackContainer

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ITModelProcessor::InitializeStepper ( G4double  currentGlobalTime,
G4double  userMinTime 
)

Definition at line 315 of file G4ITModelProcessor.cc.

317 {
318  // G4cout << "G4ITModelProcessor::InitializeStepper" << G4endl;
319  if(fpModelHandler == 0)
320  {
321  G4ExceptionDescription exceptionDescription;
322  exceptionDescription
323  << "No G4ITModelHandler was passed to the modelProcessor.";
324  G4Exception("G4ITModelProcessor::InitializeStepper",
325  "ITModelProcessor002",
327  exceptionDescription);
328  }
329  const std::vector<std::vector<G4ITModelManager*> >* modelManager =
331 
332  if(modelManager == 0)
333  {
334  G4ExceptionDescription exceptionDescription;
335  exceptionDescription
336  << "No G4ITModelManager was register to G4ITModelHandler.";
337  G4Exception("G4ITModelProcessor::InitializeStepper",
338  "ITModelProcessor003",
340  exceptionDescription);
341  }
342 
343  int nbModels1 = modelManager->size();
344 
345  G4VITTimeStepComputer::SetTimes(currentGlobalTime, userMinTime);
346 
347  // TODO !!!
348  // if( nbModels1 != 1 || (nbModels1 == 1 && !fpModelManager) )
349  {
350  int nbModels2 = -1;
351  G4VITStepModel* model = 0;
352  G4ITModelManager* modman = 0;
353 
354  for(int i = 0; i < nbModels1; i++)
355  {
356  nbModels2 = (*modelManager)[i].size();
357 
358  for(int j = 0; j <= i; j++)
359  {
360  modman = (*modelManager)[i][j];
361 
362  if(modman == 0) continue;
363 
364  model = modman->GetModel(currentGlobalTime);
365  G4VITTimeStepComputer* stepper = model->GetTimeStepper();
366 
367 #if defined (DEBUG_MEM)
368  MemStat mem_first, mem_second, mem_diff;
369 #endif
370 
371 #if defined (DEBUG_MEM)
372  mem_first = MemoryUsage();
373 #endif
374 
375  // stepper->PrepareForAllProcessors() ;
376  stepper->Prepare();
377 
378 #if defined (DEBUG_MEM)
379  mem_second = MemoryUsage();
380  mem_diff = mem_second-mem_first;
381  G4cout << "\t || MEM || G4ITModelProcessor::InitializeStepper || After computing stepper -> Prepare(), diff is : " << mem_diff << G4endl;
382 #endif
383  fCurrentModel[i][j] = model;
384  }
385  }
386 
387  if(nbModels1 == 1 && nbModels2 == 1)
388  {
389  fpModelManager = modman;
390  fpModel = model;
391  }
392  else fpModel = 0;
393  }
394 }
const std::vector< std::vector< G4ITModelManager * > > * GetAllModelManager()
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4VITStepModel * fpModel
std::vector< std::vector< G4VITStepModel * > > fCurrentModel
MemStat MemoryUsage()
Definition: G4MemStat.cc:55
static void SetTimes(const G4double &, const G4double &)
G4GLOB_DLL std::ostream G4cout
G4VITTimeStepComputer * GetTimeStepper()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4ITModelManager * fpModelManager
#define G4endl
Definition: G4ios.hh:61
G4VITStepModel * GetModel(const G4double globalTime)
const XML_Char XML_Content * model
Definition: expat.h:151
G4ITModelHandler * fpModelHandler

Here is the call graph for this function:

G4ITModelProcessor & G4ITModelProcessor::operator= ( const G4ITModelProcessor other)
protected

Assignment operator

Parameters
otherObject to assign from
Returns
A reference to this

Definition at line 110 of file G4ITModelProcessor.cc.

111 {
112  if(this == &rhs) return *this; // handle self assignment
113  //assignment operator
114  return *this;
115 }
void G4ITModelProcessor::RegisterModel ( double  time,
G4VITStepModel model 
)

Definition at line 104 of file G4ITModelProcessor.cc.

105 {
106  fpModelHandler->RegisterModel(model, time);
107 }
void RegisterModel(G4VITStepModel *aModel, const G4double globalTime)
G4ITModelHandler * fpModelHandler
void G4ITModelProcessor::SetModelHandler ( G4ITModelHandler modelHandler)
inline

Definition at line 216 of file G4ITModelProcessor.hh.

217 {
218  if (fInitialized == 1)
219  {
220  G4ExceptionDescription exceptionDescription;
221  exceptionDescription
222  << "You are trying to set a new model while the model processor has alreaday be initialized";
223  G4Exception("G4ITModelProcessor::SetModelHandler", "ITModelProcessor001",
224  FatalErrorInArgument, exceptionDescription);
225  }
226  fpModelHandler = modelHandler;
227 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4ITModelHandler * fpModelHandler

Here is the call graph for this function:

Here is the caller graph for this function:

void G4ITModelProcessor::SetTrack ( const G4Track track)
inlineprotected

Definition at line 206 of file G4ITModelProcessor.hh.

207 {
208  fpTrack = track;
209 }
const G4Track * fpTrack
void G4ITModelProcessor::SetTrackingManager ( G4ITTrackingManager trackingManager)
inline

Definition at line 152 of file G4ITModelProcessor.hh.

153  {
154  fpTrackingManager = trackingManager;
155  }
G4ITTrackingManager * fpTrackingManager

Here is the caller graph for this function:

Member Data Documentation

bool G4ITModelProcessor::fComputeReaction
protected

Definition at line 199 of file G4ITModelProcessor.hh.

bool G4ITModelProcessor::fComputeTimeStep
protected

Definition at line 198 of file G4ITModelProcessor.hh.

std::vector<std::vector<G4VITStepModel*> > G4ITModelProcessor::fCurrentModel
protected

Definition at line 186 of file G4ITModelProcessor.hh.

G4ITType G4ITModelProcessor::fCurrentType1
protected

Definition at line 193 of file G4ITModelProcessor.hh.

G4ITType G4ITModelProcessor::fCurrentType2
protected

Definition at line 194 of file G4ITModelProcessor.hh.

G4bool G4ITModelProcessor::fInitialized
protected

Definition at line 178 of file G4ITModelProcessor.hh.

G4VITStepModel* G4ITModelProcessor::fpModel
protected

Definition at line 190 of file G4ITModelProcessor.hh.

G4ITModelHandler* G4ITModelProcessor::fpModelHandler
protected

Definition at line 179 of file G4ITModelProcessor.hh.

G4ITModelManager* G4ITModelProcessor::fpModelManager
protected

Definition at line 191 of file G4ITModelProcessor.hh.

const G4Track* G4ITModelProcessor::fpTrack
protected

Definition at line 181 of file G4ITModelProcessor.hh.

G4ITTrackHolder* G4ITModelProcessor::fpTrackContainer
protected

Definition at line 176 of file G4ITModelProcessor.hh.

G4ITTrackingManager* G4ITModelProcessor::fpTrackingManager
protected

Definition at line 175 of file G4ITModelProcessor.hh.

std::vector<G4ITReactionChange*> G4ITModelProcessor::fReactionInfo
protected

Definition at line 196 of file G4ITModelProcessor.hh.

G4ITReactionSet* G4ITModelProcessor::fReactionSet
protected

Definition at line 174 of file G4ITModelProcessor.hh.

G4double G4ITModelProcessor::fTSTimeStep
protected

Definition at line 173 of file G4ITModelProcessor.hh.

G4double G4ITModelProcessor::fUserMinTimeStep
protected

Definition at line 182 of file G4ITModelProcessor.hh.


The documentation for this class was generated from the following files: