22#include <G4LogicalVolumeStore.hh>
23#include <G4Material.hh>
24#include <G4ProductionCuts.hh>
25#include <G4ProductionCutsTable.hh>
27#include <G4RegionStore.hh>
28#include <G4SystemOfUnits.hh>
45 G4cout <<
"Define regions for VMC cuts per materials." << G4endl;
51 auto g4RegionStore = G4RegionStore::GetInstance();
55 auto worldMaterial = worldLV->GetMaterial();
59 auto lvStore = G4LogicalVolumeStore::GetInstance();
61 for (std::size_t i = 0; i < lvStore->size(); ++i) {
63 auto lv = (*lvStore)[i];
64 auto materialName = lv->GetMaterial()->GetName();
67 G4cout <<
"-- Volume = " << i <<
" " << lv->GetName()
68 <<
" material = " << materialName << G4endl;
74 G4cout <<
" " <<
"skipping worldVolume" << G4endl;
80 if (lv->GetRegion() !=
nullptr &&
81 lv->GetRegion()->GetName() == materialName) {
84 <<
"has already region set, skipping" << G4endl;
91 auto regionName = materialName;
92 auto region = g4RegionStore->GetRegion(regionName,
false);
93 if (region !=
nullptr) {
94 if (lv->GetRegion() != region) {
99 <<
"adding volume in region = " << regionName << G4endl;
101 region->AddRootLogicalVolume(lv);
109 <<
"creating new region = " << regionName << G4endl;
111 region =
new G4Region(regionName);
112 region->AddRootLogicalVolume(lv);
121 G4cout <<
"Number of added regions: " << counter << G4endl;
131 G4cout <<
"Update G4 production cuts table" << G4endl;
135 auto g4ProductionCutsTable = G4ProductionCutsTable::GetProductionCutsTable();
143 std::vector<G4double> gamCuts;
144 std::vector<G4double> eleCuts;
145 std::vector<G4double> hadCuts;
151 g4ProductionCutsTable->CreateCoupleTables();
154 for (std::size_t i = 0; i < g4ProductionCutsTable->GetTableSize(); ++i) {
155 auto couple = g4ProductionCutsTable->GetMaterialCutsCouple(i);
156 auto material = couple->GetMaterial();
157 auto medium = mediumMap->GetMedium(material);
159 auto limits = (
TG4Limits*)medium->GetLimits();
164 gamCuts.push_back(cutGam);
165 eleCuts.push_back(cutEle);
166 hadCuts.push_back(cutHad);
170 g4ProductionCutsTable->SetEnergyCutVector(gamCuts, 0);
172 G4cout <<
"... table updated for Gamma with CUTGAM values" << G4endl;
177 g4ProductionCutsTable->SetEnergyCutVector(eleCuts, 1);
179 G4cout <<
"... table updated for Electron with CUTELE values" << G4endl;
184 g4ProductionCutsTable->SetEnergyCutVector(eleCuts, 2);
186 G4cout <<
"... table updated for Positron with CUTELE values" << G4endl;
191 g4ProductionCutsTable->SetEnergyCutVector(hadCuts, 3);
193 G4cout <<
"... table updated for proton with HADR values" << G4endl;
Definition of the TG4GeometryServices class.
Definition of the TG4Globals class and basic container types.
Definition of the TG4Limits class.
Definition of the TG4Medium class.
Definition of the TG4PhysicsManager class.
Definition of the TG4RegionsManager2 class.
G4VPhysicalVolume * GetWorld() const
static TG4GeometryServices * Instance()
TG4MediumMap * GetMediumMap() const
Extended G4UserLimits class.
void UpdateProductionCutsTable() override
void DefineRegions() override
G4bool fIsCheck
option to perform consistency check (by default false)
G4bool fApplyForElectron
option to apply cuts for e- (default is true)
G4bool fApplyForPositron
option to apply cuts for e+ (default is true)
G4double GetEnergyCut(TG4Limits *limits, TG4G3Cut cutType, G4double globalCutValue) const
G4bool fApplyForGamma
option to apply cuts for gamma (default is true)
void CheckRegionsInGeometry() const
G4bool fApplyForProton
option to apply cuts for proton (default is true)
G4double GetGlobalEnergyCut(TG4G3Cut cutType) const
virtual G4int VerboseLevel() const