133 if(place && parentLV)
139 G4bool bFirstCopy =
false;
141 if(logvol ==
nullptr)
144 if(theTgrVolume->
GetType() !=
"VOLDivision")
164 if(physvol !=
nullptr)
168 if(logvol ==
nullptr)
181 std::pair<G4mmapspl::iterator, G4mmapspl::iterator> children =
183 for(
auto cite = children.first; cite != children.second; ++cite)
194 G4cout <<
" G4tgbVolume::ConstructG4Volumes - construct daughter "
218 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid():" <<
G4endl
236 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid() - "
241 std::vector<G4double> solParam;
257 solid =
new G4Box(sname, solParam[0], solParam[1], solParam[2]);
259 else if(stype ==
"TUBE")
262 solid =
new G4Tubs(sname, solParam[0], solParam[1], solParam[2], 0. * deg,
265 else if(stype ==
"TUBS")
269 if(std::fabs(phiDelta - twopi) < angularTolerance)
273 solid =
new G4Tubs(sname, solParam[0], solParam[1], solParam[2],
274 solParam[3], phiDelta);
276 else if(stype ==
"TRAP")
278 if(solParam.size() == 11)
280 solid =
new G4Trap(sname, solParam[0], solParam[1], solParam[2],
281 solParam[3], solParam[4], solParam[5], solParam[6],
282 solParam[7], solParam[8], solParam[9], solParam[10]);
284 else if(solParam.size() == 4)
286 solid =
new G4Trap(sname, solParam[0], solParam[1] / deg,
287 solParam[2] / deg, solParam[3]);
291 G4String ErrMessage1 =
"Solid type " + stype;
292 G4String ErrMessage2 =
" should have 11 or 4 parameters,\n";
295 G4String ErrMessage = ErrMessage1 + ErrMessage2 + ErrMessage3 +
" !";
296 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
301 else if(stype ==
"TRD")
304 solid =
new G4Trd(sname, solParam[0], solParam[1], solParam[2], solParam[3],
307 else if(stype ==
"PARA")
310 solid =
new G4Para(sname, solParam[0], solParam[1], solParam[2],
311 solParam[3], solParam[4], solParam[5]);
313 else if(stype ==
"CONE")
316 solid =
new G4Cons(sname, solParam[0], solParam[1], solParam[2],
317 solParam[3], solParam[4], 0., 360. * deg);
319 else if(stype ==
"CONS")
323 if(std::fabs(phiDelta - twopi) < angularTolerance)
327 solid =
new G4Cons(sname, solParam[0], solParam[1], solParam[2],
328 solParam[3], solParam[4], solParam[5], phiDelta);
330 else if(stype ==
"SPHERE")
334 if(std::fabs(phiDelta - twopi) < angularTolerance)
339 if(std::fabs(thetaDelta - pi) < angularTolerance)
343 solid =
new G4Sphere(sname, solParam[0], solParam[1], solParam[2], phiDelta,
344 solParam[4], thetaDelta);
346 else if(stype ==
"ORB")
349 solid =
new G4Orb(sname, solParam[0]);
351 else if(stype ==
"TORUS")
355 if(std::fabs(phiDelta - twopi) < angularTolerance)
359 solid =
new G4Torus(sname, solParam[0], solParam[1], solParam[2],
360 solParam[3], phiDelta);
362 else if(stype ==
"POLYCONE"
363 || stype ==
"GENERICPOLYCONE")
365 std::size_t nplanes = std::size_t(solParam[2]);
366 G4bool genericPoly =
false;
367 if(solParam.size() == 3 + nplanes * 3)
371 else if(solParam.size() == 3 + nplanes * 2)
377 G4String Err1 =
"Solid type " + stype +
" should have ";
382 G4String Err4 =
" (RZ corners) parameters,\n";
385 G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 +
" !";
386 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
393 std::vector<G4double>* z_p =
new std::vector<G4double>;
394 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
395 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
396 for(std::size_t ii = 0; ii < nplanes; ++ii)
398 (*z_p).push_back(solParam[3 + 3 * ii]);
399 (*rmin_p).push_back(solParam[3 + 3 * ii + 1]);
400 (*rmax_p).push_back(solParam[3 + 3 * ii + 2]);
403 if(std::fabs(phiTotal - twopi) < angularTolerance)
407 solid =
new G4Polycone(sname, solParam[0], phiTotal,
409 &((*z_p)[0]), &((*rmin_p)[0]), &((*rmax_p)[0]));
413 std::vector<G4double>* R_c =
new std::vector<G4double>;
414 std::vector<G4double>* Z_c =
new std::vector<G4double>;
415 for(
size_t ii = 0; ii < nplanes; ii++)
417 (*R_c).push_back(solParam[3 + 2 * ii]);
418 (*Z_c).push_back(solParam[3 + 2 * ii + 1]);
421 if(std::fabs(phiTotal - twopi) < angularTolerance)
428 &((*R_c)[0]), &((*Z_c)[0]));
431 else if(stype ==
"POLYHEDRA")
433 std::size_t nplanes = std::size_t(solParam[3]);
434 G4bool genericPoly =
false;
435 if(solParam.size() == 4 + nplanes * 3)
439 else if(solParam.size() == 4 + nplanes * 2)
445 G4String Err1 =
"Solid type " + stype +
" should have ";
450 G4String Err4 =
" (RZ corners) parameters,\n";
453 G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 +
" !";
454 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
461 std::vector<G4double>* z_p =
new std::vector<G4double>;
462 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
463 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
464 for(std::size_t ii = 0; ii < nplanes; ++ii)
466 (*z_p).push_back(solParam[4 + 3 * ii]);
467 (*rmin_p).push_back(solParam[4 + 3 * ii + 1]);
468 (*rmax_p).push_back(solParam[4 + 3 * ii + 2]);
471 if(std::fabs(phiTotal - twopi) < angularTolerance)
476 (
G4int)nplanes, &((*z_p)[0]), &((*rmin_p)[0]),
481 std::vector<G4double>* R_c =
new std::vector<G4double>;
482 std::vector<G4double>* Z_c =
new std::vector<G4double>;
483 for(std::size_t ii = 0; ii < nplanes; ++ii)
485 (*R_c).push_back(solParam[4 + 2 * ii]);
486 (*Z_c).push_back(solParam[4 + 2 * ii + 1]);
489 if(std::fabs(phiTotal - twopi) < angularTolerance)
494 (
G4int)nplanes, &((*R_c)[0]), &((*Z_c)[0]));
497 else if(stype ==
"ELLIPTICALTUBE")
502 else if(stype ==
"ELLIPSOID")
505 solid =
new G4Ellipsoid(sname, solParam[0], solParam[1], solParam[2],
506 solParam[3], solParam[4]);
508 else if(stype ==
"ELLIPTICALCONE")
514 else if(stype ==
"HYPE")
517 solid =
new G4Hype(sname, solParam[0], solParam[1], solParam[2],
518 solParam[3], solParam[4]);
520 else if(stype ==
"TET")
527 solid =
new G4Tet(sname, anchor, p2, p3, p4);
529 else if(stype ==
"TWISTEDBOX")
532 solid =
new G4TwistedBox(sname, solParam[0], solParam[1], solParam[2],
535 else if(stype ==
"TWISTEDTRAP")
539 new G4TwistedTrap(sname, solParam[0], solParam[1], solParam[2],
540 solParam[3], solParam[4], solParam[5], solParam[6],
541 solParam[7], solParam[8], solParam[9], solParam[10]);
543 else if(stype ==
"TWISTEDTRD")
546 solid =
new G4TwistedTrd(sname, solParam[0], solParam[1], solParam[2],
547 solParam[3], solParam[4], solParam[5]);
549 else if(stype ==
"SCALED")
552 if(tgrSol ==
nullptr)
554 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
562 else if(stype ==
"TWISTEDTUBS")
566 if(std::fabs(phiTotal - twopi) < angularTolerance)
570 solid =
new G4TwistedTubs(sname, solParam[0], solParam[1], solParam[2],
571 solParam[3], phiTotal);
573 else if(stype ==
"TESSELLATED")
581 for(
G4int ii = 0; ii < nFacets; ++ii)
584 if(
G4int(solParam.size()) < jj + nPoints * 3 + 2)
586 G4String Err1 =
"Too small number of parameters in tesselated solid, "
587 "it should be at least " +
590 G4String Err3 =
" number of parameters is " +
592 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
593 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
600 G4ThreeVector pt0(solParam[jj + 2], solParam[jj + 3], solParam[jj + 4]);
601 G4ThreeVector vt1(solParam[jj + 5], solParam[jj + 6], solParam[jj + 7]);
605 if(solParam[jj + 11] == 0)
609 else if(solParam[jj + 11] == 1)
615 G4String Err1 =
"Wrong number of vertex type in tesselated solid, it "
616 "should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
619 G4String Err3 =
" vertex type is " +
621 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
622 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
628 else if(nPoints == 4)
630 G4ThreeVector pt0(solParam[jj + 2], solParam[jj + 3], solParam[jj + 4]);
631 G4ThreeVector vt1(solParam[jj + 5], solParam[jj + 6], solParam[jj + 7]);
637 if(solParam[jj + 14] == 0)
641 else if(solParam[jj + 14] == 1)
647 G4String Err1 =
"Wrong number of vertex type in tesselated solid, it "
648 "should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
651 G4String Err3 =
" vertex type is " +
653 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
654 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
663 "Wrong number of points in tesselated solid, it should be 3 or 4";
666 G4String Err3 =
" number of points is " +
668 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
669 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
675 jj += nPoints * 3 + 2;
678 else if(stype ==
"EXTRUDED")
680 std::vector<G4TwoVector> polygonList;
681 std::vector<G4ExtrudedSolid::ZSection> zsectionList;
684 G4int nMax = nPolygons * 2 + 1;
685 for(; ii < nMax; ii += 2)
687 polygonList.push_back(
G4TwoVector(solParam[ii], solParam[ii + 1]));
690 nMax = nPolygons * 2 + nZSections * 4 + 2;
692 for(; ii < nMax; ii += 4)
694 G4TwoVector offset(solParam[ii + 1], solParam[ii + 2]);
695 zsectionList.push_back(
700 else if(stype.substr(0, 7) ==
"Boolean")
705 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
716 if(stype ==
"Boolean_UNION")
718 solid =
new G4UnionSolid(sname, sol1, sol2, relRotMat, relPlace);
720 else if(stype ==
"Boolean_SUBTRACTION")
724 else if(stype ==
"Boolean_INTERSECTION")
730 G4String ErrMessage =
"Unknown Boolean type " + stype;
731 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
736 else if(stype ==
"MULTIUNION")
739 if(tgrSol ==
nullptr)
741 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"InvalidSetup",
751 for (
G4int i=0; i<nsol; ++i)
758 solid =
dynamic_cast<G4VSolid*
>(solidu);
763 "Solids of type " + stype +
" not implemented yet, sorry...";
764 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"NotImplemented",
772 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid()" <<
G4endl
773 <<
" Created solid " << sname <<
" of type "
781 G4cout <<
" Constructing new G4Solid: " << *solid <<
G4endl;
790 const unsigned int NoParamExpected,
791 const unsigned int NoParam)
793 if(NoParamExpected != NoParam)
795 G4String Err1 =
"Solid type " + solidType +
" should have ";
800 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
801 G4Exception(
"G4tgbVolume::CheckNoSolidParams()",
"InvalidSetup",
823 G4String ErrMessage =
"Material not found " +
826 G4Exception(
"G4tgbVolume::ConstructG4LogVol()",
"InvalidSetup",
832 G4cout <<
" G4tgbVolume::ConstructG4LogVol() -"
844 G4cout <<
" Constructing new G4LogicalVolume: " << logvol->
GetName()
856 G4cout <<
" Constructing new G4VisAttributes: " << *visAtt <<
G4endl;
886 G4cout <<
" G4tgbVolume::ConstructG4LogVol() -"
909 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() - World: " <<
GetName()
919 G4cout <<
" Constructing new : G4PVPlacement " << physvol->
GetName()
932 <<
" inside " << parentLV->
GetName() <<
" copy No: " << copyNo
938 if(theTgrVolume->
GetType() ==
"VOLSimple")
944 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() - Placement type = "
950 if(place->
GetType() ==
"PlaceSimple")
963 if(1 - std::abs(check) > tol)
965 G4cerr <<
" Matrix : " << rmName <<
" " << rotmat->
colX() <<
" "
967 <<
" product x X y * z = " << check <<
" x X y "
969 G4String ErrMessage =
"Rotation is not ortogonal " + rmName +
" !";
970 G4Exception(
"G4tgbVolume::ConstructG4PhysVol()",
"InvalidSetup",
974 else if(1 + check <= tol)
989 G4cout <<
"Construction new G4VPhysicalVolume"
990 <<
" through G4ReflectionFactory " <<
GetName()
991 <<
" in volume " << parentLV->
GetName() <<
" copyNo "
992 << copyNo <<
" position " << place->
GetPlacement() <<
" ROT "
993 << rotmat->
colX() <<
" " << rotmat->
colY() <<
" "
1006 else if(place->
GetType() ==
"PlaceParam")
1014 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1045 G4String ErrMessage =
"Parameterisation has wrong type, TYPE: " +
1047 G4Exception(
"G4tgbVolume::ConstructG4PhysVol",
"WrongArgument",
1054 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1055 <<
" New G4PVParameterised: " <<
GetName() <<
" vol "
1057 <<
" axis " << param->
GetAxis() <<
" nCopies "
1068 G4cout <<
" Constructing new G4PVParameterised: "
1070 <<
" N copies " << param->
GetNCopies() <<
" axis "
1075 else if(place->
GetType() ==
"PlaceReplica")
1083 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1097 G4cout <<
" Constructing new G4PVReplica: " << currentLV->
GetName()
1099 <<
" Width " << dpr->
GetWidth() <<
" offset "
1105 else if(theTgrVolume->
GetType() ==
"VOLDivision")
1118 G4cout <<
" Constructed new G4LogicalVolume for division: "
1134 G4cout <<
" Constructing new G4PVDivision by number of divisions: "
1149 G4cout <<
" Constructing new G4PVDivision by width: " <<
GetName()
1150 <<
" in " << parentLV->
GetName() <<
" axis "
1164 G4cout <<
" Constructing new G4PVDivision by width"
1165 <<
" and number of divisions: " <<
GetName() <<
" in "
1167 <<
" Ndiv " << placeDiv->
GetNDiv() <<
" width "
1168 << placeDiv->
GetWidth() <<
" offset "
1175 else if(theTgrVolume->
GetType() ==
"VOLAssembly")
1180 if(!theG4AssemblyVolume)
1186 G4cout <<
" Constructing new G4AssemblyVolume: "
1187 <<
" number of assembly components "
1205 if(logvol ==
nullptr)
1215 G4cout <<
" G4AssemblyVolume->AddPlacedVolume " << ii <<
" "
1216 << logvol->
GetName() <<
" translation " << transl
1217 <<
" rotmat " << rotmat->
colX() <<
" " << rotmat->
colY()
1234 theG4AssemblyVolume->
MakeImprint(parentLV_nonconst, transl, rotmat);
1239 "Volume type not supported: " + theTgrVolume->
GetType() +
", sorry...";
1240 G4Exception(
"G4tgbVolume::ConstructG4PhysVol()",
"NotImplemented",
1292 std::fabs(mpDx1 - mpDx2) >
1323 origParam.
Rmin[ii] = origParam.
Rmin[ii] * redf;
1324 origParam.
Rmax[ii] = origParam.
Rmax[ii] * redf;
1330 else if(parentSolid->
GetEntityType() ==
"G4GenericPolycone")
1336 for(
G4int ii = 0; ii < numRZ; ++ii)
1353 origParam.
Rmin[ii] = origParam.
Rmin[ii] * redf;
1354 origParam.
Rmax[ii] = origParam.
Rmax[ii] * redf;
1363 G4String ErrMessage =
"Solid type not supported. VOLUME= " +
GetName() +
1366 "Only supported types are: G4Box, G4Tubs, G4Cons," +
1367 " G4Trd, G4Para, G4Polycone, G4Polyhedra.";
1368 G4Exception(
"G4tgbVolume::BuildSolidForDivision()",
"NotImplemented",
1376 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
void AddNode(G4VSolid &solid, const G4Transform3D &trans)
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 G4tgrSolid * GetSolid(G4int ii) const
const G4Transform3D GetTransformation(G4int ii) const
const G4Scale3D GetScale3d() const
const G4tgrSolid * GetOrigSolid() 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