VGM Version 5.3
Loading...
Searching...
No Matches
Trap.cxx
Go to the documentation of this file.
1// $Id$
2
3// -----------------------------------------------------------------------
4// The Geant4GM package of the Virtual Geometry Model
5// Copyright (C) 2007, Ivana Hrivnacova
6// All rights reserved.
7//
8// For the licensing terms see vgm/LICENSE.
9// Contact: ivana@ipno.in2p3.fr
10// -----------------------------------------------------------------------
11
12//
13// Class Trap
14// ---------------
15// VGM implementation for Geant4 trap solid.
16// If reflected, the parameters are changed as follows:
17// dy1, dx1, dx2 --> dy2', dx3', dx4'
18// alpha1 --> alpha2'
19// dy2, dx3, dx4 --> dy1', dx1', dx2'
20// alpha2 --> alpha1'
21// hz --> hz'
22// theta --> theta'
23// phi --> phi'
24//
25// Author: Ivana Hrivnacova; IPN Orsay
26
27#include "ClhepVGM/Units.h"
28
31
32#include "G4ReflectedSolid.hh"
33#include "G4Trap.hh"
34
35//_____________________________________________________________________________
36Geant4GM::Trap::Trap(const std::string& name, double hz, double theta,
37 double phi, double dy1, double dx1, double dx2, double alpha1, double dy2,
38 double dx3, double dx4, double alpha2)
39 : VGM::ISolid(), VGM::ITrap(), BaseVGM::VTrap(), fIsReflected(false), fTrap(0)
40{
65
66 // Geant4 does not allow to define trapezoid with dx = 0.
67 // while other geometry can do it;
68 // change dx to 10 microns in such a case
69 if (dx1 == 0.) dx1 = 10.0e-3;
70 if (dx2 == 0.) dx2 = 10.0e-3;
71 if (dx3 == 0.) dx3 = 10.0e-3;
72 if (dx4 == 0.) dx4 = 10.0e-3;
73
74 fTrap = new G4Trap(name, hz / ClhepVGM::Units::Length(),
80
82}
83
84//_____________________________________________________________________________
85Geant4GM::Trap::Trap(G4Trap* trap, G4ReflectedSolid* reflTrap)
86 : VGM::ISolid(),
87 VGM::ITrap(),
88 BaseVGM::VTrap(),
89 fIsReflected(false),
90 fTrap(trap)
91{
93
94 if (reflTrap) {
95 fIsReflected = true;
96 Geant4GM::SolidMap::Instance()->AddSolid(this, reflTrap);
97 }
98 else
100}
101
102//_____________________________________________________________________________
103Geant4GM::Trap::Trap() : VGM::ISolid(), VGM::ITrap(), BaseVGM::VTrap()
104{
106}
107
108//_____________________________________________________________________________
110 : VGM::ISolid(rhs), VGM::ITrap(rhs), BaseVGM::VTrap(rhs)
111{
113}
114
115//_____________________________________________________________________________
117{
118 //
119}
120
121//_____________________________________________________________________________
122std::string Geant4GM::Trap::Name() const { return fTrap->GetName(); }
123
124//_____________________________________________________________________________
126{
127 return fTrap->GetZHalfLength() * ClhepVGM::Units::Length();
128}
129
130//_____________________________________________________________________________
132{
133 // std::cout << "inc1 in VMC: "
134 // << atan(fTrap->GetSymAxis().x()/fTrap->GetSymAxis().z()) / deg
135 // << std::endl;
136 if (!fIsReflected)
137 return fTrap->GetSymAxis().theta() * ClhepVGM::Units::Angle();
138 else
139 return -fTrap->GetSymAxis().theta() * ClhepVGM::Units::Angle();
140}
141
142//_____________________________________________________________________________
144{
145 // std::cout << "inc1 in VMC: "
146 // << atan(fTrap->GetSymAxis().y()/fTrap->GetSymAxis().z()) / deg
147 // << std::endl;
148 if (!fIsReflected)
149 return fTrap->GetSymAxis().phi() * ClhepVGM::Units::Angle();
150 else
151 return -fTrap->GetSymAxis().phi() * ClhepVGM::Units::Angle();
152}
153
154//_____________________________________________________________________________
156{
157 if (!fIsReflected)
158 return fTrap->GetYHalfLength1() * ClhepVGM::Units::Length();
159 else
160 return fTrap->GetYHalfLength2() * ClhepVGM::Units::Length();
161}
162
163//_____________________________________________________________________________
165{
166 if (!fIsReflected)
167 return fTrap->GetXHalfLength1() * ClhepVGM::Units::Length();
168 else
169 return fTrap->GetXHalfLength3() * ClhepVGM::Units::Length();
170}
171
172//_____________________________________________________________________________
174{
175 if (!fIsReflected)
176 return fTrap->GetXHalfLength2() * ClhepVGM::Units::Length();
177 else
178 return fTrap->GetXHalfLength4() * ClhepVGM::Units::Length();
179}
180
181//_____________________________________________________________________________
183{
184 if (!fIsReflected)
185 return atan(fTrap->GetTanAlpha1()) * ClhepVGM::Units::Angle();
186 else
187 return atan(fTrap->GetTanAlpha2()) * ClhepVGM::Units::Angle();
188}
189
190//_____________________________________________________________________________
192{
193 if (!fIsReflected)
194 return fTrap->GetYHalfLength2() * ClhepVGM::Units::Length();
195 else
196 return fTrap->GetYHalfLength1() * ClhepVGM::Units::Length();
197}
198
199//_____________________________________________________________________________
201{
202 if (!fIsReflected)
203 return fTrap->GetXHalfLength3() * ClhepVGM::Units::Length();
204 else
205 return fTrap->GetXHalfLength1() * ClhepVGM::Units::Length();
206}
207
208//_____________________________________________________________________________
210{
211 if (!fIsReflected)
212 return fTrap->GetXHalfLength4() * ClhepVGM::Units::Length();
213 else
214 return fTrap->GetXHalfLength2() * ClhepVGM::Units::Length();
215}
216
217//_____________________________________________________________________________
219{
220 if (!fIsReflected)
221 return atan(fTrap->GetTanAlpha2()) * ClhepVGM::Units::Angle();
222 else
223 return atan(fTrap->GetTanAlpha1()) * ClhepVGM::Units::Angle();
224}
static double Length()
Return CLHEP default length unit in VGM units.
Definition Units.cxx:83
static double Angle()
Return CLHEP default angle unit in VGM units.
Definition Units.cxx:92
static SolidMap * Instance()
Definition SolidMap.cxx:28
void AddSolid(VGM::ISolid *, G4VSolid *)
Definition SolidMap.cxx:59
VGM implementation for Geant4 trap solid.
Definition Trap.h:33
virtual double YHalfLengthPlusZ() const
Return the half-length along y of the face at +hz in m.
Definition Trap.cxx:191
virtual double Phi() const
Return the azimuthal angle of the line joining the centres of the faces at -hz and +hz in deg.
Definition Trap.cxx:143
virtual double XHalfLengthMinusZMinusY() const
Return the half-length along x of the side at -hy of the face at -hz in mm.
Definition Trap.cxx:164
virtual std::string Name() const
Return the name of this solid.
Definition Trap.cxx:122
virtual double AlphaMinusZ() const
Return the angle with respect to the y axis from the centre of the side at -hy to the centre at +hy o...
Definition Trap.cxx:182
virtual double XHalfLengthPlusZMinusY() const
Return the half-length along x of the side at -hy of the face at +hz in m.
Definition Trap.cxx:200
virtual double XHalfLengthPlusZPlusY() const
Return the half-length along x of the side at +hy of the face at +hz in m.
Definition Trap.cxx:209
virtual double YHalfLengthMinusZ() const
Return the half-length along y of the face at -hz in mm.
Definition Trap.cxx:155
virtual double ZHalfLength() const
Return the half-length along the z axis in mm.
Definition Trap.cxx:125
virtual double AlphaPlusZ() const
Return the angle with respect to the y axis from the centre of the side at -hy to the centre at +hy o...
Definition Trap.cxx:218
virtual ~Trap()
Definition Trap.cxx:116
virtual double XHalfLengthMinusZPlusY() const
Return the half-length along x of the side at +hy of the face at +hz in mm.
Definition Trap.cxx:173
virtual double Theta() const
Return the polar angle of the line joining the centres of the faces at -hz and +hz in deg.
Definition Trap.cxx:131
BaseVGM utilities.
Definition utilities.h:23
VGM interfaces.
Definition VMedium.h:28