00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "G4tgbPlaceParamCircle.hh"
00037 #include "G4tgrPlaceParameterisation.hh"
00038 #include "G4ThreeVector.hh"
00039 #include "G4RotationMatrix.hh"
00040 #include "G4VPhysicalVolume.hh"
00041 #include "G4tgrUtils.hh"
00042 #include "G4tgrMessenger.hh"
00043
00044
00045 G4tgbPlaceParamCircle::~G4tgbPlaceParamCircle()
00046 {
00047 }
00048
00049
00050
00051 G4tgbPlaceParamCircle::
00052 G4tgbPlaceParamCircle( G4tgrPlaceParameterisation* tgrParam )
00053 : G4tgbPlaceParameterisation(tgrParam)
00054 {
00055
00056 if( tgrParam->GetParamType() == "CIRCLE" )
00057 {
00058 CheckNExtraData( tgrParam, 7, WLSIZE_EQ, "G4tgbPlaceParamCircle:");
00059 theCircleAxis = G4ThreeVector( tgrParam->GetExtraData()[4],
00060 tgrParam->GetExtraData()[5],
00061 tgrParam->GetExtraData()[6] );
00062
00063 G4ThreeVector zaxis(0.,0.,-1.);
00064 if( zaxis.cross(theCircleAxis).mag() > 1.E-6 )
00065 {
00066 theDirInPlane = zaxis.cross(theCircleAxis);
00067 }
00068 else
00069 {
00070 theDirInPlane = theCircleAxis.cross(G4ThreeVector(0.,-1.,0.));
00071 }
00072 theAxis = kZAxis;
00073 }
00074 else
00075 {
00076 CheckNExtraData( tgrParam, 4, WLSIZE_EQ, "G4tgbPlaceParamCircle:");
00077 if( tgrParam->GetParamType() == "CIRCLE_XY" ) {
00078 theCircleAxis = G4ThreeVector(0.,0.,1.);
00079 theDirInPlane = G4ThreeVector(1.,0.,0.);
00080 theAxis = kZAxis;
00081 } else if( tgrParam->GetParamType() == "CIRCLE_XZ" ) {
00082 theCircleAxis = G4ThreeVector(0.,1.,0.);
00083 theDirInPlane = G4ThreeVector(1.,0.,0.);
00084 theAxis = kYAxis;
00085 } else if( tgrParam->GetParamType() == "CIRCLE_YZ" ) {
00086 theCircleAxis = G4ThreeVector(1.,0.,0.);
00087 theDirInPlane = G4ThreeVector(0.,1.,0.);
00088 theAxis = kXAxis;
00089 }
00090 }
00091
00092 if( theCircleAxis.mag() == 0. )
00093 {
00094 G4Exception("G4tgbPlaceParamCircle::G4tgbPlaceParamCircle()",
00095 "InvalidSetup", FatalException, "Circle axis is zero !");
00096 }
00097 theCircleAxis /= theCircleAxis.mag();
00098
00099 theAxis = kZAxis;
00100
00101 theNCopies = G4int(tgrParam->GetExtraData()[0]);
00102 theStep = tgrParam->GetExtraData()[1];
00103 theOffset = tgrParam->GetExtraData()[2];
00104 theRadius = tgrParam->GetExtraData()[3];
00105
00106 #ifdef G4VERBOSE
00107 if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00108 {
00109 G4cout << " G4tgbPlaceParamCircle::G4tgbPlaceParamCircle():" << G4endl
00110 << " param type " << tgrParam->GetParamType() << G4endl
00111 << " no copies - " << theNCopies << G4endl
00112 << " step - " << theStep << G4endl
00113 << " offset - " << theOffset << G4endl
00114 << " radius - " << theRadius << G4endl
00115 << " circle axis - " << theCircleAxis << G4endl
00116 << " dir in plane - " << theDirInPlane << G4endl;
00117 }
00118 #endif
00119 }
00120
00121
00122
00123 void G4tgbPlaceParamCircle::
00124 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
00125 {
00126 G4double posi = theOffset + copyNo*theStep;
00127 G4ThreeVector origin = theDirInPlane * theRadius;
00128 origin.rotate( posi, theCircleAxis );
00129
00130
00131 G4RotationMatrix rm;
00132 rm.rotate( -posi, theCircleAxis );
00133
00134
00135 physVol->SetTranslation(origin);
00136 G4RotationMatrix* pvRm = physVol->GetRotation();
00137 if( pvRm == 0 )
00138 {
00139 pvRm = new G4RotationMatrix;
00140 }
00141 *pvRm = *theRotationMatrix * rm;
00142 physVol->SetRotation(pvRm);
00143 physVol->SetCopyNo( copyNo );
00144
00145 #ifdef G4VERBOSE
00146 if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00147 {
00148 G4cout << " G4tgbPlaceParamCircle::ComputeTransformation():"
00149 << physVol->GetName() << G4endl
00150 << " no copies - " << theNCopies << G4endl
00151 << " centre - " << origin << G4endl
00152 << " rotation-matrix - " << *pvRm << G4endl;
00153 }
00154 #endif
00155 }