ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4tgbPlaceParamSquare.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4tgbPlaceParamSquare.cc
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 //
28 //
29 // class G4tgbPlaceParamSquare
30 
31 // History:
32 // - Created. P.Arce, CIEMAT (November 2007)
33 // -------------------------------------------------------------------------
34 
35 #include "G4tgbPlaceParamSquare.hh"
36 #include "G4RotationMatrix.hh"
37 #include "G4VPhysicalVolume.hh"
38 #include "G4tgrMessenger.hh"
40 
41 // -------------------------------------------------------------------------
43 {
44 }
45 
46 
47 // -------------------------------------------------------------------------
50  : G4tgbPlaceParameterisation(tgrParam)
51 {
52  //---- Get translation and rotation
53  if( tgrParam->GetParamType() == "SQUARE" )
54  {
55  CheckNExtraData( tgrParam, 12, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
56  theDirection1 = G4ThreeVector( tgrParam->GetExtraData()[6],
57  tgrParam->GetExtraData()[7],
58  tgrParam->GetExtraData()[8] );
59  theDirection2 = G4ThreeVector( tgrParam->GetExtraData()[9],
60  tgrParam->GetExtraData()[10],
61  tgrParam->GetExtraData()[11] );
62  theAxis = kZAxis;
63  }
64  else
65  {
66  CheckNExtraData( tgrParam, 6, WLSIZE_EQ, "G4tgbPlaceParamSquare:");
67  if( tgrParam->GetParamType() == "SQUARE_XY" )
68  {
69  theDirection1 = G4ThreeVector(1.,0.,0.);
70  theDirection2 = G4ThreeVector(0.,1.,0.);
71  theAxis = kZAxis;
72  }
73  else if( tgrParam->GetParamType() == "SQUARE_YZ" )
74  {
75  theDirection1 = G4ThreeVector(0.,1.,0.);
76  theDirection2 = G4ThreeVector(0.,0.,1.);
77  theAxis = kXAxis;
78  }
79  else if( tgrParam->GetParamType() == "SQUARE_XZ" )
80  {
81  theDirection1 = G4ThreeVector(1.,0.,0.);
82  theDirection2 = G4ThreeVector(0.,0.,1.);
83  theAxis = kYAxis;
84  }
85  }
86 
87  if( theDirection1.mag() == 0. )
88  {
89  G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
90  "InvalidSetup", FatalException, "Direction1 is zero !");
91  }
92  else
93  {
95  }
96  if( theDirection2.mag() == 0. )
97  {
98  G4Exception("G4tgbPlaceParamSquare::G4tgbPlaceParamSquare()",
99  "InvalidSetup", FatalException, "Direction2 is zero !");
100  }
101  else
102  {
104  }
105 
106  theNCopies1 = G4int(tgrParam->GetExtraData()[0]);
107  theNCopies2 = G4int(tgrParam->GetExtraData()[1]);
108  theStep1 = tgrParam->GetExtraData()[2];
109  theStep2 = tgrParam->GetExtraData()[3];
110  theOffset1 = tgrParam->GetExtraData()[4];
111  theOffset2 = tgrParam->GetExtraData()[5];
112 
115 
116 #ifdef G4VERBOSE
117  if( G4tgrMessenger::GetVerboseLevel() >= 2 )
118  G4cout << "G4tgbPlaceParamSquare: no copies "
119  << theNCopies << " = " << theNCopies1
120  << " X " << theNCopies2 << G4endl
121  << " offset1 " << theOffset1 << G4endl
122  << " offset2 " << theOffset1 << G4endl
123  << " step1 " << theStep1 << G4endl
124  << " step2 " << theStep2 << G4endl
125  << " direction1 " << theDirection1 << G4endl
126  << " direction2 " << theDirection2 << G4endl
127  << " translation " << theTranslation << G4endl;
128 #endif
129 }
130 
131 
132 // -------------------------------------------------------------------------
134 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
135 {
136 #ifdef G4VERBOSE
138  {
139  G4cout << " G4tgbPlaceParamSquare::ComputeTransformation():"
140  << physVol->GetName() << G4endl
141  << " no copies " << theNCopies << G4endl
142  << " offset1 " << theOffset1 << G4endl
143  << " offset2 " << theOffset2 << G4endl
144  << " step1 " << theStep1 << G4endl
145  << " step2 " << theStep2 << G4endl;
146  }
147 #endif
148 
149  G4int copyNo1 = copyNo%theNCopies1;
150  G4int copyNo2 = G4int(copyNo/theNCopies1);
151  G4double posi1 = copyNo1*theStep1;
152  G4double posi2 = copyNo2*theStep2;
154  origin += theTranslation;
155 
156 #ifdef G4VERBOSE
158  {
159  G4cout << " G4tgbPlaceParamSquare::ComputeTransformation() - "
160  << copyNo << " = " << copyNo1 << ", X " << copyNo2 << G4endl
161  << " pos: " << origin << ", axis: " << theAxis << G4endl;
162  }
163 #endif
164  //----- Set traslation and rotation
165  physVol->SetTranslation(origin);
166  physVol->SetCopyNo( copyNo );
167  physVol->SetRotation( theRotationMatrix );
168 }