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: G4tgbPlaceParamLinear.cc,v 1.5 2008/12/03 16:16:01 arce Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-02-ref-02 $ |
---|
29 | // |
---|
30 | // |
---|
31 | // class G4tgbPlaceParamLinear |
---|
32 | |
---|
33 | // History: |
---|
34 | // - Created. P.Arce, CIEMAT (November 2007) |
---|
35 | // ------------------------------------------------------------------------- |
---|
36 | |
---|
37 | #include "G4tgbPlaceParamLinear.hh" |
---|
38 | #include "G4RotationMatrix.hh" |
---|
39 | #include "G4VPhysicalVolume.hh" |
---|
40 | #include "G4tgrMessenger.hh" |
---|
41 | #include "G4tgrPlaceParameterisation.hh" |
---|
42 | |
---|
43 | // ------------------------------------------------------------------------- |
---|
44 | G4tgbPlaceParamLinear::~G4tgbPlaceParamLinear() |
---|
45 | { |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | // ------------------------------------------------------------------------- |
---|
50 | G4tgbPlaceParamLinear:: |
---|
51 | G4tgbPlaceParamLinear( G4tgrPlaceParameterisation* tgrParam ) |
---|
52 | : G4tgbPlaceParameterisation(tgrParam) |
---|
53 | { |
---|
54 | //---- Get translation and rotation |
---|
55 | if( tgrParam->GetParamType() == "LINEAR" ) |
---|
56 | { |
---|
57 | CheckNExtraData( tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamLinear:"); |
---|
58 | theDirection = G4ThreeVector( tgrParam->GetExtraData()[3], |
---|
59 | tgrParam->GetExtraData()[4], |
---|
60 | tgrParam->GetExtraData()[5] ); |
---|
61 | theAxis = kZAxis; |
---|
62 | } |
---|
63 | else |
---|
64 | { |
---|
65 | CheckNExtraData( tgrParam, 3, WLSIZE_EQ, "G4tgbPlaceParamLinear:"); |
---|
66 | if( tgrParam->GetParamType() == "LINEAR_X" ) { |
---|
67 | theDirection = G4ThreeVector(1.,0.,0.); |
---|
68 | theAxis = kXAxis; |
---|
69 | } else if( tgrParam->GetParamType() == "LINEAR_Y" ) { |
---|
70 | theDirection = G4ThreeVector(0.,1.,0.); |
---|
71 | theAxis = kYAxis; |
---|
72 | } else if( tgrParam->GetParamType() == "LINEAR_Z" ) { |
---|
73 | theDirection = G4ThreeVector(0.,0.,1.); |
---|
74 | theAxis = kZAxis; |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | if( theDirection.mag() == 0. ) |
---|
79 | { |
---|
80 | G4Exception("G4tgbPlaceParamLinear::G4tgbPlaceParamLinear()", |
---|
81 | "InvalidSetup", FatalException, "Direction is zero !"); |
---|
82 | } |
---|
83 | else |
---|
84 | { |
---|
85 | theDirection /= theDirection.mag(); |
---|
86 | } |
---|
87 | |
---|
88 | theNCopies = G4int(tgrParam->GetExtraData()[0]); |
---|
89 | theStep = tgrParam->GetExtraData()[1]; |
---|
90 | theOffset = tgrParam->GetExtraData()[2]; |
---|
91 | |
---|
92 | theTranslation = G4ThreeVector(0.,0.,0.)+theOffset*theDirection; |
---|
93 | |
---|
94 | #ifdef G4VERBOSE |
---|
95 | if( G4tgrMessenger::GetVerboseLevel() >= 2 ) |
---|
96 | { |
---|
97 | G4cout << " G4tgbPlaceParamLinear::G4tgbPlaceParamLinear(): " |
---|
98 | << " param type " << tgrParam->GetParamType() << G4endl |
---|
99 | << " N copies " << theNCopies << G4endl |
---|
100 | << " step " << theStep << G4endl |
---|
101 | << " offset " << theOffset << G4endl |
---|
102 | << " translation " << theTranslation << G4endl |
---|
103 | << " direction " << theDirection << G4endl |
---|
104 | << " axis " << theAxis << G4endl; |
---|
105 | } |
---|
106 | #endif |
---|
107 | } |
---|
108 | |
---|
109 | |
---|
110 | // ------------------------------------------------------------------------- |
---|
111 | void G4tgbPlaceParamLinear:: |
---|
112 | ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const |
---|
113 | { |
---|
114 | G4ThreeVector origin = theTranslation + copyNo*theStep*theDirection; |
---|
115 | |
---|
116 | #ifdef G4VERBOSE |
---|
117 | if( G4tgrMessenger::GetVerboseLevel() >= 3 ) |
---|
118 | { |
---|
119 | G4cout << " G4tgbPlaceParamLinear::ComputeTransformation() -" |
---|
120 | << physVol->GetName() << G4endl |
---|
121 | << " copyNo " << copyNo << " pos " << origin << G4endl; |
---|
122 | } |
---|
123 | #endif |
---|
124 | //----- Set traslation and rotation |
---|
125 | physVol->SetTranslation(origin); |
---|
126 | physVol->SetCopyNo( copyNo ); |
---|
127 | physVol->SetRotation( theRotationMatrix ); |
---|
128 | } |
---|