Geant4  10.01.p03
G4UTrap.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:$
28 //
29 //
30 // Implementation for G4UTrap wrapper class
31 // --------------------------------------------------------------------
32 
33 #include "G4Trap.hh"
34 #include "G4UTrap.hh"
35 #include "G4VPVParameterisation.hh"
36 #include "G4Polyhedron.hh"
37 
39 //
40 // Constructors
41 //
42 G4UTrap::G4UTrap( const G4String& pName,
43  G4double pdz,
44  G4double pTheta, G4double pPhi,
45  G4double pdy1, G4double pdx1, G4double pdx2,
46  G4double pAlp1,
47  G4double pdy2, G4double pdx3, G4double pdx4,
48  G4double pAlp2 )
49  : G4USolid(pName, new UTrap(pName, pdz, pTheta, pPhi,
50  pdy1, pdx1, pdx2, pAlp1, pdy2, pdx3, pdx4, pAlp2))
51 {
52 }
53 
54 G4UTrap::G4UTrap( const G4String& pName,
55  const G4ThreeVector pt[8] )
56  : G4USolid(pName, new UTrap(pName))
57 {
58  SetPlanes(pt);
59 }
60 
61 G4UTrap::G4UTrap( const G4String& pName,
62  G4double pZ,
63  G4double pY,
64  G4double pX, G4double pLTX )
65  : G4USolid(pName, new UTrap(pName, pZ, pY, pX, pLTX))
66 {
67 }
68 
69 G4UTrap::G4UTrap( const G4String& pName,
70  G4double pdx1, G4double pdx2,
71  G4double pdy1, G4double pdy2,
72  G4double pdz )
73  : G4USolid(pName, new UTrap(pName, pdx1, pdx2, pdy1, pdy2, pdz))
74 {
75 }
76 
78  G4double pdx, G4double pdy, G4double pdz,
79  G4double pAlpha, G4double pTheta, G4double pPhi )
80  : G4USolid(pName, new UTrap(pName, pdx, pdy, pdz, pAlpha, pTheta, pPhi))
81 {
82 }
83 
84 G4UTrap::G4UTrap( const G4String& pName )
85  : G4USolid(pName, new UTrap(pName))
86 {
87 }
88 
90 //
91 // Fake default constructor - sets only member data and allocates memory
92 // for usage restricted to object persistency.
93 //
94 G4UTrap::G4UTrap( __void__& a )
95  : G4USolid(a)
96 {
97 }
98 
100 //
101 // Destructor
102 //
104 {
105 }
106 
108 //
109 // Copy constructor
110 //
112  : G4USolid(rhs)
113 {
114 }
115 
117 //
118 // Assignment operator
119 //
121 {
122  // Check assignment to self
123  //
124  if (this == &rhs) { return *this; }
125 
126  // Copy base class data
127  //
128  G4USolid::operator=(rhs);
129 
130  return *this;
131 }
132 
134 //
135 // Dispatch to parameterisation for replication mechanism dimension
136 // computation & modification.
137 //
139  const G4int n,
140  const G4VPhysicalVolume* pRep)
141 {
142  p->ComputeDimensions(*(G4Trap*)this,n,pRep);
143 }
144 
146 //
147 // Make a clone of the object
148 //
150 {
151  return new G4UTrap(*this);
152 }
153 
155 //
156 // CreatePolyhedron()
157 //
159 {
160  G4double fTthetaSphi = GetShape()->GetThetaSphi();
161  G4double fTthetaCphi = GetShape()->GetThetaCphi();
162  G4double phi = std::atan2(fTthetaSphi, fTthetaCphi);
163  G4double alpha1 = std::atan(GetTanAlpha1());
164  G4double alpha2 = std::atan(GetTanAlpha2());
165  G4double theta = std::atan(std::sqrt(fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi));
166 
167  return new G4PolyhedronTrap(GetZHalfLength(), theta, phi,
168  GetYHalfLength1(),
169  GetXHalfLength1(), GetXHalfLength2(), alpha1,
170  GetYHalfLength2(),
171  GetXHalfLength3(), GetXHalfLength4(), alpha2);
172 }
CLHEP::Hep3Vector G4ThreeVector
G4double GetXHalfLength1() const
Definition: G4UTrap.hh:155
G4double GetYHalfLength2() const
Definition: G4UTrap.hh:167
Definition: UTrap.hh:80
UTrap * GetShape() const
Definition: G4UTrap.hh:142
G4double GetYHalfLength1() const
Definition: G4UTrap.hh:151
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
Definition: G4UTrap.cc:138
G4double a
Definition: TRTMaterials.hh:39
G4double GetXHalfLength3() const
Definition: G4UTrap.hh:171
int G4int
Definition: G4Types.hh:78
G4VSolid * Clone() const
Definition: G4UTrap.cc:149
G4double GetTanAlpha2() const
Definition: G4UTrap.hh:179
G4double GetXHalfLength4() const
Definition: G4UTrap.hh:175
G4double GetZHalfLength() const
Definition: G4UTrap.hh:147
G4UTrap & operator=(const G4UTrap &rhs)
Definition: G4UTrap.cc:120
G4double GetXHalfLength2() const
Definition: G4UTrap.hh:159
~G4UTrap()
Definition: G4UTrap.cc:103
const G4int n
G4Polyhedron * CreatePolyhedron() const
Definition: G4UTrap.cc:158
virtual void ComputeDimensions(G4Box &, const G4int, const G4VPhysicalVolume *) const
G4UTrap(const G4String &pName, G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
Definition: G4UTrap.cc:42
G4double GetTanAlpha1() const
Definition: G4UTrap.hh:163
void SetPlanes(const G4ThreeVector pt[8])
Definition: G4UTrap.hh:208
G4USolid & operator=(const G4USolid &rhs)
Definition: G4USolid.cc:377
double GetThetaSphi() const
double G4double
Definition: G4Types.hh:76
double GetThetaCphi() const