25#include <G4LogicalVolume.hh>
26#include <G4LogicalVolumeStore.hh>
27#include <G4Material.hh>
28#include <G4ProductionCuts.hh>
30#include <G4RegionStore.hh>
31#include <G4TransportationManager.hh>
37G4Mutex setRegionsNamesMutex = G4MUTEX_INITIALIZER;
38G4Mutex createRegionsMutex = G4MUTEX_INITIALIZER;
44 const G4String& name,
const G4String& availableModels)
45 :
TG4Verbose(G4String(name).append(
"ConfigurationManager")),
49 fAvailableModels(availableModels),
51 fCreateRegionsDone(false)
56 G4cout <<
"TG4ModelConfigurationManager::TG4ModelConfigurationManager"
70 ModelConfigurationVector::iterator it;
88 G4AutoLock lm(&setRegionsNamesMutex);
92 ModelConfigurationVector::iterator it;
95 const std::vector<G4String>& mediaNames = (*it)->GetRegionsMedia();
98 std::vector<G4String>::const_iterator itr;
99 for (itr = mediaNames.begin(); itr != mediaNames.end(); itr++) {
101 std::vector<TG4Medium*> media;
102 G4bool isPattern = (*itr).find(
"*") != std::string::npos;
112 TString text =
"Medium ";
113 text += (*itr).data();
114 text +=
" not found.";
116 text +=
"The special physics model will not be applied.";
118 "TG4ModelConfigurationManager",
"SetRegionsNames", text);
121 media.push_back(medium);
124 std::vector<TG4Medium*>::const_iterator itrm;
125 for (itrm = media.begin(); itrm != media.end(); itrm++) {
126 G4String materialName = (*itrm)->GetMaterial()->GetName();
127 (*it)->SetOneRegion(materialName);
133 G4cout <<
"TG4ModelConfigurationManager::SetRegionsNames: ";
134 const std::vector<G4String>& regions = (*it)->GetRegions();
135 std::vector<G4String>::const_iterator itm;
136 for (itm = regions.begin(); itm != regions.end(); itm++) {
137 G4cout <<
"\'" << (*itm) <<
"\' ";
142#ifdef G4MULTITHREADED
157 G4cout <<
"TG4ModelConfigurationManager::CreateRegions" << G4endl;
169#ifdef G4MULTITHREADED
170 G4AutoLock lm(&createRegionsMutex);
174 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
175 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
176 G4LogicalVolume* lv = (*lvStore)[i];
177 G4String materialName = lv->GetMaterial()->GetName();
180 G4cout <<
"Processing volume " << lv->GetName() <<
", material "
181 << materialName << G4endl;
185 G4bool isModelRegion =
false;
186 ModelConfigurationVector::const_iterator it;
188 if ((*it)->HasRegion(materialName)) isModelRegion =
true;
191 if (!isModelRegion) {
193 G4cout <<
"Material " << materialName <<
" is not in selection"
202 G4RegionStore::GetInstance()->GetRegion(materialName,
false);
205 region =
new G4Region(materialName);
208 G4cout <<
"Created region " << region->GetName() << region << G4endl;
213 G4cout <<
"Adding region " << region->GetName() <<
" to lv "
214 << lv->GetName() << G4endl;
216 region->AddRootLogicalVolume(lv);
217 lv->SetRegion(region);
220#ifdef G4MULTITHREADED
232 G4cout <<
"TG4ModelConfigurationManager::SetModel: " << modelName << G4endl;
239 TString text =
"Cannot create model ";
240 text += modelName.data();
248 const G4String& modelName,
const G4String& particles)
255 if (!modelConfiguration) {
256 TString text =
"The model configuration ";
257 text += modelName.data();
258 text +=
" is not defined.";
269 const G4String& modelName,
const G4String& regionsMedia)
276 if (!modelConfiguration) {
277 TString text =
"The model configuration ";
278 text += modelName.data();
279 text +=
" is not defined.";
290 const G4String& modelName,
const G4String& regionMedium)
297 if (!modelConfiguration) {
298 TString text =
"The model configuration ";
299 text += modelName.data();
300 text +=
" is not defined.";
310 const G4String& modelName, G4bool warn)
const
315 ModelConfigurationVector::const_iterator it;
317 if ((*it)->GetModelName() == modelName)
return *it;
321 TString text =
"Model configuration ";
322 text += modelName.data();
323 text +=
" does not exist";
325 "TG4ModelConfigurationManager",
"GetModelConfiguration", text);
Definition of the TG4G3ControlVector class.
Definition of the TG4GeometryServices class.
Definition of the TG4Limits class.
Definition of the TG4MediumMap class.
Definition of the TG4Medium class.
Definition of the TG4ModelConfigurationManager class.
Definition of the TG4ModelConfigurationMessenger class.
Definition of the TG4ModelConfiguration class.
Definition of the TG4PhysicsManager class.
static TG4GeometryServices * Instance()
TG4MediumMap * GetMediumMap() const
static void Warning(const TString &className, const TString &methodName, const TString &text)
The map of media to logical volumes.
TG4Medium * GetMedium(G4int mediumID, G4bool warn=true) const
void GetMedia(const G4String &namePattern, std::vector< TG4Medium * > &media, G4bool warn=true) const
Helper class to keep medium data.
void SetModelRegions(const G4String &modelName, const G4String ®ionsMedia)
void SetModel(const G4String &modelName)
TG4ModelConfiguration * GetModelConfiguration(const G4String &modelName, G4bool warn=true) const
G4bool fCreateRegionsDone
Info whether regions were constructed.
void SetModelParticles(const G4String &modelName, const G4String &particles)
TG4ModelConfigurationMessenger * fMessenger
Messenger.
void SetOneModelRegion(const G4String &modelName, const G4String ®ionMedium)
virtual ~TG4ModelConfigurationManager()
TG4ModelConfigurationManager(const G4String &name, const G4String &availableModels="")
ModelConfigurationVector fVector
Vector of registered model configurations.
Messenger class that defines commands for the special physica models.
A helper class to hold a configuration of a special physics model.
void SetParticles(const G4String &particles)
void SetOneRegionMedium(const G4String ®ionMedium)
void SetRegionsMedia(const G4String ®ionsMedia)
Base class for defining the verbose level and a common messenger.
virtual G4int VerboseLevel() const