117 : theTgrVolume(0), theG4AssemblyVolume(0)
132 theG4AssemblyVolume = 0;
149 G4bool bFirstCopy =
false;
153 if( theTgrVolume->
GetType() !=
"VOLDivision" )
189 std::pair<G4mmapspl::iterator, G4mmapspl::iterator> children
191 G4mmapspl::iterator cite;
192 for( cite = children.first; cite != children.second; cite++ )
220 if( sol == 0 ) {
return 0; }
225 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid():" <<
G4endl
226 <<
" SOLID = " << sol <<
G4endl
235 if( solid ) {
return solid; }
242 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid() - "
247 std::vector<G4double> solParam;
263 solid =
new G4Box( sname, solParam[0], solParam[1], solParam[2] );
266 else if( stype ==
"TUBE" )
269 solid =
new G4Tubs( sname, solParam[0], solParam[1], solParam[2],
272 else if( stype ==
"TUBS" )
276 if( std::fabs(phiDelta -
twopi) < angularTolerance ) { phiDelta =
twopi; }
277 solid =
new G4Tubs( sname, solParam[0], solParam[1], solParam[2],
278 solParam[3], phiDelta );
280 else if( stype ==
"TRAP" )
282 if( solParam.size() == 11 )
284 solid =
new G4Trap( sname, solParam[0], solParam[1], solParam[2],
285 solParam[3], solParam[4], solParam[5], solParam[6],
286 solParam[7], solParam[8], solParam[9], solParam[10] );
288 else if( solParam.size() == 4 )
290 solid =
new G4Trap( sname, solParam[0], solParam[1]/
deg,
291 solParam[2]/
deg, solParam[3]);
295 G4String ErrMessage1 =
"Solid type " + stype;
296 G4String ErrMessage2 =
" should have 11 or 4 parameters,\n";
297 G4String ErrMessage3 =
"and it has "
299 G4String ErrMessage = ErrMessage1 + ErrMessage2 + ErrMessage3 +
" !";
300 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
306 else if( stype ==
"TRD" )
309 solid =
new G4Trd( sname, solParam[0], solParam[1], solParam[2],
310 solParam[3], solParam[4] );
312 else if( stype ==
"PARA" )
315 solid =
new G4Para( sname, solParam[0], solParam[1], solParam[2],
316 solParam[3], solParam[4], solParam[5] );
318 else if( stype ==
"CONE" )
321 solid =
new G4Cons( sname, solParam[0], solParam[1], solParam[2],
322 solParam[3], solParam[4], 0., 360.*
deg);
324 else if( stype ==
"CONS" )
328 if( std::fabs(phiDelta -
twopi) < angularTolerance ) { phiDelta =
twopi; }
329 solid =
new G4Cons( sname, solParam[0], solParam[1], solParam[2],
330 solParam[3], solParam[4], solParam[5], phiDelta);
332 else if( stype ==
"SPHERE" )
336 if( std::fabs(phiDelta -
twopi) < angularTolerance ) { phiDelta =
twopi; }
338 if( std::fabs(thetaDelta -
pi) < angularTolerance ) { thetaDelta =
pi; }
339 solid =
new G4Sphere( sname, solParam[0], solParam[1], solParam[2],
340 phiDelta, 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 ) { phiDelta =
twopi; }
352 solid =
new G4Torus( sname, solParam[0], solParam[1], solParam[2],
353 solParam[3], phiDelta );
355 else if( stype ==
"POLYCONE" )
357 size_t nplanes = size_t(solParam[2]);
358 G4bool genericPoly =
false;
359 if( solParam.size() == 3+nplanes*3 )
363 else if( solParam.size() == 3+nplanes*2 )
369 G4String Err1 =
"Solid type " + stype +
" should have ";
371 +
" (Z,Rmin,Rmax)\n";
373 G4String Err4 =
" (RZ corners) parameters,\n";
376 G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 +
" !";
377 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
384 std::vector<G4double>* z_p =
new std::vector<G4double>;
385 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
386 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
387 for(
size_t ii = 0; ii < nplanes; ii++ )
389 (*z_p).push_back( solParam[3+3*ii] );
390 (*rmin_p).push_back( solParam[3+3*ii+1] );
391 (*rmax_p).push_back( solParam[3+3*ii+2] );
394 if( std::fabs(phiTotal -
twopi) < angularTolerance ) { phiTotal =
twopi; }
395 solid =
new G4Polycone( sname, solParam[0], phiTotal,
397 &((*z_p)[0]), &((*rmin_p)[0]), &((*rmax_p)[0]));
401 std::vector<G4double>* R_c =
new std::vector<G4double>;
402 std::vector<G4double>* Z_c =
new std::vector<G4double>;
403 for(
size_t ii = 0; ii < nplanes; ii++ )
405 (*R_c).push_back( solParam[3+2*ii] );
406 (*Z_c).push_back( solParam[3+2*ii+1] );
409 if( std::fabs(phiTotal -
twopi) < angularTolerance ) { phiTotal =
twopi; }
410 solid =
new G4Polycone( sname, solParam[0], phiTotal,
412 &((*R_c)[0]), &((*Z_c)[0]));
416 else if( stype ==
"POLYHEDRA" )
418 size_t nplanes = size_t(solParam[3]);
419 G4bool genericPoly =
false;
420 if( solParam.size() == 4+nplanes*3 )
424 else if( solParam.size() == 4+nplanes*2 )
430 G4String Err1 =
"Solid type " + stype +
" should have ";
432 +
" (Z,Rmin,Rmax)\n";
434 G4String Err4 =
" (RZ corners) parameters,\n";
437 G4String ErrMessage = Err1 + Err2 + Err3 + Err4 + Err5 +
" !";
438 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
445 std::vector<G4double>* z_p =
new std::vector<G4double>;
446 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
447 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
448 for(
size_t ii = 0; ii < nplanes; ii++ )
450 (*z_p).push_back( solParam[4+3*ii] );
451 (*rmin_p).push_back( solParam[4+3*ii+1] );
452 (*rmax_p).push_back( solParam[4+3*ii+2] );
455 if( std::fabs(phiTotal -
twopi) < angularTolerance ) { phiTotal =
twopi; }
456 solid =
new G4Polyhedra( sname, solParam[0], phiTotal,
457 G4int(solParam[2]), nplanes,
458 &((*z_p)[0]), &((*rmin_p)[0]), &((*rmax_p)[0]));
462 std::vector<G4double>* R_c =
new std::vector<G4double>;
463 std::vector<G4double>* Z_c =
new std::vector<G4double>;
464 for(
size_t ii = 0; ii < nplanes; ii++ )
466 (*R_c).push_back( solParam[4+2*ii] );
467 (*Z_c).push_back( solParam[4+2*ii+1] );
470 if( std::fabs(phiTotal -
twopi) < angularTolerance ) { phiTotal =
twopi; }
471 solid =
new G4Polyhedra( sname, solParam[0], phiTotal,
472 G4int(solParam[2]), nplanes,
473 &((*R_c)[0]), &((*Z_c)[0]));
476 else if( stype ==
"ELLIPTICALTUBE" )
479 solid =
new G4EllipticalTube( sname, solParam[0], solParam[1], solParam[2]);
481 else if( stype ==
"ELLIPSOID" )
484 solid =
new G4Ellipsoid( sname, solParam[0], solParam[1], solParam[2],
485 solParam[3], solParam[4] );
487 else if( stype ==
"ELLIPTICALCONE" )
491 solParam[2], solParam[3] );
493 else if( stype ==
"HYPE" )
496 solid =
new G4Hype( sname, solParam[0], solParam[1], solParam[2],
497 solParam[3], solParam[4] );
499 else if( stype ==
"TET" )
506 solid =
new G4Tet( sname, anchor, p2, p3, p4 );
508 else if( stype ==
"TWISTEDBOX" )
511 solid =
new G4TwistedBox( sname, solParam[0], solParam[1],
512 solParam[2], solParam[3]);
514 else if( stype ==
"TWISTEDTRAP" )
517 solid =
new G4TwistedTrap( sname, solParam[0], solParam[1], solParam[2],
518 solParam[3], solParam[4], solParam[5], solParam[6],
519 solParam[7], solParam[8], solParam[9], solParam[10] );
521 else if( stype ==
"TWISTEDTRD" )
524 solid =
new G4TwistedTrd( sname, solParam[0], solParam[1], solParam[2],
525 solParam[3], solParam[4], solParam[5]);
527 else if( stype ==
"TWISTEDTUBS" )
531 if( std::fabs(phiTotal -
twopi) < angularTolerance ) { phiTotal =
twopi; }
532 solid =
new G4TwistedTubs( sname, solParam[0], solParam[1], solParam[2],
533 solParam[3], phiTotal);
535 else if( stype ==
"BREPBOX" )
538 std::vector<G4Point3D> points;
539 for(
size_t ii = 0; ii < 8; ii++ )
541 points.push_back(
G4Point3D(solParam[ii*3+0],
545 solid =
new G4BREPSolidBox( sname, points[0], points[1], points[2],
546 points[3], points[4], points[5], points[6],
549 else if( stype ==
"BREPCYLINDER" )
556 solParam[9], solParam[10] );
558 else if( stype ==
"BREPCONE" )
565 solParam[9], solParam[10], solParam[11] );
567 else if( stype ==
"BREPSPHERE" )
577 else if( stype ==
"BREPTORUS" )
584 solParam[9], solParam[10] );
586 else if( stype ==
"BREPPCONE" )
588 size_t nplanes = size_t(solParam[2]);
590 std::vector<G4double>* z_p =
new std::vector<G4double>;
591 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
592 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
593 for(
size_t ii = 0; ii < nplanes; ii++ )
595 (*z_p).push_back( solParam[4+3*ii] );
596 (*rmin_p).push_back( solParam[4+3*ii+1] );
597 (*rmax_p).push_back( solParam[4+3*ii+2] );
600 if( std::fabs(phiTotal -
twopi) < angularTolerance ) { phiTotal =
twopi; }
605 &((*z_p)[0]), &((*rmin_p)[0]),
608 else if( stype ==
"BREPPOLYHEDRA" )
610 size_t nplanes = size_t(solParam[3]);
612 std::vector<G4double>* z_p =
new std::vector<G4double>;
613 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
614 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
615 for(
size_t ii = 0; ii < nplanes; ii++ )
617 (*z_p).push_back( solParam[5+3*ii] );
618 (*rmin_p).push_back( solParam[5+3*ii+1] );
619 (*rmax_p).push_back( solParam[5+3*ii+2] );
622 if( std::fabs(phiTotal -
twopi) < angularTolerance ) { phiTotal =
twopi; }
628 &((*z_p)[0]), &((*rmin_p)[0]),
631 else if( stype ==
"BREPOPENPCONE" )
633 size_t nplanes = size_t(solParam[2]);
634 std::vector<G4double>* z_p =
new std::vector<G4double>;
635 std::vector<G4double>* rmin_p =
new std::vector<G4double>;
636 std::vector<G4double>* rmax_p =
new std::vector<G4double>;
637 for(
size_t ii = 0; ii < nplanes; ii++ )
639 (*z_p).push_back( solParam[4+3*ii] );
640 (*rmin_p).push_back( solParam[4+3*ii+1] );
641 (*rmax_p).push_back( solParam[4+3*ii+2] );
644 if( std::fabs(phiTotal -
twopi) < angularTolerance ) { phiTotal =
twopi; }
649 &((*z_p)[0]), &((*rmin_p)[0]),
652 else if( stype ==
"TESSELLATED" )
660 for(
G4int ii = 0; ii < nFacets; ii++){
662 if(
G4int(solParam.size()) < jj + nPoints*3 + 2 ) {
666 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
667 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
674 G4ThreeVector pt0(solParam[jj+2],solParam[jj+3],solParam[jj+4]);
675 G4ThreeVector vt1(solParam[jj+5],solParam[jj+6],solParam[jj+7]);
676 G4ThreeVector vt2(solParam[jj+8],solParam[jj+9],solParam[jj+10]);
678 if( solParam[jj+11] == 0 )
682 else if( solParam[jj+11] == 1 )
688 G4String Err1 =
"Wrong number of vertex type in tesselated solid, it should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
691 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
692 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
698 else if( nPoints == 4 )
700 G4ThreeVector pt0(solParam[jj+2],solParam[jj+3],solParam[jj+4]);
701 G4ThreeVector vt1(solParam[jj+5],solParam[jj+6],solParam[jj+7]);
702 G4ThreeVector vt2(solParam[jj+8],solParam[jj+9],solParam[jj+10]);
703 G4ThreeVector vt3(solParam[jj+11],solParam[jj+12],solParam[jj+13]);
705 if( solParam[jj+14] == 0 )
709 else if( solParam[jj+14] == 1 )
715 G4String Err1 =
"Wrong number of vertex type in tesselated solid, it should be 0 =ABSOLUTE) or 1 (=RELATIVE)";
718 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
719 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
727 G4String Err1 =
"Wrong number of points in tesselated solid, it should be 3 or 4";
730 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
731 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
741 else if( stype ==
"EXTRUDED" )
743 std::vector<G4TwoVector> polygonList;
744 std::vector<G4ExtrudedSolid::ZSection> zsectionList;
747 G4int nMax = nPolygons*2+1;
748 for( ;ii < nMax; ii+=2 )
750 polygonList.push_back(
G4TwoVector(solParam[ii],solParam[ii+1]) );
753 nMax = nPolygons*2 + nZSections*4 + 2;
755 for( ; ii < nMax; ii+=4 )
763 else if( stype.substr(0,7) ==
"Boolean" )
768 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
778 if( stype ==
"Boolean_UNION" )
780 solid =
new G4UnionSolid( sname, sol1, sol2, relRotMat, relPlace );
782 else if( stype ==
"Boolean_SUBTRACTION" )
786 else if( stype ==
"Boolean_INTERSECTION" )
792 G4String ErrMessage =
"Unknown Boolean type " + stype;
793 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
800 G4String ErrMessage =
"Solids of type " + stype
801 +
" not implemented yet, sorry...";
802 G4Exception(
"G4tgbVolume::FindOrConstructG4Solid()",
"NotImplemented",
810 G4cout <<
" G4tgbVolume::FindOrConstructG4Solid()" <<
G4endl
811 <<
" Created solid " << sname
819 G4cout <<
" Constructing new G4Solid: "
829 const unsigned int NoParamExpected,
830 const unsigned int NoParam )
832 if( NoParamExpected != NoParam )
834 G4String Err1 =
"Solid type " + solidType +
" should have ";
839 G4String ErrMessage = Err1 + Err2 + Err3 +
" !";
840 G4Exception(
"G4tgbVolume::CheckNoSolidParams()",
"InvalidSetup",
863 G4String ErrMessage =
"Material not found "
865 +
" for volume " +
GetName() +
".";
866 G4Exception(
"G4tgbVolume::ConstructG4LogVol()",
"InvalidSetup",
872 G4cout <<
" G4tgbVolume::ConstructG4LogVol() -"
879 const_cast<G4Material*>(mate),
GetName() );
884 G4cout <<
" Constructing new G4LogicalVolume: "
896 G4cout <<
" Constructing new G4VisAttributes: "
927 G4cout <<
" G4tgbVolume::ConstructG4LogVol() -"
951 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() - World: "
956 const_cast<G4LogicalVolume*>(currentLV),
962 G4cout <<
" Constructing new : G4PVPlacement "
975 <<
" inside " << parentLV->
GetName() <<
" copy No: " << copyNo
981 if( theTgrVolume->
GetType() ==
"VOLSimple" )
987 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() - Placement type = "
993 if( place->
GetType() ==
"PlaceSimple" )
1005 if (1-std::abs(check)>tol)
1007 G4cerr <<
" Matrix : " << rmName <<
" " << rotmat->
colX()
1009 <<
" product x X y * z = " << check <<
" x X y "
1011 G4String ErrMessage =
"Rotation is not ortogonal " + rmName +
" !";
1016 else if (1+check<=tol)
1021 const_cast<G4LogicalVolume*>(currentLV),
1022 const_cast<G4LogicalVolume*>(parentLV),
1023 false, copyNo,
false )).first;
1030 G4cout <<
"Construction new G4VPhysicalVolume"
1031 <<
" through G4ReflectionFactory " <<
GetName()
1032 <<
" in volume " << parentLV->
GetName()
1033 <<
" copyNo " << copyNo
1035 <<
" ROT " << rotmat->
colX()
1036 <<
" " << rotmat->
colY()
1050 else if( place->
GetType() ==
"PlaceParam" )
1058 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1091 G4String ErrMessage =
"Parameterisation has wrong type, TYPE: "
1093 G4Exception(
"G4tgbVolume::ConstructG4PhysVol",
"WrongArgument",
1100 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1101 <<
" New G4PVParameterised: " <<
GetName() <<
" vol "
1103 <<
" axis " << param->
GetAxis() <<
" nCopies "
1108 const_cast<G4LogicalVolume*>(currentLV),
1109 const_cast<G4LogicalVolume*>(parentLV),
1115 G4cout <<
" Constructing new G4PVParameterised: "
1123 else if( place->
GetType() ==
"PlaceReplica" )
1131 G4cout <<
" G4tgbVolume::ConstructG4PhysVol() -" <<
G4endl
1132 <<
" replica" <<
" " << currentLV->
GetName()
1133 <<
" in " << parentLV->
GetName()
1139 const_cast<G4LogicalVolume*>(currentLV),
1140 const_cast<G4LogicalVolume*>(parentLV),
1146 G4cout <<
" Constructing new G4PVReplica: "
1148 <<
" in " << parentLV->
GetName()
1155 else if( theTgrVolume->
GetType() ==
"VOLDivision" )
1163 const_cast<G4Material*>(mate),
1168 G4cout <<
" Constructed new G4LogicalVolume for division: "
1169 << divLV->
GetName() <<
" mate " << mate->GetName() <<
G4endl;
1178 const_cast<G4LogicalVolume*>(parentLV),
1184 G4cout <<
" Constructing new G4PVDivision by number of divisions: "
1186 <<
" axis " << placeDiv->
GetAxis()
1187 <<
" Ndiv " << placeDiv->
GetNDiv()
1194 const_cast<G4LogicalVolume*>(parentLV),
1200 G4cout <<
" Constructing new G4PVDivision by width: "
1202 <<
" axis " << placeDiv->
GetAxis()
1203 <<
" width " << placeDiv->
GetWidth()
1210 const_cast<G4LogicalVolume*>(parentLV),
1217 G4cout <<
" Constructing new G4PVDivision by width"
1218 <<
" and number of divisions: "
1220 <<
" axis " << placeDiv->
GetAxis()
1221 <<
" Ndiv " << placeDiv->
GetNDiv()
1222 <<
" width " << placeDiv->
GetWidth()
1229 else if( theTgrVolume->
GetType() ==
"VOLAssembly" )
1234 if( !theG4AssemblyVolume )
1240 G4cout <<
" Constructing new G4AssemblyVolume: "
1241 <<
" number of assembly components "
1268 G4cout <<
" G4AssemblyVolume->AddPlacedVolume " << ii
1270 <<
" translation " << transl
1271 <<
" rotmat " << rotmat->
colX()
1272 <<
" " << rotmat->
colY()
1289 theG4AssemblyVolume->
MakeImprint( parentLV_nonconst, transl, rotmat );
1294 G4String ErrMessage =
"Volume type not supported: "
1295 + theTgrVolume->
GetType() +
", sorry...";
1296 G4Exception(
"G4tgbVolume::ConstructG4PhysVol()",
"NotImplemented",
1378 origParam.
Rmin[ii] = origParam.
Rmin[ii]*redf;
1379 origParam.
Rmax[ii] = origParam.
Rmax[ii]*redf;
1393 origParam.
Rmin[ii] = origParam.
Rmin[ii]*redf;
1394 origParam.
Rmax[ii] = origParam.
Rmax[ii]*redf;
1404 G4String ErrMessage =
"Solid type not supported. VOLUME= " +
GetName()
1406 +
"Only supported types are: G4Box, G4Tubs, G4Cons,"
1407 +
" G4Trd, G4Para, G4Polycone, G4Polyhedra.";
1408 G4Exception(
"G4tgbVolume::BuildSolidForDivision()",
"NotImplemented",
1416 G4cout <<
" Constructing new G4Solid for division: "