Geant4  10.00.p01
G4tgbPlaceParamSquare.cc
Go to the documentation of this file.
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 66363 2012-12-18 09:12:54Z gcosmo $
28 //
29 //
30 // class G4tgbPlaceParamSquare
31 
32 // History:
33 // - Created. P.Arce, CIEMAT (November 2007)
34 // -------------------------------------------------------------------------
35 
36 #include "G4tgbPlaceParamSquare.hh"
37 #include "G4RotationMatrix.hh"
38 #include "G4VPhysicalVolume.hh"
39 #include "G4tgrMessenger.hh"
41 
42 // -------------------------------------------------------------------------
44 {
45 }
46 
47 
48 // -------------------------------------------------------------------------
51  : G4tgbPlaceParameterisation(tgrParam)
52 {
53  //---- Get translation and rotation
54  if( tgrParam->GetParamType() == "SQUARE" )
55  {
56  CheckNExtraData( tgrParam, 12, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
57  theDirection1 = G4ThreeVector( tgrParam->GetExtraData()[6],
58  tgrParam->GetExtraData()[7],
59  tgrParam->GetExtraData()[8] );
60  theDirection2 = G4ThreeVector( tgrParam->GetExtraData()[9],
61  tgrParam->GetExtraData()[10],
62  tgrParam->GetExtraData()[11] );
63  theAxis = kZAxis;
64  }
65  else
66  {
67  CheckNExtraData( tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
68  if( tgrParam->GetParamType() == "SQUARE_XY" )
69  {
70  theDirection1 = G4ThreeVector(1.,0.,0.);
71  theDirection2 = G4ThreeVector(0.,1.,0.);
72  theAxis = kZAxis;
73  }
74  else if( tgrParam->GetParamType() == "SQUARE_YZ" )
75  {
76  theDirection1 = G4ThreeVector(0.,1.,0.);
77  theDirection2 = G4ThreeVector(0.,0.,1.);
78  theAxis = kXAxis;
79  }
80  else if( tgrParam->GetParamType() == "SQUARE_XZ" )
81  {
82  theDirection1 = G4ThreeVector(1.,0.,0.);
83  theDirection2 = G4ThreeVector(0.,0.,1.);
84  theAxis = kYAxis;
85  }
86  }
87 
88  if( theDirection1.mag() == 0. )
89  {
90  G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
91  "InvalidSetup", FatalException, "Direction1 is zero !");
92  }
93  else
94  {
96  }
97  if( theDirection2.mag() == 0. )
98  {
99  G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
100  "InvalidSetup", FatalException, "Direction2 is zero !");
101  }
102  else
103  {
104  theDirection2 /= theDirection2.mag();
105  }
106 
107  theNCopies1 = G4int(tgrParam->GetExtraData()[0]);
108  theNCopies2 = G4int(tgrParam->GetExtraData()[1]);
109  theStep1 = tgrParam->GetExtraData()[2];
110  theStep2 = tgrParam->GetExtraData()[3];
111  theOffset1 = tgrParam->GetExtraData()[4];
112  theOffset2 = tgrParam->GetExtraData()[5];
113 
116 
117 #ifdef G4VERBOSE
118  if( G4tgrMessenger::GetVerboseLevel() >= 2 )
119  G4cout << "G4tgbPlaceParamSquare: no copies "
120  << theNCopies << " = " << theNCopies1
121  << " X " << theNCopies2 << G4endl
122  << " offset1 " << theOffset1 << G4endl
123  << " offset2 " << theOffset1 << G4endl
124  << " step1 " << theStep1 << G4endl
125  << " step2 " << theStep2 << G4endl
126  << " direction1 " << theDirection1 << G4endl
127  << " direction2 " << theDirection2 << G4endl
128  << " translation " << theTranslation << G4endl;
129 #endif
130 }
131 
132 
133 // -------------------------------------------------------------------------
135 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
136 {
137 #ifdef G4VERBOSE
139  {
140  G4cout << " G4tgbPlaceParamSquare::ComputeTransformation():"
141  << physVol->GetName() << G4endl
142  << " no copies " << theNCopies << G4endl
143  << " offset1 " << theOffset1 << G4endl
144  << " offset2 " << theOffset2 << G4endl
145  << " step1 " << theStep1 << G4endl
146  << " step2 " << theStep2 << G4endl;
147  }
148 #endif
149 
150  G4int copyNo1 = copyNo%theNCopies1;
151  G4int copyNo2 = G4int(copyNo/theNCopies1);
152  G4double posi1 = copyNo1*theStep1;
153  G4double posi2 = copyNo2*theStep2;
154  G4ThreeVector origin = posi1*theDirection1+ posi2*theDirection2;
155  origin += theTranslation;
156 
157 #ifdef G4VERBOSE
159  {
160  G4cout << " G4tgbPlaceParamSquare::ComputeTransformation() - "
161  << copyNo << " = " << copyNo1 << ", X " << copyNo2 << G4endl
162  << " pos: " << origin << ", axis: " << theAxis << G4endl;
163  }
164 #endif
165  //----- Set traslation and rotation
166  physVol->SetTranslation(origin);
167  physVol->SetCopyNo( copyNo );
168  physVol->SetRotation( theRotationMatrix );
169 }
void CheckNExtraData(G4tgrPlaceParameterisation *tgrParam, G4int nWcheck, WLSIZEtype st, const G4String &methodName)
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
CLHEP::Hep3Vector G4ThreeVector
G4tgbPlaceParamSquare(G4tgrPlaceParameterisation *)
int G4int
Definition: G4Types.hh:78
void SetRotation(G4RotationMatrix *)
std::vector< G4double > GetExtraData() const
G4GLOB_DLL std::ostream G4cout
const G4String & GetName() const
static G4int GetVerboseLevel()
virtual void SetCopyNo(G4int CopyNo)=0
void SetTranslation(const G4ThreeVector &v)
const G4String & GetParamType() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76