78G4tgbGeometryDumper::G4tgbGeometryDumper()
85 if(theInstance ==
nullptr)
95 theFile =
new std::ofstream(fname);
115 for(
auto ite = pvstore->cbegin(); ite != pvstore->cend(); ++ite)
188 std::vector<G4VPhysicalVolume*> pvChildren = GetPVChildren(lv);
189 for(
auto ite = pvChildren.cbegin(); ite != pvChildren.cend(); ++ite)
203 if(rotMat ==
nullptr)
214 G4cout <<
" G4tgbGeometryDumper::DumpPVPlacement() - Reflected volume: "
224 G4Rep3x3 rottemp(colx.
x(), coly.
x(), colz.
x(), colx.
y(), coly.
y(), colz.
y(),
225 colx.
z(), coly.
z(), colz.
z());
242 if(!CheckIfPhysVolExists(fullname, pv))
244 (*theFile) <<
":PLACE " << SubstituteRefl(AddQuotes(lvName)) <<
" "
247 <<
" " << AddQuotes(rotName) <<
" " << pos.x() <<
" " << pos.y()
248 <<
" " << pos.z() <<
G4endl;
250 thePhysVols[fullname] = pv;
272 std::vector<G4double> newParams;
276 for(
G4int ii = 0; ii < nReplicas; ++ii)
363 if(ii == 0 || mate1st != newMate || params1st[0] != newParams[0])
371 lvName =
DumpLogVol(lv, extraName, newSolid, newMate);
409 "Unknown axis of replication for volume" + pv->
GetName();
410 G4Exception(
"G4tgbGeometryDumper::DumpPVReplica",
"Wrong axis ",
417 if(!CheckIfPhysVolExists(fullname, pv))
419 (*theFile) <<
":REPL " << SubstituteRefl(AddQuotes(lvName)) <<
" "
421 <<
" " << axisName <<
" " << nReplicas;
424 (*theFile) <<
" " << width <<
" " << offset <<
G4endl;
428 (*theFile) <<
" " << width / deg <<
"*deg"
429 <<
" " << offset / deg <<
"*deg" <<
G4endl;
432 thePhysVols[fullname] = pv;
446 lvName = GetObjectName(lv, theLogVols);
450 lvName = lv->
GetName() + extraName;
453 if(theLogVols.find(lvName) != theLogVols.cend())
474 (*theFile) <<
":VOLU " << SubstituteRefl(AddQuotes(lvName)) <<
" "
475 << SupressRefl(AddQuotes(solidName)) <<
" " << AddQuotes(mateName)
478 theLogVols[lvName] = lv;
486 G4String mateName = GetObjectName(mat, theMaterials);
487 if(theMaterials.find(mateName) != theMaterials.cend())
499 (*theFile) <<
":MATE " << AddQuotes(mateName) <<
" " << mat->
GetZ() <<
" "
500 << mat->
GetA() / (g / mole) <<
" " << density <<
G4endl;
506 for(std::size_t ii = 0; ii < numElements; ++ii)
511 (*theFile) <<
":MIXT " << AddQuotes(mateName) <<
" " << density <<
" "
514 for(std::size_t ii = 0; ii < numElements; ++ii)
516 (*theFile) <<
" " << AddQuotes(GetObjectName((*elems)[ii], theElements))
517 <<
" " << fractions[ii] <<
G4endl;
521 (*theFile) <<
":MATE_MEE " << AddQuotes(mateName) <<
" "
525 (*theFile) <<
":MATE_TEMPERATURE " << AddQuotes(mateName) <<
" "
528 (*theFile) <<
":MATE_PRESSURE " << AddQuotes(mateName) <<
" "
536 stateStr =
"Undefined";
549 (*theFile) <<
":MATE_STATE " << AddQuotes(mateName) <<
" " << stateStr
552 theMaterials[mateName] = mat;
560 G4String elemName = GetObjectName(ele, theElements);
562 if(theElements.find(elemName) != theElements.cend())
571 if(symbol ==
"" || symbol ==
" ")
576 if(ele->GetNumberOfIsotopes() == 0)
578 (*theFile) <<
":ELEM " << AddQuotes(elemName) <<
" " << AddQuotes(symbol)
579 <<
" " << ele->GetZ() <<
" " << ele->GetA() / (g / mole) <<
" "
585 for(std::size_t ii = 0; ii < ele->GetNumberOfIsotopes(); ++ii)
590 (*theFile) <<
":ELEM_FROM_ISOT " << AddQuotes(elemName) <<
" "
591 << AddQuotes(symbol) <<
" " << ele->GetNumberOfIsotopes()
593 const G4double* fractions = ele->GetRelativeAbundanceVector();
594 for(std::size_t ii = 0; ii < ele->GetNumberOfIsotopes(); ++ii)
596 (*theFile) <<
" " << AddQuotes(GetObjectName((*isots)[ii], theIsotopes))
597 <<
" " << fractions[ii] <<
G4endl;
600 theElements[elemName] = ele;
606 G4String isotName = GetObjectName(isot, theIsotopes);
607 if(theIsotopes.find(isotName) != theIsotopes.cend())
612 (*theFile) <<
":ISOT " << AddQuotes(isotName) <<
" " << isot->
GetZ() <<
" "
613 << isot->
GetN() <<
" " << isot->
GetA() / (g / mole) <<
" "
616 theIsotopes[isotName] = isot;
626 solidName = GetObjectName(solid, theSolids);
630 solidName = solid->
GetName() + extraName;
633 if(theSolids.find(solidName) != theSolids.cend())
639 solidType = GetTGSolidType(solidType);
641 if(solidType ==
"UNIONSOLID")
645 else if(solidType ==
"SUBTRACTIONSOLID")
649 else if(solidType ==
"INTERSECTIONSOLID")
653 else if(solidType ==
"REFLECTEDSOLID")
656 if(solidrefl ==
nullptr)
658 G4Exception(
"G4tgbGeometryDumper::DumpSolid()",
"InvalidType",
667 (*theFile) <<
":SOLID " << AddQuotes(solidName) <<
" ";
668 (*theFile) << AddQuotes(solidType) <<
" ";
670 theSolids[solidName] = solid;
692 if(solid1Disp !=
nullptr)
718 G4String bsoName = GetObjectName(so, theSolids);
719 if(theSolids.find(bsoName) != theSolids.cend())
721 G4String solid0Name = FindSolidName(solid0);
722 G4String solid1Name = FindSolidName(solid1);
724 (*theFile) <<
":SOLID " << AddQuotes(bsoName) <<
" " << AddQuotes(solidType)
725 <<
" " << AddQuotes(solid0Name) <<
" " << AddQuotes(solid1Name)
726 <<
" " << AddQuotes(rotName) <<
" " << approxTo0(pos.x()) <<
" "
727 << approxTo0(pos.y()) <<
" " << approxTo0(pos.z()) <<
" "
730 theSolids[bsoName] = bso;
737 for(std::size_t ii = 0; ii < params.size(); ++ii)
739 (*theFile) << params[ii] <<
" ";
747 std::vector<G4double> params;
750 solidType = GetTGSolidType(solidType);
752 if(solidType ==
"BOX")
754 const G4Box* sb =
dynamic_cast<const G4Box*
>(so);
762 else if(solidType ==
"TUBS")
774 else if(solidType ==
"TRAP")
781 params.push_back(symAxis.
theta() / deg);
782 params.push_back(symAxis.
phi() / deg);
793 else if(solidType ==
"TRD")
795 const G4Trd* tr =
dynamic_cast<const G4Trd*
>(so);
805 else if(solidType ==
"PARA")
814 params.push_back(std::atan(para->
GetTanAlpha()) / deg);
815 params.push_back(symAxis.
theta() / deg);
816 params.push_back(symAxis.
phi() / deg);
819 else if(solidType ==
"CONS")
833 else if(solidType ==
"SPHERE")
836 if(sphere !=
nullptr)
846 else if(solidType ==
"ORB")
848 const G4Orb* orb =
dynamic_cast<const G4Orb*
>(so);
854 else if(solidType ==
"TORUS")
859 params.push_back(torus->
GetRmin());
860 params.push_back(torus->
GetRmax());
861 params.push_back(torus->
GetRtor());
862 params.push_back(torus->
GetSPhi() / deg);
863 params.push_back(torus->
GetDPhi() / deg);
866 else if(solidType ==
"POLYCONE")
874 if(angphi > 180 * deg)
879 params.push_back(angphi);
881 params.push_back(ncor);
883 for(
G4int ii = 0; ii < ncor; ++ii)
890 else if(solidType ==
"GENERICPOLYCONE")
897 if(angphi > 180 * deg)
902 if(endphi > 180 * deg)
907 params.push_back(angphi);
908 params.push_back(endphi - angphi);
909 params.push_back(ncor);
911 for(
G4int ii = 0; ii < ncor; ++ii)
918 else if(solidType ==
"POLYHEDRA")
926 if(angphi > 180 * deg)
931 params.push_back(angphi);
934 params.push_back(ncor);
936 for(
G4int ii = 0; ii < ncor; ++ii)
943 else if(solidType ==
"ELLIPTICALTUBE")
948 params.push_back(eltu->
GetDx());
949 params.push_back(eltu->
GetDy());
950 params.push_back(eltu->
GetDz());
953 else if(solidType ==
"ELLIPSOID")
965 else if(solidType ==
"ELLIPTICAL_CONE")
972 params.push_back(elco->
GetZMax());
976 else if(solidType ==
"HYPE")
989 else if(solidType ==
"TWISTEDBOX")
1000 else if(solidType ==
"TWISTEDTRAP")
1003 if(ttrap !=
nullptr)
1018 else if(solidType ==
"TWISTEDTRD")
1031 else if(solidType ==
"TWISTEDTUBS")
1039 params.push_back(ttub->
GetDPhi() / deg);
1045 G4String ErrMessage =
"Solid type not supported, sorry... " + solidType;
1046 G4Exception(
"G4tgbGeometryDumpe::DumpSolidParams()",
"NotImplemented",
1061 G4double de = MatDeterminant(rotm);
1062 G4String rotName = LookForExistingRotation(rotm);
1071 (*theFile) <<
":ROTM ";
1075 (*theFile) << AddQuotes(rotName) << std::setprecision(9) <<
" "
1076 << approxTo0(rotm->
xx()) <<
" " << approxTo0(rotm->
yx()) <<
" "
1077 << approxTo0(rotm->
zx()) <<
" " << approxTo0(rotm->
xy()) <<
" "
1078 << approxTo0(rotm->
yy()) <<
" " << approxTo0(rotm->
zy()) <<
" "
1079 << approxTo0(rotm->
xz()) <<
" " << approxTo0(rotm->
yz()) <<
" "
1080 << approxTo0(rotm->
zz()) <<
G4endl;
1084 (*theFile) <<
":ROTM ";
1088 (*theFile) << AddQuotes(rotName) <<
" " << approxTo0(rotm->
thetaX() / deg)
1089 <<
" " << approxTo0(rotm->
phiX() / deg) <<
" "
1090 << approxTo0(rotm->
thetaY() / deg) <<
" "
1091 << approxTo0(rotm->
phiY() / deg) <<
" "
1092 << approxTo0(rotm->
thetaZ() / deg) <<
" "
1096 theRotMats[rotName] = rotm;
1102std::vector<G4VPhysicalVolume*>
1106 std::vector<G4VPhysicalVolume*> children;
1107 for(
auto ite = pvstore->cbegin(); ite != pvstore->cend(); ++ite)
1109 if((*ite)->GetMotherLogical() == lv)
1111 children.push_back(*ite);
1115 G4cout <<
" G4tgbGeometryDumper::GetPVChildren() - adding children: "
1128 G4String newsolidType = solidType.substr(2, solidType.length());
1129 for(std::size_t ii = 0; ii < newsolidType.length(); ++ii)
1131 newsolidType[ii] = toupper(newsolidType[ii]);
1133 return newsolidType;
1151 if(std::fabs(val) < precision)
1164 std::size_t siz = str.length();
1165 for(std::size_t ii = 0; ii < siz; ++ii)
1167 if(str.substr(ii, 1) ==
" ")
1198 name =
name.substr(0, irefl) +
"_REFL";
1210 std::map<G4String, G4Isotope*>::const_iterator ite;
1211 for(ite = theIsotopes.cbegin(); ite != theIsotopes.cend(); ++ite)
1213 if(isot == (*ite).second)
1215 return (*ite).
first;
1222 ite = theIsotopes.find(isotName);
1223 if(ite != theIsotopes.cend())
1228 if(!Same2G4Isotopes(isot, isotold))
1236 std::map<G4String, G4Isotope*>::const_iterator ite2 =
1237 theIsotopes.find(newIsotName);
1238 if(ite2 == theIsotopes.cend())
1240 isotName = newIsotName;
1245 if(Same2G4Isotopes(isot, (*ite2).second))
1247 isotName = newIsotName;
1260G4String G4tgbGeometryDumper::GetObjectName(
1261 TYP* obj, std::map<G4String, TYP*> objectsDumped)
1268 typename std::map<G4String, TYP*>::const_iterator ite;
1269 for(ite = objectsDumped.cbegin(); ite != objectsDumped.cend(); ++ite)
1271 if(obj == (*ite).second)
1273 return (*ite).
first;
1280 ite = objectsDumped.find(objName);
1282 if(ite != objectsDumped.cend())
1284 TYP* objold = (*ite).second;
1291 typename std::map<G4String, TYP*>::const_iterator ite2 =
1292 objectsDumped.find(newObjName);
1293 if(ite2 == objectsDumped.cend())
1295 objName = newObjName;
1305G4bool G4tgbGeometryDumper::CheckIfLogVolExists(
const G4String& name,
1308 if(theLogVols.find(name) != theLogVols.cend())
1334G4bool G4tgbGeometryDumper::CheckIfPhysVolExists(
const G4String& name,
1340 G4cout <<
" G4tgbGeometryDumper::CheckIfPhysVolExists() - " <<
name
1344 if(thePhysVols.find(name) != thePhysVols.cend())
1346 if((*(thePhysVols.find(name))).second != pt)
1352 G4cerr <<
" G4tgbGeometryDumper::CheckIfPhysVolExists () -"
1353 <<
" Placement found but not same as before : " <<
name <<
G4endl;
1369 for(
auto ite = theRotMats.cbegin(); ite != theRotMats.cend(); ++ite)
1371 if((*ite).second->isNear(*rotm))
1373 rmName = (*ite).
first;
1397 std::map<G4String, G4VSolid*>::const_iterator ite;
1398 for(ite = theSolids.cbegin(); ite != theSolids.cend(); ++ite)
1400 if(solid == (*ite).second)
1402 return (*ite).
first;
1406 if(ite == theSolids.cend())
1408 G4Exception(
"G4tgbGeometryDumper::FindSolidName()",
"ReadError",
1411 return (*ite).first;
std::vector< G4Element * > G4ElementVector
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::vector< G4Isotope * > G4IsotopeVector
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
HepRotation inverse() const
virtual const G4VSolid * GetConstituentSolid(G4int no) const
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4double GetOuterRadiusPlusZ() const
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadiusMinusZ() const
G4double GetInnerRadiusPlusZ() const
G4double GetOuterRadiusMinusZ() const
G4double GetZHalfLength() const
G4VSolid * GetConstituentMovedSolid() const
G4AffineTransform GetTransform() const
G4ThreeVector GetObjectTranslation() const
G4double GetSemiAxisMax(G4int i) const
G4double GetZTopCut() const
G4double GetZBottomCut() const
G4double GetSemiAxisX() const
G4double GetSemiAxisY() const
G4double GetZTopCut() const
G4double GetStartPhi() const
G4double GetEndPhi() const
G4int GetNumRZCorner() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4double GetInnerStereo() const
G4double GetZHalfLength() const
G4double GetOuterStereo() const
G4double GetOuterRadius() const
G4double GetInnerRadius() const
G4double GetMeanExcitationEnergy() const
const G4String & GetName() const
G4VSolid * GetSolid() const
G4Material * GetMaterial() const
const G4String & GetName() const
G4double GetPressure() const
G4double GetDensity() const
const G4ElementVector * GetElementVector() const
G4double GetTemperature() const
const G4double * GetFractionVector() const
G4IonisParamMat * GetIonisation() const
size_t GetNumberOfElements() const
G4double GetRadius() const
void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
G4VPVParameterisation * GetParameterisation() const
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
G4double GetTanAlpha() const
G4ThreeVector GetSymAxis() const
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
static G4PhysicalVolumeStore * GetInstance()
G4double GetStartPhi() const
G4PolyconeHistorical * GetOriginalParameters() const
G4int GetNumRZCorner() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4int GetNumRZCorner() const
G4PolyhedraHistorical * GetOriginalParameters() const
G4PolyhedraSideRZ GetCorner(const G4int index) const
G4double GetStartPhi() const
G4VSolid * GetConstituentMovedSolid() const
G4bool IsReflected(G4LogicalVolume *lv) const
static G4ReflectionFactory * Instance()
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetDeltaThetaAngle() const
G4double GetStartThetaAngle() const
std::size_t first(char) const
G4double GetYHalfLength1() const
G4double GetTanAlpha2() const
G4double GetXHalfLength2() const
G4ThreeVector GetSymAxis() const
G4double GetXHalfLength4() const
G4double GetZHalfLength() const
G4double GetYHalfLength2() const
G4double GetTanAlpha1() const
G4double GetXHalfLength3() const
G4double GetXHalfLength1() const
G4double GetXHalfLength2() const
G4double GetYHalfLength2() const
G4double GetXHalfLength1() const
G4double GetYHalfLength1() const
G4double GetZHalfLength() const
G4double GetZHalfLength() const
G4double GetInnerRadius() const
G4double GetOuterRadius() const
G4double GetStartPhiAngle() const
G4double GetDeltaPhiAngle() const
G4double GetPhiTwist() const
G4double GetXHalfLength() const
G4double GetZHalfLength() const
G4double GetYHalfLength() const
G4double GetPolarAngleTheta() const
G4double GetAzimuthalAnglePhi() const
G4double GetTiltAngleAlpha() const
G4double GetZHalfLength() const
G4double GetX1HalfLength() const
G4double GetX2HalfLength() const
G4double GetX3HalfLength() const
G4double GetX4HalfLength() const
G4double GetY2HalfLength() const
G4double GetPhiTwist() const
G4double GetY1HalfLength() const
G4double GetX2HalfLength() const
G4double GetY2HalfLength() const
G4double GetY1HalfLength() const
G4double GetZHalfLength() const
G4double GetPhiTwist() const
G4double GetX1HalfLength() const
G4double GetOuterRadius() const
G4double GetZHalfLength() const
G4double GetPhiTwist() const
G4double GetInnerRadius() const
static G4String ConvertToString(G4bool boolVal)
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=nullptr)
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4LogicalVolume * GetMotherLogical() const
virtual G4bool IsReplicated() const =0
const G4RotationMatrix * GetRotation() const
const G4ThreeVector GetTranslation() const
G4LogicalVolume * GetLogicalVolume() const
virtual G4int GetCopyNo() const =0
const G4String & GetName() const
virtual G4bool IsParameterised() const =0
virtual G4GeometryType GetEntityType() const =0
static G4tgbGeometryDumper * GetInstance()
void DumpIsotope(G4Isotope *ele)
void DumpGeometry(const G4String &fname)
G4String DumpLogVol(G4LogicalVolume *lv, const G4String &extraName="", G4VSolid *solid=nullptr, G4Material *mate=nullptr)
void DumpPhysVol(G4VPhysicalVolume *pv)
G4String DumpRotationMatrix(G4RotationMatrix *rotm)
void DumpBooleanVolume(const G4String &solidType, G4VSolid *so)
G4String DumpMaterial(G4Material *mat)
void DumpPVReplica(G4PVReplica *pv, const G4String &lvName)
void DumpPVParameterised(G4PVParameterised *pv)
G4VPhysicalVolume * GetTopPhysVol()
G4String DumpSolid(G4VSolid *solid, const G4String &extraName="")
void DumpElement(G4Element *ele)
void DumpSolidParams(G4VSolid *so)
void DumpPVPlacement(G4VPhysicalVolume *pv, const G4String &lvName, G4int copyNo=-999)
std::vector< G4double > GetSolidParams(const G4VSolid *so)
static G4int GetVerboseLevel()
const char * name(G4int ptype)