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 "G4tgbPlaceParamLinear.hh"
00037 #include "G4RotationMatrix.hh"
00038 #include "G4VPhysicalVolume.hh"
00039 #include "G4tgrMessenger.hh"
00040 #include "G4tgrPlaceParameterisation.hh"
00041
00042
00043 G4tgbPlaceParamLinear::~G4tgbPlaceParamLinear()
00044 {
00045 }
00046
00047
00048
00049 G4tgbPlaceParamLinear::
00050 G4tgbPlaceParamLinear( G4tgrPlaceParameterisation* tgrParam )
00051 : G4tgbPlaceParameterisation(tgrParam)
00052 {
00053
00054 if( tgrParam->GetParamType() == "LINEAR" )
00055 {
00056 CheckNExtraData( tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamLinear:");
00057 theDirection = G4ThreeVector( tgrParam->GetExtraData()[3],
00058 tgrParam->GetExtraData()[4],
00059 tgrParam->GetExtraData()[5] );
00060 theAxis = kZAxis;
00061 }
00062 else
00063 {
00064 CheckNExtraData( tgrParam, 3, WLSIZE_EQ, "G4tgbPlaceParamLinear:");
00065 if( tgrParam->GetParamType() == "LINEAR_X" ) {
00066 theDirection = G4ThreeVector(1.,0.,0.);
00067 theAxis = kXAxis;
00068 } else if( tgrParam->GetParamType() == "LINEAR_Y" ) {
00069 theDirection = G4ThreeVector(0.,1.,0.);
00070 theAxis = kYAxis;
00071 } else if( tgrParam->GetParamType() == "LINEAR_Z" ) {
00072 theDirection = G4ThreeVector(0.,0.,1.);
00073 theAxis = kZAxis;
00074 }
00075 }
00076
00077 if( theDirection.mag() == 0. )
00078 {
00079 G4Exception("G4tgbPlaceParamLinear::G4tgbPlaceParamLinear()",
00080 "InvalidSetup", FatalException, "Direction is zero !");
00081 }
00082 else
00083 {
00084 theDirection /= theDirection.mag();
00085 }
00086
00087 theNCopies = G4int(tgrParam->GetExtraData()[0]);
00088 theStep = tgrParam->GetExtraData()[1];
00089 theOffset = tgrParam->GetExtraData()[2];
00090
00091 theTranslation = G4ThreeVector(0.,0.,0.)+theOffset*theDirection;
00092
00093 #ifdef G4VERBOSE
00094 if( G4tgrMessenger::GetVerboseLevel() >= 2 )
00095 {
00096 G4cout << " G4tgbPlaceParamLinear::G4tgbPlaceParamLinear(): "
00097 << " param type " << tgrParam->GetParamType() << G4endl
00098 << " N copies " << theNCopies << G4endl
00099 << " step " << theStep << G4endl
00100 << " offset " << theOffset << G4endl
00101 << " translation " << theTranslation << G4endl
00102 << " direction " << theDirection << G4endl
00103 << " axis " << theAxis << G4endl;
00104 }
00105 #endif
00106 }
00107
00108
00109
00110 void G4tgbPlaceParamLinear::
00111 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
00112 {
00113 G4ThreeVector origin = theTranslation + copyNo*theStep*theDirection;
00114
00115 #ifdef G4VERBOSE
00116 if( G4tgrMessenger::GetVerboseLevel() >= 3 )
00117 {
00118 G4cout << " G4tgbPlaceParamLinear::ComputeTransformation() -"
00119 << physVol->GetName() << G4endl
00120 << " copyNo " << copyNo << " pos " << origin << G4endl;
00121 }
00122 #endif
00123
00124 physVol->SetTranslation(origin);
00125 physVol->SetCopyNo( copyNo );
00126 physVol->SetRotation( theRotationMatrix );
00127 }