42#ifndef G3G4_NO_REFLECTION
55 fNofDivisions(nofDivisions),
75 fType = division.fType;
76 fNofDivisions = division.fNofDivisions;
77 fIAxis = division.fIAxis;
78 fNmed = division.fNmed;
80 fStep = division.fStep;
101 if (fNmed == 0) fNmed = fMVTE->
GetNmed();
109 if (fType ==
kDvn) envVTE = Dvn();
110 else if (fType ==
kDvn2) envVTE = Dvn2();
111 else if (fType ==
kDvt) envVTE = Dvt();
112 else if (fType ==
kDvt2) envVTE = Dvt2();
134 if (shape ==
"PARA") {
140 for (
G4int i=0; i<fNofDivisions; i++) {
142 position[fIAxis-1] = fLowRange + fWidth/2. + i*fWidth;
146 #ifndef G3G4_NO_REFLECTION
161 G4cout <<
"Create G4PVReplica name " << name <<
" logical volume name "
162 << lv->
GetName() <<
" mother logical volme name "
163 << mlv->
GetName() <<
" axis " << fAxis <<
" ndivisions "
164 << fNofDivisions <<
" width " << fWidth <<
" Offset "
168 #ifndef G3G4_NO_REFLECTION
170 ->
Replicate(name, lv, mlv, fAxis, fNofDivisions, fWidth, fOffset);
173 new G4PVReplica(name, lv, mlv, fAxis, fNofDivisions, fWidth, fOffset);
182 G4String err_message =
"G3Division::" + where +
" for "
183 + what +
" is not implemented";
184 G4Exception(
"G3Division::Exception()",
"G3toG40004",
189void G3Division::SetRangeAndAxis()
202 default:
G4Exception(
"G3Division::SetRangeAndAxis()",
"G3toG40005",
206 if ( shape ==
"BOX" ) {
207 fHighRange =
Rpar[fIAxis-1]*cm;
208 fLowRange = -fHighRange;
210 else if ( shape ==
"TRD1" ) {
212 fHighRange = std::max(
Rpar[0]*cm,
Rpar[1]*cm);
214 else if( fIAxis == 2) {
215 fHighRange =
Rpar[2]*cm;
217 else if( fIAxis == 3) {
218 fHighRange =
Rpar[3]*cm;
220 fLowRange = - fHighRange;
222 else if ( shape ==
"TRD2" ) {
224 fHighRange = std::max(
Rpar[0]*cm,
Rpar[1]*cm);
226 else if( fIAxis == 2) {
227 fHighRange = std::max(
Rpar[2]*cm,
Rpar[3]*cm);
229 else if( fIAxis == 3) {
230 fHighRange =
Rpar[4]*cm;
233 else if ( shape ==
"TRAP" ) {
234 if ( fIAxis == 3 ) fHighRange =
Rpar[0]*cm;
235 else fHighRange = 0.;
236 fLowRange = -fHighRange;
238 else if ( shape ==
"TUBE" ) {
240 fHighRange =
Rpar[1]*cm;
241 fLowRange =
Rpar[0]*cm;
244 else if( fIAxis == 2) {
245 fHighRange = 360.*deg;
249 else if( fIAxis == 3) {
250 fHighRange =
Rpar[2]*cm;
251 fLowRange = -fHighRange;
254 else if ( shape ==
"TUBS" ) {
256 fHighRange =
Rpar[1]*cm;
257 fLowRange =
Rpar[0]*cm;
260 else if( fIAxis == 2) {
262 fLowRange =
Rpar[3]*deg;
263 fHighRange =
Rpar[4]*deg - fLowRange;
264 if (
Rpar[4]*deg <= fLowRange )fHighRange = fHighRange + 360.*deg;
265 fHighRange = fHighRange + fLowRange;
268 else if( fIAxis == 3) {
269 fHighRange =
Rpar[2]*cm;
270 fLowRange = -fHighRange;
273 else if ( shape ==
"CONE" ) {
275 fHighRange = std::max(
Rpar[2]*cm,
Rpar[4]*cm);
276 fLowRange = std::max(
Rpar[1]*cm,
Rpar[3]*cm);
279 else if( fIAxis == 2) {
282 fHighRange = 360.*deg;
285 else if( fIAxis == 3) {
286 fHighRange =
Rpar[0]*cm;
287 fLowRange = -fHighRange;
290 else if ( shape ==
"CONS" ) {
292 fHighRange = std::max(
Rpar[2]*cm,
Rpar[4]*cm);
293 fLowRange = std::max(
Rpar[1]*cm,
Rpar[3]*cm);
296 else if( fIAxis == 2) {
298 fLowRange =
Rpar[5]*deg;
299 fHighRange =
Rpar[6]*deg - fLowRange;
300 if (
Rpar[6]*deg <= fLowRange )fHighRange = fHighRange + 360.*deg;
301 fHighRange = fHighRange + fLowRange;
304 else if( fIAxis == 3) {
305 fHighRange =
Rpar[2]*cm;
306 fLowRange = -fHighRange;
309 else if ( shape ==
"SPHE" ) {
311 fHighRange =
Rpar[1]*cm;
312 fLowRange =
Rpar[0]*cm;
315 else if( fIAxis == 2) {
316 fLowRange = std::min(
Rpar[2]*deg,
Rpar[3]*deg);
317 fHighRange = std::max(
Rpar[2]*deg,
Rpar[3]*deg);
320 else if( fIAxis == 3) {
321 fLowRange = std::min(
Rpar[4]*deg,
Rpar[5]*deg);
322 fHighRange = std::max(
Rpar[4]*deg,
Rpar[5]*deg);
326 else if ( shape ==
"PARA" ) {
327 fHighRange =
Rpar[fIAxis-1]*cm;
328 fLowRange = -fHighRange;
330 else if ( shape ==
"PGON" ) {
341 rangehi[0] = -kInfinity ;
342 rangelo[0] = kInfinity ;
343 rangehi[2] = -kInfinity ;
344 rangelo[2] = kInfinity ;
352 DzArray[i] =
Rpar[i4]*cm;
353 Rmin[i] =
Rpar[i5]*cm;
354 Rmax[i] =
Rpar[i6]*cm;
355 rangelo[0] = std::min(rangelo[0], Rmin[i]);
356 rangehi[0] = std::max(rangehi[0], Rmax[i]);
357 rangelo[2] = std::min(rangelo[2], DzArray[i]);
358 rangehi[2] = std::max(rangehi[2], DzArray[i]);
361 assert(Rmin[i]>=0 && Rmax[i]>=Rmin[i]);
363 rangehi[1] = pPhi1 + dPhi;
365 fHighRange = rangehi[fIAxis-1];
366 fLowRange = rangelo[fIAxis-1];
367 if (fIAxis == 1)fAxis =
kRho;
368 else if (fIAxis == 2)fAxis =
kPhi;
369 else if (fIAxis == 3)fAxis =
kZAxis;
376 else if ( shape ==
"PCON" ) {
388 rangehi[0] = -kInfinity ;
389 rangelo[0] = kInfinity ;
390 rangehi[2] = -kInfinity ;
391 rangelo[2] = kInfinity ;
398 DzArray[i] =
Rpar[i4]*cm;
399 Rmin[i] =
Rpar[i5]*cm;
400 Rmax[i] =
Rpar[i6]*cm;
401 rangelo[0] = std::min(rangelo[0], Rmin[i]);
402 rangehi[0] = std::max(rangehi[0], Rmax[i]);
403 rangelo[2] = std::min(rangelo[2], DzArray[i]);
404 rangehi[2] = std::max(rangehi[2], DzArray[i]);
407 assert(Rmin[i]>=0 && Rmax[i]>=Rmin[i]);
409 rangehi[1] = pPhi1 + dPhi;
411 fHighRange = rangehi[fIAxis-1];
412 fLowRange = rangelo[fIAxis-1];
413 if (fIAxis == 1)fAxis =
kRho;
414 else if (fIAxis == 2)fAxis =
kPhi;
415 else if (fIAxis == 3)fAxis =
kZAxis;
422 else if ( shape ==
"ELTU" || shape ==
"HYPE" || shape ==
"GTRA" ||
424 Exception(
"SetRangeAndAxis", shape);
427 Exception(
"SetRangeAndAxis",
"Unknown shape" + shape);
432 G4cout <<
"Shape " << shape <<
" SetRangeAndAxis: "
433 << fLowRange <<
" " << fHighRange <<
" " << fAxis <<
G4endl;
449 for (
G4int i=0; i<npar; ++i){
Rpar[i] = par[i];}
452 if ( shape ==
"BOX" ) {
453 Rpar[fIAxis-1] = (hi - lo)/2./cm;
454 pos [fIAxis-1] = (hi + lo)/2.;
456 else if ( shape ==
"TRD1" ) {
457 if ( fIAxis == 1 || fIAxis == 2 ) {
458 Exception(
"CreateEnvelope",
"TRD1-x,y");
460 else if ( fIAxis == 3 ) {
465 Rpar[0] = x1 + tn * (lo/cm - z1);
466 Rpar[1] = x1 + tn * (hi/cm - z1);
467 Rpar[3] = (hi - lo)/2./cm;
468 pos[2] = (hi + lo)/2.;
471 else if ( shape ==
"TRD2" ) {
472 if ( fIAxis == 1 || fIAxis == 2) {
473 Exception(
"CreateEnvelope",
"TRD2-x,y");
475 else if ( fIAxis == 3 ) {
482 Rpar[0] = x1 + tn1 * (lo/cm - z1);
483 Rpar[1] = x1 + tn1 * (hi/cm - z1);
484 Rpar[2] = y1 + tn2 * (lo/cm - z1);
485 Rpar[3] = y1 + tn2 * (hi/cm - z1);
486 Rpar[4] = (hi - lo)/2./cm;
487 pos[2] = (hi + lo)/2.;
490 else if ( shape ==
"TRAP" ) {
491 Exception(
"CreateEnvelope",
"TRAP-x,y,z");
493 else if ( shape ==
"TUBE" ) {
498 else if ( fIAxis == 2 ) {
504 else if ( fIAxis == 3 ) {
505 Rpar[2] = (hi - lo)/2./cm;
506 pos [2] = (hi + lo)/2.;
509 else if ( shape ==
"TUBS" ) {
514 else if ( fIAxis == 2 ) {
518 else if ( fIAxis == 3 ) {
519 Rpar[2] = (hi - lo)/2./cm;
520 pos [2] = (hi + lo)/2.;
523 else if ( shape ==
"CONE" ) {
525 Exception(
"CreateEnvelope",
"CONE-x,z");
527 else if ( fIAxis == 2 ) {
533 else if ( fIAxis == 3 ) {
538 Rpar[1] = rmin + tn1 * (lo/cm - z1);
539 Rpar[3] = rmin + tn1 * (hi/cm - z1);
540 Rpar[2] = rmax + tn2 * (lo/cm - z1);
541 Rpar[4] = rmax + tn2 * (hi/cm - z1);
542 Rpar[0] = (hi - lo)/2./cm;
543 pos[2] = (hi + lo)/2.;
546 else if ( shape ==
"CONS" ) {
548 Exception(
"CreateEnvelope",
"CONS-x");
550 else if ( fIAxis == 2 ) {
554 else if ( fIAxis == 3 ) {
559 Rpar[1] = rmin + tn1 * (lo/cm - z1);
560 Rpar[3] = rmin + tn1 * (hi/cm - z1);
561 Rpar[2] = rmax + tn2 * (lo/cm - z1);
562 Rpar[4] = rmax + tn2 * (hi/cm - z1);
563 Rpar[0] = (hi - lo)/2./cm;
564 pos[2] = (hi + lo)/2.;
567 else if ( shape ==
"SPHE" ) {
568 Exception(
"CreateEnvelope",
"SPHE-x,y,z");
570 else if ( shape ==
"PARA" ) {
571 Exception(
"CreateEnvelope",
"PARA-x,y,z");
573 else if ( shape ==
"PGON" ) {
580 Exception(
"CreateEnvelope",
"PGON-x,z");
583 else if ( shape ==
"PCON" ) {
590 Exception(
"CreateEnvelope",
"PCON-x,z");
594 Exception(
"CreateEnvelope",
"Unknown shape" + shape);
606 G3Pos* aG3Pos =
new G3Pos(motherName, 1, offset, 0, only);
619 for (
G4int i=0; i<npar; ++i){
Rpar[i] = par[i];}
628 if ( shape ==
"BOX" ) {
629 if ( fIAxis == 1 )
Rpar[0] = fWidth/2./cm;
630 else if ( fIAxis == 2 )
Rpar[1] = fWidth/2./cm;
631 else if ( fIAxis == 3 )
Rpar[2] = fWidth/2./cm;
633 else if ( shape ==
"TRD1" ) {
634 if ( fIAxis == 1 || fIAxis == 2 ) {
635 Exception(
"CreateSolid",
"TRD1-x,y");
637 else if ( fIAxis == 3 ) {
638 Rpar[3] = fWidth/2./cm;
641 else if ( shape ==
"TRD2" ) {
642 if ( fIAxis == 1 || fIAxis == 2 ) {
643 Exception(
"CreateSolid",
"TRD2-x,y");
645 else if ( fIAxis == 3 ) {
646 Rpar[4] = fWidth/2./cm;
649 else if ( shape ==
"TRAP" ) {
650 if ( fIAxis == 1 || fIAxis == 2) {
651 Exception(
"CreateSolid",
"TRAP-x,y");
653 else if ( fIAxis == 3 ) {
654 Rpar[0] = fWidth/2./cm;
657 else if ( shape ==
"TUBE" ) {
660 fOffset =
Rpar[0]*cm;
662 else if ( fIAxis == 2 ) {
664 Rpar[4] = fWidth/deg;
668 else if ( fIAxis == 3 ) {
669 Rpar[2] = fWidth/2./cm;
672 else if ( shape ==
"TUBS" ) {
675 fOffset =
Rpar[0]*cm;
677 else if ( fIAxis == 2 ) {
678 fOffset =
Rpar[3]*deg;
680 Rpar[4] = fWidth/deg;
682 else if ( fIAxis == 3 ) {
683 Rpar[2] = fWidth/2./cm;
686 else if ( shape ==
"CONE" ) {
688 Exception(
"CreateSolid",
"CONE-x");
690 else if ( fIAxis == 2 ) {
692 Rpar[6] = fWidth/deg;
696 else if ( fIAxis == 3 ) {
697 Rpar[0] = fWidth/2./cm;
700 else if ( shape ==
"CONS" ) {
702 Exception(
"CreateSolid",
"CONS-x");
704 else if ( fIAxis == 2 ) {
705 fOffset =
Rpar[5]*deg;
707 Rpar[6] = fWidth/deg;
709 else if ( fIAxis == 3 ) {
710 Rpar[0] = fWidth/2./cm;
713 else if (shape ==
"PARA") {
715 Rpar[0] = fWidth/2./cm;
717 else if (
Rpar[4] == 0. &&
Rpar[5] == 0. ) {
720 Rpar[1] = fWidth/2./cm;
722 else if ( fIAxis == 3) {
723 Rpar[2] = fWidth/2./cm;
727 Exception(
"CreateSolid", shape);
729 else if (shape ==
"SPHE") {
730 Exception(
"CreateSolid", shape);
732 else if ( shape ==
"PGON" ) {
734 fOffset =
Rpar[0]*deg;
736 Rpar[1] = fWidth/deg;
740 Exception(
"CreateSolid", shape);
742 else if ( shape ==
"PCON" ) {
744 fOffset =
Rpar[0]*deg;
746 Rpar[1] = fWidth/deg;
749 Exception(
"CreateSolid", shape);
753 Exception(
"CreateSolid",
"Unknown shape" + shape);
765 +
" has negative parameters.";
766 G4Exception(
"G3Division::CreateSolid()",
"G3toG40006",
796 fWidth = (fHighRange - fLowRange)/fNofDivisions;
797 CreateSolid(shape,
Rpar, npar);
812 if (fAxis ==
kPhi) c0 = c0*deg;
817 if( std::abs(c0 - fLowRange) > Rmin) {
818 envVTE = CreateEnvelope(shape, fHighRange, c0,
Rpar, npar);
824 fWidth = (fHighRange - c0)/fNofDivisions;
825 CreateSolid(shape,
Rpar, npar);
841 G4int ndvmx = fNofDivisions;
844 if (fAxis ==
kPhi) step = step*deg;
847 G4int ndiv =
G4int((fHighRange - fLowRange + Rmin)/step);
849 if (ndvmx > 255) ndvmx = 255;
850 if (ndiv > ndvmx && ndvmx > 0 ) ndiv = ndvmx;
854 G4double delta = std::abs((fHighRange - fLowRange) - ndiv*step);
857 = CreateEnvelope(shape, fHighRange-delta/2., fLowRange+delta/2.,
865 fNofDivisions = ndiv;
866 CreateSolid(shape,
Rpar, npar);
882 G4int ndvmx = fNofDivisions;
895 G4int ndiv =
G4int((fHighRange - c0 + Rmin)/step);
897 if (ndvmx > 255) ndvmx = 255;
898 if (ndiv > ndvmx && ndvmx > 0 ) ndiv = ndvmx;
902 G4double delta = std::abs((fHighRange - c0) - ndiv*step);
903 if (std::abs(c0 - fLowRange) > Rmin) {
905 = CreateEnvelope(shape, fHighRange-delta/2., c0+delta/2.,
Rpar, npar);
912 fNofDivisions = ndiv;
913 CreateSolid(shape,
Rpar, npar);
G3VolTableEntry * G4CreateVTE(G4String vname, G4String shape, G4int nmed, G4double Rpar[], G4int npar)
G4VSolid * G3toG4MakeSolid(const G4String &vname, const G4String &shape, const G4double *Rpar, const G4int npar, G4bool &NegVolPars, G4bool &Deferred, G4bool *OKAxis)
G3G4DLL_API G4double Rpar[1000]
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
CLHEP::Hep3Vector G4ThreeVector
G4GLOB_DLL std::ostream G4cout
G3Division(G3DivType type, G3VolTableEntry *vte, G3VolTableEntry *mvte, G4int nofDivision, G4int iaxis, G4int nmed, G4double c0, G4double step)
void AddMother(G3VolTableEntry *aDaughter)
G3VolTableEntry * GetMasterClone()
void ReplaceDaughter(G3VolTableEntry *vteOld, G3VolTableEntry *vteNew)
void ReplaceMother(G3VolTableEntry *vteOld, G3VolTableEntry *vteNew)
void AddG3Pos(G3Pos *aG3Pos)
void SetHasNegPars(G4bool hasNegPars)
void SetNRpar(G4int npar, G4double *Rpar)
void AddDaughter(G3VolTableEntry *aDaughter)
G4LogicalVolume * GetLV()
void SetSolid(G4VSolid *solid)
G4VSolid * GetSolid() const
const G4String & GetName() const
static G4ReflectionFactory * Instance()
G4PhysicalVolumesPair Place(const G4Transform3D &transform3D, const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, G4bool isMany, G4int copyNo, G4bool surfCheck=false)
G4PhysicalVolumesPair Replicate(const G4String &name, G4LogicalVolume *LV, G4LogicalVolume *motherLV, EAxis axis, G4int nofReplicas, G4double width, G4double offset=0.)