41#ifndef G3G4_NO_REFLECTION
54 fNofDivisions(nofDivisions),
74 fType = division.fType;
75 fNofDivisions = division.fNofDivisions;
76 fIAxis = division.fIAxis;
77 fNmed = division.fNmed;
79 fStep = division.fStep;
100 if (fNmed == 0) fNmed = fMVTE->
GetNmed();
108 if (fType ==
kDvn) envVTE = Dvn();
109 else if (fType ==
kDvn2) envVTE = Dvn2();
110 else if (fType ==
kDvt) envVTE = Dvt();
111 else if (fType ==
kDvt2) envVTE = Dvt2();
133 if (shape ==
"PARA") {
139 for (
G4int i=0; i<fNofDivisions; i++) {
141 position[fIAxis-1] = fLowRange + fWidth/2. + i*fWidth;
145 #ifndef G3G4_NO_REFLECTION
160 G4cout <<
"Create G4PVReplica name " << name <<
" logical volume name "
161 << lv->
GetName() <<
" mother logical volme name "
162 << mlv->
GetName() <<
" axis " << fAxis <<
" ndivisions "
163 << fNofDivisions <<
" width " << fWidth <<
" Offset "
167 #ifndef G3G4_NO_REFLECTION
169 ->
Replicate(name, lv, mlv, fAxis, fNofDivisions, fWidth, fOffset);
172 new G4PVReplica(name, lv, mlv, fAxis, fNofDivisions, fWidth, fOffset);
181 G4String err_message =
"G3Division::" + where +
" for "
182 + what +
" is not implemented";
183 G4Exception(
"G3Division::Exception()",
"G3toG40004",
188void G3Division::SetRangeAndAxis()
201 default:
G4Exception(
"G3Division::SetRangeAndAxis()",
"G3toG40005",
205 if ( shape ==
"BOX" ) {
206 fHighRange =
Rpar[fIAxis-1]*cm;
207 fLowRange = -fHighRange;
209 else if ( shape ==
"TRD1" ) {
211 fHighRange = std::max(
Rpar[0]*cm,
Rpar[1]*cm);
213 else if( fIAxis == 2) {
214 fHighRange =
Rpar[2]*cm;
216 else if( fIAxis == 3) {
217 fHighRange =
Rpar[3]*cm;
219 fLowRange = - fHighRange;
221 else if ( shape ==
"TRD2" ) {
223 fHighRange = std::max(
Rpar[0]*cm,
Rpar[1]*cm);
225 else if( fIAxis == 2) {
226 fHighRange = std::max(
Rpar[2]*cm,
Rpar[3]*cm);
228 else if( fIAxis == 3) {
229 fHighRange =
Rpar[4]*cm;
232 else if ( shape ==
"TRAP" ) {
233 if ( fIAxis == 3 ) fHighRange =
Rpar[0]*cm;
234 else fHighRange = 0.;
235 fLowRange = -fHighRange;
237 else if ( shape ==
"TUBE" ) {
239 fHighRange =
Rpar[1]*cm;
240 fLowRange =
Rpar[0]*cm;
243 else if( fIAxis == 2) {
244 fHighRange = 360.*deg;
248 else if( fIAxis == 3) {
249 fHighRange =
Rpar[2]*cm;
250 fLowRange = -fHighRange;
253 else if ( shape ==
"TUBS" ) {
255 fHighRange =
Rpar[1]*cm;
256 fLowRange =
Rpar[0]*cm;
259 else if( fIAxis == 2) {
261 fLowRange =
Rpar[3]*deg;
262 fHighRange =
Rpar[4]*deg - fLowRange;
263 if (
Rpar[4]*deg <= fLowRange )fHighRange = fHighRange + 360.*deg;
264 fHighRange = fHighRange + fLowRange;
267 else if( fIAxis == 3) {
268 fHighRange =
Rpar[2]*cm;
269 fLowRange = -fHighRange;
272 else if ( shape ==
"CONE" ) {
274 fHighRange = std::max(
Rpar[2]*cm,
Rpar[4]*cm);
275 fLowRange = std::max(
Rpar[1]*cm,
Rpar[3]*cm);
278 else if( fIAxis == 2) {
281 fHighRange = 360.*deg;
284 else if( fIAxis == 3) {
285 fHighRange =
Rpar[0]*cm;
286 fLowRange = -fHighRange;
289 else if ( shape ==
"CONS" ) {
291 fHighRange = std::max(
Rpar[2]*cm,
Rpar[4]*cm);
292 fLowRange = std::max(
Rpar[1]*cm,
Rpar[3]*cm);
295 else if( fIAxis == 2) {
297 fLowRange =
Rpar[5]*deg;
298 fHighRange =
Rpar[6]*deg - fLowRange;
299 if (
Rpar[6]*deg <= fLowRange )fHighRange = fHighRange + 360.*deg;
300 fHighRange = fHighRange + fLowRange;
303 else if( fIAxis == 3) {
304 fHighRange =
Rpar[2]*cm;
305 fLowRange = -fHighRange;
308 else if ( shape ==
"SPHE" ) {
310 fHighRange =
Rpar[1]*cm;
311 fLowRange =
Rpar[0]*cm;
314 else if( fIAxis == 2) {
315 fLowRange = std::min(
Rpar[2]*deg,
Rpar[3]*deg);
316 fHighRange = std::max(
Rpar[2]*deg,
Rpar[3]*deg);
319 else if( fIAxis == 3) {
320 fLowRange = std::min(
Rpar[4]*deg,
Rpar[5]*deg);
321 fHighRange = std::max(
Rpar[4]*deg,
Rpar[5]*deg);
325 else if ( shape ==
"PARA" ) {
326 fHighRange =
Rpar[fIAxis-1]*cm;
327 fLowRange = -fHighRange;
329 else if ( shape ==
"PGON" ) {
340 rangehi[0] = -kInfinity ;
341 rangelo[0] = kInfinity ;
342 rangehi[2] = -kInfinity ;
343 rangelo[2] = kInfinity ;
351 DzArray[i] =
Rpar[i4]*cm;
352 Rmin[i] =
Rpar[i5]*cm;
353 Rmax[i] =
Rpar[i6]*cm;
354 rangelo[0] = std::min(rangelo[0], Rmin[i]);
355 rangehi[0] = std::max(rangehi[0], Rmax[i]);
356 rangelo[2] = std::min(rangelo[2], DzArray[i]);
357 rangehi[2] = std::max(rangehi[2], DzArray[i]);
360 assert(Rmin[i]>=0 && Rmax[i]>=Rmin[i]);
362 rangehi[1] = pPhi1 + dPhi;
364 fHighRange = rangehi[fIAxis-1];
365 fLowRange = rangelo[fIAxis-1];
366 if (fIAxis == 1)fAxis =
kRho;
367 else if (fIAxis == 2)fAxis =
kPhi;
368 else if (fIAxis == 3)fAxis =
kZAxis;
375 else if ( shape ==
"PCON" ) {
387 rangehi[0] = -kInfinity ;
388 rangelo[0] = kInfinity ;
389 rangehi[2] = -kInfinity ;
390 rangelo[2] = kInfinity ;
397 DzArray[i] =
Rpar[i4]*cm;
398 Rmin[i] =
Rpar[i5]*cm;
399 Rmax[i] =
Rpar[i6]*cm;
400 rangelo[0] = std::min(rangelo[0], Rmin[i]);
401 rangehi[0] = std::max(rangehi[0], Rmax[i]);
402 rangelo[2] = std::min(rangelo[2], DzArray[i]);
403 rangehi[2] = std::max(rangehi[2], DzArray[i]);
406 assert(Rmin[i]>=0 && Rmax[i]>=Rmin[i]);
408 rangehi[1] = pPhi1 + dPhi;
410 fHighRange = rangehi[fIAxis-1];
411 fLowRange = rangelo[fIAxis-1];
412 if (fIAxis == 1)fAxis =
kRho;
413 else if (fIAxis == 2)fAxis =
kPhi;
414 else if (fIAxis == 3)fAxis =
kZAxis;
421 else if ( shape ==
"ELTU" || shape ==
"HYPE" || shape ==
"GTRA" ||
423 Exception(
"SetRangeAndAxis", shape);
426 Exception(
"SetRangeAndAxis",
"Unknown shape" + shape);
431 G4cout <<
"Shape " << shape <<
" SetRangeAndAxis: "
432 << fLowRange <<
" " << fHighRange <<
" " << fAxis <<
G4endl;
448 for (
G4int i=0; i<npar; ++i){
Rpar[i] = par[i];}
451 if ( shape ==
"BOX" ) {
452 Rpar[fIAxis-1] = (hi - lo)/2./cm;
453 pos [fIAxis-1] = (hi + lo)/2.;
455 else if ( shape ==
"TRD1" ) {
456 if ( fIAxis == 1 || fIAxis == 2 ) {
457 Exception(
"CreateEnvelope",
"TRD1-x,y");
459 else if ( fIAxis == 3 ) {
464 Rpar[0] = x1 + tn * (lo/cm - z1);
465 Rpar[1] = x1 + tn * (hi/cm - z1);
466 Rpar[3] = (hi - lo)/2./cm;
467 pos[2] = (hi + lo)/2.;
470 else if ( shape ==
"TRD2" ) {
471 if ( fIAxis == 1 || fIAxis == 2) {
472 Exception(
"CreateEnvelope",
"TRD2-x,y");
474 else if ( fIAxis == 3 ) {
481 Rpar[0] = x1 + tn1 * (lo/cm - z1);
482 Rpar[1] = x1 + tn1 * (hi/cm - z1);
483 Rpar[2] = y1 + tn2 * (lo/cm - z1);
484 Rpar[3] = y1 + tn2 * (hi/cm - z1);
485 Rpar[4] = (hi - lo)/2./cm;
486 pos[2] = (hi + lo)/2.;
489 else if ( shape ==
"TRAP" ) {
490 Exception(
"CreateEnvelope",
"TRAP-x,y,z");
492 else if ( shape ==
"TUBE" ) {
497 else if ( fIAxis == 2 ) {
503 else if ( fIAxis == 3 ) {
504 Rpar[2] = (hi - lo)/2./cm;
505 pos [2] = (hi + lo)/2.;
508 else if ( shape ==
"TUBS" ) {
513 else if ( fIAxis == 2 ) {
517 else if ( fIAxis == 3 ) {
518 Rpar[2] = (hi - lo)/2./cm;
519 pos [2] = (hi + lo)/2.;
522 else if ( shape ==
"CONE" ) {
524 Exception(
"CreateEnvelope",
"CONE-x,z");
526 else if ( fIAxis == 2 ) {
532 else if ( fIAxis == 3 ) {
537 Rpar[1] = rmin + tn1 * (lo/cm - z1);
538 Rpar[3] = rmin + tn1 * (hi/cm - z1);
539 Rpar[2] = rmax + tn2 * (lo/cm - z1);
540 Rpar[4] = rmax + tn2 * (hi/cm - z1);
541 Rpar[0] = (hi - lo)/2./cm;
542 pos[2] = (hi + lo)/2.;
545 else if ( shape ==
"CONS" ) {
547 Exception(
"CreateEnvelope",
"CONS-x");
549 else if ( fIAxis == 2 ) {
553 else if ( fIAxis == 3 ) {
558 Rpar[1] = rmin + tn1 * (lo/cm - z1);
559 Rpar[3] = rmin + tn1 * (hi/cm - z1);
560 Rpar[2] = rmax + tn2 * (lo/cm - z1);
561 Rpar[4] = rmax + tn2 * (hi/cm - z1);
562 Rpar[0] = (hi - lo)/2./cm;
563 pos[2] = (hi + lo)/2.;
566 else if ( shape ==
"SPHE" ) {
567 Exception(
"CreateEnvelope",
"SPHE-x,y,z");
569 else if ( shape ==
"PARA" ) {
570 Exception(
"CreateEnvelope",
"PARA-x,y,z");
572 else if ( shape ==
"PGON" ) {
579 Exception(
"CreateEnvelope",
"PGON-x,z");
582 else if ( shape ==
"PCON" ) {
589 Exception(
"CreateEnvelope",
"PCON-x,z");
593 Exception(
"CreateEnvelope",
"Unknown shape" + shape);
605 G3Pos* aG3Pos =
new G3Pos(motherName, 1, offset, 0, only);
618 for (
G4int i=0; i<npar; ++i){
Rpar[i] = par[i];}
627 if ( shape ==
"BOX" ) {
628 if ( fIAxis == 1 )
Rpar[0] = fWidth/2./cm;
629 else if ( fIAxis == 2 )
Rpar[1] = fWidth/2./cm;
630 else if ( fIAxis == 3 )
Rpar[2] = fWidth/2./cm;
632 else if ( shape ==
"TRD1" ) {
633 if ( fIAxis == 1 || fIAxis == 2 ) {
634 Exception(
"CreateSolid",
"TRD1-x,y");
636 else if ( fIAxis == 3 ) {
637 Rpar[3] = fWidth/2./cm;
640 else if ( shape ==
"TRD2" ) {
641 if ( fIAxis == 1 || fIAxis == 2 ) {
642 Exception(
"CreateSolid",
"TRD2-x,y");
644 else if ( fIAxis == 3 ) {
645 Rpar[4] = fWidth/2./cm;
648 else if ( shape ==
"TRAP" ) {
649 if ( fIAxis == 1 || fIAxis == 2) {
650 Exception(
"CreateSolid",
"TRAP-x,y");
652 else if ( fIAxis == 3 ) {
653 Rpar[0] = fWidth/2./cm;
656 else if ( shape ==
"TUBE" ) {
659 fOffset =
Rpar[0]*cm;
661 else if ( fIAxis == 2 ) {
663 Rpar[4] = fWidth/deg;
667 else if ( fIAxis == 3 ) {
668 Rpar[2] = fWidth/2./cm;
671 else if ( shape ==
"TUBS" ) {
674 fOffset =
Rpar[0]*cm;
676 else if ( fIAxis == 2 ) {
677 fOffset =
Rpar[3]*deg;
679 Rpar[4] = fWidth/deg;
681 else if ( fIAxis == 3 ) {
682 Rpar[2] = fWidth/2./cm;
685 else if ( shape ==
"CONE" ) {
687 Exception(
"CreateSolid",
"CONE-x");
689 else if ( fIAxis == 2 ) {
691 Rpar[6] = fWidth/deg;
695 else if ( fIAxis == 3 ) {
696 Rpar[0] = fWidth/2./cm;
699 else if ( shape ==
"CONS" ) {
701 Exception(
"CreateSolid",
"CONS-x");
703 else if ( fIAxis == 2 ) {
704 fOffset =
Rpar[5]*deg;
706 Rpar[6] = fWidth/deg;
708 else if ( fIAxis == 3 ) {
709 Rpar[0] = fWidth/2./cm;
712 else if (shape ==
"PARA") {
714 Rpar[0] = fWidth/2./cm;
716 else if (
Rpar[4] == 0. &&
Rpar[5] == 0. ) {
719 Rpar[1] = fWidth/2./cm;
721 else if ( fIAxis == 3) {
722 Rpar[2] = fWidth/2./cm;
726 Exception(
"CreateSolid", shape);
728 else if (shape ==
"SPHE") {
729 Exception(
"CreateSolid", shape);
731 else if ( shape ==
"PGON" ) {
733 fOffset =
Rpar[0]*deg;
735 Rpar[1] = fWidth/deg;
739 Exception(
"CreateSolid", shape);
741 else if ( shape ==
"PCON" ) {
743 fOffset =
Rpar[0]*deg;
745 Rpar[1] = fWidth/deg;
748 Exception(
"CreateSolid", shape);
752 Exception(
"CreateSolid",
"Unknown shape" + shape);
764 +
" has negative parameters.";
765 G4Exception(
"G3Division::CreateSolid()",
"G3toG40006",
795 fWidth = (fHighRange - fLowRange)/fNofDivisions;
796 CreateSolid(shape,
Rpar, npar);
811 if (fAxis ==
kPhi) c0 = c0*deg;
816 if( std::abs(c0 - fLowRange) > Rmin) {
817 envVTE = CreateEnvelope(shape, fHighRange, c0,
Rpar, npar);
823 fWidth = (fHighRange - c0)/fNofDivisions;
824 CreateSolid(shape,
Rpar, npar);
840 G4int ndvmx = fNofDivisions;
843 if (fAxis ==
kPhi) step = step*deg;
846 G4int ndiv =
G4int((fHighRange - fLowRange + Rmin)/step);
848 if (ndvmx > 255) ndvmx = 255;
849 if (ndiv > ndvmx && ndvmx > 0 ) ndiv = ndvmx;
853 G4double delta = std::abs((fHighRange - fLowRange) - ndiv*step);
856 = CreateEnvelope(shape, fHighRange-delta/2., fLowRange+delta/2.,
864 fNofDivisions = ndiv;
865 CreateSolid(shape,
Rpar, npar);
881 G4int ndvmx = fNofDivisions;
894 G4int ndiv =
G4int((fHighRange - c0 + Rmin)/step);
896 if (ndvmx > 255) ndvmx = 255;
897 if (ndiv > ndvmx && ndvmx > 0 ) ndiv = ndvmx;
901 G4double delta = std::abs((fHighRange - c0) - ndiv*step);
902 if (std::abs(c0 - fLowRange) > Rmin) {
904 = CreateEnvelope(shape, fHighRange-delta/2., c0+delta/2.,
Rpar, npar);
911 fNofDivisions = ndiv;
912 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]
CLHEP::Hep3Vector G4ThreeVector
G4DLLIMPORT 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
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)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)