Changeset 1228 for trunk/source/geometry/divisions/src
- Timestamp:
- Jan 8, 2010, 11:56:51 AM (14 years ago)
- Location:
- trunk/source/geometry/divisions/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/geometry/divisions/src/G4PVDivision.cc
r1010 r1228 26 26 // 27 27 // $Id: G4PVDivision.cc,v 1.22 2008/12/03 16:41:45 arce Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4PVDivision Implementation file -
trunk/source/geometry/divisions/src/G4PVDivisionFactory.cc
r1010 r1228 26 26 // 27 27 // $Id: G4PVDivisionFactory.cc,v 1.2 2006/06/29 18:18:33 gunter Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4PVDivisionFactory Implementation file -
trunk/source/geometry/divisions/src/G4ParameterisationBox.cc
r1010 r1228 26 26 // 27 27 // $Id: G4ParameterisationBox.cc,v 1.10 2006/06/29 18:18:35 gunter Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4ParameterisationBox Implementation file -
trunk/source/geometry/divisions/src/G4ParameterisationCons.cc
r1010 r1228 26 26 // 27 27 // $Id: G4ParameterisationCons.cc,v 1.9 2006/06/29 18:18:38 gunter Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4ParameterisationCons Implementation file -
trunk/source/geometry/divisions/src/G4ParameterisationPara.cc
r1010 r1228 26 26 // 27 27 // $Id: G4ParameterisationPara.cc,v 1.11 2006/06/29 18:18:42 gunter Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4ParameterisationPara Implementation file -
trunk/source/geometry/divisions/src/G4ParameterisationPolycone.cc
r1010 r1228 25 25 // 26 26 // 27 // $Id: G4ParameterisationPolycone.cc,v 1.1 5 2006/06/29 18:18:44 gunterExp $28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$27 // $Id: G4ParameterisationPolycone.cc,v 1.17 2009/05/18 19:30:29 ivana Exp $ 28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4ParameterisationPolycone Implementation file … … 355 355 G4double width, G4double offset, 356 356 G4VSolid* msolid, DivisionType divType) 357 : G4VParameterisationPolycone( axis, nDiv, width, offset, msolid, divType ) 357 : G4VParameterisationPolycone( axis, nDiv, width, offset, msolid, divType ), 358 fNSegment(0), 359 fOrigParamMother(((G4Polycone*)fmotherSolid)->GetOriginalParameters()) 358 360 { 359 361 … … 361 363 SetType( "DivisionPolyconeZ" ); 362 364 363 G4Polycone* msol = (G4Polycone*)(fmotherSolid);364 G4PolyconeHistorical* origparamMother = msol->GetOriginalParameters();365 366 365 if( divType == DivWIDTH ) 367 366 { 368 367 fnDiv = 369 CalculateNDiv( origparamMother->Z_values[origparamMother->Num_z_planes-1]370 - origparamMother->Z_values[0] , width, offset );368 CalculateNDiv( fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 369 - fOrigParamMother->Z_values[0] , width, offset ); 371 370 } 372 371 else if( divType == DivNDIV ) 373 372 { 374 373 fwidth = 375 CalculateNDiv( origparamMother->Z_values[origparamMother->Num_z_planes-1]376 - origparamMother->Z_values[0] , nDiv, offset );374 CalculateNDiv( fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 375 - fOrigParamMother->Z_values[0] , nDiv, offset ); 377 376 } 378 377 … … 394 393 395 394 //------------------------------------------------------------------------ 395 G4double G4ParameterisationPolyconeZ::GetR(G4double z, 396 G4double z1, G4double r1, 397 G4double z2, G4double r2) const 398 { 399 // Linear parameterisation: 400 // r = az + b 401 // a = (r1 - r2)/(z1-z2) 402 // b = r1 - a*z1 403 404 return (r1-r2)/(z1-z2)*z + ( r1 - (r1-r2)/(z1-z2)*z1 ) ; 405 } 406 407 //------------------------------------------------------------------------ 408 G4double G4ParameterisationPolyconeZ::GetRmin(G4double z, G4int nseg) const 409 { 410 // Get Rmin in the given z position for the given polycone segment 411 412 return GetR(z, 413 fOrigParamMother->Z_values[nseg], 414 fOrigParamMother->Rmin[nseg], 415 fOrigParamMother->Z_values[nseg+1], 416 fOrigParamMother->Rmin[nseg+1]); 417 } 418 419 //------------------------------------------------------------------------ 420 G4double G4ParameterisationPolyconeZ::GetRmax(G4double z, G4int nseg) const 421 { 422 // Get Rmax in the given z position for the given polycone segment 423 424 return GetR(z, 425 fOrigParamMother->Z_values[nseg], 426 fOrigParamMother->Rmax[nseg], 427 fOrigParamMother->Z_values[nseg+1], 428 fOrigParamMother->Rmax[nseg+1]); 429 } 430 431 //------------------------------------------------------------------------ 396 432 G4double G4ParameterisationPolyconeZ::GetMaxParameter() const 397 433 { 398 G4Polycone* msol = (G4Polycone*)(fmotherSolid); 399 G4PolyconeHistorical* origparamMother = msol->GetOriginalParameters(); 400 return std::abs (origparamMother->Z_values[origparamMother->Num_z_planes-1] 401 -origparamMother->Z_values[0]); 434 return std::abs (fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 435 -fOrigParamMother->Z_values[0]); 402 436 } 403 437 … … 406 440 { 407 441 G4VDivisionParameterisation::CheckParametersValidity(); 408 409 G4Polycone* msol = (G4Polycone*)(fmotherSolid); 410 411 if( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) 412 { 413 G4cerr << "WARNING - " 414 << "G4ParameterisationPolyconeZ::CheckParametersValidity()" 415 << G4endl 416 << " Solid " << msol->GetName() << G4endl 417 << " Division along Z will be done splitting in the " 418 << "defined z_planes." << G4endl 419 << " WIDTH will not be used !" << G4endl; 420 } 421 422 if( foffset != 0. ) 423 { 424 G4cerr << "WARNING - " 425 << "G4ParameterisationPolyconeZ::CheckParametersValidity()" 426 << G4endl 427 << " Solid " << msol->GetName() << G4endl 428 << " Division along Z will be done splitting in the " 429 << "defined z_planes." << G4endl 430 << " OFFSET will not be used !" << G4endl; 431 } 432 433 G4PolyconeHistorical* origparamMother = msol->GetOriginalParameters(); 434 435 if( origparamMother->Num_z_planes-1 != fnDiv ) 436 { 437 G4cerr << "ERROR - " 438 << "G4ParameterisationPolyconeZ::CheckParametersValidity()" 439 << G4endl 440 << " Division along Z will be done splitting in the defined" 441 << G4endl 442 << " z_planes, i.e, the number of division would be :" 443 << " " << origparamMother->Num_z_planes-1 444 << " instead of " << fnDiv << " !" 445 << G4endl; 446 G4Exception("G4ParameterisationPolyconeZ::CheckParametersValidity()", 442 443 // Division will be following the mother polycone segments 444 if( fDivisionType == DivNDIV ) { 445 if( fnDiv > fOrigParamMother->Num_z_planes-1 ) { 446 G4cerr << "ERROR - " 447 << "G4ParameterisationPolyconeZ::CheckParametersValidity()" 448 << G4endl 449 << " Division along Z will be done splitting in the defined" 450 << G4endl 451 << " z_planes, i.e, the number of division would be :" 452 << " " << fOrigParamMother->Num_z_planes-1 453 << " instead of " << fnDiv << " !" 454 << G4endl; 455 G4Exception("G4ParameterisationPolyconeZ::CheckParametersValidity()", 447 456 "IllegalConstruct", FatalException, 448 457 "Not supported configuration."); 449 } 458 } 459 } 460 461 // Division will be done within one polycone segment 462 // with applying given width and offset 463 if( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) { 464 // Check if divided region does not span over more 465 // than one z segment 466 467 G4int isegstart = -1; // number of the segment containing start position 468 G4int isegend = -1; // number of the segment containing end position 469 470 if ( ! fReflectedSolid ) { 471 // The start/end position of the divided region 472 G4double zstart 473 = fOrigParamMother->Z_values[0] + foffset; 474 G4double zend 475 = fOrigParamMother->Z_values[0] + foffset + fnDiv* fwidth; 476 477 G4int counter = 0; 478 while ( isegend < 0 && counter < fOrigParamMother->Num_z_planes-1 ) { 479 // first segment 480 if ( zstart >= fOrigParamMother->Z_values[counter] && 481 zstart < fOrigParamMother->Z_values[counter+1] ) { 482 isegstart = counter; 483 } 484 // last segment 485 if ( zend > fOrigParamMother->Z_values[counter] && 486 zend <= fOrigParamMother->Z_values[counter+1] ) { 487 isegend = counter; 488 } 489 ++counter; 490 } 491 } 492 else { 493 // The start/end position of the divided region 494 G4double zstart 495 = fOrigParamMother->Z_values[0] - foffset; 496 G4double zend 497 = fOrigParamMother->Z_values[0] - ( foffset + fnDiv* fwidth); 498 499 G4int counter = 0; 500 while ( isegend < 0 && counter < fOrigParamMother->Num_z_planes-1 ) { 501 // first segment 502 if ( zstart <= fOrigParamMother->Z_values[counter] && 503 zstart > fOrigParamMother->Z_values[counter+1] ) { 504 isegstart = counter; 505 } 506 // last segment 507 if ( zend < fOrigParamMother->Z_values[counter] && 508 zend >= fOrigParamMother->Z_values[counter+1] ) { 509 isegend = counter; 510 } 511 ++counter; 512 } 513 } 514 515 516 if ( isegstart != isegend ) { 517 G4cerr << "WARNING - " 518 << "G4ParameterisationPolyconeZ::CheckParametersValidity()" 519 << G4endl 520 << " Division with user defined width." << G4endl 521 << " Solid " << fmotherSolid->GetName() << G4endl 522 << " Divided region is not between two z planes." 523 << G4endl; 524 525 G4Exception("G4ParameterisationPolyconeZ::CheckParametersValidity()", 526 "IllegalConstruct", FatalException, 527 "Not supported configuration."); 528 } 529 530 fNSegment = isegstart; 531 } 450 532 } 451 533 … … 455 537 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const 456 538 { 457 G4Polycone* msol = (G4Polycone*)(GetMotherSolid()); 458 459 //----- set translation: along Z axis 460 G4PolyconeHistorical* origparamMother = msol->GetOriginalParameters(); 461 G4double posi = (origparamMother->Z_values[copyNo] 462 + origparamMother->Z_values[copyNo+1])/2; 463 G4ThreeVector origin(0.,0.,posi); 464 physVol->SetTranslation( origin ); 539 if ( fDivisionType == DivNDIV ) { 540 // The position of the centre of copyNo-th mother polycone segment 541 G4double posi 542 = ( fOrigParamMother->Z_values[copyNo] 543 + fOrigParamMother->Z_values[copyNo+1])/2; 544 physVol->SetTranslation( G4ThreeVector(0, 0, posi) ); 545 } 546 547 if ( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) { 548 // The position of the centre of copyNo-th division 549 G4double posi = fOrigParamMother->Z_values[0]; 550 551 if ( ! fReflectedSolid ) 552 posi += foffset + (2*copyNo + 1) * fwidth/2.; 553 else 554 posi -= foffset + (2*copyNo + 1) * fwidth/2.; 555 556 physVol->SetTranslation( G4ThreeVector(0, 0, posi) ); 557 } 465 558 466 559 //----- calculate rotation matrix: unit … … 494 587 const G4VPhysicalVolume* ) const 495 588 { 496 // only for mother number of planes = 2!! 497 // 498 G4Polycone* msol = (G4Polycone*)(fmotherSolid); 499 500 G4PolyconeHistorical* origparamMother = msol->GetOriginalParameters(); 501 G4PolyconeHistorical origparam( *origparamMother ); 502 503 G4double posi = (origparamMother->Z_values[copyNo] 504 + origparamMother->Z_values[copyNo+1])/2; 505 506 origparam.Num_z_planes = 2; 507 origparam.Z_values[0] = origparamMother->Z_values[copyNo] - posi; 508 origparam.Z_values[1] = origparamMother->Z_values[copyNo+1] - posi; 509 origparam.Rmin[0] = origparamMother->Rmin[copyNo]; 510 origparam.Rmin[1] = origparamMother->Rmin[copyNo+1]; 511 origparam.Rmax[0] = origparamMother->Rmax[copyNo]; 512 origparam.Rmax[1] = origparamMother->Rmax[copyNo+1]; 589 590 // Define division solid 591 G4PolyconeHistorical origparam; 592 G4int nz = 2; 593 origparam.Num_z_planes = nz; 594 origparam.Start_angle = fOrigParamMother->Start_angle; 595 origparam.Opening_angle = fOrigParamMother->Opening_angle; 596 597 // Define division solid z sections 598 origparam.Z_values = new G4double[nz]; 599 origparam.Rmin = new G4double[nz]; 600 origparam.Rmax = new G4double[nz]; 601 602 if ( fDivisionType == DivNDIV ) { 603 // The position of the centre of copyNo-th mother polycone segment 604 G4double posi = (fOrigParamMother->Z_values[copyNo] 605 + fOrigParamMother->Z_values[copyNo+1])/2; 606 607 origparam.Z_values[0] = fOrigParamMother->Z_values[copyNo] - posi; 608 origparam.Z_values[1] = fOrigParamMother->Z_values[copyNo+1] - posi; 609 origparam.Rmin[0] = fOrigParamMother->Rmin[copyNo]; 610 origparam.Rmin[1] = fOrigParamMother->Rmin[copyNo+1]; 611 origparam.Rmax[0] = fOrigParamMother->Rmax[copyNo]; 612 origparam.Rmax[1] = fOrigParamMother->Rmax[copyNo+1]; 613 } 614 615 if ( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) { 616 if ( ! fReflectedSolid ) { 617 origparam.Z_values[0] = - fwidth/2.; 618 origparam.Z_values[1] = fwidth/2.; 619 620 // The position of the centre of copyNo-th division 621 G4double posi 622 = fOrigParamMother->Z_values[0] + foffset + (2*copyNo + 1) * fwidth/2.; 623 624 // The first and last z sides z values 625 G4double zstart = posi - fwidth/2.; 626 G4double zend = posi + fwidth/2.; 627 origparam.Rmin[0] = GetRmin(zstart, fNSegment); 628 origparam.Rmax[0] = GetRmax(zstart, fNSegment); 629 origparam.Rmin[1] = GetRmin(zend, fNSegment); 630 origparam.Rmax[1] = GetRmax(zend, fNSegment); 631 } 632 else { 633 origparam.Z_values[0] = fwidth/2.; 634 origparam.Z_values[1] = - fwidth/2.; 635 636 // The position of the centre of copyNo-th division 637 G4double posi 638 = fOrigParamMother->Z_values[0] - ( foffset + (2*copyNo + 1) * fwidth/2.); 639 640 // The first and last z sides z values 641 G4double zstart = posi + fwidth/2.; 642 G4double zend = posi - fwidth/2.; 643 origparam.Rmin[0] = GetRmin(zstart, fNSegment); 644 origparam.Rmax[0] = GetRmax(zstart, fNSegment); 645 origparam.Rmin[1] = GetRmin(zend, fNSegment); 646 origparam.Rmax[1] = GetRmax(zend, fNSegment); 647 } 648 649 // It can happen due to rounding errors 650 if ( origparam.Rmin[0] < 0.0 ) origparam.Rmin[0] = 0.0; 651 if ( origparam.Rmin[nz-1] < 0.0 ) origparam.Rmin[1] = 0.0; 652 } 513 653 514 654 pcone.SetOriginalParameters(&origparam); // copy values & transfer pointers -
trunk/source/geometry/divisions/src/G4ParameterisationPolyhedra.cc
r1010 r1228 25 25 // 26 26 // 27 // $Id: G4ParameterisationPolyhedra.cc,v 1.1 6 2007/05/18 07:27:23 gcosmoExp $28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$27 // $Id: G4ParameterisationPolyhedra.cc,v 1.19 2009/05/20 08:35:52 ivana Exp $ 28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4ParameterisationPolyhedra Implementation file … … 288 288 if( divType == DivWIDTH ) 289 289 { 290 fnDiv = CalculateNDiv( deltaPhi, width, offset ); 291 } 292 else if( divType == DivNDIV ) 293 { 294 fwidth = CalculateWidth( deltaPhi, nDiv, offset ); 295 } 290 fnDiv = msol->GetNumSide(); 291 } 292 293 fwidth = CalculateWidth( deltaPhi, fnDiv, 0.0 ); 296 294 297 295 #ifdef G4DIVDEBUG … … 348 346 G4PolyhedraHistorical* origparamMother = msol->GetOriginalParameters(); 349 347 350 if( origparamMother->numSide != fnDiv )348 if( origparamMother->numSide != fnDiv && fDivisionType != DivWIDTH) 351 349 { 352 350 G4cerr << "ERROR - " … … 433 431 G4double width, G4double offset, 434 432 G4VSolid* msolid, DivisionType divType ) 435 : G4VParameterisationPolyhedra( axis, nDiv, width, offset, msolid, divType ) 433 : G4VParameterisationPolyhedra( axis, nDiv, width, offset, msolid, divType ), 434 fNSegment(0), 435 fOrigParamMother(((G4Polyhedra*)fmotherSolid)->GetOriginalParameters()) 436 436 { 437 437 CheckParametersValidity(); 438 438 SetType( "DivisionPolyhedraZ" ); 439 439 440 G4Polyhedra* msol = (G4Polyhedra*)(fmotherSolid);441 G4PolyhedraHistorical* origparamMother = msol->GetOriginalParameters();442 443 440 if( divType == DivWIDTH ) 444 441 { 445 442 fnDiv = 446 CalculateNDiv( origparamMother->Z_values[origparamMother->Num_z_planes-1]447 - origparamMother->Z_values[0] , width, offset );443 CalculateNDiv( fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 444 - fOrigParamMother->Z_values[0] , width, offset ); 448 445 } 449 446 else if( divType == DivNDIV ) 450 447 { 451 448 fwidth = 452 CalculateNDiv( origparamMother->Z_values[origparamMother->Num_z_planes-1]453 - origparamMother->Z_values[0] , nDiv, offset );449 CalculateNDiv( fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 450 - fOrigParamMother->Z_values[0] , nDiv, offset ); 454 451 } 455 452 … … 471 468 472 469 //------------------------------------------------------------------------ 470 G4double G4ParameterisationPolyhedraZ::GetR(G4double z, 471 G4double z1, G4double r1, 472 G4double z2, G4double r2) const 473 { 474 // Linear parameterisation: 475 // r = az + b 476 // a = (r1 - r2)/(z1-z2) 477 // b = r1 - a*z1 478 479 return (r1-r2)/(z1-z2)*z + ( r1 - (r1-r2)/(z1-z2)*z1 ) ; 480 } 481 482 //------------------------------------------------------------------------ 483 G4double G4ParameterisationPolyhedraZ::GetRmin(G4double z, G4int nseg) const 484 { 485 // Get Rmin in the given z position for the given polyhedra segment 486 487 return GetR(z, 488 fOrigParamMother->Z_values[nseg], 489 fOrigParamMother->Rmin[nseg], 490 fOrigParamMother->Z_values[nseg+1], 491 fOrigParamMother->Rmin[nseg+1]); 492 } 493 494 //------------------------------------------------------------------------ 495 G4double G4ParameterisationPolyhedraZ::GetRmax(G4double z, G4int nseg) const 496 { 497 // Get Rmax in the given z position for the given polyhedra segment 498 499 return GetR(z, 500 fOrigParamMother->Z_values[nseg], 501 fOrigParamMother->Rmax[nseg], 502 fOrigParamMother->Z_values[nseg+1], 503 fOrigParamMother->Rmax[nseg+1]); 504 } 505 506 //------------------------------------------------------------------------ 473 507 G4double G4ParameterisationPolyhedraZ::GetMaxParameter() const 474 508 { 475 G4Polyhedra* msol = (G4Polyhedra*)(fmotherSolid); 476 G4PolyhedraHistorical* origparamMother = msol->GetOriginalParameters(); 477 return std::abs (origparamMother->Z_values[origparamMother->Num_z_planes-1] 478 -origparamMother->Z_values[0]); 509 return std::abs (fOrigParamMother->Z_values[fOrigParamMother->Num_z_planes-1] 510 -fOrigParamMother->Z_values[0]); 479 511 } 480 512 … … 484 516 G4VDivisionParameterisation::CheckParametersValidity(); 485 517 486 G4Polyhedra* msol = (G4Polyhedra*)(fmotherSolid); 487 488 if( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) 489 { 490 G4cerr << "WARNING - " 491 << "G4ParameterisationPolyhedraZ::CheckParametersValidity()" 492 << G4endl 493 << " Solid " << msol->GetName() << G4endl 494 << " Division along Z will be done splitting " 495 << "in the defined z_planes." << G4endl 496 << " WIDTH will not be used !" << G4endl; 497 } 498 499 if( foffset != 0. ) 500 { 501 G4cerr << "WARNING - " 502 << "G4ParameterisationPolyhedraZ::CheckParametersValidity()" 503 << G4endl 504 << " Solid " << msol->GetName() << G4endl 505 << " Division along Z will be done splitting " 506 << "in the defined z_planes." << G4endl 507 << " OFFSET will not be used !" << G4endl; 508 } 509 510 G4PolyhedraHistorical* origparamMother = msol->GetOriginalParameters(); 511 512 if( origparamMother->Num_z_planes-1 != fnDiv ) 513 { 514 G4cerr << "ERROR - " 515 << "G4ParameterisationPolyhedraZ::CheckParametersValidity()" 516 << G4endl 517 << " Division along Z will be done splitting in the defined" 518 << G4endl 519 << " z_planes, i.e, the number of division would be :" 520 << " " << origparamMother->Num_z_planes-1 521 << " instead of " << fnDiv << " !" 522 << G4endl; 523 G4Exception("G4ParameterisationPolyhedraZ::CheckParametersValidity()", 524 "IllegalConstruct", FatalException, 525 "Not supported configuration."); 526 } 518 // Division will be following the mother polyhedra segments 519 if( fDivisionType == DivNDIV ) { 520 if( fOrigParamMother->Num_z_planes-1 != fnDiv ) { 521 G4cerr << "ERROR - " 522 << "G4ParameterisationPolyhedraZ::CheckParametersValidity()" 523 << G4endl 524 << " Division along Z will be done splitting in the defined" 525 << G4endl 526 << " z_planes, i.e, the number of division would be :" 527 << " " << fOrigParamMother->Num_z_planes-1 528 << " instead of " << fnDiv << " !" 529 << G4endl; 530 G4Exception("G4ParameterisationPolyhedraZ::CheckParametersValidity()", 531 "IllegalConstruct", FatalException, 532 "Not supported configuration."); 533 } 534 } 535 536 // Division will be done within one polyhedra segment 537 // with applying given width and offset 538 if( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) { 539 // Check if divided region does not span over more 540 // than one z segment 541 542 G4int isegstart = -1; // number of the segment containing start position 543 G4int isegend = -1; // number of the segment containing end position 544 545 if ( ! fReflectedSolid ) { 546 // The start/end position of the divided region 547 G4double zstart 548 = fOrigParamMother->Z_values[0] + foffset; 549 G4double zend 550 = fOrigParamMother->Z_values[0] + foffset + fnDiv* fwidth; 551 552 G4int counter = 0; 553 while ( isegend < 0 && counter < fOrigParamMother->Num_z_planes-1 ) { 554 // first segment 555 if ( zstart >= fOrigParamMother->Z_values[counter] && 556 zstart < fOrigParamMother->Z_values[counter+1] ) { 557 isegstart = counter; 558 } 559 // last segment 560 if ( zend > fOrigParamMother->Z_values[counter] && 561 zend <= fOrigParamMother->Z_values[counter+1] ) { 562 isegend = counter; 563 } 564 ++counter; 565 } 566 } 567 else { 568 // The start/end position of the divided region 569 G4double zstart 570 = fOrigParamMother->Z_values[0] - foffset; 571 G4double zend 572 = fOrigParamMother->Z_values[0] - ( foffset + fnDiv* fwidth); 573 574 G4int counter = 0; 575 while ( isegend < 0 && counter < fOrigParamMother->Num_z_planes-1 ) { 576 // first segment 577 if ( zstart <= fOrigParamMother->Z_values[counter] && 578 zstart > fOrigParamMother->Z_values[counter+1] ) { 579 isegstart = counter; 580 } 581 // last segment 582 if ( zend < fOrigParamMother->Z_values[counter] && 583 zend >= fOrigParamMother->Z_values[counter+1] ) { 584 isegend = counter; 585 } 586 ++counter; 587 } 588 } 589 590 if ( isegstart != isegend ) { 591 G4cerr << "WARNING - " 592 << "G4ParameterisationPolyhedraZ::CheckParametersValidity()" 593 << G4endl 594 << " Division with user defined width." << G4endl 595 << " Solid " << fmotherSolid->GetName() << G4endl 596 << " Divided region is not between two z planes." 597 << G4endl; 598 599 G4Exception("G4ParameterisationPolyhedraZ::CheckParametersValidity()", 600 "IllegalConstruct", FatalException, 601 "Not supported configuration."); 602 } 603 604 fNSegment = isegstart; 605 } 527 606 } 528 607 … … 532 611 ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol) const 533 612 { 534 G4Polyhedra* msol = (G4Polyhedra*)(GetMotherSolid()); 535 536 //----- set translation: along Z axis 537 G4PolyhedraHistorical* origparamMother = msol->GetOriginalParameters(); 538 G4double posi = (origparamMother->Z_values[copyNo] 539 + origparamMother->Z_values[copyNo+1])/2; 540 G4ThreeVector origin(0.,0.,posi); 541 physVol->SetTranslation( origin ); 613 if ( fDivisionType == DivNDIV ) { 614 // The position of the centre of copyNo-th mother polycone segment 615 G4double posi = ( fOrigParamMother->Z_values[copyNo] 616 + fOrigParamMother->Z_values[copyNo+1])/2; 617 physVol->SetTranslation( G4ThreeVector(0, 0, posi) ); 618 } 619 620 if ( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) { 621 // The position of the centre of copyNo-th division 622 623 G4double posi = fOrigParamMother->Z_values[0]; 624 625 if ( ! fReflectedSolid ) 626 posi += foffset + (2*copyNo + 1) * fwidth/2.; 627 else 628 posi -= foffset + (2*copyNo + 1) * fwidth/2.; 629 630 physVol->SetTranslation( G4ThreeVector(0, 0, posi) ); 631 } 542 632 543 633 //----- calculate rotation matrix: unit … … 571 661 const G4VPhysicalVolume* ) const 572 662 { 573 // only for mother number of planes = 2!! 574 // 575 G4Polyhedra* msol = (G4Polyhedra*)(fmotherSolid); 576 577 G4PolyhedraHistorical* origparamMother = msol->GetOriginalParameters(); 578 G4PolyhedraHistorical origparam( *origparamMother ); 579 580 G4double posi = (origparamMother->Z_values[copyNo] 581 + origparamMother->Z_values[copyNo+1])/2; 582 583 origparam.Num_z_planes = 2; 584 origparam.Z_values[0] = origparamMother->Z_values[copyNo] - posi; 585 origparam.Z_values[1] = origparamMother->Z_values[copyNo+1] - posi; 586 origparam.Rmin[0] = origparamMother->Rmin[copyNo]; 587 origparam.Rmin[1] = origparamMother->Rmin[copyNo+1]; 588 origparam.Rmax[0] = origparamMother->Rmax[copyNo]; 589 origparam.Rmax[1] = origparamMother->Rmax[copyNo+1]; 663 // Define division solid 664 G4PolyhedraHistorical origparam; 665 G4int nz = 2; 666 origparam.Num_z_planes = nz; 667 origparam.numSide = fOrigParamMother->numSide; 668 origparam.Start_angle = fOrigParamMother->Start_angle; 669 origparam.Opening_angle = fOrigParamMother->Opening_angle; 670 671 // Define division solid z sections 672 origparam.Z_values = new G4double[nz]; 673 origparam.Rmin = new G4double[nz]; 674 origparam.Rmax = new G4double[nz]; 675 origparam.Z_values[0] = - fwidth/2.; 676 origparam.Z_values[1] = fwidth/2.; 677 678 if ( fDivisionType == DivNDIV ) { 679 // The position of the centre of copyNo-th mother polycone segment 680 G4double posi = ( fOrigParamMother->Z_values[copyNo] 681 + fOrigParamMother->Z_values[copyNo+1])/2; 682 683 origparam.Z_values[0] = fOrigParamMother->Z_values[copyNo] - posi; 684 origparam.Z_values[1] = fOrigParamMother->Z_values[copyNo+1] - posi; 685 origparam.Rmin[0] = fOrigParamMother->Rmin[copyNo]; 686 origparam.Rmin[1] = fOrigParamMother->Rmin[copyNo+1]; 687 origparam.Rmax[0] = fOrigParamMother->Rmax[copyNo]; 688 origparam.Rmax[1] = fOrigParamMother->Rmax[copyNo+1]; 689 } 690 691 if ( fDivisionType == DivNDIVandWIDTH || fDivisionType == DivWIDTH ) { 692 if ( ! fReflectedSolid ) { 693 origparam.Z_values[0] = - fwidth/2.; 694 origparam.Z_values[1] = fwidth/2.; 695 696 // The position of the centre of copyNo-th division 697 G4double posi 698 = fOrigParamMother->Z_values[0] + foffset + (2*copyNo + 1) * fwidth/2.; 699 700 // The first and last z sides z values 701 G4double zstart = posi - fwidth/2.; 702 G4double zend = posi + fwidth/2.; 703 origparam.Rmin[0] = GetRmin(zstart, fNSegment); 704 origparam.Rmax[0] = GetRmax(zstart, fNSegment); 705 origparam.Rmin[1] = GetRmin(zend, fNSegment); 706 origparam.Rmax[1] = GetRmax(zend, fNSegment); 707 } 708 else { 709 origparam.Z_values[0] = fwidth/2.; 710 origparam.Z_values[1] = - fwidth/2.; 711 712 // The position of the centre of copyNo-th division 713 G4double posi 714 = fOrigParamMother->Z_values[0] - ( foffset + (2*copyNo + 1) * fwidth/2.); 715 716 // The first and last z sides z values 717 G4double zstart = posi + fwidth/2.; 718 G4double zend = posi - fwidth/2.; 719 origparam.Rmin[0] = GetRmin(zstart, fNSegment); 720 origparam.Rmax[0] = GetRmax(zstart, fNSegment); 721 origparam.Rmin[1] = GetRmin(zend, fNSegment); 722 origparam.Rmax[1] = GetRmax(zend, fNSegment); 723 } 724 725 // It can happen due to rounding errors 726 if ( origparam.Rmin[0] < 0.0 ) origparam.Rmin[0] = 0.0; 727 if ( origparam.Rmin[nz-1] < 0.0 ) origparam.Rmin[1] = 0.0; 728 } 590 729 591 730 phedra.SetOriginalParameters(&origparam); // copy values & transfer pointers -
trunk/source/geometry/divisions/src/G4ParameterisationTrd.cc
r1010 r1228 26 26 // 27 27 // $Id: G4ParameterisationTrd.cc,v 1.16 2008/12/18 12:57:20 gunter Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4ParameterisationTrd Implementation file -
trunk/source/geometry/divisions/src/G4ParameterisationTubs.cc
r1010 r1228 26 26 // 27 27 // $Id: G4ParameterisationTubs.cc,v 1.8 2006/06/29 18:18:50 gunter Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4ParameterisationTubs Implementation file -
trunk/source/geometry/divisions/src/G4VDivisionParameterisation.cc
r1010 r1228 26 26 // 27 27 // $Id: G4VDivisionParameterisation.cc,v 1.14 2008/12/03 16:41:15 arce Exp $ 28 // GEANT4 tag $Name: geant4-09-0 2-ref-02$28 // GEANT4 tag $Name: geant4-09-03 $ 29 29 // 30 30 // class G4VDivisionParameterisation Implementation file
Note: See TracChangeset
for help on using the changeset viewer.