25#include <G4LogicalVolumeStore.hh>
26#include <G4ProductionCuts.hh>
28#include <G4RegionStore.hh>
29#include <G4RunManager.hh>
30#include <G4SystemOfUnits.hh>
31#include <G4UnitsTable.hh>
32#include <G4VUserPhysicsList.hh>
33#include <G4Version.hh>
42 "RegionWithDefaultCuts";
76 G4double cutValue = 0.;
77 if ((*isCutVector)[cutType] && (*cutVector)[cutType] > 0.) {
78 cutValue = (*cutVector)[cutType];
84 " is not defined." +
TG4Globals::Endl() +
"The default Geant3 value will be used"
105 cut = globalCutValue;
113 const G4MaterialCutsCouple* couple,
const G4Region* region)
const
118 G4ProductionCuts* productionCuts = region->GetProductionCuts();
119 std::vector<G4Material*>::const_iterator itm = region->GetMaterialIterator();
120 size_t nofMaterials = region->GetNumberOfMaterials();
121 for (
size_t i = 0; i < nofMaterials; i++, itm++) {
122 if (couple->GetMaterial() == (*itm) &&
123 couple->GetProductionCuts() == productionCuts) {
138 G4cout <<
".. Checking regions materials " << G4endl;
142 G4LogicalVolumeStore* lvStore = G4LogicalVolumeStore::GetInstance();
143 for (G4int i = 0; i < G4int(lvStore->size()); i++) {
145 G4LogicalVolume* lv = (*lvStore)[i];
154 if (!medium)
continue;
156 if (lv->GetRegion()->GetName() != lv->GetMaterial()->GetName() &&
159 G4cout <<
"The region name " << lv->GetRegion()->GetName()
160 <<
" for LV = " << lv->GetName()
161 <<
" does not match its material name "
162 << lv->GetMaterial()->GetName() << G4endl;
168 G4cout <<
".. Regions are consistent with materials." << G4endl;
171 G4cout <<
".. Found inconsistencies between regions and materials."
182 output << std::setw(30) << std::left <<
"# material name"
188 <<
" vmcCutEle[GeV]" << G4endl;
201 auto name =
"\'" + matName +
"\';";
205 output << std::setw(30) << std::left << name <<
" "
222 G4ProductionCutsTable* productionCutsTable =
223 G4ProductionCutsTable::GetProductionCutsTable();
225 if (productionCutsTable->GetTableSize() == 0) {
226 G4cout <<
"No production cuts defined." << G4endl;
232 for (G4int i = 0; i < G4int(productionCutsTable->GetTableSize()); i++) {
233 const G4MaterialCutsCouple* couple =
234 productionCutsTable->GetMaterialCutsCouple(i);
236 const G4Material* material = couple->GetMaterial();
237 G4ProductionCuts* cuts = couple->GetProductionCuts();
239 G4double rangeGam = cuts->GetProductionCut(0);
240 G4double rangeEle = cuts->GetProductionCut(1);
246 const std::vector<G4double>* energyCutsGam =
247 productionCutsTable->GetEnergyCutsVector(0);
248 const std::vector<G4double>* energyCutsEle =
249 productionCutsTable->GetEnergyCutsVector(1);
251 G4double cutGam = (*energyCutsGam)[couple->GetIndex()];
252 G4double cutEle = (*energyCutsEle)[couple->GetIndex()];
258 G4double cutGamLimits = DBL_MAX;
259 G4double cutEleLimits = DBL_MAX;
262 "Limits for material " + TString(material->GetName()) +
" not found. " +
270 G4String matName = material->
GetName();
272 {rangeGam, rangeEle, cutGam, cutEle, cutGamLimits, cutEleLimits};
305 std::ofstream fileOutput;
306 fileOutput.open(fileName, std::ios::out);
307 if (! fileOutput.is_open()) {
309 "Saving regions in file " + TString(fileName.data()) +
" has failed.");
314 G4cout <<
"Saving regions from production cuts table in file: " << fileName << G4endl;
327 auto regionStore = G4RegionStore::GetInstance();
329 G4cout <<
"========= Region Store Dump ======================================"
332 for (
auto region : *regionStore ) {
333 G4cout << region->GetName() <<
":" << G4endl;
335 auto cuts = region->GetProductionCuts();
336 if (cuts !=
nullptr) {
337 auto rangeGam = cuts->GetProductionCut(0);
338 auto rangeEle = cuts->GetProductionCut(1);
339 G4cout <<
" ProductionCuts: rangeGam=" << rangeGam <<
" rangeEle=" << rangeEle << G4endl;
342 size_t lvCounter = 0;
343 auto lvIt = region->GetRootLogicalVolumeIterator();
344 G4cout <<
" RootVolumes: ";
345 while (lvCounter < region->GetNumberOfRootVolumes()) {
346 G4cout <<
" " << (*lvIt++)->GetName() <<
"; ";
351 size_t matCounter = 0;
352 auto matIt = region->GetMaterialIterator();
353 G4cout <<
" Materials: ";
354 while (matCounter < region->GetNumberOfMaterials()) {
355 G4cout <<
" " << (*matIt)->GetName() <<
"; ";;
361 G4cout <<
"========= End Region Store Dump =================================="
Definition of the TG4G3CutVector class.
Definition of the TG4G3PhysicsManager class.
Definition of the TG4G3Units class.
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 TG4RegionsMessenger class.
Definition of the TG4VRegionsManager class.
Vector of kinetic energy cut values with convenient set/get methods.
static const G4String & GetCutName(TG4G3Cut cut)
static TG4G3Defaults * Instance()
G4double CutValue(G4int cut) const
static TG4G3PhysicsManager * Instance()
TG4boolVector * GetIsCutVector() const
TG4G3CutVector * GetCutVector() const
static G4double InverseEnergy()
TG4Limits * FindLimits(const G4String &name, G4bool silent=false) const
static TG4GeometryServices * Instance()
TG4MediumMap * GetMediumMap() const
static void Warning(const TString &className, const TString &methodName, const TString &text)
Extended G4UserLimits class.
const TG4G3CutVector * GetCutVector() const
TG4Medium * GetMedium(G4int mediumID, G4bool warn=true) const
Helper class to keep medium data.
Base class for mangers for converting VMC cuts in energy in G4 regions.
static constexpr size_t fgkRangeGamIdx
void PrintLegend(std::ostream &output) const
void PrintRegionData(std::ostream &output, const G4String &matName, const TG4RegionData &values) const
static const G4String fgkDefaultRegionName
the name of the region with default cuts
static const G4String fgkDefaultFileName
the name of the region with default cuts
static TG4VRegionsManager * fgInstance
the singleton instance
static constexpr size_t fgkCutGamIdx
G4double GetEnergyCut(TG4Limits *limits, TG4G3Cut cutType, G4double globalCutValue) const
virtual void SaveRegions()
G4bool IsCoupleUsedInTheRegion(const G4MaterialCutsCouple *couple, const G4Region *region) const
std::array< G4double, fgkValuesSize > TG4RegionData
static constexpr size_t fgkCutEleIdx
static constexpr size_t fgkVmcCutGamIdx
void PrintFromG4Table(std::ostream &output) const
void CheckRegionsInGeometry() const
G4double GetGlobalEnergyCut(TG4G3Cut cutType) const
virtual void DumpRegionStore() const
static constexpr size_t fgkRangeEleIdx
G4String fFileName
file name for regions output
virtual void CheckRegions() const
virtual void PrintRegions(std::ostream &output) const
static constexpr size_t fgkVmcCutEleIdx
virtual ~TG4VRegionsManager()
Base class for defining the verbose level and a common messenger.
virtual G4int VerboseLevel() const
TG4G3Cut
Enumeration for G3 types of kinetic energy cuts.
std::vector< G4bool > TG4boolVector