129 if(place && parentLV)
135 G4bool bFirstCopy =
false;
137 if(logvol ==
nullptr)
140 if(theTgrVolume->
GetType() !=
"VOLDivision")
160 if(physvol !=
nullptr)
164 if(logvol ==
nullptr)
177 std::pair<G4mmapspl::iterator, G4mmapspl::iterator> children =
179 for(
auto cite = children.first; cite != children.second; ++cite)
190 G4cout <<
" G4tgbVolume::ConstructG4Volumes - construct daughter "
214 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid():" <<
G4endl
232 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid() - "
237 std::vector<G4double> solParam;
253 solid =
new G4Box(sname, solParam[0], solParam[1], solParam[2]);
255 else if(stype ==
"TUBE")
258 solid =
new G4Tubs(sname, solParam[0], solParam[1], solParam[2], 0. * deg,
261 else if(stype ==
"TUBS")
265 if(std::fabs(phiDelta - twopi) < angularTolerance)
269 solid =
new G4Tubs(sname, solParam[0], solParam[1], solParam[2],
270 solParam[3], phiDelta);
272 else if(stype ==
"TRAP")
274 if(solParam.size() == 11)
276 solid =
new G4Trap(sname, solParam[0], solParam[1], solParam[2],
277 solParam[3], solParam[4], solParam[5], solParam[6],
278 solParam[7], solParam[8], solParam[9], solParam[10]);
280 else if(solParam.size() == 4)
282 solid =
new G4Trap(sname, solParam[0], solParam[1] / deg,
283 solParam[2] / deg, solParam[3]);
287 G4String ErrMessage1 =
"Solid type " + stype;
288 G4String ErrMessage2 =
" should have 11 or 4 parameters,\n";
291 G4String ErrMessage = ErrMessage1 + ErrMessage2 + ErrMessage3 +
" !";
292 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
297 else if(stype ==
"TRD")
300 solid =
new G4Trd(sname, solParam[0], solParam[1], solParam[2], solParam[3],
303 else if(stype ==
"PARA")
306 solid =
new G4Para(sname, solParam[0], solParam[1], solParam[2],
307 solParam[3], solParam[4], solParam[5]);
309 else if(stype ==
"CONE")
312 solid =
new G4Cons(sname, solParam[0], solParam[1], solParam[2],
313 solParam[3], solParam[4], 0., 360. * deg);
315 else if(stype ==
"CONS")
319 if(std::fabs(phiDelta - twopi) < angularTolerance)
323 solid =
new G4Cons(sname, solParam[0], solParam[1], solParam[2],
324 solParam[3], solParam[4], solParam[5], phiDelta);
326 else if(stype ==
"SPHERE")
330 if(std::fabs(phiDelta - twopi) < angularTolerance)
335 if(std::fabs(thetaDelta - pi) < angularTolerance)
339 solid =
new G4Sphere(sname, solParam[0], solParam[1], solParam[2], phiDelta,
340 solParam[4], thetaDelta);
342 else if(stype ==
"ORB")
345 solid =
new G4Orb(sname, solParam[0]);
347 else if(stype ==
"TORUS")
351 if(std::fabs(phiDelta - twopi) < angularTolerance)
355 solid =
new G4Torus(sname, solParam[0], solParam[1], solParam[2],
356 solParam[3], phiDelta);
358 else if(stype ==
"POLYCONE")
360 std::size_t nplanes = std::size_t(solParam[2]);
361 G4bool genericPoly =
false;
362 if(solParam.size() == 3 + nplanes * 3)
366 else if(solParam.size() == 3 + nplanes * 2)
372 G4String Err1 =
"Solid type " + stype +
" should have ";
377 G4String Err4 =
" (RZ corners) parameters,\n";
380 G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 +
" !";
381 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
388 std::vector<G4double>* z_p =
new std::vector<G4double>;
389 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
390 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
391 for(std::size_t ii = 0; ii < nplanes; ++ii)
393 (*z_p).push_back(solParam[3 + 3 * ii]);
394 (*rmin_p).push_back(solParam[3 + 3 * ii + 1]);
395 (*rmax_p).push_back(solParam[3 + 3 * ii + 2]);
398 if(std::fabs(phiTotal - twopi) < angularTolerance)
402 solid =
new G4Polycone(sname, solParam[0], phiTotal,
404 &((*z_p)[0]), &((*rmin_p)[0]), &((*rmax_p)[0]));
408 std::vector<G4double>* R_c =
new std::vector<G4double>;
409 std::vector<G4double>* Z_c =
new std::vector<G4double>;
410 for(
size_t ii = 0; ii < nplanes; ii++)
412 (*R_c).push_back(solParam[3 + 2 * ii]);
413 (*Z_c).push_back(solParam[3 + 2 * ii + 1]);
416 if(std::fabs(phiTotal - twopi) < angularTolerance)
423 &((*R_c)[0]), &((*Z_c)[0]));
426 else if(stype ==
"POLYHEDRA")
428 std::size_t nplanes = std::size_t(solParam[3]);
429 G4bool genericPoly =
false;
430 if(solParam.size() == 4 + nplanes * 3)
434 else if(solParam.size() == 4 + nplanes * 2)
440 G4String Err1 =
"Solid type " + stype +
" should have ";
445 G4String Err4 =
" (RZ corners) parameters,\n";
448 G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 +
" !";
449 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
456 std::vector<G4double>* z_p =
new std::vector<G4double>;
457 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
458 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
459 for(std::size_t ii = 0; ii < nplanes; ++ii)
461 (*z_p).push_back(solParam[4 + 3 * ii]);
462 (*rmin_p).push_back(solParam[4 + 3 * ii + 1]);
463 (*rmax_p).push_back(solParam[4 + 3 * ii + 2]);
466 if(std::fabs(phiTotal - twopi) < angularTolerance)
471 nplanes, &((*z_p)[0]), &((*rmin_p)[0]),
476 std::vector<G4double>* R_c =
new std::vector<G4double>;
477 std::vector<G4double>* Z_c =
new std::vector<G4double>;
478 for(std::size_t ii = 0; ii < nplanes; ++ii)
480 (*R_c).push_back(solParam[4 + 2 * ii]);
481 (*Z_c).push_back(solParam[4 + 2 * ii + 1]);
484 if(std::fabs(phiTotal - twopi) < angularTolerance)
489 nplanes, &((*R_c)[0]), &((*Z_c)[0]));
492 else if(stype ==
"ELLIPTICALTUBE")
497 else if(stype ==
"ELLIPSOID")
500 solid =
new G4Ellipsoid(sname, solParam[0], solParam[1], solParam[2],
501 solParam[3], solParam[4]);
503 else if(stype ==
"ELLIPTICALCONE")
509 else if(stype ==
"HYPE")
512 solid =
new G4Hype(sname, solParam[0], solParam[1], solParam[2],
513 solParam[3], solParam[4]);
515 else if(stype ==
"TET")
522 solid =
new G4Tet(sname, anchor, p2, p3, p4);
524 else if(stype ==
"TWISTEDBOX")
527 solid =
new G4TwistedBox(sname, solParam[0], solParam[1], solParam[2],
530 else if(stype ==
"TWISTEDTRAP")
534 new G4TwistedTrap(sname, solParam[0], solParam[1], solParam[2],
535 solParam[3], solParam[4], solParam[5], solParam[6],
536 solParam[7], solParam[8], solParam[9], solParam[10]);
538 else if(stype ==
"TWISTEDTRD")
541 solid =
new G4TwistedTrd(sname, solParam[0], solParam[1], solParam[2],
542 solParam[3], solParam[4], solParam[5]);
544 else if(stype ==
"TWISTEDTUBS")
548 if(std::fabs(phiTotal - twopi) < angularTolerance)
552 solid =
new G4TwistedTubs(sname, solParam[0], solParam[1], solParam[2],
553 solParam[3], phiTotal);
555 else if(stype ==
"TESSELLATED")
563 for(
G4int ii = 0; ii < nFacets; ++ii)
566 if(
G4int(solParam.size()) < jj + nPoints * 3 + 2)
568 G4String Err1 =
"Too small number of parameters in tesselated solid, "
569 "it should be at least " +
572 G4String Err3 =
" number of parameters is " +
574 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
575 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
582 G4ThreeVector pt0(solParam[jj + 2], solParam[jj + 3], solParam[jj + 4]);
583 G4ThreeVector vt1(solParam[jj + 5], solParam[jj + 6], solParam[jj + 7]);
587 if(solParam[jj + 11] == 0)
591 else if(solParam[jj + 11] == 1)
597 G4String Err1 =
"Wrong number of vertex type in tesselated solid, it "
598 "should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
601 G4String Err3 =
" vertex type is " +
603 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
604 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
610 else if(nPoints == 4)
612 G4ThreeVector pt0(solParam[jj + 2], solParam[jj + 3], solParam[jj + 4]);
613 G4ThreeVector vt1(solParam[jj + 5], solParam[jj + 6], solParam[jj + 7]);
619 if(solParam[jj + 14] == 0)
623 else if(solParam[jj + 14] == 1)
629 G4String Err1 =
"Wrong number of vertex type in tesselated solid, it "
630 "should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
633 G4String Err3 =
" vertex type is " +
635 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
636 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
645 "Wrong number of points in tesselated solid, it should be 3 or 4";
648 G4String Err3 =
" number of points is " +
650 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
651 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
657 jj += nPoints * 3 + 2;
660 else if(stype ==
"EXTRUDED")
662 std::vector<G4TwoVector> polygonList;
663 std::vector<G4ExtrudedSolid::ZSection> zsectionList;
666 G4int nMax = nPolygons * 2 + 1;
667 for(; ii < nMax; ii += 2)
669 polygonList.push_back(
G4TwoVector(solParam[ii], solParam[ii + 1]));
672 nMax = nPolygons * 2 + nZSections * 4 + 2;
674 for(; ii < nMax; ii += 4)
676 G4TwoVector offset(solParam[ii + 1], solParam[ii + 2]);
677 zsectionList.push_back(
682 else if(stype.substr(0, 7) ==
"Boolean")
687 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
698 if(stype ==
"Boolean_UNION")
700 solid =
new G4UnionSolid(sname, sol1, sol2, relRotMat, relPlace);
702 else if(stype ==
"Boolean_SUBTRACTION")
706 else if(stype ==
"Boolean_INTERSECTION")
712 G4String ErrMessage =
"Unknown Boolean type " + stype;
713 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
721 "Solids of type " + stype +
" not implemented yet, sorry...";
722 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"NotImplemented",
730 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid()" <<
G4endl
731 <<
" Created solid " << sname <<
" of type "
739 G4cout <<
" Constructing new G4Solid: " << *solid <<
G4endl;
748 const unsigned int NoParamExpected,
749 const unsigned int NoParam)
751 if(NoParamExpected != NoParam)
753 G4String Err1 =
"Solid type " + solidType +
" should have ";
758 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
759 G4Exception(
"G4tgbVolume::CheckNoSolidParams()",
"InvalidSetup",
781 G4String ErrMessage =
"Material not found " +
784 G4Exception(
"G4tgbVolume::ConstructG4LogVol()",
"InvalidSetup",
790 G4cout <<
" G4tgbVolume::ConstructG4LogVol() -"
802 G4cout <<
" Constructing new G4LogicalVolume: " << logvol->
GetName()
814 G4cout <<
" Constructing new G4VisAttributes: " << *visAtt <<
G4endl;
844 G4cout <<
" G4tgbVolume::ConstructG4LogVol() -"
867 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() - World: " <<
GetName()
877 G4cout <<
" Constructing new : G4PVPlacement " << physvol->
GetName()
890 <<
" inside " << parentLV->
GetName() <<
" copy No: " << copyNo
896 if(theTgrVolume->
GetType() ==
"VOLSimple")
902 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() - Placement type = "
908 if(place->
GetType() ==
"PlaceSimple")
921 if(1 - std::abs(check) > tol)
923 G4cerr <<
" Matrix : " << rmName <<
" " << rotmat->
colX() <<
" "
925 <<
" product x X y * z = " << check <<
" x X y "
927 G4String ErrMessage =
"Rotation is not ortogonal " + rmName +
" !";
928 G4Exception(
"G4tgbVolume::ConstructG4PhysVol()",
"InvalidSetup",
932 else if(1 + check <= tol)
947 G4cout <<
"Construction new G4VPhysicalVolume"
948 <<
" through G4ReflectionFactory " <<
GetName()
949 <<
" in volume " << parentLV->
GetName() <<
" copyNo "
950 << copyNo <<
" position " << place->
GetPlacement() <<
" ROT "
951 << rotmat->
colX() <<
" " << rotmat->
colY() <<
" "
964 else if(place->
GetType() ==
"PlaceParam")
972 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1003 G4String ErrMessage =
"Parameterisation has wrong type, TYPE: " +
1005 G4Exception(
"G4tgbVolume::ConstructG4PhysVol",
"WrongArgument",
1012 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1013 <<
" New G4PVParameterised: " <<
GetName() <<
" vol "
1015 <<
" axis " << param->
GetAxis() <<
" nCopies "
1026 G4cout <<
" Constructing new G4PVParameterised: "
1028 <<
" N copies " << param->
GetNCopies() <<
" axis "
1033 else if(place->
GetType() ==
"PlaceReplica")
1041 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1055 G4cout <<
" Constructing new G4PVReplica: " << currentLV->
GetName()
1057 <<
" Width " << dpr->
GetWidth() <<
" offset "
1063 else if(theTgrVolume->
GetType() ==
"VOLDivision")
1076 G4cout <<
" Constructed new G4LogicalVolume for division: "
1092 G4cout <<
" Constructing new G4PVDivision by number of divisions: "
1107 G4cout <<
" Constructing new G4PVDivision by width: " <<
GetName()
1108 <<
" in " << parentLV->
GetName() <<
" axis "
1122 G4cout <<
" Constructing new G4PVDivision by width"
1123 <<
" and number of divisions: " <<
GetName() <<
" in "
1125 <<
" Ndiv " << placeDiv->
GetNDiv() <<
" width "
1126 << placeDiv->
GetWidth() <<
" offset "
1133 else if(theTgrVolume->
GetType() ==
"VOLAssembly")
1138 if(!theG4AssemblyVolume)
1144 G4cout <<
" Constructing new G4AssemblyVolume: "
1145 <<
" number of assembly components "
1163 if(logvol ==
nullptr)
1173 G4cout <<
" G4AssemblyVolume->AddPlacedVolume " << ii <<
" "
1174 << logvol->
GetName() <<
" translation " << transl
1175 <<
" rotmat " << rotmat->
colX() <<
" " << rotmat->
colY()
1192 theG4AssemblyVolume->
MakeImprint(parentLV_nonconst, transl, rotmat);
1197 "Volume type not supported: " + theTgrVolume->
GetType() +
", sorry...";
1198 G4Exception(
"G4tgbVolume::ConstructG4PhysVol()",
"NotImplemented",
1250 std::fabs(mpDx1 - mpDx2) >
1281 origParam.
Rmin[ii] = origParam.
Rmin[ii] * redf;
1282 origParam.
Rmax[ii] = origParam.
Rmax[ii] * redf;
1288 else if(parentSolid->
GetEntityType() ==
"G4GenericPolycone")
1294 for(
G4int ii = 0; ii < numRZ; ++ii)
1311 origParam.
Rmin[ii] = origParam.
Rmin[ii] * redf;
1312 origParam.
Rmax[ii] = origParam.
Rmax[ii] * redf;
1321 G4String ErrMessage =
"Solid type not supported. VOLUME= " +
GetName() +
1324 "Only supported types are: G4Box, G4Tubs, G4Cons," +
1325 " G4Trd, G4Para, G4Polycone, G4Polyhedra.";
1326 G4Exception(
"G4tgbVolume::BuildSolidForDivision()",
"NotImplemented",
1334 G4cout <<
" Constructing new G4Solid for division: " << *solid <<
G4endl;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
CLHEP::Hep2Vector G4TwoVector
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
Hep3Vector cross(const Hep3Vector &) const
void MakeImprint(G4LogicalVolume *pMotherLV, G4ThreeVector &translationInMother, G4RotationMatrix *pRotationInMother, G4int copyNumBase=0, G4bool surfCheck=false)
void AddPlacedVolume(G4LogicalVolume *pPlacedVolume, G4ThreeVector &translation, G4RotationMatrix *rotation)
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
G4double GetStartPhi() const
G4double GetEndPhi() const
G4int GetNumRZCorner() const
G4PolyconeSideRZ GetCorner(G4int index) const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4double GetAngularTolerance() const
G4VSolid * GetSolid() const
void SetVisAttributes(const G4VisAttributes *pVA)
const G4String & GetName() const
const G4String & GetName() const
G4double GetTanAlpha() const
G4ThreeVector GetSymAxis() const
G4double GetYHalfLength() const
G4double GetZHalfLength() const
G4double GetXHalfLength() const
G4double GetEndPhi() const
G4double GetStartPhi() const
G4PolyconeHistorical * GetOriginalParameters() const
G4double GetEndPhi() const
G4PolyhedraHistorical * GetOriginalParameters() const
G4double GetStartPhi() const
static G4ReflectionFactory * Instance()
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
G4bool AddFacet(G4VFacet *aFacet)
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
static G4String ConvertToString(G4bool boolVal)
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
virtual G4VisExtent GetExtent() const
virtual G4GeometryType GetEntityType() const =0
void SetColour(const G4Colour &)
void SetVisibility(G4bool=true)
G4Material * FindOrBuildG4Material(const G4String &name, G4bool bMustExist=true)
static G4tgbMaterialMgr * GetInstance()
static G4tgbRotationMatrixMgr * GetInstance()
G4RotationMatrix * FindOrBuildG4RotMatrix(const G4String &name)
G4LogicalVolume * FindG4LogVol(const G4String &theName, const G4bool bExists=false)
G4tgbVolume * FindVolume(const G4String &volname)
G4VSolid * FindG4Solid(const G4String &name)
void RegisterMe(const G4tgbVolume *vol)
static G4tgbVolumeMgr * GetInstance()
void RegisterChildParentLVs(const G4LogicalVolume *logvol, const G4LogicalVolume *parentLV)
G4VPhysicalVolume * ConstructG4PhysVol(const G4tgrPlace *place, const G4LogicalVolume *currentLV, const G4LogicalVolume *parentLV)
const G4String & GetName() const
G4VSolid * FindOrConstructG4Solid(const G4tgrSolid *vol)
void CheckNoSolidParams(const G4String &solidType, const unsigned int NoParamExpected, const unsigned int NoParam)
G4VSolid * BuildSolidForDivision(G4VSolid *parentSolid, EAxis axis)
G4LogicalVolume * ConstructG4LogVol(const G4VSolid *solid)
const G4double * GetColour() const
void ConstructG4Volumes(const G4tgrPlace *place, const G4LogicalVolume *parentLV)
G4bool GetVisibility() const
static G4int GetVerboseLevel()
G4double GetOffset() const
G4double GetWidth() const
G4DivType GetDivType() const
const G4String & GetParamType() const
const G4String & GetRotMatName() const
virtual G4ThreeVector GetPlacement() const
const G4String & GetType() const
unsigned int GetCopyNo() const
G4tgrVolume * GetVolume() const
const G4tgrSolid * GetSolid(G4int ii) const
G4ThreeVector GetRelativePlace() const
const G4String & GetType() const
const G4String & GetName() const
virtual const G4String & GetRelativeRotMatName() const
const std::vector< std::vector< G4double > * > GetSolidParams() const
G4ThreeVector GetComponentPos(G4int ii) const
const G4String & GetComponentRM(G4int ii) const
G4int GetNoComponents() const
const G4String & GetComponentName(G4int ii) const
G4tgrPlaceDivRep * GetPlaceDivision()
static G4tgrVolumeMgr * GetInstance()
std::pair< G4mmapspl::iterator, G4mmapspl::iterator > GetChildren(const G4String &name)
G4bool GetCheckOverlaps() const
const G4String & GetName() const
G4tgrSolid * GetSolid() const
const G4String & GetType() const
const G4String & GetMaterialName() const