ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4tgbPlaceParamCircle.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4tgbPlaceParamCircle.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 G4tgbPlaceParamCircle
30 
31 // History:
32 // - Created. P.Arce, CIEMAT (November 2007)
33 // -------------------------------------------------------------------------
34 
35 #include "G4tgbPlaceParamCircle.hh"
37 #include "G4ThreeVector.hh"
38 #include "G4RotationMatrix.hh"
39 #include "G4VPhysicalVolume.hh"
40 #include "G4tgrUtils.hh"
41 #include "G4tgrMessenger.hh"
42 
43 // -------------------------------------------------------------------------
45 {
46 }
47 
48 
49 // -------------------------------------------------------------------------
52  : G4tgbPlaceParameterisation(tgrParam)
53 {
54  //---- Get translation and rotation
55  if( tgrParam->GetParamType() == "CIRCLE" )
56  {
57  CheckNExtraData( tgrParam, 7, WLSIZE_EQ, "G4tgbPlaceParamCircle:");
58  theCircleAxis = G4ThreeVector( tgrParam->GetExtraData()[4],
59  tgrParam->GetExtraData()[5],
60  tgrParam->GetExtraData()[6] );
61 
62  G4ThreeVector zaxis(0.,0.,-1.);
63  if( zaxis.cross(theCircleAxis).mag() > 1.E-6 )
64  {
66  }
67  else
68  {
70  }
71  theAxis = kZAxis;
72  }
73  else
74  {
75  CheckNExtraData( tgrParam, 4, WLSIZE_EQ, "G4tgbPlaceParamCircle:");
76  if( tgrParam->GetParamType() == "CIRCLE_XY" ) {
77  theCircleAxis = G4ThreeVector(0.,0.,1.);
78  theDirInPlane = G4ThreeVector(1.,0.,0.);
79  theAxis = kZAxis;
80  } else if( tgrParam->GetParamType() == "CIRCLE_XZ" ) {
81  theCircleAxis = G4ThreeVector(0.,1.,0.);
82  theDirInPlane = G4ThreeVector(1.,0.,0.);
83  theAxis = kYAxis;
84  } else if( tgrParam->GetParamType() == "CIRCLE_YZ" ) {
85  theCircleAxis = G4ThreeVector(1.,0.,0.);
86  theDirInPlane = G4ThreeVector(0.,1.,0.);
87  theAxis = kXAxis;
88  }
89  }
90 
91  if( theCircleAxis.mag() == 0. )
92  {
93  G4Exception("G4tgbPlaceParamCircle::G4tgbPlaceParamCircle()",
94  "InvalidSetup", FatalException, "Circle axis is zero !");
95  }
97 
98  theAxis = kZAxis;
99 
100  theNCopies = G4int(tgrParam->GetExtraData()[0]);
101  theStep = tgrParam->GetExtraData()[1];
102  theOffset = tgrParam->GetExtraData()[2];
103  theRadius = tgrParam->GetExtraData()[3];
104 
105 #ifdef G4VERBOSE
107  {
108  G4cout << " G4tgbPlaceParamCircle::G4tgbPlaceParamCircle():" << G4endl
109  << " param type " << tgrParam->GetParamType() << G4endl
110  << " no copies - " << theNCopies << G4endl
111  << " step - " << theStep << G4endl
112  << " offset - " << theOffset << G4endl
113  << " radius - " << theRadius << G4endl
114  << " circle axis - " << theCircleAxis << G4endl
115  << " dir in plane - " << theDirInPlane << G4endl;
116  }
117 #endif
118 }
119 
120 
121 // -------------------------------------------------------------------------
123 ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
124 {
125  G4double posi = theOffset + copyNo*theStep;
127  origin.rotate( posi, theCircleAxis );
128 
129  //----- Calculate rotation matrix (so that all volumes point to the centre)
130  G4RotationMatrix rm;
131  rm.rotate( -posi, theCircleAxis );
132 
133  //----- Set translation and rotation
134  physVol->SetTranslation(origin);
135  G4RotationMatrix* pvRm = physVol->GetRotation();
136  if( pvRm == 0 )
137  {
138  pvRm = new G4RotationMatrix;
139  }
140  *pvRm = *theRotationMatrix * rm;
141  physVol->SetRotation(pvRm);
142  physVol->SetCopyNo( copyNo );
143 
144 #ifdef G4VERBOSE
146  {
147  G4cout << " G4tgbPlaceParamCircle::ComputeTransformation():"
148  << physVol->GetName() << G4endl
149  << " no copies - " << theNCopies << G4endl
150  << " centre - " << origin << G4endl
151  << " rotation-matrix - " << *pvRm << G4endl;
152  }
153 #endif
154 }