74 : firstUse(true),verboseLevel(1),fMessenger(0)
151 (*CoupleItr)->SetUseFlag(
false);
155 typedef std::vector<G4Region*>::iterator regionIterator;
162 if((*rItr)->IsInMassGeometry() || (*rItr)->IsInParallelGeometry())
166 std::vector<G4Material*>::const_iterator mItr =
167 (*rItr)->GetMaterialIterator();
168 size_t nMaterial = (*rItr)->GetNumberOfMaterials();
171 for(
size_t iMate=0;iMate<nMaterial;iMate++){
173 G4bool coupleAlreadyDefined =
false;
177 if( (*cItr)->GetMaterial()==(*mItr) &&
178 (*cItr)->GetProductionCuts()==fProductionCut){
179 coupleAlreadyDefined =
true;
186 if(!coupleAlreadyDefined){
193 (*rItr)->RegisterMaterialCouplePair((*mItr),aCouple);
198 std::vector<G4LogicalVolume*>::iterator rootLVItr
199 = (*rItr)->GetRootLogicalVolumeIterator();
200 size_t nRootLV = (*rItr)->GetNumberOfRootVolumes();
201 for(
size_t iLV=0;iLV<nRootLV;iLV++) {
224 G4bool newCoupleAppears = nCouple>nTable;
225 if(newCoupleAppears) {
226 for(
size_t n=nCouple-nTable;
n>0;
n--) {
244 if((*cItr)->IsRecalcNeeded()) {
260 G4cout <<
"G4ProductionCutsTable::UpdateCoupleTable "
261 <<
" elapsed time for calculation of energy cuts " <<
G4endl;
266 if(newCoupleAppears){
270 if(rangeVOld)
delete [] rangeVOld;
271 if(energyVOld)
delete [] energyVOld;
296 if (material ==0)
return -1.0;
299 if (range ==0.0)
return 0.0;
300 if (range <0.0)
return -1.0;
308 G4cout <<
"G4ProductionCutsTable::ConvertRangeToEnergy" ;
353 if((aRegion!=0) && aLV->
GetRegion()!=aRegion)
return;
361 if(noDaughters==0)
return;
364 for(
size_t i=0;i<noDaughters;i++){
374 G4cout <<
"========= Table of registered couples =============================="
382 <<
" used in the geometry : ";
390 G4cout <<
" Range cuts : "
396 G4cout <<
" Energy thresholds : " ;
408 G4cout <<
" Region(s) which use this couple : " <<
G4endl;
409 typedef std::vector<G4Region*>::iterator regionIterator;
413 G4cout <<
" " << (*rItr)->GetName() <<
G4endl;
419 G4cout <<
"====================================================================" <<
G4endl;
435 G4cout <<
"G4ProductionCutsTable::StoreCutsTable " ;
436 G4cout <<
" Material/Cuts information have been succesfully stored ";
438 G4cout <<
" in Ascii mode ";
440 G4cout <<
" in Binary mode ";
456 G4cout <<
"G4ProductionCutsTable::RetrieveCutsTable " ;
457 G4cout <<
" Material/Cuts information have been succesfully retreived ";
459 G4cout <<
" in Ascii mode ";
461 G4cout <<
" in Binary mode ";
477 G4cerr <<
"G4ProductionCutsTable::CheckForRetrieveCutsTable!!"<<
G4endl;
481 G4cerr <<
"G4ProductionCutsTable::CheckMaterialInfo passed !!"<<
G4endl;
485 G4cerr <<
"G4ProductionCutsTable::CheckMaterialCutsCoupleInfo passed !!"<<
G4endl;
496 const G4String fileName = directory +
"/" +
"material.dat";
497 const G4String key =
"MATERIAL-V3.0";
502 fOut.open(fileName,std::ios::out|std::ios::binary);
504 fOut.open(fileName,std::ios::out);
511 G4cerr <<
"G4ProductionCutsTable::StoreMaterialInfo ";
515 G4Exception(
"G4ProductionCutsTable::StoreMaterialInfo()",
523 G4int numberOfMaterial = matTable->size();
531 fOut << numberOfMaterial <<
G4endl;
533 fOut.setf(std::ios::scientific);
536 for (
size_t idx=0;
static_cast<G4int>(idx)<numberOfMaterial; ++idx){
538 << ((*matTable)[idx])->GetName();
540 << ((*matTable)[idx])->GetDensity()/(
g/
cm3) << G4endl;
543 fOut.unsetf(std::ios::scientific);
554 for (i=0; i<key.length() && i<FixedStringLengthForStore-1; ++i){
557 fOut.write(temp, FixedStringLengthForStore);
560 fOut.write( (
char*)(&numberOfMaterial),
sizeof (
G4int));
563 for (
size_t imat=0;
static_cast<G4int>(imat)<numberOfMaterial; ++imat){
565 G4double density = ((*matTable)[imat])->GetDensity();
567 for (i=0; i<name.length() && i<FixedStringLengthForStore-1; ++i)
569 fOut.write(temp, FixedStringLengthForStore);
570 fOut.write( (
char*)(&density),
sizeof (
G4double));
583 const G4String fileName = directory +
"/" +
"material.dat";
584 const G4String key =
"MATERIAL-V3.0";
597 G4cerr <<
"G4ProductionCutsTable::CheckMaterialInfo ";
601 G4Exception(
"G4ProductionCutsTable::CheckMaterialInfo()",
615 keyword = (
const char*)(temp);
620 G4cerr <<
"G4ProductionCutsTable::CheckMaterialInfo ";
621 G4cerr <<
" Key word in " << fileName <<
"= " << keyword ;
625 G4Exception(
"G4ProductionCutsTable::CheckMaterialInfo()",
636 fIn.read( (
char*)(&nmat),
sizeof (
G4int));
638 if ((nmat<=0) || (nmat >100000)){
639 G4Exception(
"G4ProductionCutsTable::CheckMaterialInfo()",
641 "Number of materials is less than zero or too big");
646 for (
G4int idx=0; idx<nmat ; ++idx){
651 G4cout <<
"G4ProductionCutsTable::CheckMaterialInfo ";
652 G4cout <<
" encountered End of File " ;
664 fIn >> name >> density;
669 fIn.read((
char*)(&density),
sizeof (
G4double));
674 G4cerr <<
"G4ProductionCutsTable::CheckMaterialInfo ";
675 G4cerr <<
" Bad data format ";
679 G4Exception(
"G4ProductionCutsTable::CheckMaterialInfo()",
687 if (aMaterial ==0 )
continue;
690 if ((0.999>ratio) || (ratio>1.001) ){
693 G4cerr <<
"G4ProductionCutsTable::CheckMaterialInfo ";
697 G4cerr <<
"Density:" << std::setiosflags(std::ios::scientific) << density / (
g/
cm3) ;
699 G4cerr << std::resetiosflags(std::ios::scientific);
702 G4Exception(
"G4ProductionCutsTable::CheckMaterialInfo()",
724 const G4String fileName = directory +
"/" +
"couple.dat";
731 fOut.open(fileName,std::ios::out|std::ios::binary);
733 fOut.open(fileName,std::ios::out);
740 G4cerr <<
"G4ProductionCutsTable::StoreMaterialCutsCoupleInfo ";
744 G4Exception(
"G4ProductionCutsTable::StoreMaterialCutsCoupleInfo()",
756 fOut << numberOfCouples <<
G4endl;
762 for (i=0; i<key.length() && i<FixedStringLengthForStore-1; ++i)
764 fOut.write(temp, FixedStringLengthForStore);
767 fOut.write( (
char*)(&numberOfCouples),
sizeof (
G4int));
786 typedef std::vector<G4Region*>::iterator regionIterator;
790 regionName = (*rItr)->GetName();
807 fOut.setf(std::ios::scientific);
813 fOut.unsetf(std::ios::scientific);
818 fOut.write( (
char*)(&index),
sizeof (
G4int));
823 for (i=0; i<materialName.length() && i<FixedStringLengthForStore-1; ++i) {
824 temp[i]=materialName[i];
826 fOut.write(temp, FixedStringLengthForStore);
830 for (i=0; i<regionName.length() && i<FixedStringLengthForStore-1; ++i) {
831 temp[i]=regionName[i];
833 fOut.write(temp, FixedStringLengthForStore);
837 fOut.write( (
char*)(&(cutValues[idx])),
sizeof (
G4double));
855 const G4String fileName = directory +
"/" +
"couple.dat";
869 G4cerr <<
"G4ProductionCutTable::CheckMaterialCutsCoupleInfo ";
873 G4Exception(
"G4ProductionCutsTable::CheckMaterialCutsCoupleInfo()",
887 keyword = (
const char*)(temp);
892 G4cerr <<
"G4ProductionCutTable::CheckMaterialCutsCoupleInfo ";
893 G4cerr <<
" Key word in " << fileName <<
"= " << keyword ;
897 G4Exception(
"G4ProductionCutsTable::CheckMaterialCutsCoupleInfo()",
905 G4int numberOfCouples;
907 fIn >> numberOfCouples;
909 fIn.read( (
char*)(&numberOfCouples),
sizeof (
G4int));
916 for (
G4int idx=0; idx<numberOfCouples; idx+=1){
922 fIn.read( (
char*)(&index),
sizeof (
G4int));
943 cutValues[i] *= (
mm);
945 fIn.read( (
char*)(&(cutValues[i])),
sizeof (
G4double));
964 fRatio = fRatio && (0.999<ratio) && (ratio<1.001) ;
967 if (!fRatio)
continue;
980 if ( regionname !=
"NONE" ) {
983 G4cout <<
"G4ProductionCutTable::CheckMaterialCutsCoupleInfo ";
984 G4cout <<
"Region " << regionname <<
" is not found ";
988 if ( ( (regionname ==
"NONE") && (aCouple->
IsUsed()) ) ||
990 G4cout <<
"G4ProductionCutTable::CheckMaterialCutsCoupleInfo ";
991 G4cout <<
"A Couple is used differnt region in the current setup ";
993 G4cout <<
" material: " << mat_name ;
996 G4cout <<
"cut[" << ii <<
"]=" << cutValues[ii]/
mm;
1000 }
else if ( index != aCouple->
GetIndex() ) {
1001 G4cout <<
"G4ProductionCutTable::CheckMaterialCutsCoupleInfo ";
1004 G4cout <<
" is defined as " ;
1005 G4cout << index <<
":" << mat_name <<
" in " << fileName <<
G4endl;
1007 G4cout <<
"G4ProductionCutTable::CheckMaterialCutsCoupleInfo ";
1008 G4cout << index <<
":" << mat_name <<
" in " << fileName ;
1009 G4cout <<
" is consistent with current setup" <<
G4endl;
1016 G4cout <<
"G4ProductionCutTable::CheckMaterialCutsCoupleInfo ";
1017 G4cout <<
"Couples is not defined in the current detector setup ";
1019 G4cout <<
" material: " << mat_name ;
1022 G4cout <<
"cut[" << ii <<
"]=" << cutValues[ii]/
mm;
1042 const G4String fileName = directory +
"/" +
"cut.dat";
1049 fOut.open(fileName,std::ios::out|std::ios::binary);
1051 fOut.open(fileName,std::ios::out);
1057 G4cerr <<
"G4ProductionCutsTable::StoreCutsInfo ";
1060 G4Exception(
"G4ProductionCutsTable::StoreCutsInfo()",
1073 fOut << numberOfCouples <<
G4endl;
1079 for (i=0; i<key.length() && i<FixedStringLengthForStore-1; ++i)
1081 fOut.write(temp, FixedStringLengthForStore);
1084 fOut.write( (
char*)(&numberOfCouples),
sizeof (
G4int));
1097 fOut.setf(std::ios::scientific);
1098 fOut << std::setw(20) << (*fRange)[i]/
mm ;
1099 fOut << std::setw(20) << (*fEnergy)[i]/
keV <<
G4endl;
1100 fOut.unsetf(std::ios::scientific);
1104 fOut.write((
char*)(&cut),
sizeof (
G4double));
1105 cut = (*fEnergy)[i];
1106 fOut.write((
char*)(&cut),
sizeof (
G4double));
1120 const G4String fileName = directory +
"/" +
"cut.dat";
1133 G4cerr <<
"G4ProductionCutTable::RetrieveCutsInfo ";
1136 G4Exception(
"G4ProductionCutsTable::RetrieveCutsInfo()",
1150 keyword = (
const char*)(temp);
1154 G4cerr <<
"G4ProductionCutTable::RetrieveCutsInfo ";
1155 G4cerr <<
" Key word in " << fileName <<
"= " << keyword ;
1158 G4Exception(
"G4ProductionCutsTable::RetrieveCutsInfo()",
1165 G4int numberOfCouples;
1167 fIn >> numberOfCouples;
1169 G4Exception(
"G4ProductionCutsTable::RetrieveCutsInfo()",
1175 fIn.read( (
char*)(&numberOfCouples),
sizeof (
G4int));
1179 G4Exception(
"G4ProductionCutsTable::RetrieveCutsInfo()",
1181 "Number of Couples in the file exceeds defined couples ");
1192 for (
size_t i=0;
static_cast<G4int>(i)< numberOfCouples; i++){
1195 fIn >> rcut >> ecut;
1197 G4Exception(
"G4ProductionCutsTable::RetrieveCutsInfo()",
1205 fIn.read((
char*)(&rcut),
sizeof (
G4double));
1206 fIn.read((
char*)(&ecut),
sizeof (
G4double));
1210 (*fRange)[new_index] = rcut;
1211 (*fEnergy)[new_index] = ecut;
G4VRangeToEnergyConverter * converters[NumberOfG4CutIndex]
static void SetMaxEnergyCut(G4double value)
G4bool IsUsed(size_t index) const
static G4double GetLowEdgeEnergy()
G4LogicalVolume * GetLogicalVolume() const
G4double ConvertRangeToEnergy(const G4ParticleDefinition *particle, const G4Material *material, G4double range)
static G4ParticleTable * GetParticleTable()
void ScanAndSetCouple(G4LogicalVolume *aLV, G4MaterialCutsCouple *aCouple, G4Region *aRegion)
G4CoupleTable coupleTable
G4CutTable energyCutTable
static G4MaterialTable * GetMaterialTable()
G4int GetVerboseLevel() const
static constexpr double keV
static constexpr double mm
static G4double GetHighEdgeEnergy()
virtual G4bool StoreMaterialCutsCoupleInfo(const G4String &directory, G4bool ascii=false)
void SetMaxEnergyCut(G4double value)
G4double GetMaxEnergyCut()
virtual G4bool StoreMaterialInfo(const G4String &directory, G4bool ascii=false)
const G4String & GetParticleName() const
G4int GetNoDaughters() const
static G4int GetIndex(const G4String &name)
void SetEnergyRange(G4double lowedge, G4double highedge)
G4double GetHighEdgeEnergy() const
G4bool CheckForRetrieveCutsTable(const G4String &directory, G4bool ascii=false)
static G4Material * GetMaterial(const G4String &name, G4bool warning=true)
const std::vector< G4double > * GetEnergyCutsVector(size_t pcIdx) const
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
G4Material * GetMaterial() const
G4RegionStore * fG4RegionStore
G4double GetProductionCut(G4int index) const
const G4String & GetName() const
const std::vector< G4double > & GetProductionCuts() const
static constexpr double g
bool IsCoupleUsedInTheRegion(const G4MaterialCutsCouple *aCouple, const G4Region *aRegion) const
G4ProductionCuts * defaultProductionCuts
const XML_Char int const XML_Char * value
const G4ParticleDefinition const G4Material *G4double range
virtual G4bool CheckMaterialCutsCoupleInfo(const G4String &directory, G4bool ascii=false)
static G4ProductionCutsTable * fG4ProductionCutsTable
std::vector< G4MaterialCutsCouple * >::const_iterator CoupleTableIterator
void SetUseFlag(G4bool flg=true)
void SetVerboseLevel(G4int value)
G4bool StoreCutsTable(const G4String &directory, G4bool ascii=false)
virtual G4bool CheckMaterialInfo(const G4String &directory, G4bool ascii=false)
void SetMaterialCutsCouple(G4MaterialCutsCouple *cuts)
G4double GetLowEdgeEnergy() const
virtual ~G4ProductionCutsTable()
virtual G4bool RetrieveCutsInfo(const G4String &directory, G4bool ascii=false)
void SetNewIndex(size_t index, size_t new_value)
G4bool RetrieveCutsTable(const G4String &directory, G4bool ascii=false)
virtual G4double Convert(G4double rangeCut, const G4Material *material)
G4GLOB_DLL std::ostream G4cerr
G4double * energyDoubleVector[NumberOfG4CutIndex]
#define G4BestUnit(a, b)
#define G4_USE_G4BESTUNIT_FOR_VERBOSE 1
std::vector< G4Material * > G4MaterialTable
std::vector< G4double > G4CutVectorForAParticle
static G4ProductionCutsTable * GetProductionCutsTable()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static G4RegionStore * GetInstance()
const std::vector< G4double > * GetRangeCutsVector(size_t pcIdx) const
G4double * rangeDoubleVector[NumberOfG4CutIndex]
G4GLOB_DLL std::ostream G4cout
G4ProductionCuts * GetProductionCuts() const
G4ProductionCutsTableMessenger * fMessenger
const G4Material * GetMaterial() const
G4MCCIndexConversionTable mccConversionTable
virtual G4bool StoreCutsInfo(const G4String &directory, G4bool ascii=false)
static constexpr double cm3
void UpdateCoupleTable(G4VPhysicalVolume *currentWorld)
static G4double GetMaxEnergyCut()
G4Region * GetRegion() const
G4int GetIndex(size_t index) const
static void SetEnergyRange(G4double lowedge, G4double highedge)
G4VPhysicalVolume * GetDaughter(const G4int i) const
G4double GetDensity() const
void SetVerboseLevel(G4int value)