Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// G4tgbPlaceParamSquare implementation
27//
28// Author: P.Arce, CIEMAT (November 2007)
29// --------------------------------------------------------------------
30
32#include "G4RotationMatrix.hh"
33#include "G4VPhysicalVolume.hh"
34#include "G4tgrMessenger.hh"
36
37// --------------------------------------------------------------------
39{
40}
41
42// --------------------------------------------------------------------
46{
47 //---- Get translation and rotation
48 if(tgrParam->GetParamType() == "SQUARE")
49 {
50 CheckNExtraData(tgrParam, 12, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
51 theDirection1 =
52 G4ThreeVector(tgrParam->GetExtraData()[6], tgrParam->GetExtraData()[7],
53 tgrParam->GetExtraData()[8]);
54 theDirection2 =
55 G4ThreeVector(tgrParam->GetExtraData()[9], tgrParam->GetExtraData()[10],
56 tgrParam->GetExtraData()[11]);
58 }
59 else
60 {
61 CheckNExtraData(tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
62 if(tgrParam->GetParamType() == "SQUARE_XY")
63 {
64 theDirection1 = G4ThreeVector(1., 0., 0.);
65 theDirection2 = G4ThreeVector(0., 1., 0.);
67 }
68 else if(tgrParam->GetParamType() == "SQUARE_YZ")
69 {
70 theDirection1 = G4ThreeVector(0., 1., 0.);
71 theDirection2 = G4ThreeVector(0., 0., 1.);
73 }
74 else if(tgrParam->GetParamType() == "SQUARE_XZ")
75 {
76 theDirection1 = G4ThreeVector(1., 0., 0.);
77 theDirection2 = G4ThreeVector(0., 0., 1.);
79 }
80 }
81
82 if(theDirection1.mag() == 0.)
83 {
84 G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
85 "InvalidSetup", FatalException, "Direction1 is zero !");
86 }
87 else
88 {
89 theDirection1 /= theDirection1.mag();
90 }
91 if(theDirection2.mag() == 0.)
92 {
93 G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
94 "InvalidSetup", FatalException, "Direction2 is zero !");
95 }
96 else
97 {
98 theDirection2 /= theDirection2.mag();
99 }
100
101 theNCopies1 = G4int(tgrParam->GetExtraData()[0]);
102 theNCopies2 = G4int(tgrParam->GetExtraData()[1]);
103 theStep1 = tgrParam->GetExtraData()[2];
104 theStep2 = tgrParam->GetExtraData()[3];
105 theOffset1 = tgrParam->GetExtraData()[4];
106 theOffset2 = tgrParam->GetExtraData()[5];
107
108 theNCopies = theNCopies1 * theNCopies2;
109 theTranslation = theOffset1 * theDirection1 + theOffset2 * theDirection2;
110
111#ifdef G4VERBOSE
113 G4cout << "G4tgbPlaceParamSquare: no copies " << theNCopies << " = "
114 << theNCopies1 << " X " << theNCopies2 << G4endl << " offset1 "
115 << theOffset1 << G4endl << " offset2 " << theOffset1 << G4endl
116 << " step1 " << theStep1 << G4endl << " step2 " << theStep2 << G4endl
117 << " direction1 " << theDirection1 << G4endl << " direction2 "
118 << theDirection2 << G4endl << " translation " << theTranslation
119 << G4endl;
120#endif
121}
122
123// --------------------------------------------------------------------
125ComputeTransformation(const G4int copyNo, G4VPhysicalVolume* physVol) const
126{
127#ifdef G4VERBOSE
129 {
130 G4cout << " G4tgbPlaceParamSquare::ComputeTransformation():"
131 << physVol->GetName() << G4endl << " no copies " << theNCopies
132 << G4endl << " offset1 " << theOffset1 << G4endl << " offset2 "
133 << theOffset2 << G4endl << " step1 " << theStep1 << G4endl
134 << " step2 " << theStep2 << G4endl;
135 }
136#endif
137
138 G4int copyNo1 = copyNo % theNCopies1;
139 G4int copyNo2 = G4int(copyNo / theNCopies1);
140 G4double posi1 = copyNo1 * theStep1;
141 G4double posi2 = copyNo2 * theStep2;
142 G4ThreeVector origin = posi1 * theDirection1 + posi2 * theDirection2;
143 origin += theTranslation;
144
145#ifdef G4VERBOSE
147 {
148 G4cout << " G4tgbPlaceParamSquare::ComputeTransformation() - " << copyNo
149 << " = " << copyNo1 << ", X " << copyNo2 << G4endl
150 << " pos: " << origin << ", axis: " << theAxis << G4endl;
151 }
152#endif
153 //----- Set traslation and rotation
154 physVol->SetTranslation(origin);
155 physVol->SetCopyNo(copyNo);
157}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
@ WLSIZE_EQ
Definition: G4tgrUtils.hh:47
double mag() const
virtual void SetCopyNo(G4int CopyNo)=0
const G4String & GetName() const
void SetTranslation(const G4ThreeVector &v)
void SetRotation(G4RotationMatrix *)
G4tgbPlaceParamSquare(G4tgrPlaceParameterisation *)
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
void CheckNExtraData(G4tgrPlaceParameterisation *tgrParam, G4int nWcheck, WLSIZEtype st, const G4String &methodName)
static G4int GetVerboseLevel()
std::vector< G4double > GetExtraData() const
const G4String & GetParamType() const
@ kYAxis
Definition: geomdefs.hh:56
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57