1 | // |
---|
2 | // ******************************************************************** |
---|
3 | // * License and Disclaimer * |
---|
4 | // * * |
---|
5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
7 | // * conditions of the Geant4 Software License, included in the file * |
---|
8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
9 | // * include a list of copyright holders. * |
---|
10 | // * * |
---|
11 | // * Neither the authors of this software system, nor their employing * |
---|
12 | // * institutes,nor the agencies providing financial support for this * |
---|
13 | // * work make any representation or warranty, express or implied, * |
---|
14 | // * regarding this software system or assume any liability for its * |
---|
15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
16 | // * for the full disclaimer and the limitation of liability. * |
---|
17 | // * * |
---|
18 | // * This code implementation is the result of the scientific and * |
---|
19 | // * technical work of the GEANT4 collaboration. * |
---|
20 | // * By using, copying, modifying or distributing the software (or * |
---|
21 | // * any work based on the software) you agree to acknowledge its * |
---|
22 | // * use in resulting scientific publications, and indicate your * |
---|
23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
24 | // ******************************************************************** |
---|
25 | // |
---|
26 | // |
---|
27 | // $Id: G4tgbPlaceParamSquare.cc,v 1.6 2008/12/03 16:16:01 arce Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // class G4tgbPlaceParamSquare |
---|
32 | |
---|
33 | // History: |
---|
34 | // - Created. P.Arce, CIEMAT (November 2007) |
---|
35 | // ------------------------------------------------------------------------- |
---|
36 | |
---|
37 | #include "G4tgbPlaceParamSquare.hh" |
---|
38 | #include "G4RotationMatrix.hh" |
---|
39 | #include "G4VPhysicalVolume.hh" |
---|
40 | #include "G4tgrMessenger.hh" |
---|
41 | #include "G4tgrPlaceParameterisation.hh" |
---|
42 | |
---|
43 | // ------------------------------------------------------------------------- |
---|
44 | G4tgbPlaceParamSquare::~G4tgbPlaceParamSquare() |
---|
45 | { |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | // ------------------------------------------------------------------------- |
---|
50 | G4tgbPlaceParamSquare:: |
---|
51 | G4tgbPlaceParamSquare( G4tgrPlaceParameterisation* tgrParam ) |
---|
52 | : G4tgbPlaceParameterisation(tgrParam) |
---|
53 | { |
---|
54 | //---- Get translation and rotation |
---|
55 | if( tgrParam->GetParamType() == "SQUARE" ) |
---|
56 | { |
---|
57 | CheckNExtraData( tgrParam, 12, WLSIZE_EQ, "G4tgbPlaceParamSquare:"); |
---|
58 | theDirection1 = G4ThreeVector( tgrParam->GetExtraData()[6], |
---|
59 | tgrParam->GetExtraData()[7], |
---|
60 | tgrParam->GetExtraData()[8] ); |
---|
61 | theDirection2 = G4ThreeVector( tgrParam->GetExtraData()[9], |
---|
62 | tgrParam->GetExtraData()[10], |
---|
63 | tgrParam->GetExtraData()[11] ); |
---|
64 | theAxis = kZAxis; |
---|
65 | } |
---|
66 | else |
---|
67 | { |
---|
68 | CheckNExtraData( tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamSquare:"); |
---|
69 | if( tgrParam->GetParamType() == "SQUARE_XY" ) |
---|
70 | { |
---|
71 | theDirection1 = G4ThreeVector(1.,0.,0.); |
---|
72 | theDirection2 = G4ThreeVector(0.,1.,0.); |
---|
73 | theAxis = kZAxis; |
---|
74 | } |
---|
75 | else if( tgrParam->GetParamType() == "SQUARE_YZ" ) |
---|
76 | { |
---|
77 | theDirection1 = G4ThreeVector(0.,1.,0.); |
---|
78 | theDirection2 = G4ThreeVector(0.,0.,1.); |
---|
79 | theAxis = kXAxis; |
---|
80 | } |
---|
81 | else if( tgrParam->GetParamType() == "SQUARE_XZ" ) |
---|
82 | { |
---|
83 | theDirection1 = G4ThreeVector(1.,0.,0.); |
---|
84 | theDirection2 = G4ThreeVector(0.,0.,1.); |
---|
85 | theAxis = kYAxis; |
---|
86 | } |
---|
87 | } |
---|
88 | |
---|
89 | if( theDirection1.mag() == 0. ) |
---|
90 | { |
---|
91 | G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()", |
---|
92 | "InvalidSetup", FatalException, "Direction1 is zero !"); |
---|
93 | } |
---|
94 | else |
---|
95 | { |
---|
96 | theDirection1 /= theDirection1.mag(); |
---|
97 | } |
---|
98 | if( theDirection2.mag() == 0. ) |
---|
99 | { |
---|
100 | G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()", |
---|
101 | "InvalidSetup", FatalException, "Direction2 is zero !"); |
---|
102 | } |
---|
103 | else |
---|
104 | { |
---|
105 | theDirection2 /= theDirection2.mag(); |
---|
106 | } |
---|
107 | |
---|
108 | theNCopies1 = G4int(tgrParam->GetExtraData()[0]); |
---|
109 | theNCopies2 = G4int(tgrParam->GetExtraData()[1]); |
---|
110 | theStep1 = tgrParam->GetExtraData()[2]; |
---|
111 | theStep2 = tgrParam->GetExtraData()[3]; |
---|
112 | theOffset1 = tgrParam->GetExtraData()[4]; |
---|
113 | theOffset2 = tgrParam->GetExtraData()[5]; |
---|
114 | |
---|
115 | theNCopies = theNCopies1 * theNCopies2; |
---|
116 | theTranslation = theOffset1*theDirection1 + theOffset2*theDirection2; |
---|
117 | |
---|
118 | #ifdef G4VERBOSE |
---|
119 | if( G4tgrMessenger::GetVerboseLevel() >= 2 ) |
---|
120 | G4cout << "G4tgbPlaceParamSquare: no copies " |
---|
121 | << theNCopies << " = " << theNCopies1 |
---|
122 | << " X " << theNCopies2 << G4endl |
---|
123 | << " offset1 " << theOffset1 << G4endl |
---|
124 | << " offset2 " << theOffset1 << G4endl |
---|
125 | << " step1 " << theStep1 << G4endl |
---|
126 | << " step2 " << theStep2 << G4endl |
---|
127 | << " direction1 " << theDirection1 << G4endl |
---|
128 | << " direction2 " << theDirection2 << G4endl |
---|
129 | << " translation " << theTranslation << G4endl; |
---|
130 | #endif |
---|
131 | } |
---|
132 | |
---|
133 | |
---|
134 | // ------------------------------------------------------------------------- |
---|
135 | void G4tgbPlaceParamSquare:: |
---|
136 | ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const |
---|
137 | { |
---|
138 | #ifdef G4VERBOSE |
---|
139 | if( G4tgrMessenger::GetVerboseLevel() >= 3 ) |
---|
140 | { |
---|
141 | G4cout << " G4tgbPlaceParamSquare::ComputeTransformation():" |
---|
142 | << physVol->GetName() << G4endl |
---|
143 | << " no copies " << theNCopies << G4endl |
---|
144 | << " offset1 " << theOffset1 << G4endl |
---|
145 | << " offset2 " << theOffset2 << G4endl |
---|
146 | << " step1 " << theStep1 << G4endl |
---|
147 | << " step2 " << theStep2 << G4endl; |
---|
148 | } |
---|
149 | #endif |
---|
150 | |
---|
151 | G4int copyNo1 = copyNo%theNCopies1; |
---|
152 | G4int copyNo2 = G4int(copyNo/theNCopies1); |
---|
153 | G4double posi1 = copyNo1*theStep1; |
---|
154 | G4double posi2 = copyNo2*theStep2; |
---|
155 | G4ThreeVector origin = posi1*theDirection1+ posi2*theDirection2; |
---|
156 | origin += theTranslation; |
---|
157 | |
---|
158 | #ifdef G4VERBOSE |
---|
159 | if( G4tgrMessenger::GetVerboseLevel() >= 3 ) |
---|
160 | { |
---|
161 | G4cout << " G4tgbPlaceParamSquare::ComputeTransformation() - " |
---|
162 | << copyNo << " = " << copyNo1 << ", X " << copyNo2 << G4endl |
---|
163 | << " pos: " << origin << ", axis: " << theAxis << G4endl; |
---|
164 | } |
---|
165 | #endif |
---|
166 | //----- Set traslation and rotation |
---|
167 | physVol->SetTranslation(origin); |
---|
168 | physVol->SetCopyNo( copyNo ); |
---|
169 | physVol->SetRotation( theRotationMatrix ); |
---|
170 | } |
---|