Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ProductionCutsTable Class Reference

#include <G4ProductionCutsTable.hh>

Public Member Functions

 G4ProductionCutsTable (const G4ProductionCutsTable &)=delete
 
G4ProductionCutsTableoperator= (const G4ProductionCutsTable &)=delete
 
virtual ~G4ProductionCutsTable ()
 
void UpdateCoupleTable (G4VPhysicalVolume *currentWorld)
 
void SetEnergyRange (G4double lowedge, G4double highedge)
 
G4double GetLowEdgeEnergy () const
 
G4double GetHighEdgeEnergy () const
 
G4double GetMaxEnergyCut ()
 
void SetMaxEnergyCut (G4double value)
 
void DumpCouples () const
 
const G4MCCIndexConversionTableGetMCCIndexConversionTable () const
 
const std::vector< G4double > * GetRangeCutsVector (std::size_t pcIdx) const
 
const std::vector< G4double > * GetEnergyCutsVector (std::size_t pcIdx) const
 
std::size_t GetTableSize () const
 
const G4MaterialCutsCoupleGetMaterialCutsCouple (G4int i) const
 
const G4MaterialCutsCoupleGetMaterialCutsCouple (const G4Material *aMat, const G4ProductionCuts *aCut) const
 
G4int GetCoupleIndex (const G4MaterialCutsCouple *aCouple) const
 
G4int GetCoupleIndex (const G4Material *aMat, const G4ProductionCuts *aCut) const
 
G4bool IsModified () const
 
void PhysicsTableUpdated ()
 
G4ProductionCutsGetDefaultProductionCuts () const
 
G4double ConvertRangeToEnergy (const G4ParticleDefinition *particle, const G4Material *material, G4double range)
 
void ResetConverters ()
 
G4bool StoreCutsTable (const G4String &directory, G4bool ascii=false)
 
G4bool RetrieveCutsTable (const G4String &directory, G4bool ascii=false)
 
G4bool CheckForRetrieveCutsTable (const G4String &directory, G4bool ascii=false)
 
G4doubleGetRangeCutsDoubleVector (std::size_t pcIdx) const
 
G4doubleGetEnergyCutsDoubleVector (std::size_t pcIdx) const
 
void SetVerboseLevel (G4int value)
 
G4int GetVerboseLevel () const
 

Static Public Member Functions

static G4ProductionCutsTableGetProductionCutsTable ()
 

Protected Member Functions

 G4ProductionCutsTable ()
 
virtual G4bool StoreMaterialInfo (const G4String &directory, G4bool ascii=false)
 
virtual G4bool CheckMaterialInfo (const G4String &directory, G4bool ascii=false)
 
virtual G4bool StoreMaterialCutsCoupleInfo (const G4String &directory, G4bool ascii=false)
 
virtual G4bool CheckMaterialCutsCoupleInfo (const G4String &directory, G4bool ascii=false)
 
virtual G4bool StoreCutsInfo (const G4String &directory, G4bool ascii=false)
 
virtual G4bool RetrieveCutsInfo (const G4String &directory, G4bool ascii=false)
 

Detailed Description

Definition at line 56 of file G4ProductionCutsTable.hh.

Constructor & Destructor Documentation

◆ G4ProductionCutsTable() [1/2]

G4ProductionCutsTable::G4ProductionCutsTable ( const G4ProductionCutsTable )
delete

◆ ~G4ProductionCutsTable()

G4ProductionCutsTable::~G4ProductionCutsTable ( )
virtual

Definition at line 87 of file G4ProductionCutsTable.cc.

88{
89 delete defaultProductionCuts;
90 defaultProductionCuts = nullptr;
91
92 for(auto itr=coupleTable.cbegin(); itr!=coupleTable.cend(); ++itr)
93 {
94 delete (*itr);
95 }
96 coupleTable.clear();
97
98 for(std::size_t i=0; i< NumberOfG4CutIndex; ++i)
99 {
100 delete rangeCutTable[i];
101 delete energyCutTable[i];
102 delete converters[i];
103 if(rangeDoubleVector[i] != nullptr) delete [] rangeDoubleVector[i];
104 if(energyDoubleVector[i] != nullptr) delete [] energyDoubleVector[i];
105 rangeCutTable[i] = nullptr;
106 energyCutTable[i] = nullptr;
107 converters[i] = nullptr;
108 rangeDoubleVector[i] = nullptr;
109 energyDoubleVector[i] = nullptr;
110 }
111 fProductionCutsTable = nullptr;
112
113 delete fMessenger;
114 fMessenger = nullptr;
115}
@ NumberOfG4CutIndex

◆ G4ProductionCutsTable() [2/2]

G4ProductionCutsTable::G4ProductionCutsTable ( )
protected

Definition at line 69 of file G4ProductionCutsTable.cc.

70{
71 for(std::size_t i=0; i< NumberOfG4CutIndex; ++i)
72 {
73 rangeCutTable.push_back(new std::vector<G4double>);
74 energyCutTable.push_back(new std::vector<G4double>);
75 rangeDoubleVector[i] = nullptr;
76 energyDoubleVector[i] = nullptr;
77 converters[i] = nullptr;
78 }
79 fG4RegionStore = G4RegionStore::GetInstance();
80 defaultProductionCuts = new G4ProductionCuts();
81
82 // add messenger for UI
83 fMessenger = new G4ProductionCutsTableMessenger(this);
84}
static G4RegionStore * GetInstance()

Member Function Documentation

◆ CheckForRetrieveCutsTable()

G4bool G4ProductionCutsTable::CheckForRetrieveCutsTable ( const G4String directory,
G4bool  ascii = false 
)

Definition at line 515 of file G4ProductionCutsTable.cc.

517{
518 // check stored material and cut values are consistent
519 // with the current detector setup
520
521 G4cerr << "G4ProductionCutsTable::CheckForRetrieveCutsTable()"<< G4endl;
522 // isNeedForRestoreCoupleInfo = false;
523 if (!CheckMaterialInfo(directory, ascii)) return false;
524 if (verboseLevel >2)
525 {
526 G4cerr << "G4ProductionCutsTable::CheckMaterialInfo passed !!"<< G4endl;
527 }
528 if (!CheckMaterialCutsCoupleInfo(directory, ascii)) return false;
529 if (verboseLevel >2)
530 {
531 G4cerr << "G4ProductionCutsTable::CheckMaterialCutsCoupleInfo passed !!"
532 << G4endl;
533 }
534 return true;
535}
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
virtual G4bool CheckMaterialInfo(const G4String &directory, G4bool ascii=false)
virtual G4bool CheckMaterialCutsCoupleInfo(const G4String &directory, G4bool ascii=false)

Referenced by RetrieveCutsTable().

◆ CheckMaterialCutsCoupleInfo()

G4bool G4ProductionCutsTable::CheckMaterialCutsCoupleInfo ( const G4String directory,
G4bool  ascii = false 
)
protectedvirtual

Definition at line 926 of file G4ProductionCutsTable.cc.

928{
929 // Check stored materialCutsCouple is consistent
930 // with the current detector setup.
931
932 const G4String fileName = directory + "/" + "couple.dat";
933 const G4String key = "COUPLE-V3.0";
934 std::ifstream fIn;
935
936 // open input file
937 if (!ascii ) fIn.open(fileName,std::ios::in|std::ios::binary);
938 else fIn.open(fileName,std::ios::in);
939
940 // check if the file has been opened successfully
941 if (!fIn)
942 {
943#ifdef G4VERBOSE
944 if (verboseLevel >0)
945 {
946 G4cerr << "G4ProductionCutTable::CheckMaterialCutsCoupleInfo() - ";
947 G4cerr << "Cannot open file!" << fileName << G4endl;
948 }
949#endif
950 G4Exception( "G4ProductionCutsTable::CheckMaterialCutsCoupleInfo()",
951 "ProcCuts102", JustWarning, "Cannot open file!");
952 return false;
953 }
954
955 char temp[FixedStringLengthForStore];
956
957 // key word
958 G4String keyword;
959 if (ascii)
960 {
961 fIn >> keyword;
962 }
963 else
964 {
965 fIn.read(temp, FixedStringLengthForStore);
966 keyword = (const char*)(temp);
967 }
968 if (key!=keyword)
969 {
970#ifdef G4VERBOSE
971 if (verboseLevel >0)
972 {
973 G4cerr << "G4ProductionCutTable::CheckMaterialCutsCoupleInfo() - ";
974 G4cerr << "Key word in " << fileName << "= " << keyword ;
975 G4cerr <<"( should be "<< key << ")" << G4endl;
976 }
977#endif
978 G4Exception( "G4ProductionCutsTable::CheckMaterialCutsCoupleInfo()",
979 "ProcCuts103", JustWarning, "Bad Data Format");
980 fIn.close();
981 return false;
982 }
983
984 // numberOfCouples
985 G4int numberOfCouples;
986 if (ascii)
987 {
988 fIn >> numberOfCouples;
989 }
990 else
991 {
992 fIn.read( (char*)(&numberOfCouples), sizeof(G4int));
993 }
994
995 // Reset MCCIndexConversionTable
996 mccConversionTable.Reset(numberOfCouples);
997
998 // Read in couple information
999 for (G4int idx=0; idx<numberOfCouples; ++idx)
1000 {
1001 // read in index
1002 G4int index;
1003 if (ascii)
1004 {
1005 fIn >> index;
1006 }
1007 else
1008 {
1009 fIn.read( (char*)(&index), sizeof(G4int));
1010 }
1011 // read in index material name
1012 char mat_name[FixedStringLengthForStore];
1013 if (ascii)
1014 {
1015 fIn >> mat_name;
1016 }
1017 else
1018 {
1019 fIn.read(mat_name, FixedStringLengthForStore);
1020 }
1021 // read in index and region name
1022 char region_name[FixedStringLengthForStore];
1023 if (ascii)
1024 {
1025 fIn >> region_name;
1026 }
1027 else
1028 {
1029 fIn.read(region_name, FixedStringLengthForStore);
1030 }
1031 // cut value
1032 G4double cutValues[NumberOfG4CutIndex];
1033 for (std::size_t i=0; i< NumberOfG4CutIndex; ++i)
1034 {
1035 if (ascii)
1036 {
1037 fIn >> cutValues[i];
1038 cutValues[i] *= (mm);
1039 }
1040 else
1041 {
1042 fIn.read( (char*)(&(cutValues[i])), sizeof(G4double));
1043 }
1044 }
1045
1046 // Loop over all couples
1047 G4bool fOK = false;
1048 G4MaterialCutsCouple* aCouple = nullptr;
1049 for (auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
1050 {
1051 aCouple = (*cItr);
1052 // check material name
1053 if ( mat_name != aCouple->GetMaterial()->GetName() ) continue;
1054 // check cut values
1055 G4ProductionCuts* aCut = aCouple->GetProductionCuts();
1056 G4bool fRatio = true;
1057 for (std::size_t j=0; j< NumberOfG4CutIndex; ++j)
1058 {
1059 // check ratio only if values are not the same
1060 if (cutValues[j] != aCut->GetProductionCut(j))
1061 {
1062 G4double ratio = cutValues[j]/aCut->GetProductionCut(j);
1063 fRatio = fRatio && (0.999<ratio) && (ratio<1.001) ;
1064 }
1065 }
1066 if (!fRatio) continue;
1067 // MCC matched
1068 fOK = true;
1069 mccConversionTable.SetNewIndex(index, aCouple->GetIndex());
1070 break;
1071 }
1072
1073 if (fOK)
1074 {
1075#ifdef G4VERBOSE
1076 // debug information
1077 if (verboseLevel >1)
1078 {
1079 G4String regionname(region_name);
1080 G4Region* fRegion = nullptr;
1081 if ( regionname != "NONE" )
1082 {
1083 fRegion = fG4RegionStore->GetRegion(region_name);
1084 if (fRegion == nullptr)
1085 {
1086 G4cout << "G4ProductionCutTable::CheckMaterialCutsCoupleInfo() - ";
1087 G4cout << "Region " << regionname << " is not found ";
1088 G4cout << index << ": in " << fileName << G4endl;
1089 }
1090 }
1091 if (((regionname == "NONE") && (aCouple->IsUsed()))
1092 || ((fRegion!=nullptr) && !IsCoupleUsedInTheRegion(aCouple, fRegion)))
1093 {
1094 G4cout << "G4ProductionCutTable::CheckMaterialCutsCoupleInfo()"
1095 << G4endl;
1096 G4cout << "A Couple is used different region in the current setup ";
1097 G4cout << index << ": in " << fileName << G4endl;
1098 G4cout << " material: " << mat_name ;
1099 G4cout << " region: " << region_name << G4endl;
1100 for (std::size_t ii=0; ii< NumberOfG4CutIndex; ++ii)
1101 {
1102 G4cout << "cut[" << ii << "]=" << cutValues[ii]/mm;
1103 G4cout << " mm : ";
1104 }
1105 G4cout << G4endl;
1106 }
1107 else if ( index != aCouple->GetIndex() )
1108 {
1109 G4cout << "G4ProductionCutTable::CheckMaterialCutsCoupleInfo() - ";
1110 G4cout << "Index of couples was modified "<< G4endl;
1111 G4cout << aCouple->GetIndex() << ":"
1112 << aCouple->GetMaterial()->GetName();
1113 G4cout <<" is defined as " ;
1114 G4cout << index << ":" << mat_name << " in " << fileName << G4endl;
1115 }
1116 else
1117 {
1118 G4cout << "G4ProductionCutTable::CheckMaterialCutsCoupleInfo() - ";
1119 G4cout << index << ":" << mat_name << " in " << fileName ;
1120 G4cout << " is consistent with current setup" << G4endl;
1121 }
1122 }
1123#endif
1124 }
1125 else
1126 {
1127#ifdef G4VERBOSE
1128 if (verboseLevel >0)
1129 {
1130 G4cout << "G4ProductionCutTable::CheckMaterialCutsCoupleInfo()"
1131 << G4endl;
1132 G4cout << "Couples are not defined in the current detector setup ";
1133 G4cout << index << ": in " << fileName << G4endl;
1134 G4cout << " material: " << mat_name ;
1135 G4cout << " region: " << region_name << G4endl;
1136 for (std::size_t ii=0; ii< NumberOfG4CutIndex; ++ii)
1137 {
1138 G4cout << "cut[" << ii << "]=" << cutValues[ii]/mm;
1139 G4cout << " mm : ";
1140 }
1141 G4cout << G4endl;
1142 }
1143#endif
1144 }
1145 }
1146 fIn.close();
1147 return true;
1148}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
void SetNewIndex(std::size_t index, std::size_t new_value)
const G4Material * GetMaterial() const
G4ProductionCuts * GetProductionCuts() const
const G4String & GetName() const
Definition: G4Material.hh:175
G4double GetProductionCut(G4int index) const
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const

Referenced by CheckForRetrieveCutsTable().

◆ CheckMaterialInfo()

G4bool G4ProductionCutsTable::CheckMaterialInfo ( const G4String directory,
G4bool  ascii = false 
)
protectedvirtual

Definition at line 632 of file G4ProductionCutsTable.cc.

634{
635 // Check stored material is consistent with the current detector setup
636
637 const G4String fileName = directory + "/" + "material.dat";
638 const G4String key = "MATERIAL-V3.0";
639 std::ifstream fIn;
640
641 // open input file
642 if (!ascii ) fIn.open(fileName,std::ios::in|std::ios::binary);
643 else fIn.open(fileName,std::ios::in);
644
645 // check if the file has been opened successfully
646 if (!fIn)
647 {
648#ifdef G4VERBOSE
649 if (verboseLevel >0)
650 {
651 G4cerr << "G4ProductionCutsTable::CheckMaterialInfo() - ";
652 G4cerr << "Cannot open file: " << fileName << G4endl;
653 }
654#endif
655 G4Exception( "G4ProductionCutsTable::CheckMaterialInfo()",
656 "ProcCuts102", JustWarning, "Cannot open file!");
657 return false;
658 }
659
660 char temp[FixedStringLengthForStore];
661
662 // key word
663 G4String keyword;
664 if (ascii)
665 {
666 fIn >> keyword;
667 }
668 else
669 {
670 fIn.read(temp, FixedStringLengthForStore);
671 keyword = (const char*)(temp);
672 }
673 if (key!=keyword)
674 {
675#ifdef G4VERBOSE
676 if (verboseLevel >0)
677 {
678 G4cerr << "G4ProductionCutsTable::CheckMaterialInfo() - ";
679 G4cerr << "Key word in " << fileName << "= " << keyword ;
680 G4cerr <<"( should be "<< key << ")" <<G4endl;
681 }
682#endif
683 G4Exception( "G4ProductionCutsTable::CheckMaterialInfo()",
684 "ProcCuts103", JustWarning, "Bad Data Format");
685 return false;
686 }
687
688 // number of materials in the table
689 G4int nmat;
690 if (ascii)
691 {
692 fIn >> nmat;
693 }
694 else
695 {
696 fIn.read( (char*)(&nmat), sizeof(G4int));
697 }
698 if ((nmat<=0) || (nmat >100000))
699 {
700 G4Exception( "G4ProductionCutsTable::CheckMaterialInfo()",
701 "ProcCuts108", JustWarning,
702 "Number of materials is less than zero or too big");
703 return false;
704 }
705
706 // list of material
707 for (G4int idx=0; idx<nmat ; ++idx)
708 {
709 // check eof
710 if(fIn.eof())
711 {
712#ifdef G4VERBOSE
713 if (verboseLevel >0)
714 {
715 G4cout << "G4ProductionCutsTable::CheckMaterialInfo() - ";
716 G4cout << "Encountered End of File " ;
717 G4cout << " at " << idx+1 << "th material "<< G4endl;
718 }
719#endif
720 fIn.close();
721 return false;
722 }
723
724 // check material name and density
725 char name[FixedStringLengthForStore];
726 G4double density;
727 if (ascii)
728 {
729 fIn >> name >> density;
730 density *= (g/cm3);
731
732 }
733 else
734 {
735 fIn.read(name, FixedStringLengthForStore);
736 fIn.read((char*)(&density), sizeof(G4double));
737 }
738 if (fIn.fail())
739 {
740#ifdef G4VERBOSE
741 if (verboseLevel >0)
742 {
743 G4cerr << "G4ProductionCutsTable::CheckMaterialInfo() - ";
744 G4cerr << "Bad data format ";
745 G4cerr << " at " << idx+1 << "th material "<< G4endl;
746 }
747#endif
748 G4Exception( "G4ProductionCutsTable::CheckMaterialInfo()",
749 "ProcCuts103", JustWarning, "Bad Data Format");
750 fIn.close();
751 return false;
752 }
753
754 G4Material* aMaterial = G4Material::GetMaterial(name);
755 if (aMaterial == nullptr ) continue;
756
757 G4double ratio = std::fabs(density/aMaterial->GetDensity() );
758 if ((0.999>ratio) || (ratio>1.001) )
759 {
760#ifdef G4VERBOSE
761 if (verboseLevel >0)
762 {
763 G4cerr << "G4ProductionCutsTable::CheckMaterialInfo() - ";
764 G4cerr << "Inconsistent material density" << G4endl;;
765 G4cerr << " at " << idx+1 << "th material "<< G4endl;
766 G4cerr << "Name: " << name << G4endl;
767 G4cerr << "Density:" << std::setiosflags(std::ios::scientific)
768 << density / (g/cm3) ;
769 G4cerr << "(should be " << aMaterial->GetDensity()/(g/cm3)<< ")"
770 << " [g/cm3]"<< G4endl;
771 G4cerr << std::resetiosflags(std::ios::scientific);
772 }
773#endif
774 G4Exception( "G4ProductionCutsTable::CheckMaterialInfo()",
775 "ProcCuts104", JustWarning, "Inconsistent material density");
776 fIn.close();
777 return false;
778 }
779 }
780
781 fIn.close();
782 return true;
783}
G4double GetDensity() const
Definition: G4Material.hh:178
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
Definition: G4Material.cc:651
const char * name(G4int ptype)

Referenced by CheckForRetrieveCutsTable().

◆ ConvertRangeToEnergy()

G4double G4ProductionCutsTable::ConvertRangeToEnergy ( const G4ParticleDefinition particle,
const G4Material material,
G4double  range 
)

Definition at line 299 of file G4ProductionCutsTable.cc.

303{
304 // This method gives energy corresponding to range value
305
306 // protection against premature call
307 if(firstUse)
308 {
309#ifdef G4VERBOSE
310 if(verboseLevel>0)
311 {
313 ed << "Invoked prematurely before it is fully initialized.";
314 G4Exception("G4ProductionCutsTable::ConvertRangeToEnergy()",
315 "CUTS0100", JustWarning, ed);
316 }
317#endif
318 return -1.0;
319 }
320
321 // check material
322 if (material == nullptr) return -1.0;
323
324 // check range
325 if (range == 0.0) return 0.0;
326 if (range <0.0) return -1.0;
327
328 // check particle
329 G4int index = G4ProductionCuts::GetIndex(particle);
330
331 if (index<0 || converters[index] == nullptr)
332 {
333#ifdef G4VERBOSE
334 if(verboseLevel>0)
335 {
337 ed << "Invoked ";
338 if(particle != nullptr)
339 { ed << "for particle <" << particle->GetParticleName() << ">."; }
340 else
341 { ed << "without valid particle pointer."; }
342 G4Exception("G4ProductionCutsTable::ConvertRangeToEnergy()",
343 "CUTS0101", JustWarning, ed);
344 }
345#endif
346 return -1.0;
347 }
348
349 return converters[index]->Convert(range, material);
350}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
const G4String & GetParticleName() const
static G4int GetIndex(const G4String &name)
virtual G4double Convert(G4double rangeCut, const G4Material *material)

Referenced by G4GDMLWriteStructure::ExportEnergyCuts(), and G4EmModelManager::Initialise().

◆ DumpCouples()

void G4ProductionCutsTable::DumpCouples ( ) const

Definition at line 405 of file G4ProductionCutsTable.cc.

406{
407 G4cout << G4endl;
408 G4cout << "========= Table of registered couples ============================"
409 << G4endl;
410 for(auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
411 {
412 G4MaterialCutsCouple* aCouple = (*cItr);
413 G4ProductionCuts* aCut = aCouple->GetProductionCuts();
414 G4cout << G4endl;
415 G4cout << "Index : " << aCouple->GetIndex()
416 << " used in the geometry : ";
417 if(aCouple->IsUsed()) G4cout << "Yes";
418 else G4cout << "No ";
419//// G4cout << " recalculation needed : ";
420//// if(aCouple->IsRecalcNeeded()) G4cout << "Yes";
421//// else G4cout << "No ";
422 G4cout << G4endl;
423 G4cout << " Material : " << aCouple->GetMaterial()->GetName() << G4endl;
424 G4cout << " Range cuts : "
425 << " gamma " << G4BestUnit(aCut->GetProductionCut("gamma"),"Length")
426 << " e- " << G4BestUnit(aCut->GetProductionCut("e-"),"Length")
427 << " e+ " << G4BestUnit(aCut->GetProductionCut("e+"),"Length")
428 << " proton " << G4BestUnit(aCut->GetProductionCut("proton"),"Length")
429 << G4endl;
430 G4cout << " Energy thresholds : " ;
431//// if(aCouple->IsRecalcNeeded()) {
432//// G4cout << " is not ready to print";
433//// } else {
434 G4cout << " gamma " << G4BestUnit((*(energyCutTable[0]))[aCouple->GetIndex()],"Energy")
435 << " e- " << G4BestUnit((*(energyCutTable[1]))[aCouple->GetIndex()],"Energy")
436 << " e+ " << G4BestUnit((*(energyCutTable[2]))[aCouple->GetIndex()],"Energy")
437 << " proton " << G4BestUnit((*(energyCutTable[3]))[aCouple->GetIndex()],"Energy");
438//// }
439 G4cout << G4endl;
440
441 if(aCouple->IsUsed())
442 {
443 G4cout << " Region(s) which use this couple : " << G4endl;
444 for(auto rItr=fG4RegionStore->cbegin();
445 rItr!=fG4RegionStore->cend(); ++rItr)
446 {
447 if (IsCoupleUsedInTheRegion(aCouple, *rItr) )
448 {
449 G4cout << " " << (*rItr)->GetName() << G4endl;
450 }
451 }
452 }
453 }
454 G4cout << G4endl;
455 G4cout << "==================================================================" << G4endl;
456 G4cout << G4endl;
457}
#define G4BestUnit(a, b)

Referenced by G4VUserPhysicsList::DumpCutValuesTableIfRequested(), and G4RunMessenger::SetNewValue().

◆ GetCoupleIndex() [1/2]

G4int G4ProductionCutsTable::GetCoupleIndex ( const G4Material aMat,
const G4ProductionCuts aCut 
) const
inline

Definition at line 340 of file G4ProductionCutsTable.hh.

342{
343 const G4MaterialCutsCouple* aCouple = GetMaterialCutsCouple(aMat,aCut);
344 return GetCoupleIndex(aCouple);
345}
const G4MaterialCutsCouple * GetMaterialCutsCouple(G4int i) const
G4int GetCoupleIndex(const G4MaterialCutsCouple *aCouple) const

◆ GetCoupleIndex() [2/2]

G4int G4ProductionCutsTable::GetCoupleIndex ( const G4MaterialCutsCouple aCouple) const
inline

Definition at line 328 of file G4ProductionCutsTable.hh.

329{
330 G4int idx = 0;
331 for(auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
332 {
333 if((*cItr)==aCouple) return idx;
334 ++idx;
335 }
336 return -1;
337}

Referenced by G4ITStepProcessor::ApplyProductionCut(), and GetCoupleIndex().

◆ GetDefaultProductionCuts()

G4ProductionCuts * G4ProductionCutsTable::GetDefaultProductionCuts ( ) const
inline

Definition at line 289 of file G4ProductionCutsTable.hh.

290{
291 return defaultProductionCuts;
292}

Referenced by G4RunManagerKernel::CheckRegions().

◆ GetEnergyCutsDoubleVector()

G4double * G4ProductionCutsTable::GetEnergyCutsDoubleVector ( std::size_t  pcIdx) const
inline

Definition at line 283 of file G4ProductionCutsTable.hh.

284{
285 return energyDoubleVector[pcIdx];
286}

◆ GetEnergyCutsVector()

◆ GetHighEdgeEnergy()

G4double G4ProductionCutsTable::GetHighEdgeEnergy ( ) const

◆ GetLowEdgeEnergy()

G4double G4ProductionCutsTable::GetLowEdgeEnergy ( ) const

◆ GetMaterialCutsCouple() [1/2]

const G4MaterialCutsCouple * G4ProductionCutsTable::GetMaterialCutsCouple ( const G4Material aMat,
const G4ProductionCuts aCut 
) const
inline

Definition at line 315 of file G4ProductionCutsTable.hh.

317{
318 for(auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
319 {
320 if((*cItr)->GetMaterial()!=aMat) continue;
321 if((*cItr)->GetProductionCuts()==aCut) return (*cItr);
322 }
323 return nullptr;
324}

◆ GetMaterialCutsCouple() [2/2]

const G4MaterialCutsCouple * G4ProductionCutsTable::GetMaterialCutsCouple ( G4int  i) const
inline

Definition at line 246 of file G4ProductionCutsTable.hh.

247{
248 return coupleTable[std::size_t(i)];
249}

Referenced by G4BremsstrahlungCrossSectionHandler::BuildCrossSectionsForMaterials(), G4eIonisationCrossSectionHandler::BuildCrossSectionsForMaterials(), G4CrossSectionHandler::BuildCrossSectionsForMaterials(), G4VEnergyLossProcess::BuildDEDXTable(), G4VEnergyLossProcess::BuildLambdaTable(), G4GammaGeneralProcess::BuildPhysicsTable(), G4MicroElecSurface::BuildPhysicsTable(), G4hImpactIonisation::BuildPhysicsTable(), G4LossTableBuilder::BuildTableForModel(), G4AdjointCSManager::BuildTotalSigmaTables(), G4ForwardXrayTR::BuildXrayTRtables(), G4hRDEnergyLoss::CutsWhereModified(), G4EmCalculator::FindCouple(), G4ForwardXrayTR::G4ForwardXrayTR(), GetCoupleIndex(), G4ForwardXrayTR::GetEnergyTR(), G4PAIPhotData::Initialise(), G4EmBiasingManager::Initialise(), G4BoldyshevTripletModel::Initialise(), G4IonParametrisedLossModel::Initialise(), G4JAEAElasticScatteringModel::Initialise(), G4JAEAPolarizedElasticScatteringModel::Initialise(), G4LivermoreComptonModel::Initialise(), G4LivermoreGammaConversionModelRC::Initialise(), G4LivermoreNuclearGammaConversionModel::Initialise(), G4LivermorePhotoElectricModel::Initialise(), G4LivermorePolarizedComptonModel::Initialise(), G4LivermorePolarizedGammaConversionModel::Initialise(), G4LivermorePolarizedPhotoElectricGDModel::Initialise(), G4LivermorePolarizedPhotoElectricModel::Initialise(), G4LivermorePolarizedRayleighModel::Initialise(), G4LivermoreRayleighModel::Initialise(), G4LowEPComptonModel::Initialise(), G4LowEPPolarizedComptonModel::Initialise(), G4PenelopeBremsstrahlungModel::Initialise(), G4PenelopeGammaConversionModel::Initialise(), G4PenelopeIonisationModel::Initialise(), G4PenelopePhotoElectricModel::Initialise(), G4PenelopeRayleighModel::Initialise(), G4mplIonisationModel::Initialise(), G4mplIonisationWithDeltaModel::Initialise(), G4LivermoreGammaConversion5DModel::Initialise(), G4LivermoreGammaConversionModel::Initialise(), G4MicroElecElasticModel_new::Initialise(), G4MicroElecInelasticModel_new::Initialise(), G4PenelopeRayleighModelMI::Initialise(), G4eDPWACoulombScatteringModel::Initialise(), G4WentzelVIModel::Initialise(), G4EmModelManager::Initialise(), G4VAtomDeexcitation::InitialiseAtomicDeexcitation(), G4LossTableBuilder::InitialiseBaseMaterials(), G4VEmModel::InitialiseElementSelectors(), G4EmCorrections::InitialiseForNewRun(), G4PenelopeBremsstrahlungModel::InitialiseLocal(), G4ElasticHadrNucleusHE::InitialiseModel(), G4GoudsmitSaundersonTable::InitSCPCorrection(), G4eDPWAElasticDCS::InitSCPCorrection(), G4ITTransportation::PostStepDoIt(), G4CoupledTransportation::PostStepDoIt(), G4Transportation::PostStepDoIt(), G4VEnergyLossProcess::PreparePhysicsTable(), G4PhysicsTableHelper::PreparePhysicsTable(), G4hImpactIonisation::PrintInfoDefinition(), and G4ParallelWorldProcess::SwitchMaterial().

◆ GetMaxEnergyCut()

G4double G4ProductionCutsTable::GetMaxEnergyCut ( )

◆ GetMCCIndexConversionTable()

const G4MCCIndexConversionTable * G4ProductionCutsTable::GetMCCIndexConversionTable ( ) const
inline

Definition at line 355 of file G4ProductionCutsTable.hh.

356{
357 return &mccConversionTable;
358}

Referenced by G4PhysicsTableHelper::RetrievePhysicsTable().

◆ GetProductionCutsTable()

G4ProductionCutsTable * G4ProductionCutsTable::GetProductionCutsTable ( )
static

Definition at line 58 of file G4ProductionCutsTable.cc.

59{
60 static G4ProductionCutsTable theProductionCutsTable;
61 if(fProductionCutsTable == nullptr)
62 {
63 fProductionCutsTable = &theProductionCutsTable;
64 }
65 return fProductionCutsTable;
66}

Referenced by G4ITStepProcessor::ApplyProductionCut(), G4BremsstrahlungCrossSectionHandler::BuildCrossSectionsForMaterials(), G4eIonisationCrossSectionHandler::BuildCrossSectionsForMaterials(), G4CrossSectionHandler::BuildCrossSectionsForMaterials(), G4hRDEnergyLoss::BuildDEDXTable(), G4VEnergyLossProcess::BuildDEDXTable(), G4VEnergyLossProcess::BuildLambdaTable(), G4VCrossSectionHandler::BuildMeanFreePathForMaterials(), G4GammaNuclearXS::BuildPhysicsTable(), G4NeutronCaptureXS::BuildPhysicsTable(), G4NeutronElasticXS::BuildPhysicsTable(), G4NeutronInelasticXS::BuildPhysicsTable(), G4ParticleInelasticXS::BuildPhysicsTable(), G4GammaGeneralProcess::BuildPhysicsTable(), G4GammaConversionToMuons::BuildPhysicsTable(), G4MicroElecSurface::BuildPhysicsTable(), G4hImpactIonisation::BuildPhysicsTable(), G4RunManagerKernel::BuildPhysicsTables(), G4LossTableBuilder::BuildTableForModel(), G4AdjointCSManager::BuildTotalSigmaTables(), G4ForwardXrayTR::BuildXrayTRtables(), G4RunManagerKernel::CheckRegions(), G4EmCalculator::ComputeEnergyCutFromRangeCut(), G4AdjointCSManager::ComputeTotalAdjointCS(), G4TheRayTracer::CreateBitMap(), G4PenelopeRayleighModelMI::CrossSectionPerVolume(), G4hRDEnergyLoss::CutsWhereModified(), G4VEmAdjointModel::DefineCurrentMaterial(), G4VUserPhysicsList::DumpCutValuesTableIfRequested(), G4RunManagerKernel::DumpRegion(), G4GDMLWriteStructure::ExportEnergyCuts(), G4EmCalculator::FindCouple(), G4ForwardXrayTR::G4ForwardXrayTR(), G4RunManagerKernel::G4RunManagerKernel(), G4VUserPhysicsList::G4VUserPhysicsList(), G4ForwardXrayTR::GetEnergyTR(), G4PAIPhotData::Initialise(), G4EmBiasingManager::Initialise(), G4BoldyshevTripletModel::Initialise(), G4IonParametrisedLossModel::Initialise(), G4JAEAElasticScatteringModel::Initialise(), G4JAEAPolarizedElasticScatteringModel::Initialise(), G4LivermoreComptonModel::Initialise(), G4LivermoreGammaConversionModelRC::Initialise(), G4LivermoreNuclearGammaConversionModel::Initialise(), G4LivermorePhotoElectricModel::Initialise(), G4LivermorePolarizedComptonModel::Initialise(), G4LivermorePolarizedGammaConversionModel::Initialise(), G4LivermorePolarizedPhotoElectricGDModel::Initialise(), G4LivermorePolarizedPhotoElectricModel::Initialise(), G4LivermorePolarizedRayleighModel::Initialise(), G4LivermoreRayleighModel::Initialise(), G4LowEPComptonModel::Initialise(), G4LowEPPolarizedComptonModel::Initialise(), G4PenelopeBremsstrahlungModel::Initialise(), G4PenelopeGammaConversionModel::Initialise(), G4PenelopeIonisationModel::Initialise(), G4PenelopePhotoElectricModel::Initialise(), G4PenelopeRayleighModel::Initialise(), G4mplIonisationModel::Initialise(), G4mplIonisationWithDeltaModel::Initialise(), G4LivermoreGammaConversion5DModel::Initialise(), G4LivermoreGammaConversionModel::Initialise(), G4MicroElecElasticModel_new::Initialise(), G4MicroElecInelasticModel_new::Initialise(), G4PenelopeRayleighModelMI::Initialise(), G4eDPWACoulombScatteringModel::Initialise(), G4SeltzerBergerModel::Initialise(), G4WentzelVIModel::Initialise(), G4WentzelVIRelModel::Initialise(), G4EmModelManager::Initialise(), G4VAtomDeexcitation::InitialiseAtomicDeexcitation(), G4LossTableBuilder::InitialiseBaseMaterials(), G4VEmModel::InitialiseElementSelectors(), G4EmCorrections::InitialiseForNewRun(), G4PenelopeBremsstrahlungModel::InitialiseLocal(), G4ElasticHadrNucleusHE::InitialiseModel(), G4GammaGeneralProcess::InitialiseProcess(), G4GoudsmitSaundersonTable::InitSCPCorrection(), G4eDPWAElasticDCS::InitSCPCorrection(), G4NeutrinoElectronProcess::PostStepDoIt(), G4ElNeutrinoNucleusProcess::PostStepDoIt(), G4HadronElasticProcess::PostStepDoIt(), G4MuNeutrinoNucleusProcess::PostStepDoIt(), G4ITTransportation::PostStepDoIt(), G4CoupledTransportation::PostStepDoIt(), G4Transportation::PostStepDoIt(), G4VEmProcess::PreparePhysicsTable(), G4VEnergyLossProcess::PreparePhysicsTable(), G4PhysicsTableHelper::PreparePhysicsTable(), G4hImpactIonisation::PrintInfoDefinition(), G4PhysicsTableHelper::RetrievePhysicsTable(), G4RunManagerKernel::RunTermination(), LBE::SetCuts(), G4RunMessenger::SetNewValue(), G4VUserPhysicsList::SetParticleCuts(), G4ProductionCuts::SetProductionCuts(), G4ParallelWorldProcess::SwitchMaterial(), and G4RunManagerKernel::UpdateRegion().

◆ GetRangeCutsDoubleVector()

G4double * G4ProductionCutsTable::GetRangeCutsDoubleVector ( std::size_t  pcIdx) const
inline

Definition at line 276 of file G4ProductionCutsTable.hh.

277{
278 return rangeDoubleVector[pcIdx];
279}

◆ GetRangeCutsVector()

const std::vector< G4double > * G4ProductionCutsTable::GetRangeCutsVector ( std::size_t  pcIdx) const
inline

Definition at line 226 of file G4ProductionCutsTable.hh.

227{
228 return rangeCutTable[pcIdx];
229}

Referenced by StoreCutsInfo().

◆ GetTableSize()

std::size_t G4ProductionCutsTable::GetTableSize ( ) const
inline

Definition at line 239 of file G4ProductionCutsTable.hh.

240{
241 return coupleTable.size();
242}

Referenced by G4BremsstrahlungCrossSectionHandler::BuildCrossSectionsForMaterials(), G4eIonisationCrossSectionHandler::BuildCrossSectionsForMaterials(), G4CrossSectionHandler::BuildCrossSectionsForMaterials(), G4hRDEnergyLoss::BuildDEDXTable(), G4VEnergyLossProcess::BuildDEDXTable(), G4VEnergyLossProcess::BuildLambdaTable(), G4VCrossSectionHandler::BuildMeanFreePathForMaterials(), G4GammaGeneralProcess::BuildPhysicsTable(), G4GammaConversionToMuons::BuildPhysicsTable(), G4MicroElecSurface::BuildPhysicsTable(), G4hImpactIonisation::BuildPhysicsTable(), G4LossTableBuilder::BuildTableForModel(), G4AdjointCSManager::BuildTotalSigmaTables(), G4ForwardXrayTR::BuildXrayTRtables(), G4hRDEnergyLoss::CutsWhereModified(), G4ForwardXrayTR::G4ForwardXrayTR(), G4ForwardXrayTR::GetEnergyTR(), G4PAIPhotData::Initialise(), G4EmBiasingManager::Initialise(), G4BoldyshevTripletModel::Initialise(), G4IonParametrisedLossModel::Initialise(), G4JAEAElasticScatteringModel::Initialise(), G4JAEAPolarizedElasticScatteringModel::Initialise(), G4LivermoreComptonModel::Initialise(), G4LivermoreGammaConversionModelRC::Initialise(), G4LivermoreNuclearGammaConversionModel::Initialise(), G4LivermorePhotoElectricModel::Initialise(), G4LivermorePolarizedComptonModel::Initialise(), G4LivermorePolarizedGammaConversionModel::Initialise(), G4LivermorePolarizedPhotoElectricGDModel::Initialise(), G4LivermorePolarizedPhotoElectricModel::Initialise(), G4LivermorePolarizedRayleighModel::Initialise(), G4LivermoreRayleighModel::Initialise(), G4LowEPComptonModel::Initialise(), G4LowEPPolarizedComptonModel::Initialise(), G4PenelopeBremsstrahlungModel::Initialise(), G4PenelopeGammaConversionModel::Initialise(), G4PenelopeIonisationModel::Initialise(), G4PenelopePhotoElectricModel::Initialise(), G4PenelopeRayleighModel::Initialise(), G4mplIonisationModel::Initialise(), G4mplIonisationWithDeltaModel::Initialise(), G4LivermoreGammaConversion5DModel::Initialise(), G4LivermoreGammaConversionModel::Initialise(), G4MicroElecElasticModel_new::Initialise(), G4MicroElecInelasticModel_new::Initialise(), G4PenelopeRayleighModelMI::Initialise(), G4eDPWACoulombScatteringModel::Initialise(), G4WentzelVIModel::Initialise(), G4WentzelVIRelModel::Initialise(), G4EmModelManager::Initialise(), G4VAtomDeexcitation::InitialiseAtomicDeexcitation(), G4LossTableBuilder::InitialiseBaseMaterials(), G4VEmModel::InitialiseElementSelectors(), G4EmCorrections::InitialiseForNewRun(), G4PenelopeBremsstrahlungModel::InitialiseLocal(), G4ElasticHadrNucleusHE::InitialiseModel(), G4GammaGeneralProcess::InitialiseProcess(), G4GoudsmitSaundersonTable::InitSCPCorrection(), G4eDPWAElasticDCS::InitSCPCorrection(), G4VEmProcess::PreparePhysicsTable(), G4VEnergyLossProcess::PreparePhysicsTable(), G4PhysicsTableHelper::PreparePhysicsTable(), and G4hImpactIonisation::PrintInfoDefinition().

◆ GetVerboseLevel()

G4int G4ProductionCutsTable::GetVerboseLevel ( ) const
inline

Definition at line 348 of file G4ProductionCutsTable.hh.

349{
350 return verboseLevel;
351}

Referenced by G4ProductionCutsTableMessenger::GetCurrentValue(), and UpdateCoupleTable().

◆ IsModified()

G4bool G4ProductionCutsTable::IsModified ( ) const
inline

Definition at line 252 of file G4ProductionCutsTable.hh.

253{
254 if(firstUse) return true;
255 for(auto itr=coupleTable.cbegin(); itr!=coupleTable.cend(); ++itr)
256 {
257 if((*itr)->IsRecalcNeeded())
258 {
259 return true;
260 }
261 }
262 return false;
263}

◆ operator=()

G4ProductionCutsTable & G4ProductionCutsTable::operator= ( const G4ProductionCutsTable )
delete

◆ PhysicsTableUpdated()

void G4ProductionCutsTable::PhysicsTableUpdated ( )
inline

Definition at line 266 of file G4ProductionCutsTable.hh.

267{
268 for(auto itr=coupleTable.cbegin(); itr!=coupleTable.cend(); ++itr)
269 {
270 (*itr)->PhysicsTableUpdated();
271 }
272}

Referenced by G4RunManagerKernel::RunTermination().

◆ ResetConverters()

void G4ProductionCutsTable::ResetConverters ( )

Definition at line 353 of file G4ProductionCutsTable.cc.

354{
355 for(std::size_t i=0; i< NumberOfG4CutIndex; ++i)
356 {
357 if (converters[i]!=0) converters[i]->Reset();
358 }
359}

◆ RetrieveCutsInfo()

G4bool G4ProductionCutsTable::RetrieveCutsInfo ( const G4String directory,
G4bool  ascii = false 
)
protectedvirtual

Definition at line 1234 of file G4ProductionCutsTable.cc.

1236{
1237 // Retrieve cut values information in files under the specified directory
1238
1239 const G4String fileName = directory + "/" + "cut.dat";
1240 const G4String key = "CUT-V3.0";
1241 std::ifstream fIn;
1242
1243 // open input file
1244 if (!ascii ) fIn.open(fileName,std::ios::in|std::ios::binary);
1245 else fIn.open(fileName,std::ios::in);
1246
1247 // check if the file has been opened successfully
1248 if (!fIn)
1249 {
1250 if (verboseLevel >0)
1251 {
1252 G4cerr << "G4ProductionCutTable::RetrieveCutsInfo() - ";
1253 G4cerr << "Cannot open file: " << fileName << G4endl;
1254 }
1255 G4Exception( "G4ProductionCutsTable::RetrieveCutsInfo()",
1256 "ProcCuts102", JustWarning, "Cannot open file!");
1257 return false;
1258 }
1259
1260 char temp[FixedStringLengthForStore];
1261
1262 // key word
1263 G4String keyword;
1264 if (ascii)
1265 {
1266 fIn >> keyword;
1267 }
1268 else
1269 {
1270 fIn.read(temp, FixedStringLengthForStore);
1271 keyword = (const char*)(temp);
1272 }
1273 if (key!=keyword)
1274 {
1275 if (verboseLevel >0)
1276 {
1277 G4cerr << "G4ProductionCutTable::RetrieveCutsInfo() - ";
1278 G4cerr << "Key word in " << fileName << "= " << keyword ;
1279 G4cerr <<"( should be "<< key << ")" << G4endl;
1280 }
1281 G4Exception( "G4ProductionCutsTable::RetrieveCutsInfo()",
1282 "ProcCuts103", JustWarning, "Bad Data Format");
1283 return false;
1284 }
1285
1286 // numberOfCouples
1287 G4int numberOfCouples;
1288 if (ascii)
1289 {
1290 fIn >> numberOfCouples;
1291 if (fIn.fail())
1292 {
1293 G4Exception( "G4ProductionCutsTable::RetrieveCutsInfo()",
1294 "ProcCuts103", JustWarning, "Bad Data Format");
1295 return false;
1296 }
1297 }
1298 else
1299 {
1300 fIn.read( (char*)(&numberOfCouples), sizeof(G4int));
1301 }
1302
1303 if (numberOfCouples > static_cast<G4int>(mccConversionTable.size()) )
1304 {
1305 G4Exception( "G4ProductionCutsTable::RetrieveCutsInfo()",
1306 "ProcCuts109", JustWarning,
1307 "Number of Couples in the file exceeds defined couples");
1308 }
1309 numberOfCouples = mccConversionTable.size();
1310
1311 for (std::size_t idx=0; static_cast<G4int>(idx) <NumberOfG4CutIndex; ++idx)
1312 {
1313 std::vector<G4double>* fRange = rangeCutTable[idx];
1314 std::vector<G4double>* fEnergy = energyCutTable[idx];
1315 fRange->clear();
1316 fEnergy->clear();
1317
1318 // Loop over all couples
1319 for (std::size_t i=0; static_cast<G4int>(i)< numberOfCouples; ++i)
1320 {
1321 G4double rcut, ecut;
1322 if (ascii)
1323 {
1324 fIn >> rcut >> ecut;
1325 if (fIn.fail())
1326 {
1327 G4Exception( "G4ProductionCutsTable::RetrieveCutsInfo()",
1328 "ProcCuts103", JustWarning, "Bad Data Format");
1329 return false;
1330 }
1331 rcut *= mm;
1332 ecut *= keV;
1333 }
1334 else
1335 {
1336 fIn.read((char*)(&rcut), sizeof(G4double));
1337 fIn.read((char*)(&ecut), sizeof(G4double));
1338 }
1339 if (!mccConversionTable.IsUsed(i)) continue;
1340 std::size_t new_index = mccConversionTable.GetIndex(i);
1341 (*fRange)[new_index] = rcut;
1342 (*fEnergy)[new_index] = ecut;
1343 }
1344 }
1345 return true;
1346}
G4bool IsUsed(std::size_t index) const
G4int GetIndex(std::size_t index) const

Referenced by RetrieveCutsTable().

◆ RetrieveCutsTable()

G4bool G4ProductionCutsTable::RetrieveCutsTable ( const G4String directory,
G4bool  ascii = false 
)

Definition at line 489 of file G4ProductionCutsTable.cc.

491{
492 if (!CheckForRetrieveCutsTable(dir, ascii)) return false;
493 if (!RetrieveCutsInfo(dir, ascii)) return false;
494#ifdef G4VERBOSE
495 if (verboseLevel >2)
496 {
497 G4cout << "G4ProductionCutsTable::RetrieveCutsTable()" << G4endl;
498 G4cout << " Material/Cuts information have been successfully retrieved ";
499 if (ascii)
500 {
501 G4cout << " in Ascii mode ";
502 }
503 else
504 {
505 G4cout << " in Binary mode ";
506 }
507 G4cout << " under " << dir << G4endl;
508 }
509#endif
510 return true;
511}
virtual G4bool RetrieveCutsInfo(const G4String &directory, G4bool ascii=false)
G4bool CheckForRetrieveCutsTable(const G4String &directory, G4bool ascii=false)

Referenced by G4VUserPhysicsList::BuildPhysicsTable().

◆ SetEnergyRange()

void G4ProductionCutsTable::SetEnergyRange ( G4double  lowedge,
G4double  highedge 
)

Definition at line 362 of file G4ProductionCutsTable.cc.

363{
365}
static void SetEnergyRange(G4double lowedge, G4double highedge)

Referenced by G4VUserPhysicsList::G4VUserPhysicsList(), LBE::SetCuts(), and G4ProductionCutsTableMessenger::SetNewValue().

◆ SetMaxEnergyCut()

void G4ProductionCutsTable::SetMaxEnergyCut ( G4double  value)

Definition at line 1370 of file G4ProductionCutsTable.cc.

1371{
1373}
static void SetMaxEnergyCut(G4double value)

Referenced by G4ProductionCutsTableMessenger::SetNewValue().

◆ SetVerboseLevel()

void G4ProductionCutsTable::SetVerboseLevel ( G4int  value)

Definition at line 1349 of file G4ProductionCutsTable.cc.

1350{
1351 // Set same verbosity to all registered RangeToEnergyConverters
1352
1353 verboseLevel = value;
1354 for (G4int ip=0; ip< NumberOfG4CutIndex; ++ip)
1355 {
1356 if (converters[ip] != nullptr )
1357 {
1358 converters[ip]->SetVerboseLevel(value);
1359 }
1360 }
1361}

Referenced by G4ProductionCutsTableMessenger::SetNewValue(), and G4VUserPhysicsList::SetVerboseLevel().

◆ StoreCutsInfo()

G4bool G4ProductionCutsTable::StoreCutsInfo ( const G4String directory,
G4bool  ascii = false 
)
protectedvirtual

Definition at line 1151 of file G4ProductionCutsTable.cc.

1153{
1154 // Store cut values information in files under the specified directory
1155
1156 const G4String fileName = directory + "/" + "cut.dat";
1157 const G4String key = "CUT-V3.0";
1158 std::ofstream fOut;
1159 char temp[FixedStringLengthForStore];
1160
1161 // open output file
1162 if (!ascii ) fOut.open(fileName,std::ios::out|std::ios::binary);
1163 else fOut.open(fileName,std::ios::out);
1164
1165 // check if the file has been opened successfully
1166 if (!fOut)
1167 {
1168 if(verboseLevel>0)
1169 {
1170 G4cerr << "G4ProductionCutsTable::StoreCutsInfo() - ";
1171 G4cerr << "Cannot open file: " << fileName << G4endl;
1172 }
1173 G4Exception( "G4ProductionCutsTable::StoreCutsInfo()",
1174 "ProcCuts102", JustWarning, "Cannot open file!");
1175 return false;
1176 }
1177
1178 G4int numberOfCouples = coupleTable.size();
1179 if (ascii)
1180 {
1181 /////////////// ASCII mode /////////////////
1182 // key word
1183 fOut << key << G4endl;
1184
1185 // number of couples in the table
1186 fOut << numberOfCouples << G4endl;
1187 }
1188 else
1189 {
1190 /////////////// Binary mode /////////////////
1191 // key word
1192 std::size_t i;
1193 for (i=0; i<FixedStringLengthForStore; ++i)
1194 temp[i] = '\0';
1195 for (i=0; i<key.length() && i<FixedStringLengthForStore-1; ++i)
1196 temp[i]=key[i];
1197 fOut.write(temp, FixedStringLengthForStore);
1198
1199 // number of couples in the table
1200 fOut.write( (char*)(&numberOfCouples), sizeof(G4int));
1201 }
1202
1203 for (std::size_t idx=0; idx <NumberOfG4CutIndex; ++idx)
1204 {
1205 const std::vector<G4double>* fRange = GetRangeCutsVector(idx);
1206 const std::vector<G4double>* fEnergy = GetEnergyCutsVector(idx);
1207 std::size_t i=0;
1208 // Loop over all couples
1209 for (auto cItr=coupleTable.cbegin();cItr!=coupleTable.cend(); ++cItr, ++i)
1210 {
1211 if (ascii)
1212 {
1213 /////////////// ASCII mode /////////////////
1214 fOut.setf(std::ios::scientific);
1215 fOut << std::setw(20) << (*fRange)[i]/mm ;
1216 fOut << std::setw(20) << (*fEnergy)[i]/keV << G4endl;
1217 fOut.unsetf(std::ios::scientific);
1218 }
1219 else
1220 {
1221 /////////////// Binary mode /////////////////
1222 G4double cut = (*fRange)[i];
1223 fOut.write((char*)(&cut), sizeof(G4double));
1224 cut = (*fEnergy)[i];
1225 fOut.write((char*)(&cut), sizeof(G4double));
1226 }
1227 }
1228 }
1229 fOut.close();
1230 return true;
1231}
const std::vector< G4double > * GetRangeCutsVector(std::size_t pcIdx) const
const std::vector< G4double > * GetEnergyCutsVector(std::size_t pcIdx) const

Referenced by StoreCutsTable().

◆ StoreCutsTable()

G4bool G4ProductionCutsTable::StoreCutsTable ( const G4String directory,
G4bool  ascii = false 
)

Definition at line 460 of file G4ProductionCutsTable.cc.

462{
463 // Store cuts and material information in files under the specified directory
464
465 if (!StoreMaterialInfo(dir, ascii)) return false;
466 if (!StoreMaterialCutsCoupleInfo(dir, ascii)) return false;
467 if (!StoreCutsInfo(dir, ascii)) return false;
468
469#ifdef G4VERBOSE
470 if (verboseLevel >2)
471 {
472 G4cout << "G4ProductionCutsTable::StoreCutsTable()" << G4endl;
473 G4cout << " Material/Cuts information have been successfully stored ";
474 if (ascii)
475 {
476 G4cout << " in Ascii mode ";
477 }
478 else
479 {
480 G4cout << " in Binary mode ";
481 }
482 G4cout << " under " << dir << G4endl;
483 }
484#endif
485 return true;
486}
virtual G4bool StoreCutsInfo(const G4String &directory, G4bool ascii=false)
virtual G4bool StoreMaterialInfo(const G4String &directory, G4bool ascii=false)
virtual G4bool StoreMaterialCutsCoupleInfo(const G4String &directory, G4bool ascii=false)

Referenced by G4VUserPhysicsList::StorePhysicsTable().

◆ StoreMaterialCutsCoupleInfo()

G4bool G4ProductionCutsTable::StoreMaterialCutsCoupleInfo ( const G4String directory,
G4bool  ascii = false 
)
protectedvirtual

Definition at line 787 of file G4ProductionCutsTable.cc.

789{
790 // Store materialCutsCouple information in files under the specified directory
791
792 const G4String fileName = directory + "/" + "couple.dat";
793 const G4String key = "COUPLE-V3.0";
794 std::ofstream fOut;
795 char temp[FixedStringLengthForStore];
796
797 // open output file
798 if (!ascii ) fOut.open(fileName,std::ios::out|std::ios::binary);
799 else fOut.open(fileName,std::ios::out);
800
801
802 // check if the file has been opened successfully
803 if (!fOut)
804 {
805#ifdef G4VERBOSE
806 if (verboseLevel >0)
807 {
808 G4cerr << "G4ProductionCutsTable::StoreMaterialCutsCoupleInfo() - ";
809 G4cerr << "Cannot open file: " << fileName << G4endl;
810 }
811#endif
812 G4Exception( "G4ProductionCutsTable::StoreMaterialCutsCoupleInfo()",
813 "ProcCuts102",
814 JustWarning, "Cannot open file!");
815 return false;
816 }
817 G4int numberOfCouples = coupleTable.size();
818 if (ascii)
819 {
820 /////////////// ASCII mode /////////////////
821 // key word
822 fOut << std::setw(FixedStringLengthForStore) << key << G4endl;
823
824 // number of couples in the table
825 fOut << numberOfCouples << G4endl;
826 }
827 else
828 {
829 /////////////// Binary mode /////////////////
830 // key word
831 std::size_t i;
832 for (i=0; i<FixedStringLengthForStore; ++i)
833 temp[i] = '\0';
834 for (i=0; i<key.length() && i<FixedStringLengthForStore-1; ++i)
835 temp[i]=key[i];
836 fOut.write(temp, FixedStringLengthForStore);
837
838 // number of couples in the table
839 fOut.write( (char*)(&numberOfCouples), sizeof(G4int));
840 }
841
842 // Loop over all couples
843 for (auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
844 {
845 G4MaterialCutsCouple* aCouple = (*cItr);
846 G4int index = aCouple->GetIndex();
847 // cut value
848 G4ProductionCuts* aCut = aCouple->GetProductionCuts();
849 G4double cutValues[NumberOfG4CutIndex];
850 for (std::size_t idx=0; idx <NumberOfG4CutIndex; ++idx)
851 {
852 cutValues[idx] = aCut->GetProductionCut(idx);
853 }
854 // material/region info
855 G4String materialName = aCouple->GetMaterial()->GetName();
856 G4String regionName = "NONE";
857 if (aCouple->IsUsed())
858 {
859 for(auto rItr=fG4RegionStore->cbegin();
860 rItr!=fG4RegionStore->cend(); ++rItr)
861 {
862 if (IsCoupleUsedInTheRegion(aCouple, *rItr))
863 {
864 regionName = (*rItr)->GetName();
865 break;
866 }
867 }
868 }
869
870 if (ascii)
871 {
872 /////////////// ASCII mode /////////////////
873 // index number
874 fOut << index << G4endl;
875
876 // material name
877 fOut << std::setw(FixedStringLengthForStore) << materialName<< G4endl;
878
879 // region name
880 fOut << std::setw(FixedStringLengthForStore) << regionName<< G4endl;
881
882 fOut.setf(std::ios::scientific);
883 // cut values
884 for (std::size_t idx=0; idx< NumberOfG4CutIndex; ++idx)
885 {
886 fOut << std::setw(FixedStringLengthForStore) << cutValues[idx]/(mm)
887 << G4endl;
888 }
889 fOut.unsetf(std::ios::scientific);
890
891 }
892 else
893 {
894 /////////////// Binary mode /////////////////
895 // index
896 fOut.write( (char*)(&index), sizeof(G4int));
897
898 // material name
899 std::size_t i;
900 for (i=0; i<FixedStringLengthForStore; ++i)
901 temp[i] = '\0';
902 for (i=0; i<materialName.length() && i<FixedStringLengthForStore-1; ++i)
903 temp[i]=materialName[i];
904 fOut.write(temp, FixedStringLengthForStore);
905
906 // region name
907 for (i=0; i<FixedStringLengthForStore; ++i)
908 temp[i] = '\0';
909 for (i=0; i<regionName.length() && i<FixedStringLengthForStore-1; ++i)
910 temp[i]=regionName[i];
911 fOut.write(temp, FixedStringLengthForStore);
912
913 // cut values
914 for (std::size_t idx=0; idx< NumberOfG4CutIndex; ++idx)
915 {
916 fOut.write( (char*)(&(cutValues[idx])), sizeof(G4double));
917 }
918 }
919 }
920 fOut.close();
921 return true;
922}

Referenced by StoreCutsTable().

◆ StoreMaterialInfo()

G4bool G4ProductionCutsTable::StoreMaterialInfo ( const G4String directory,
G4bool  ascii = false 
)
protectedvirtual

Definition at line 538 of file G4ProductionCutsTable.cc.

540{
541 // Store material information in files under the specified directory
542
543 const G4String fileName = directory + "/" + "material.dat";
544 const G4String key = "MATERIAL-V3.0";
545 std::ofstream fOut;
546
547 // open output file
548 if (!ascii ) fOut.open(fileName,std::ios::out|std::ios::binary);
549 else fOut.open(fileName,std::ios::out);
550
551 // check if the file has been opened successfully
552 if (!fOut)
553 {
554#ifdef G4VERBOSE
555 if (verboseLevel>0)
556 {
557 G4cerr << "G4ProductionCutsTable::StoreMaterialInfo() - ";
558 G4cerr << "Cannot open file: " << fileName << G4endl;
559 }
560#endif
561 G4Exception( "G4ProductionCutsTable::StoreMaterialInfo()",
562 "ProcCuts102", JustWarning, "Cannot open file!");
563 return false;
564 }
565
567 // number of materials in the table
568 G4int numberOfMaterial = matTable->size();
569
570 if (ascii)
571 {
572 /////////////// ASCII mode /////////////////
573 // key word
574 fOut << key << G4endl;
575
576 // number of materials in the table
577 fOut << numberOfMaterial << G4endl;
578
579 fOut.setf(std::ios::scientific);
580
581 // material name and density
582 for (std::size_t idx=0; static_cast<G4int>(idx)<numberOfMaterial; ++idx)
583 {
584 fOut << std::setw(FixedStringLengthForStore)
585 << ((*matTable)[idx])->GetName();
586 fOut << std::setw(FixedStringLengthForStore)
587 << ((*matTable)[idx])->GetDensity()/(g/cm3) << G4endl;
588 }
589
590 fOut.unsetf(std::ios::scientific);
591
592 }
593 else
594 {
595 /////////////// Binary mode /////////////////
596 char temp[FixedStringLengthForStore];
597 std::size_t i;
598
599 // key word
600 for (i=0; i<FixedStringLengthForStore; ++i)
601 {
602 temp[i] = '\0';
603 }
604 for (i=0; i<key.length() && i<FixedStringLengthForStore-1; ++i)
605 {
606 temp[i]=key[i];
607 }
608 fOut.write(temp, FixedStringLengthForStore);
609
610 // number of materials in the table
611 fOut.write( (char*)(&numberOfMaterial), sizeof(G4int));
612
613 // material name and density
614 for (std::size_t imat=0; static_cast<G4int>(imat)<numberOfMaterial; ++imat)
615 {
616 G4String name = ((*matTable)[imat])->GetName();
617 G4double density = ((*matTable)[imat])->GetDensity();
618 for (i=0; i<FixedStringLengthForStore; ++i)
619 temp[i] = '\0';
620 for (i=0; i<name.length() && i<FixedStringLengthForStore-1; ++i)
621 temp[i]=name[i];
622 fOut.write(temp, FixedStringLengthForStore);
623 fOut.write( (char*)(&density), sizeof(G4double));
624 }
625 }
626
627 fOut.close();
628 return true;
629}
std::vector< G4Material * > G4MaterialTable
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:637

Referenced by StoreCutsTable().

◆ UpdateCoupleTable()

void G4ProductionCutsTable::UpdateCoupleTable ( G4VPhysicalVolume currentWorld)

Definition at line 118 of file G4ProductionCutsTable.cc.

119{
120 if(firstUse)
121 {
122 if(G4ParticleTable::GetParticleTable()->FindParticle("gamma"))
123 {
124 converters[0] = new G4RToEConvForGamma();
125 converters[0]->SetVerboseLevel(GetVerboseLevel());
126 }
127 if(G4ParticleTable::GetParticleTable()->FindParticle("e-"))
128 {
129 converters[1] = new G4RToEConvForElectron();
130 converters[1]->SetVerboseLevel(GetVerboseLevel());
131 }
132 if(G4ParticleTable::GetParticleTable()->FindParticle("e+"))
133 {
134 converters[2] = new G4RToEConvForPositron();
135 converters[2]->SetVerboseLevel(GetVerboseLevel());
136 }
137 if(G4ParticleTable::GetParticleTable()->FindParticle("proton"))
138 {
139 converters[3] = new G4RToEConvForProton();
140 converters[3]->SetVerboseLevel(GetVerboseLevel());
141 }
142 firstUse = false;
143 }
144
145 // Reset "used" flags of all couples
146 for(auto CoupleItr=coupleTable.cbegin();
147 CoupleItr!=coupleTable.cend(); ++CoupleItr)
148 {
149 (*CoupleItr)->SetUseFlag(false);
150 }
151
152 // Update Material-Cut-Couple
153 for(auto rItr=fG4RegionStore->cbegin(); rItr!=fG4RegionStore->cend(); ++rItr)
154 {
155 // Material scan is to be done only for the regions appear in the
156 // current tracking world.
157 // if((*rItr)->GetWorldPhysical()!=currentWorld) continue;
158
159 if( (*rItr)->IsInMassGeometry() || (*rItr)->IsInParallelGeometry() )
160 {
161 G4ProductionCuts* fProductionCut = (*rItr)->GetProductionCuts();
162 auto mItr = (*rItr)->GetMaterialIterator();
163 std::size_t nMaterial = (*rItr)->GetNumberOfMaterials();
164 (*rItr)->ClearMap();
165
166 for(std::size_t iMate=0; iMate<nMaterial; ++iMate)
167 {
168 //check if this material cut couple has already been made
169 G4bool coupleAlreadyDefined = false;
170 G4MaterialCutsCouple* aCouple;
171 for(auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
172 {
173 if( (*cItr)->GetMaterial()==(*mItr)
174 && (*cItr)->GetProductionCuts()==fProductionCut)
175 {
176 coupleAlreadyDefined = true;
177 aCouple = *cItr;
178 break;
179 }
180 }
181
182 // If this combination is new, cleate and register a couple
183 if(!coupleAlreadyDefined)
184 {
185 aCouple = new G4MaterialCutsCouple((*mItr),fProductionCut);
186 coupleTable.push_back(aCouple);
187 aCouple->SetIndex(coupleTable.size()-1);
188 }
189
190 // Register this couple to the region
191 (*rItr)->RegisterMaterialCouplePair((*mItr),aCouple);
192
193 // Set the couple to the proper logical volumes in that region
194 aCouple->SetUseFlag();
195
196 auto rootLVItr = (*rItr)->GetRootLogicalVolumeIterator();
197 std::size_t nRootLV = (*rItr)->GetNumberOfRootVolumes();
198 for(std::size_t iLV=0; iLV<nRootLV; ++iLV)
199 {
200 // Set the couple to the proper logical volumes in that region
201 G4LogicalVolume* aLV = *rootLVItr;
202 G4Region* aR = *rItr;
203
204 ScanAndSetCouple(aLV,aCouple,aR);
205
206 // Proceed to the next root logical volume in this region
207 ++rootLVItr;
208 }
209
210 // Proceed to next material in this region
211 ++mItr;
212 }
213 }
214 }
215
216 // Check if sizes of Range/Energy cuts tables are equal to the size of
217 // the couple table. If new couples are made during the previous procedure,
218 // nCouple becomes larger then nTable
219
220 std::size_t nCouple = coupleTable.size();
221 std::size_t nTable = energyCutTable[0]->size();
222 G4bool newCoupleAppears = nCouple>nTable;
223 if(newCoupleAppears)
224 {
225 for(std::size_t n=nCouple-nTable; n>0; --n)
226 {
227 for(std::size_t nn=0; nn< NumberOfG4CutIndex; ++nn)
228 {
229 rangeCutTable[nn]->push_back(-1.);
230 energyCutTable[nn]->push_back(-1.);
231 }
232 }
233 }
234
235 // Update RangeEnergy cuts tables
236 std::size_t idx = 0;
237 G4Timer timer;
238 if (verboseLevel>2)
239 {
240 timer.Start();
241 }
242 for(auto cItr=coupleTable.cbegin(); cItr!=coupleTable.cend(); ++cItr)
243 {
244 G4ProductionCuts* aCut = (*cItr)->GetProductionCuts();
245 const G4Material* aMat = (*cItr)->GetMaterial();
246 if((*cItr)->IsRecalcNeeded())
247 {
248 for(std::size_t ptcl=0; ptcl< NumberOfG4CutIndex; ++ptcl)
249 {
250 G4double rCut = aCut->GetProductionCut(ptcl);
251 (*(rangeCutTable[ptcl]))[idx] = rCut;
252 // if(converters[ptcl] && (*cItr)->IsUsed())
253 if(converters[ptcl])
254 {
255 (*(energyCutTable[ptcl]))[idx] = converters[ptcl]->Convert(rCut,aMat);
256 }
257 else
258 {
259 (*(energyCutTable[ptcl]))[idx] = -1.;
260 }
261 }
262 }
263 ++idx;
264 }
265 if (verboseLevel>2)
266 {
267 timer.Stop();
268 G4cout << "G4ProductionCutsTable::UpdateCoupleTable() - "
269 << "Elapsed time for calculation of energy cuts: " << G4endl;
270 G4cout << timer << G4endl;
271 }
272
273 // resize Range/Energy cuts double vectors if new couple is made
274 if(newCoupleAppears)
275 {
276 for(std::size_t ix=0; ix<NumberOfG4CutIndex; ++ix)
277 {
278 G4double* rangeVOld = rangeDoubleVector[ix];
279 G4double* energyVOld = energyDoubleVector[ix];
280 if(rangeVOld) delete [] rangeVOld;
281 if(energyVOld) delete [] energyVOld;
282 rangeDoubleVector[ix] = new G4double[(*(rangeCutTable[ix])).size()];
283 energyDoubleVector[ix] = new G4double[(*(energyCutTable[ix])).size()];
284 }
285 }
286
287 // Update Range/Energy cuts double vectors
288 for(std::size_t ix=0; ix<NumberOfG4CutIndex; ++ix)
289 {
290 for(std::size_t ixx=0; ixx<(*(rangeCutTable[ix])).size(); ++ixx)
291 {
292 rangeDoubleVector[ix][ixx] = (*(rangeCutTable[ix]))[ixx];
293 energyDoubleVector[ix][ixx] = (*(energyCutTable[ix]))[ixx];
294 }
295 }
296}
void SetUseFlag(G4bool flg=true)
static G4ParticleTable * GetParticleTable()
const std::vector< G4double > & GetProductionCuts() const
void Stop()
void Start()

Referenced by G4TheRayTracer::CreateBitMap(), and G4RunManagerKernel::UpdateRegion().


The documentation for this class was generated from the following files: