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 "G4tgbPlaceParamSquare.hh"
00037 #include "G4RotationMatrix.hh"
00038 #include "G4VPhysicalVolume.hh"
00039 #include "G4tgrMessenger.hh"
00040 #include "G4tgrPlaceParameterisation.hh"
00041
00042
00043 G4tgbPlaceParamSquare::~G4tgbPlaceParamSquare()
00044 {
00045 }
00046
00047
00048
00049 G4tgbPlaceParamSquare::
00050 G4tgbPlaceParamSquare( G4tgrPlaceParameterisation* tgrParam )
00051 : G4tgbPlaceParameterisation(tgrParam)
00052 {
00053
00054 if( tgrParam->GetParamType() == "SQUARE" )
00055 {
00056 CheckNExtraData( tgrParam, 12, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
00057 theDirection1 = G4ThreeVector( tgrParam->GetExtraData()[6],
00058 tgrParam->GetExtraData()[7],
00059 tgrParam->GetExtraData()[8] );
00060 theDirection2 = G4ThreeVector( tgrParam->GetExtraData()[9],
00061 tgrParam->GetExtraData()[10],
00062 tgrParam->GetExtraData()[11] );
00063 theAxis = kZAxis;
00064 }
00065 else
00066 {
00067 CheckNExtraData( tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
00068 if( tgrParam->GetParamType() == "SQUARE_XY" )
00069 {
00070 theDirection1 = G4ThreeVector(1.,0.,0.);
00071 theDirection2 = G4ThreeVector(0.,1.,0.);
00072 theAxis = kZAxis;
00073 }
00074 else if( tgrParam->GetParamType() == "SQUARE_YZ" )
00075 {
00076 theDirection1 = G4ThreeVector(0.,1.,0.);
00077 theDirection2 = G4ThreeVector(0.,0.,1.);
00078 theAxis = kXAxis;
00079 }
00080 else if( tgrParam->GetParamType() == "SQUARE_XZ" )
00081 {
00082 theDirection1 = G4ThreeVector(1.,0.,0.);
00083 theDirection2 = G4ThreeVector(0.,0.,1.);
00084 theAxis = kYAxis;
00085 }
00086 }
00087
00088 if( theDirection1.mag() == 0. )
00089 {
00090 G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
00091 "InvalidSetup", FatalException, "Direction1 is zero !");
00092 }
00093 else
00094 {
00095 theDirection1 /= theDirection1.mag();
00096 }
00097 if( theDirection2.mag() == 0. )
00098 {
00099 G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
00100 "InvalidSetup", FatalException, "Direction2 is zero !");
00101 }
00102 else
00103 {
00104 theDirection2 /= theDirection2.mag();
00105 }
00106
00107 theNCopies1 = G4int(tgrParam->GetExtraData()[0]);
00108 theNCopies2 = G4int(tgrParam->GetExtraData()[1]);
00109 theStep1 = tgrParam->GetExtraData()[2];
00110 theStep2 = tgrParam->GetExtraData()[3];
00111 theOffset1 = tgrParam->GetExtraData()[4];
00112 theOffset2 = tgrParam->GetExtraData()[5];
00113
00114 theNCopies = theNCopies1 * theNCopies2;
00115 theTranslation = theOffset1*theDirection1 + theOffset2*theDirection2;
00116
00117 #ifdef G4VERBOSE
00118 if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00119 G4cout << "G4tgbPlaceParamSquare: no copies "
00120 << theNCopies << " = " << theNCopies1
00121 << " X " << theNCopies2 << G4endl
00122 << " offset1 " << theOffset1 << G4endl
00123 << " offset2 " << theOffset1 << G4endl
00124 << " step1 " << theStep1 << G4endl
00125 << " step2 " << theStep2 << G4endl
00126 << " direction1 " << theDirection1 << G4endl
00127 << " direction2 " << theDirection2 << G4endl
00128 << " translation " << theTranslation << G4endl;
00129 #endif
00130 }
00131
00132
00133
00134 void G4tgbPlaceParamSquare::
00135 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
00136 {
00137 #ifdef G4VERBOSE
00138 if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00139 {
00140 G4cout << " G4tgbPlaceParamSquare::ComputeTransformation():"
00141 << physVol->GetName() << G4endl
00142 << " no copies " << theNCopies << G4endl
00143 << " offset1 " << theOffset1 << G4endl
00144 << " offset2 " << theOffset2 << G4endl
00145 << " step1 " << theStep1 << G4endl
00146 << " step2 " << theStep2 << G4endl;
00147 }
00148 #endif
00149
00150 G4int copyNo1 = copyNo%theNCopies1;
00151 G4int copyNo2 = G4int(copyNo/theNCopies1);
00152 G4double posi1 = copyNo1*theStep1;
00153 G4double posi2 = copyNo2*theStep2;
00154 G4ThreeVector origin = posi1*theDirection1+ posi2*theDirection2;
00155 origin += theTranslation;
00156
00157 #ifdef G4VERBOSE
00158 if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00159 {
00160 G4cout << " G4tgbPlaceParamSquare::ComputeTransformation() - "
00161 << copyNo << " = " << copyNo1 << ", X " << copyNo2 << G4endl
00162 << " pos: " << origin << ", axis: " << theAxis << G4endl;
00163 }
00164 #endif
00165
00166 physVol->SetTranslation(origin);
00167 physVol->SetCopyNo( copyNo );
00168 physVol->SetRotation( theRotationMatrix );
00169 }