Geant4  10.02
G4VUserChemistryList.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 /*
27  * G4VUserChemistryList.cc
28  *
29  * Created on: 23 oct. 2013
30  * Author: kara
31  */
32 
33 #include "G4VUserChemistryList.hh"
34 
35 #include <G4VScheduler.hh>
36 #include "G4MoleculeTable.hh"
37 #include "G4MoleculeDefinition.hh"
38 #include "G4ProcessManager.hh"
39 #include "G4DNAChemistryManager.hh"
40 
42 {
43  verboseLevel = 1;
44 }
45 
47 {
49  if (chemMan)
50  {
51  chemMan->Deregister(this);
52  }
53 }
54 
56  double startingTime)
57 {
58  G4VScheduler::Instance()->RegisterModel(timeStepModel, startingTime);
59 }
60 
62 {
63  G4MoleculeTable* theMoleculeTable = G4MoleculeTable::Instance();
64 
66  theMoleculeTable->GetDefintionIterator();
67 
68  iterator.reset();
69  while (iterator())
70  {
71  G4MoleculeDefinition* moleculeDef = iterator.value();
72  BuildPhysicsTable(moleculeDef);
73  }
74 }
75 
77 {
78  //Get processes from master thread;
79  G4ProcessManager* pManager = moleculeDef->GetProcessManager();
80 
81  if (!pManager)
82  {
83 #ifdef G4VERBOSE
84  if (verboseLevel > 0)
85  {
86  G4cout << "G4VUserPhysicsList::BuildPhysicsTable "
87  << " : No Process Manager for " << moleculeDef->GetParticleName()
88  << G4endl;
89  G4cout << moleculeDef->GetParticleName()
90  << " should be created in your PhysicsList" <<G4endl;
91  }
92 #endif
93  G4Exception("G4VUserChemistryList::BuildPhysicsTable",
94  "Run0271", FatalException,
95  "No process manager");
96  return;
97  }
98 
99  G4ProcessManager* pManagerShadow = moleculeDef->GetMasterProcessManager();
100  G4ProcessVector* pVector = pManager->GetProcessList();
101  if (!pVector)
102  {
103 #ifdef G4VERBOSE
104  if (verboseLevel > 0)
105  {
106  G4cout << "G4VUserChemistryList::BuildPhysicsTable "
107  << " : No Process Vector for " << moleculeDef->GetParticleName()
108  << G4endl;
109  }
110 #endif
111  G4Exception("G4VUserChemistryList::BuildPhysicsTable",
112  "Run0272", FatalException,
113  "No process Vector");
114  return;
115  }
116 #ifdef G4VERBOSE
117  if (verboseLevel > 2)
118  {
119  G4cout << "G4VUserChemistryList::BuildPhysicsTable %%%%%% "
120  << moleculeDef->GetParticleName() << G4endl;
121  G4cout << " ProcessManager : " << pManager
122  << " ProcessManagerShadow : " << pManagerShadow << G4endl;
123  for(G4int iv1=0;iv1<pVector->size();iv1++)
124  {
125  G4cout << " " << iv1 << " - " << (*pVector)[iv1]->GetProcessName()
126  << G4endl;
127  }
128  G4cout << "--------------------------------------------------------------"
129  << G4endl;
130  G4ProcessVector* pVectorShadow = pManagerShadow->GetProcessList();
131 
132  for(G4int iv2=0;iv2<pVectorShadow->size();iv2++)
133  {
134  G4cout << " " << iv2 << " - " << (*pVectorShadow)[iv2]->GetProcessName()
135  << G4endl;
136  }
137  }
138 #endif
139  for (G4int j = 0; j < pVector->size(); ++j)
140  {
141  //Andrea July 16th 2013 : migration to new interface...
142  //Infer if we are in a worker thread or master thread
143  //Master thread is the one in which the process manager
144  // and process manager shadow pointers are the same
145  if (pManagerShadow == pManager)
146  {
147  (*pVector)[j]->BuildPhysicsTable(*moleculeDef);
148  }
149  else
150  {
151  (*pVector)[j]->BuildWorkerPhysicsTable(*moleculeDef);
152  }
153 
154  }
155 }
void Deregister(G4VUserChemistryList *)
static G4VScheduler * Instance()
Definition: G4VScheduler.cc:48
Define what to do before stepping and after stepping.
WARNING: THIS CLASS IS A PROTOTYPE G4DNAChemistryManager is called from the physics models...
virtual void RegisterModel(G4VITStepModel *, double)
Definition: G4VScheduler.hh:69
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4GLOB_DLL std::ostream G4cout
G4ProcessManager * GetMasterProcessManager() const
static G4MoleculeTable * Instance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int size() const
G4MoleculeDefinitionIterator GetDefintionIterator()
#define G4endl
Definition: G4ios.hh:61
static G4DNAChemistryManager * GetInstanceIfExists()
G4ProcessVector * GetProcessList() const
void RegisterTimeStepModel(G4VITStepModel *timeStepModel, double startingTime=0)