Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4DNAMolecularReactionTable Class Reference

#include <G4DNAMolecularReactionTable.hh>

+ Inheritance diagram for G4DNAMolecularReactionTable:

Public Member Functions

virtual ~G4DNAMolecularReactionTable ()
 
void SetReaction (G4double observedReactionRate, const G4Molecule *reactive1, const G4Molecule *reactive2)
 
void SetReaction (G4DNAMolecularReactionData *)
 
const G4DNAMolecularReactionDataGetReactionData (const G4Molecule *, const G4Molecule *) const
 
const std::vector< const G4Molecule * > * CanReactWith (const G4Molecule *aMolecule) const
 
const std::map< const G4Molecule *, const G4DNAMolecularReactionData *, compMoleculeP > * GetReativesNData (const G4Molecule *aMolecule) const
 
const std::vector< const G4DNAMolecularReactionData * > * GetReactionData (const G4Molecule *) const
 
void PrintTable (G4VDNAReactionModel *=0)
 
- Public Member Functions inherited from G4ITReactionTable
 G4ITReactionTable ()
 
virtual ~G4ITReactionTable ()
 
 G4ITReactionTable (const G4ITReactionTable &)
 
G4ITReactionTableoperator= (const G4ITReactionTable &)
 

Static Public Member Functions

static G4DNAMolecularReactionTableGetReactionTable ()
 
static void DeleteInstance ()
 

Protected Types

typedef std::map< const G4Molecule *, std::map< const G4Molecule *, const G4DNAMolecularReactionData *, compMoleculeP >, compMoleculePReactionDataMap
 
typedef std::map< const G4Molecule *, std::vector< const G4Molecule * >, compMoleculePReactivesMV
 
typedef std::map< const G4Molecule *, std::vector< const G4DNAMolecularReactionData * >, compMoleculePReactionDataMV
 

Protected Member Functions

 G4DNAMolecularReactionTable ()
 

Protected Attributes

const G4MoleculeHandleManagerfMoleculeHandleManager
 
G4bool fVerbose
 
ReactionDataMap fReactionData
 
ReactivesMV fReactivesMV
 
ReactionDataMV fReactionDataMV
 

Static Protected Attributes

static G4DNAMolecularReactionTablefInstance
 

Detailed Description

G4DNAMolecularReactionTable sorts out the G4DNAMolecularReactionData for bimolecular reaction

Definition at line 111 of file G4DNAMolecularReactionTable.hh.

Member Typedef Documentation

◆ ReactionDataMap

◆ ReactionDataMV

◆ ReactivesMV

Definition at line 159 of file G4DNAMolecularReactionTable.hh.

Constructor & Destructor Documentation

◆ G4DNAMolecularReactionTable()

G4DNAMolecularReactionTable::G4DNAMolecularReactionTable ( )
protected

Definition at line 129 of file G4DNAMolecularReactionTable.cc.

131{
132// G4cout << "G4DNAMolecularReactionTable::G4DNAMolecularReactionTable()" << G4endl;
133 fVerbose = false;
134 return;
135}
const G4MoleculeHandleManager * fMoleculeHandleManager
static G4MoleculeHandleManager * Instance()

Referenced by GetReactionTable().

◆ ~G4DNAMolecularReactionTable()

G4DNAMolecularReactionTable::~G4DNAMolecularReactionTable ( )
virtual

Definition at line 137 of file G4DNAMolecularReactionTable.cc.

138{
139 // DEBUG
140// G4cout << "G4MolecularReactionTable::~G4MolecularReactionTable" << G4endl;
141 ReactionDataMap::iterator it1 = fReactionData.begin();
142
143 std::map<const G4Molecule*,
145 compMoleculeP>::iterator it2;
146
147 for(;it1!=fReactionData.end();it1++)
148 {
149 for(it2 = it1->second.begin();it2 != it1->second.end();it2++)
150 {
151 const G4DNAMolecularReactionData* reactionData = it2->second;
152 if(reactionData)
153 {
154 const G4Molecule* reactive1 = reactionData->GetReactive1();
155 const G4Molecule* reactive2 = reactionData->GetReactive2();
156
157 fReactionData[reactive1][reactive2] = 0;
158 fReactionData[reactive2][reactive1] = 0;
159
160 delete reactionData;
161 }
162 }
163 }
164
165 fReactionDataMV.clear();
166 fReactionData.clear();
167 fReactivesMV.clear();
168}
const G4Molecule * GetReactive2() const
const G4Molecule * GetReactive1() const

Member Function Documentation

◆ CanReactWith()

const std::vector< const G4Molecule * > * G4DNAMolecularReactionTable::CanReactWith ( const G4Molecule aMolecule) const

Given a molecule's type, it returns with which a reaction is allowed

Definition at line 386 of file G4DNAMolecularReactionTable.cc.

387{
388 if(fReactivesMV.empty())
389 {
390 G4String errMsg = "No reaction table was implemented";
391 G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
392 return 0;
393 }
394
395 ReactivesMV::const_iterator itReactivesMap = fReactivesMV.find(aMolecule) ;
396
397 if(itReactivesMap == fReactivesMV.end())
398 {
399 G4cout<<"Nom : " << aMolecule->GetName()<<G4endl;
400 G4String errMsg = "No reaction table was implemented for this molecule Definition : "
401 + aMolecule -> GetName();
402 G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
403 return 0;
404 }
405 else
406 {
407 if(fVerbose)
408 {
409 G4cout<< " G4MolecularInteractionTable::CanReactWith :"<<G4endl;
410 G4cout<<"You are checking reactants for : " << aMolecule->GetName()<<G4endl;
411 G4cout<<" the number of reactants is : " << itReactivesMap->second.size()<<G4endl;
412
413 std::vector<const G4Molecule*>::const_iterator itProductsVector =
414 itReactivesMap->second.begin();
415
416 for( ; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
417 {
418 G4cout<<(*itProductsVector)->GetName()<<G4endl;
419 }
420 }
421 return &(itReactivesMap->second);
422 }
423 return 0;
424}
@ FatalErrorInArgument
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
const G4String & GetName() const
Definition: G4Molecule.cc:259
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41

Referenced by PrintTable().

◆ DeleteInstance()

void G4DNAMolecularReactionTable::DeleteInstance ( )
static

Definition at line 120 of file G4DNAMolecularReactionTable.cc.

121{
122 // DEBUG
123// G4cout << "G4MolecularReactionTable::DeleteInstance" << G4endl;
124 if(fInstance)
125 delete fInstance;
126 fInstance = 0;
127}
static G4DNAMolecularReactionTable * fInstance

◆ GetReactionData() [1/2]

const std::vector< const G4DNAMolecularReactionData * > * G4DNAMolecularReactionTable::GetReactionData ( const G4Molecule molecule) const

Definition at line 472 of file G4DNAMolecularReactionTable.cc.

473{
474 if(fReactionDataMV.empty())
475 {
476 G4String errMsg = "No reaction table was implemented";
477 G4Exception("G4MolecularInteractionTable::CanInteractWith","",FatalErrorInArgument, errMsg);
478 return 0 ;
479 }
480 ReactionDataMV::const_iterator it = fReactionDataMV.find(molecule) ;
481
482 if(it == fReactionDataMV.end())
483 {
484 G4cout<<"Nom : " << molecule->GetName()<<G4endl;
485 G4String errMsg = "No reaction table was implemented for this molecule Definition : "
486 + molecule -> GetName();
487 G4Exception("G4MolecularInteractionTable::GetReactionData","",FatalErrorInArgument, errMsg);
488 return 0; // coverity
489 }
490
491 return &(it->second);
492}

◆ GetReactionData() [2/2]

const G4DNAMolecularReactionData * G4DNAMolecularReactionTable::GetReactionData ( const G4Molecule reactive1,
const G4Molecule reactive2 
) const

Definition at line 350 of file G4DNAMolecularReactionTable.cc.

352{
353 if(fReactionData.empty())
354 {
355 G4String errMsg = "No reaction table was implemented";
356 G4Exception("G4MolecularInteractionTable::CanInteractWith","",FatalErrorInArgument, errMsg);
357 return 0;
358 }
359
360 ReactionDataMap::const_iterator it1 = fReactionData.find(reactive1);
361
362 if(it1 == fReactionData.end())
363 {
364 G4cout<<"Nom : " << reactive1->GetName()<<G4endl;
365 G4String errMsg = "No reaction table was implemented for this molecule Definition : "
366 + reactive1 -> GetName();
367 G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
368 }
369
370 std::map<const G4Molecule*,
372 compMoleculeP>::const_iterator it2 = it1->second.find(reactive2);
373
374 if(it2 == it1->second.end())
375 {
376 G4cout<<"Nom : " << reactive2->GetName()<<G4endl;
377 G4String errMsg = "No reaction table was implemented for this molecule Definition : "
378 + reactive2 -> GetName();
379 G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
380 }
381
382 return (it2->second);
383}

Referenced by G4DNASmoluchowskiReactionModel::Initialise(), G4DNASmoluchowskiReactionModel::InitialiseToPrint(), and G4DNAMolecularReaction::MakeReaction().

◆ GetReactionTable()

G4DNAMolecularReactionTable * G4DNAMolecularReactionTable::GetReactionTable ( )
static

◆ GetReativesNData()

const std::map< const G4Molecule *, const G4DNAMolecularReactionData *, compMoleculeP > * G4DNAMolecularReactionTable::GetReativesNData ( const G4Molecule aMolecule) const

Definition at line 428 of file G4DNAMolecularReactionTable.cc.

429{
430
431 if(fReactionData.empty())
432 {
433 G4String errMsg = "No reaction table was implemented";
434 G4Exception("G4MolecularInteractionTable::CanInteractWith","",FatalErrorInArgument, errMsg);
435 return 0;
436 }
437
438 ReactionDataMap::const_iterator itReactivesMap = fReactionData.find(molecule) ;
439
440 if(itReactivesMap == fReactionData.end())
441 {
442 G4cout<<"Nom : " << molecule->GetName()<<G4endl;
443 G4String errMsg = "No reaction table was implemented for this molecule Definition : "
444 + molecule -> GetName();
445 G4Exception("G4MolecularInteractionTable::CanReactWith","",FatalErrorInArgument, errMsg);
446 }
447 else
448 {
449 if(fVerbose)
450 {
451 G4cout<< " G4MolecularInteractionTable::CanReactWith :"<<G4endl;
452 G4cout<<"You are checking reactants for : " << molecule->GetName()<<G4endl;
453 G4cout<<" the number of reactants is : " << itReactivesMap->second.size()<<G4endl;
454
455 std::map<const G4Molecule*,
457 compMoleculeP>::const_iterator itProductsVector =
458 itReactivesMap->second.begin();
459
460 for( ; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
461 {
462 G4cout<<itProductsVector->first->GetName()<<G4endl;
463 }
464 }
465 return &(itReactivesMap->second);
466 }
467
468 return 0;
469}

◆ PrintTable()

void G4DNAMolecularReactionTable::PrintTable ( G4VDNAReactionModel pReactionModel = 0)

Definition at line 195 of file G4DNAMolecularReactionTable.cc.

196{
197 // Print Reactions and Interaction radius for jump step = 3ps
198
199 if(pReactionModel)
200 {
201 if(!(pReactionModel->GetReactionTable()))
202 pReactionModel -> SetReactionTable(this);
203 }
204
205 ReactivesMV::iterator itReactives;
206
207 map<G4Molecule*,map<G4Molecule*, G4bool> > alreadyPrint;
208
209 G4cout<<"Nombre particules intervenants dans les reactions = "<< fReactivesMV.size() <<G4endl;
210
211 G4int nbPrintable = fReactivesMV.size()*fReactivesMV.size();
212
213 G4String *outputReaction = new G4String[nbPrintable];
214 G4String *outputReactionRate = new G4String[nbPrintable];
215 G4String *outputRange = new G4String[nbPrintable];
216 G4int n = 0;
217
218 for(itReactives = fReactivesMV.begin() ; itReactives != fReactivesMV.end() ; itReactives++)
219 {
220 G4Molecule* moleculeA = (G4Molecule*) itReactives->first;
221 const vector<const G4Molecule*>* reactivesVector = CanReactWith(moleculeA);
222
223 if(pReactionModel)
224 pReactionModel -> InitialiseToPrint(moleculeA);
225
226 G4int nbReactants = fReactivesMV[itReactives->first].size();
227
228 for(G4int iReact = 0 ; iReact < nbReactants ; iReact++)
229 {
230
231 G4Molecule* moleculeB = (G4Molecule*) (*reactivesVector)[iReact];
232
233 const G4DNAMolecularReactionData* reactionData = fReactionData[moleculeA][moleculeB];
234
235 //-----------------------------------------------------------
236 // Name of the reaction
237 if(!alreadyPrint[moleculeA][moleculeB])
238 {
239 outputReaction[n]=
240 moleculeA->GetName()
241 +" + " +
242 moleculeB->GetName();
243
244 G4int nbProducts = reactionData->GetNbProducts();
245
246 if(nbProducts)
247 {
248 outputReaction[n] += " -> "+ reactionData->GetProduct(0)->GetName();
249
250 for(G4int j = 1 ; j < nbProducts ; j++)
251 {
252 outputReaction[n]+=" + "+reactionData->GetProduct(j)->GetName();
253 }
254 }
255 else
256 {
257 outputReaction[n]+=" -> No product";
258 }
259
260 //-----------------------------------------------------------
261 // Interaction Rate
262 outputReactionRate[n] = G4UIcommand::ConvertToString(reactionData->GetReactionRate()/(1e-3*m3/(mole*s)));
263
264 //-----------------------------------------------------------
265 // Calculation of the Interaction Range
266 G4double interactionRange = -1;
267 if(pReactionModel)
268 interactionRange = pReactionModel->GetReactionRadius(iReact);
269
270 if(interactionRange!=-1)
271 {
272 outputRange[n] = G4UIcommand::ConvertToString(interactionRange/nanometer);
273 }
274 else
275 {
276 outputRange[n] = "";
277 }
278
279 alreadyPrint[moleculeB][moleculeA] = TRUE;
280 n++;
281 }
282 }
283 }
284 G4cout<<"Number of possible reactions: "<< n << G4endl;
285
286 ////////////////////////////////////////////////////////////////////
287 // Tableau dynamique en fonction du nombre de caractère maximal dans
288 // chaque colonne
289 ////////////////////////////////////////////////////////////////////
290
291 G4int maxlengthOutputReaction = -1;
292 G4int maxlengthOutputReactionRate = -1;
293
294 for(G4int i = 0 ; i < n ; i++)
295 {
296 if(maxlengthOutputReaction < (G4int) outputReaction[i].length())
297 {
298 maxlengthOutputReaction = outputReaction[i].length();
299 }
300 if(maxlengthOutputReactionRate < (G4int)outputReactionRate[i].length())
301 {
302 maxlengthOutputReactionRate = outputReactionRate[i].length();
303 }
304 }
305
306 maxlengthOutputReaction+=2;
307 maxlengthOutputReactionRate+=2;
308
309 if(maxlengthOutputReaction<10) maxlengthOutputReaction = 10;
310 if(maxlengthOutputReactionRate<30) maxlengthOutputReactionRate = 30;
311
312 G4String title[3];
313
314 title[0] = "Reaction";
315 title[1] = "Reaction Rate [dm3/(mol*s)]";
316 title[2] = "Interaction Range for chosen reaction model";
317
318 G4cout<< setfill(' ')
319 << setw(maxlengthOutputReaction) << left << title[0]
320 << setw(maxlengthOutputReactionRate) << left << title[1]
321 << setw(2) << left << title[2]
322 << G4endl;
323
324 G4cout.fill('-');
325 G4cout.width(maxlengthOutputReaction+2+maxlengthOutputReactionRate+2+(G4int)title[2].length());
326 G4cout<<"-"<<G4endl;
327 G4cout.fill(' ');
328
329 for(G4int i = 0 ; i < n ; i ++)
330 {
331 G4cout<< setw(maxlengthOutputReaction)<< left << outputReaction[i]
332 << setw(maxlengthOutputReactionRate) << left << outputReactionRate[i]
333 << setw(2) << left <<outputRange[i]
334 <<G4endl;
335
336 G4cout.fill('-');
337 G4cout.width(maxlengthOutputReaction+2+maxlengthOutputReactionRate+2+(G4int)title[2].length());
338 G4cout<<"-"<<G4endl;
339 G4cout.fill(' ');
340 }
341
342 delete [] outputReaction;
343 delete [] outputReactionRate;
344 delete [] outputRange;
345}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
const G4Molecule * GetProduct(G4int i) const
const std::vector< const G4Molecule * > * CanReactWith(const G4Molecule *aMolecule) const
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:349
const G4DNAMolecularReactionTable * GetReactionTable()
virtual G4double GetReactionRadius(const G4Molecule *, const G4Molecule *)=0
#define TRUE
Definition: globals.hh:55

◆ SetReaction() [1/2]

void G4DNAMolecularReactionTable::SetReaction ( G4DNAMolecularReactionData reactionData)

Definition at line 170 of file G4DNAMolecularReactionTable.cc.

171{
172 const G4Molecule* reactive1 = reactionData->GetReactive1() ;
173 const G4Molecule* reactive2 = reactionData->GetReactive2() ;
174
175 fReactionData[reactive1][reactive2] = reactionData;
176 fReactivesMV[reactive1].push_back(reactive2);
177 fReactionDataMV[reactive1].push_back(reactionData);
178
179 if(reactive1 != reactive2)
180 {
181 fReactionData[reactive2][reactive1] = reactionData;
182 fReactivesMV[reactive2].push_back(reactive1);
183 fReactionDataMV[reactive2].push_back(reactionData);
184 }
185}

◆ SetReaction() [2/2]

void G4DNAMolecularReactionTable::SetReaction ( G4double  observedReactionRate,
const G4Molecule reactive1,
const G4Molecule reactive2 
)

Define a reaction : First argument : reaction rate Second argument : reactant 1 Third argument : reactant 2 Fourth argument : a std std::vector holding the molecular products if this last argument is NULL then it will be interpreted as a reaction giving no products

Definition at line 187 of file G4DNAMolecularReactionTable.cc.

190{
191 G4DNAMolecularReactionData* reactionData = new G4DNAMolecularReactionData(reactionRate, reactive1, reactive2);
192 SetReaction(reactionData);
193}
void SetReaction(G4double observedReactionRate, const G4Molecule *reactive1, const G4Molecule *reactive2)

Referenced by SetReaction().

Member Data Documentation

◆ fInstance

G4DNAMolecularReactionTable * G4DNAMolecularReactionTable::fInstance
staticprotected

Definition at line 115 of file G4DNAMolecularReactionTable.hh.

Referenced by DeleteInstance(), and GetReactionTable().

◆ fMoleculeHandleManager

const G4MoleculeHandleManager* G4DNAMolecularReactionTable::fMoleculeHandleManager
protected

Definition at line 150 of file G4DNAMolecularReactionTable.hh.

◆ fReactionData

ReactionDataMap G4DNAMolecularReactionTable::fReactionData
protected

◆ fReactionDataMV

ReactionDataMV G4DNAMolecularReactionTable::fReactionDataMV
protected

◆ fReactivesMV

ReactivesMV G4DNAMolecularReactionTable::fReactivesMV
protected

◆ fVerbose

G4bool G4DNAMolecularReactionTable::fVerbose
protected

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