49 using namespace CLHEP;
55 using namespace G4MemStat;
58 G4DNAMoleculeEncounterStepper::Utils::Utils(
const G4Track& tA,
60 trackA(tA), moleculeB(mB)
63 DA = moleculeA->GetDiffusionCoefficient();
64 DB = moleculeB->GetDiffusionCoefficient();
65 Constant = 8 * (DA + DB + 2 * sqrt(DA * DB));
70 fMolecularReactionTable(
75 fHasAlreadyReachedNullTime =
false;
80 if (
this == &rhs)
return *
this;
82 fVerbose = rhs.fVerbose;
83 fMolecularReactionTable = rhs.fMolecularReactionTable;
84 fHasAlreadyReachedNullTime =
false;
94 fMolecularReactionTable(
97 fVerbose = right.fVerbose;
98 fMolecularReactionTable = right.fMolecularReactionTable;
100 fHasAlreadyReachedNullTime =
false;
109 #if defined (DEBUG_MEM)
110 MemStat mem_first, mem_second, mem_diff;
113 #if defined (DEBUG_MEM)
118 #if defined (DEBUG_MEM)
120 mem_diff = mem_second-mem_first;
121 G4cout <<
"\t || MEM || G4DNAMoleculeEncounterStepper::Prepare || "
122 "After computing G4ITManager<G4Molecule>::Instance()->"
123 "UpdatePositionMap, diff is : " << mem_diff <<
G4endl;
127 void G4DNAMoleculeEncounterStepper::InitializeForNewTrack()
132 fHasAlreadyReachedNullTime =
false;
138 return std::numeric_limits<T>::has_infinity
139 && value == std::numeric_limits<T>::infinity();
151 InitializeForNewTrack();
158 <<
"_______________________________________________________________________"
160 G4cout <<
"G4DNAMoleculeEncounterStepper::CalculateStep" <<
G4endl;
161 G4cout <<
"Check done for molecule : " << moleculeA->
GetName()
171 const vector<G4MolecularConfiguration*>* reactivesVector = fMolecularReactionTable
174 if (!reactivesVector)
182 G4cout <<
"G4MoleculeEncounterStepper::CalculateStep will return infinity "
183 "for the reaction because the molecule "
185 <<
" does not have any reactants given in the reaction table."
193 G4int nbReactives = reactivesVector->size();
195 if (nbReactives == 0)
204 G4cout <<
"G4MoleculeEncounterStepper::CalculateStep will return infinity "
205 "for the reaction because the molecule "
207 <<
" does not have any reactants given in the reaction table."
208 <<
"This message can also result from a wrong implementation of the reaction table."
231 for (
G4int i = 0; i < nbReactives; i++)
247 if (resultsNearest == 0)
continue;
249 G4double r2 = resultsNearest->GetDistanceSqr();
250 Utils utils(trackA, moleculeB);
259 if (fHasAlreadyReachedNullTime ==
false)
262 fHasAlreadyReachedNullTime =
true;
270 CheckAndRecordResults(utils,
279 G4double tempMinET = pow(r - R, 2) / utils.Constant;
303 FindNearestInRange(moleculeA,
307 CheckAndRecordResults(utils,
322 CheckAndRecordResults(utils,
352 G4cout <<
"G4MoleculeEncounterStepper::CalculateStep will finally return :"
357 G4cout <<
"Selected reactants for trackA: " << moleculeA->
GetName()
360 vector<G4Track*>::iterator it;
374 void G4DNAMoleculeEncounterStepper::CheckAndRecordResults(
const Utils& utils,
386 G4cout <<
"No molecule " << utils.moleculeB->GetName()
387 <<
" found to react with " << utils.moleculeA->GetName()
394 for (results->Rewind(); !results->End(); results->Next())
397 G4IT* reactiveB = results->GetItem<
G4IT>();
412 <<
"The reactant B found using the MoleculeFinder does not have a valid "
413 "track attached to it. If this is done on purpose, please do "
414 "not record this molecule in the MoleculeFinder."
416 G4Exception(
"G4DNAMoleculeEncounterStepper::RetrieveResults",
418 exceptionDescription);
442 if (trackB == &utils.trackA)
447 <<
"A track is reacting with itself (which is impossible) ie trackA == trackB"
449 exceptionDescription <<
"Molecule A (and B) is of type : "
450 << utils.moleculeA->GetName() <<
" with trackID : "
451 << utils.trackA.GetTrackID() <<
G4endl;
453 G4Exception(
"G4DNAMoleculeEncounterStepper::RetrieveResults",
455 exceptionDescription);
459 if (fabs(trackB->
GetGlobalTime() - utils.trackA.GetGlobalTime())
460 > utils.trackA.GetGlobalTime() * (1 - 1 / 100))
465 <<
"The interacting tracks are not synchronized in time" <<
G4endl;
467 <<
"trackB->GetGlobalTime() != trackA.GetGlobalTime()" <<
G4endl;
469 exceptionDescription <<
"trackA : trackID : " << utils.trackA.GetTrackID()
470 <<
"\t Name :" << utils.moleculeA->GetName()
471 <<
"\t trackA->GetGlobalTime() = "
472 <<
G4BestUnit(utils.trackA.GetGlobalTime(),
"Time") << G4endl;
474 exceptionDescription <<
"trackB : trackID : " << trackB->
GetTrackID()
475 <<
"\t Name :" << utils.moleculeB->GetName()
476 <<
"\t trackB->GetGlobalTime() = "
479 G4Exception(
"G4DNAMoleculeEncounterStepper::RetrieveResults",
481 exceptionDescription);
487 G4double r2 = results->GetDistanceSqr();
488 G4cout <<
"\t ************************************************** " <<
G4endl;
489 G4cout <<
"\t Reaction between "
490 << utils.moleculeA->GetName() <<
" (" << utils.trackA.GetTrackID() <<
") "
491 <<
" & " << utils.moleculeB->GetName() <<
" (" << trackB->
GetTrackID() <<
"), "
492 <<
"Interaction Range = "
494 G4cout <<
"\t Real distance between reactants = "
496 G4cout <<
"\t Distance between reactants calculated by nearest neighbor algorithm = "
std::ostringstream G4ExceptionDescription
G4TrackVectorHandle fReactants
G4DNAMoleculeEncounterStepper()
const G4ThreeVector & GetPosition() const
G4TrackStatus GetTrackStatus() const
ReturnType & reference_cast(OriginalType &source)
static G4ITFinder * Instance()
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
G4MolecularConfiguration * GetMolecularConfiguration() const
const G4ThreeVector const G4double const
virtual ~G4DNAMoleculeEncounterStepper()
virtual G4double CalculateStep(const G4Track &, const G4double &)
G4double fSampledMinTimeStep
const G4String & GetName() const
G4GLOB_DLL std::ostream G4cout
static G4ThreadLocal G4double fUserMinTimeStep
const XML_Char int const XML_Char * value
const G4ParticleDefinition const G4Material *G4double range
virtual G4double GetReactionRadius(G4MolecularConfiguration *, G4MolecularConfiguration *)=0
virtual void UpdatePositionMap()
G4double GetGlobalTime() const
virtual void Initialise(G4MolecularConfiguration *, const G4Track &)
G4Molecule * GetMolecule(const G4Track &track)
G4int GetMoleculeID() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
const std::vector< G4MolecularConfiguration * > * CanReactWith(G4MolecularConfiguration *) const