22#include <G4FastSimulationManagerProcess.hh>
23#include <G4ParticleDefinition.hh>
24#include <G4ProcessManager.hh>
26#include <G4RegionStore.hh>
41 G4int theVerboseLevel,
const G4String& name)
53 ProcessMap::iterator it;
68 const std::vector<TG4ModelConfiguration*>& models)
72 G4cout <<
"TG4FastSimulationPhysics::UpdateRegions" << G4endl;
76 std::vector<TG4ModelConfiguration*>::const_iterator it;
77 for (it = models.begin(); it != models.end(); it++) {
80 G4String modelName = (*it)->GetModelName();
81 const std::vector<G4String>& regions = (*it)->GetRegions();
82 G4VFastSimulationModel* fastSimulationModel =
83 (*it)->GetFastSimulationModel();
86 G4cout <<
"Adding fast simulation model " << modelName <<
" to regions ";
87 std::vector<G4String>::const_iterator itm;
88 for (itm = regions.begin(); itm != regions.end(); itm++) {
89 G4cout << (*itm) <<
" ";
94 if (!fastSimulationModel) {
95 TString text =
"The fast simulation model ";
96 text += modelName.data();
97 text +=
" was not found.";
102 if (!regions.size()) {
103 TString text =
"The fast simulation model ";
104 text += modelName.data();
105 text +=
" has no associated region.";
110 for (G4int j = 0; j < G4int(regions.size()); ++j) {
113 G4Region* region = G4RegionStore::GetInstance()->GetRegion(regions[j]);
116 TString text =
"The region ";
117 text += regions[j].data();
118 text +=
" was not found.";
124 G4FastSimulationManager* fastSimulationManager =
125 region->GetFastSimulationManager();
126 if (!fastSimulationManager) {
128 G4cout <<
"creating G4FastSimulationManager for the region" << G4endl;
131 G4bool isUnique =
false;
132 fastSimulationManager =
new G4FastSimulationManager(region, isUnique);
134 fastSimulationManager->AddFastSimulationModel(fastSimulationModel);
140G4FastSimulationManagerProcess*
142 const G4String& modelName)
153 G4FastSimulationManagerProcess* fastSimulationProcess = 0;
154 ProcessMap::iterator it =
fgProcessMap->find(modelName);
156 fastSimulationProcess = it->second;
160 fastSimulationProcess =
new G4FastSimulationManagerProcess();
161 (*fgProcessMap)[modelName] = fastSimulationProcess;
162 G4cout <<
"... created fastSimulationProcess" << G4endl;
165 return fastSimulationProcess;
170 const std::vector<TG4ModelConfiguration*>& models)
176 G4cout <<
"TG4FastSimulationPhysics::AddFastSimulationProcess" << G4endl;
180 std::vector<TG4ModelConfiguration*>::const_iterator it;
181 for (it = models.begin(); it != models.end(); it++) {
184 G4String modelName = (*it)->GetModelName();
185 G4String particles = (*it)->GetParticles();
188 G4FastSimulationManagerProcess* fastSimulationProcess =
192 auto aParticleIterator = GetParticleIterator();
193 aParticleIterator->reset();
194 while ((*aParticleIterator)()) {
196 G4String particleName = particle->GetParticleName();
199 if (particles !=
"all" && (!(*it)->HasParticle(particleName))) {
204 if (!particle->GetProcessManager())
continue;
207 G4cout <<
"Adding model " << modelName <<
" to particle "
208 << particle->GetParticleName() << G4endl;
212 particle->GetProcessManager()->AddDiscreteProcess(fastSimulationProcess);
231 G4cout <<
"TG4FastSimulationPhysics::ConstructProcess " << G4endl;
238 const std::vector<TG4ModelConfiguration*>& models =
242 if (models.size() == 0) {
244 G4cout <<
"No fast simulation models are defined." << G4endl;
261 G4cout <<
"### Fast simulation models added to physics processes" << G4endl;
279 "Fast simulation was already defined, setting is ignored.");
Definition of the TG4FastSimulationPhysics class.
Definition of the TG4GeometryManager class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4ModelConfigurationManager class.
Definition of the TG4ModelConfiguration class.
Definition of the TG4VUserFastSimulation class.
void SetUserFastSimulation(TG4VUserFastSimulation *userFastSimulation)
static G4ThreadLocal ProcessMap * fgProcessMap
fast simulation processes map
void UpdateRegions(const std::vector< TG4ModelConfiguration * > &models)
TG4FastSimulationPhysics(const G4String &name="FastSimulation")
TG4VUserFastSimulation * fUserFastSimulation
the user fast simulation
void AddFastSimulationProcess(const std::vector< TG4ModelConfiguration * > &models)
virtual void ConstructProcess()
Construct physics processes.
virtual void ConstructParticle()
Construct particles.
std::map< G4String, G4FastSimulationManagerProcess * > ProcessMap
virtual ~TG4FastSimulationPhysics()
G4FastSimulationManagerProcess * GetOrCreateFastSimulationProcess(const G4String &modelName)
TG4ModelConfigurationManager * GetFastModelsManager() const
static TG4GeometryManager * Instance()
static void Warning(const TString &className, const TString &methodName, const TString &text)
The model configuration vector with suitable setters and a messenger.
const ModelConfigurationVector & GetVector() const
Abstract base class for physics constructors with verbose.
virtual G4int VerboseLevel() const
The abstract base class which is used to build fast simulation models.
virtual void Construct()=0
Method to be overriden by user.