84 G4tgbGeometryDumper::G4tgbGeometryDumper()
85 : theFile(0), theRotationNumber(0)
92 if( theInstance == 0 ){
103 theFile =
new std::ofstream(fname);
113 G4PhysicalVolumeStore::const_iterator ite;
118 if( lv == 0 ) {
break; }
121 for( ite = pvstore->begin(); ite != pvstore->end(); ite++ )
157 G4bool bVolExists = CheckIfLogVolExists( lv->
GetName(), lv );
196 std::vector<G4VPhysicalVolume*> pvChildren = GetPVChildren( lv );
197 std::vector<G4VPhysicalVolume*>::const_iterator ite;
198 for( ite = pvChildren.begin(); ite != pvChildren.end(); ite++ )
223 G4cout <<
" G4tgbGeometryDumper::DumpPVPlacement() - Reflected volume: "
234 colx.
y(),coly.
y(),colz.
y(),
235 colx.
z(),coly.
z(),colz.
z());
238 *rotMat = (*rotMat).inverse();
253 if( !CheckIfPhysVolExists(fullname, pv ))
257 << SubstituteRefl(AddQuotes(lvName))
258 <<
" " << copyNo <<
" "
260 <<
" " << AddQuotes(rotName) <<
" "
261 << pos.
x() <<
" " << pos.
y() <<
" " << pos.
z() <<
G4endl;
263 thePhysVols[fullname] = pv;
286 std::vector<G4double> newParams;
290 for(
G4int ii = 0; ii < nReplicas; ii++ )
377 if( ii == 0 || mate1st != newMate || params1st[0] != newParams[0] )
385 lvName =
DumpLogVol( lv, extraName, newSolid, newMate );
424 G4String ErrMessage =
"Unknown axis of replication for volume"
434 if( !CheckIfPhysVolExists(fullname, pv ))
438 << SubstituteRefl(AddQuotes(lvName))
446 <<
" " << offset <<
G4endl;
451 <<
" " << width/
deg <<
"*deg"
452 <<
" " << offset/
deg <<
"*deg" <<
G4endl;
455 thePhysVols[fullname] = pv;
467 if( extraName ==
"" )
469 lvName = GetObjectName(lv,theLogVols);
473 lvName = lv->
GetName()+extraName;
476 if( theLogVols.find( lvName ) != theLogVols.end() )
481 if( !solid ) { solid = lv->
GetSolid(); }
491 (*theFile) <<
":VOLU " << SubstituteRefl(AddQuotes(lvName)) <<
" "
492 << SupressRefl(AddQuotes(solidName))
493 <<
" " << AddQuotes(mateName) <<
G4endl;
495 theLogVols[lvName] = lv;
504 G4String mateName = GetObjectName(mat,theMaterials);
505 if( theMaterials.find( mateName ) != theMaterials.end() )
516 if (numElements == 1)
518 (*theFile) <<
":MATE " << AddQuotes(mateName) <<
" "
526 for (
size_t ii = 0; ii < numElements; ii++)
531 (*theFile) <<
":MIXT "<< AddQuotes(mateName) <<
" "
532 << density <<
" " << numElements <<
G4endl;
534 for (
size_t ii = 0; ii < numElements; ii++)
537 << AddQuotes(GetObjectName((*elems)[ii],theElements)) <<
" "
538 << fractions[ii] <<
G4endl;
543 (*theFile) <<
":MATE_MEE " << AddQuotes(mateName) <<
" "
547 (*theFile) <<
":MATE_TEMPERATURE " << AddQuotes(mateName) <<
" "
550 (*theFile) <<
":MATE_PRESSURE " << AddQuotes(mateName) <<
" "
557 stateStr =
"Undefined";
570 (*theFile) <<
":MATE_STATE " << AddQuotes(mateName) <<
" "
573 theMaterials[mateName] = mat;
582 G4String elemName = GetObjectName(ele,theElements);
584 if( theElements.find( elemName ) != theElements.end() )
593 if( symbol ==
"" || symbol ==
" " )
600 (*theFile) <<
":ELEM " << AddQuotes(elemName) <<
" "
601 << AddQuotes(symbol) <<
" " << ele->
GetZ() <<
" "
612 (*theFile) <<
":ELEM_FROM_ISOT " << AddQuotes(elemName) <<
" "
619 << AddQuotes(GetObjectName((*isots)[ii],theIsotopes)) <<
" "
620 << fractions[ii] <<
G4endl;
623 theElements[elemName] =
ele;
630 G4String isotName = GetObjectName(isot,theIsotopes);
631 if( theIsotopes.find( isotName ) != theIsotopes.end() )
636 (*theFile) <<
":ISOT " << AddQuotes(isotName) <<
" "
637 << isot->
GetZ() <<
" " << isot->
GetN() <<
" "
640 theIsotopes[isotName] = isot;
649 if( extraName ==
"" )
651 solidName = GetObjectName(solid,theSolids);
655 solidName = solid->
GetName()+extraName;
658 if( theSolids.find( solidName ) != theSolids.end() )
664 solidType = GetTGSolidType( solidType );
666 if (solidType ==
"UNIONSOLID")
670 }
else if (solidType ==
"SUBTRACTIONSOLID") {
673 }
else if (solidType ==
"INTERSECTIONSOLID") {
676 }
else if (solidType ==
"REFLECTEDSOLID") {
689 (*theFile) <<
":SOLID " << AddQuotes(solidName) <<
" ";
690 (*theFile) << AddQuotes(solidType) <<
" ";
692 theSolids[solidName] = solid;
704 if (!bso) {
return; }
723 GetTransform().NetRotation()).inverse() ) );
731 G4String bsoName = GetObjectName(so,theSolids);
732 if( theSolids.find( bsoName ) != theSolids.end() )
return;
733 G4String solid0Name = FindSolidName( solid0 );
734 G4String solid1Name = FindSolidName( solid1 );
736 (*theFile) <<
":SOLID "
737 << AddQuotes(bsoName) <<
" "
738 << AddQuotes(solidType) <<
" "
739 << AddQuotes(solid0Name) <<
" "
740 << AddQuotes(solid1Name) <<
" "
741 << AddQuotes(rotName) <<
" "
742 << approxTo0(pos.
x()) <<
" "
743 << approxTo0(pos.
y()) <<
" "
744 << approxTo0(pos.
z()) <<
" " <<
G4endl;
746 theSolids[bsoName] = bso;
754 for(
size_t ii = 0 ; ii < params.size(); ii++ )
756 (*theFile) << params[ii] <<
" " ;
765 std::vector<G4double> params;
768 solidType = GetTGSolidType( solidType );
770 if (solidType ==
"BOX") {
771 const G4Box * sb = dynamic_cast <
const G4Box*>(so);
777 }
else if (solidType ==
"TUBS") {
778 const G4Tubs * tu = dynamic_cast <
const G4Tubs * > (so);
786 }
else if (solidType ==
"TRAP") {
787 const G4Trap * trp = dynamic_cast <
const G4Trap * > (so);
791 params.push_back( symAxis.theta()/
deg);
792 params.push_back( symAxis.phi()/
deg);
802 }
else if (solidType ==
"TRD") {
803 const G4Trd * tr = dynamic_cast <
const G4Trd * > (so);
811 }
else if (solidType ==
"PARA") {
812 const G4Para * para = dynamic_cast <
const G4Para * > (so);
819 params.push_back( symAxis.theta()/
deg);
820 params.push_back( symAxis.phi()/
deg);
822 }
else if (solidType ==
"CONS") {
823 const G4Cons * cn = dynamic_cast <
const G4Cons * > (so);
833 }
else if (solidType ==
"SPHERE") {
843 }
else if (solidType ==
"ORB") {
844 const G4Orb * orb = dynamic_cast <
const G4Orb * > (so);
848 }
else if (solidType ==
"TORUS") {
851 params.push_back( torus->
GetRmin());
852 params.push_back( torus->
GetRmax());
853 params.push_back( torus->
GetRtor());
857 }
else if (solidType ==
"POLYCONE") {
863 if( angphi > 180*
deg ) { angphi -= 360*
deg; }
865 params.push_back( angphi );
867 params.push_back( ncor );
869 for(
G4int ii = 0; ii < ncor; ii++ )
875 }
else if (solidType ==
"GENERICPOLYCONE") {
881 if( angphi > 180*
deg ) { angphi -= 360*
deg; }
883 if( endphi > 180*
deg ) { endphi -= 360*
deg; }
885 params.push_back( angphi );
886 params.push_back( endphi-angphi );
887 params.push_back( ncor );
889 for(
G4int ii = 0; ii < ncor; ii++ )
895 }
else if (solidType ==
"POLYHEDRA") {
901 if( angphi > 180*
deg ) angphi -= 360*
deg;
905 params.push_back( angphi );
908 params.push_back( ncor );
910 for(
G4int ii = 0; ii < ncor; ii++ )
916 }
else if (solidType ==
"ELLIPTICALTUBE") {
920 params.push_back( eltu->
GetDx());
921 params.push_back( eltu->
GetDy());
922 params.push_back( eltu->
GetDz());
924 }
else if (solidType ==
"ELLIPSOID" ){
933 }
else if (solidType ==
"ELLIPTICAL_CONE") {
937 params.push_back( elco-> GetSemiAxisX() );
938 params.push_back( elco-> GetSemiAxisY() );
939 params.push_back( elco-> GetZMax() );
940 params.push_back( elco-> GetZTopCut() );
942 }
else if (solidType ==
"HYPE") {
943 const G4Hype* hype = dynamic_cast <
const G4Hype * > (so);
953 }
else if( solidType ==
"TWISTEDBOX" ) {
961 }
else if( solidType ==
"TWISTEDTRAP" ) {
976 }
else if( solidType ==
"TWISTEDTRD" ) {
986 }
else if( solidType ==
"TWISTEDTUBS" ) {
998 G4String ErrMessage =
"Solid type not supported, sorry... " + solidType;
999 G4Exception(
"G4tgbGeometryDumpe::DumpSolidParams()",
1012 G4double de = MatDeterminant(rotm);
1013 G4String rotName = LookForExistingRotation( rotm );
1014 if( rotName !=
"" ) {
return rotName; }
1019 (*theFile) <<
":ROTM ";
1023 (*theFile) << AddQuotes(rotName) << std::setprecision(9) <<
" "
1024 << approxTo0(rotm->
xx()) <<
" "
1025 << approxTo0(rotm->
yx()) <<
" "
1026 << approxTo0(rotm->
zx()) <<
" "
1027 << approxTo0(rotm->
xy()) <<
" "
1028 << approxTo0(rotm->
yy()) <<
" "
1029 << approxTo0(rotm->
zy()) <<
" "
1030 << approxTo0(rotm->
xz()) <<
" "
1031 << approxTo0(rotm->
yz()) <<
" "
1032 << approxTo0(rotm->
zz()) <<
G4endl;
1036 (*theFile) <<
":ROTM ";
1040 (*theFile) << AddQuotes(rotName) <<
" "
1042 << approxTo0(rotm->
phiX()/
deg) <<
" "
1044 << approxTo0(rotm->
phiY()/
deg) <<
" "
1049 theRotMats[rotName] = rotm;
1056 std::vector<G4VPhysicalVolume*>
1060 G4PhysicalVolumeStore::const_iterator ite;
1061 std::vector<G4VPhysicalVolume*> children;
1062 for( ite = pvstore->begin(); ite != pvstore->end(); ite++ )
1064 if( (*ite)->GetMotherLogical() == lv )
1066 children.push_back( *ite );
1070 G4cout <<
" G4tgbGeometryDumper::GetPVChildren() - adding children: "
1084 G4String newsolidType = solidType.substr(2,solidType.length() );
1085 for(
size_t ii = 0; ii < newsolidType.length(); ii++ )
1087 newsolidType[ii] = toupper(newsolidType[ii] );
1089 return newsolidType;
1109 if( std::fabs(val) < precision ) { val = 0; }
1120 size_t siz = str.length();
1121 for(
size_t ii = 0; ii < siz; ii++ )
1123 if( str.substr(ii,1) ==
" " )
1141 G4int irefl = name.rfind(
"_refl");
1144 name = name.substr( 0, irefl );
1152 G4int irefl = name.rfind(
"_refl");
1155 name = name.substr( 0, irefl ) +
"_REFL";
1168 std::map<G4String,G4Isotope*>::const_iterator ite;
1169 for( ite = theIsotopes.begin(); ite != theIsotopes.end(); ite++ )
1171 if( isot == (*ite).second ) {
return (*ite).
first; }
1177 ite = theIsotopes.find( isotName );
1178 if( ite != theIsotopes.end() )
1181 if( isot != isotold )
1183 if( !Same2G4Isotopes(isot, isotold))
1189 G4String newIsotName = isotName +
"_"
1191 std::map<G4String,G4Isotope*>::const_iterator ite2 =
1192 theIsotopes.find( newIsotName );
1193 if( ite2 == theIsotopes.end() )
1195 isotName = newIsotName;
1200 if( Same2G4Isotopes( isot, (*ite2).second ) )
1202 isotName = newIsotName;
1215 template<
class TYP >
G4String G4tgbGeometryDumper::
1216 GetObjectName( TYP* obj, std::map<G4String,TYP*> objectsDumped )
1223 typename std::map<G4String,TYP*>::const_iterator ite;
1224 for( ite = objectsDumped.begin(); ite != objectsDumped.end(); ite++ )
1226 if( obj == (*ite).second ) {
return (*ite).
first; }
1232 ite = objectsDumped.find( objName );
1234 if( ite != objectsDumped.end() )
1236 TYP* objold = (*ite).second;
1243 typename std::map<G4String,TYP*>::const_iterator ite2 =
1244 objectsDumped.find( newObjName );
1245 if( ite2 == objectsDumped.end() )
1247 objName = newObjName;
1258 G4bool G4tgbGeometryDumper::CheckIfLogVolExists(
const G4String& name,
1261 if( theLogVols.find( name ) != theLogVols.end() )
1288 G4bool G4tgbGeometryDumper::CheckIfPhysVolExists(
const G4String& name,
1294 G4cout <<
" G4tgbGeometryDumper::CheckIfPhysVolExists() - "
1298 if( thePhysVols.find( name ) != thePhysVols.end() )
1300 if( (*(thePhysVols.find(name))).second != pt )
1306 G4cerr <<
" G4tgbGeometryDumper::CheckIfPhysVolExists () -"
1307 <<
" Placement found but not same as before : " << name <<
G4endl;
1320 G4tgbGeometryDumper::LookForExistingRotation(
const G4RotationMatrix* rotm )
1324 std::map<G4String,G4RotationMatrix*>::const_iterator ite;
1325 for( ite = theRotMats.begin(); ite != theRotMats.end(); ite++ )
1327 if( (*ite).second->isNear( *rotm ) )
1329 rmName = (*ite).
first;
1341 if ( (isot1->
GetZ() != isot2->
GetZ())
1342 || (isot1->
GetN() != isot2->
GetN())
1343 || (isot1->
GetA() != isot2->
GetA()) )
1357 std::map<G4String,G4VSolid*>::const_iterator ite;
1358 for( ite = theSolids.begin(); ite != theSolids.end(); ite++ )
1360 if( solid == (*ite).second ) {
return (*ite).
first; }
1363 if( ite == theSolids.end() )
1365 G4Exception(
"G4tgbGeometryDumper::FindSolidName()",
"ReadError",
1368 return (*ite).first;
G4ThreeVector GetSymAxis() const
G4double GetPressure() const
size_t GetNumberOfIsotopes() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4double GetXHalfLength4() const
G4IonisParamMat * GetIonisation() const
G4double GetXHalfLength() const
G4double GetOuterStereo() const
G4double GetX1HalfLength() const
virtual G4Material * ComputeMaterial(const G4int repNo, G4VPhysicalVolume *currentVol, const G4VTouchable *parentTouch=0)
std::vector< G4Isotope * > G4IsotopeVector
G4double GetY1HalfLength() const
G4double GetPolarAngleTheta() const
G4Material * GetMaterial() const
const G4String & GetName() const
G4double GetYHalfLength2() const
std::vector< G4Element * > G4ElementVector
G4double GetYHalfLength1() const
G4double GetInnerStereo() const
CLHEP::Hep3Vector G4ThreeVector
G4double GetInnerRadius() const
CLHEP::HepRotation G4RotationMatrix
virtual void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
void DumpIsotope(G4Isotope *ele)
virtual G4bool IsReplicated() const =0
G4String DumpMaterial(G4Material *mat)
const G4String & GetSymbol() const
G4int GetNumRZCorner() const
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
void DumpSolidParams(G4VSolid *so)
G4double GetZTopCut() const
G4double GetZHalfLength() const
G4double GetSurfaceTolerance() const
G4double GetZHalfLength() const
G4double GetDensity() const
G4VSolid * GetSolid() const
static G4String ConvertToString(G4bool boolVal)
G4double GetZBottomCut() const
G4double GetOuterRadiusMinusZ() const
const G4RotationMatrix * GetRotation() const
G4double GetX2HalfLength() const
G4double GetInnerRadius() const
virtual G4GeometryType GetEntityType() const =0
G4double GetZHalfLength() const
G4double GetDeltaPhiAngle() const
const G4ElementVector * GetElementVector() const
G4double GetZHalfLength() const
G4double GetSemiAxisMax(G4int i) const
G4bool IsReflected(G4LogicalVolume *lv) const
G4ThreeVector GetObjectTranslation() const
G4double GetXHalfLength2() const
static G4ReflectionFactory * Instance()
G4double GetZHalfLength() const
G4double GetZHalfLength() const
void DumpPVReplica(G4PVReplica *pv, const G4String &lvName)
G4double GetEndPhi() const
G4double GetTanAlpha2() const
G4int GetNumRZCorner() const
void DumpPhysVol(G4VPhysicalVolume *pv)
G4double GetPhiTwist() const
static G4PhysicalVolumeStore * GetInstance()
G4double GetY1HalfLength() const
G4double GetXHalfLength2() const
G4double GetRadius() const
void DumpGeometry(const G4String &fname)
G4VPVParameterisation * GetParameterisation() const
G4double GetXHalfLength1() const
G4GLOB_DLL std::ostream G4cout
G4double GetDeltaPhiAngle() const
G4double GetStartThetaAngle() const
const G4String & GetName() const
G4double GetXHalfLength3() const
static G4int GetVerboseLevel()
G4double GetY2HalfLength() const
G4double GetX3HalfLength() const
G4double GetPhiTwist() const
G4double * GetRelativeAbundanceVector() const
static constexpr double eV
G4double GetYHalfLength() const
G4double GetStartPhiAngle() const
G4double GetYHalfLength2() const
G4double GetOuterRadius() const
G4double GetStartPhiAngle() const
G4double GetStartPhi() const
G4double GetInnerRadiusPlusZ() const
G4LogicalVolume * GetMotherLogical() const
G4double GetInnerRadius() const
G4PolyconeHistorical * GetOriginalParameters() const
G4double GetStartPhi() const
static constexpr double kelvin
static constexpr double cm3
G4VSolid * GetConstituentMovedSolid() const
G4double GetXHalfLength() const
G4double GetInnerRadius() const
virtual const G4VSolid * GetConstituentSolid(G4int no) const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual G4bool IsParameterised() const =0
const G4ThreeVector & GetTranslation() const
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4double GetX4HalfLength() const
void DumpPVPlacement(G4VPhysicalVolume *pv, const G4String &lvName, G4int copyNo=-999)
G4double GetYHalfLength() const
G4IsotopeVector * GetIsotopeVector() const
G4String DumpRotationMatrix(G4RotationMatrix *rotm)
G4double GetZHalfLength() const
G4LogicalVolume * GetLogicalVolume() const
G4double GetTanAlpha() const
void DumpBooleanVolume(const G4String &solidType, G4VSolid *so)
static G4tgbGeometryDumper * GetInstance()
void GetReplicationData(EAxis &axis, G4int &nReplicas, G4double &width, G4double &offset, G4bool &consuming) const
G4VSolid * GetConstituentMovedSolid() const
std::vector< G4double > GetSolidParams(const G4VSolid *so)
void DumpPVParameterised(G4PVParameterised *pv)
G4VPhysicalVolume * GetTopPhysVol()
virtual void ComputeTransformation(const G4int, G4VPhysicalVolume *) const =0
virtual G4int GetCopyNo() const =0
static const G4double ele
G4PolyhedraHistorical * GetOriginalParameters() const
G4double GetZHalfLength() const
G4double GetZHalfLength() const
G4ThreeVector GetSymAxis() const
G4double GetZHalfLength() const
G4double GetMeanExcitationEnergy() const
G4double GetAzimuthalAnglePhi() const
G4double GetTemperature() const
G4double GetStartPhi() const
G4double GetXHalfLength1() const
size_t GetNumberOfElements() const
G4double GetOuterRadius() const
G4double GetStartPhiAngle() const
G4PolyhedraSideRZ GetCorner(const G4int index) const
G4double GetYHalfLength1() const
G4String DumpSolid(G4VSolid *solid, const G4String &extraName="")
const G4String & GetName() const
G4double GetPhiTwist() const
G4double GetInnerRadiusMinusZ() const
static constexpr double deg
G4double GetTanAlpha1() const
const G4double * GetFractionVector() const
G4int GetNumRZCorner() const
G4double GetDeltaThetaAngle() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4double GetX1HalfLength() const
static constexpr double atmosphere
G4double GetTiltAngleAlpha() const
G4double GetX2HalfLength() const
static constexpr double mole
G4double GetOuterRadiusPlusZ() const
G4double GetZHalfLength() const
G4double GetOuterRadius() const
G4double GetXHalfLength() const
static const G4double pos
static G4GeometryTolerance * GetInstance()
G4double GetPhiTwist() const
G4double GetOuterRadius() const
G4GLOB_DLL std::ostream G4cerr
G4String DumpLogVol(G4LogicalVolume *lv, G4String extraName="", G4VSolid *solid=0, G4Material *mate=0)
G4double GetY2HalfLength() const
void DumpElement(G4Element *ele)
G4double GetDeltaPhiAngle() const
G4double GetYHalfLength() const