VGM Version 5.3
Loading...
Searching...
No Matches
Polycone.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 Polycone
14// ---------------
15// VGM implementation for Geant4 polycone solid.
16// If reflected, the parameters are changed as follows:
17// sphi, dphi --> sphi', dphi'
18// nofZplanes --> nofZplanes'
19// z[i] --> -z'[i]
20// rin, rout --> rin', rout'
21//
22// Author: Ivana Hrivnacova; IPN Orsay
23
24#include "ClhepVGM/Units.h"
25
28
29#include "G4Cons.hh"
30#include "G4Polycone.hh"
31#include "G4ReflectedSolid.hh"
32#include "G4Tubs.hh"
33
34const int Geant4GM::Polycone::fgkMaxNofZPlanes = 50;
35double* Geant4GM::Polycone::fgZBuffer = 0;
36double* Geant4GM::Polycone::fgRinBuffer = 0;
37double* Geant4GM::Polycone::fgRoutBuffer = 0;
38
39//_____________________________________________________________________________
40Geant4GM::Polycone::Polycone(const std::string& name, double sphi, double dphi,
41 int nofZplanes, double* z, double* rin, double* rout)
42 : VGM::ISolid(),
43 VGM::IPolycone(),
44 BaseVGM::VPolycone(),
45 fIsReflected(false),
46 fZValuesRefl(0),
47 fPolycone(0)
48{
57
58 // Apply units
59
60 double* z2 = new double[nofZplanes];
61 double* rin2 = new double[nofZplanes];
62 double* rout2 = new double[nofZplanes];
63
64 for (int i = 0; i < nofZplanes; i++) {
65 z2[i] = z[i] / ClhepVGM::Units::Length();
66 rin2[i] = rin[i] / ClhepVGM::Units::Length();
67 rout2[i] = rout[i] / ClhepVGM::Units::Length();
68 }
69
70 fPolycone = new G4Polycone(name, sphi / ClhepVGM::Units::Angle(),
71 dphi / ClhepVGM::Units::Angle(), nofZplanes, z2, rin2, rout2);
72
73 Geant4GM::SolidMap::Instance()->AddSolid(this, fPolycone);
74
75 CreateBuffers();
76
77 delete[] z2;
78 delete[] rin2;
79 delete[] rout2;
80}
81
82//_____________________________________________________________________________
84 G4Polycone* polycone, G4ReflectedSolid* reflPolycone)
85 : VGM::ISolid(),
86 VGM::IPolycone(),
87 BaseVGM::VPolycone(),
88 fIsReflected(false),
89 fZValuesRefl(0),
90 fPolycone(polycone)
91{
93
94 if (reflPolycone) {
95 int nofZplanes = polycone->GetOriginalParameters()->Num_z_planes;
96 double* zValues = polycone->GetOriginalParameters()->Z_values;
97 fZValuesRefl = new double[nofZplanes];
98 for (int i = 0; i < nofZplanes; i++) fZValuesRefl[i] = -zValues[i];
99
100 fIsReflected = true;
101 Geant4GM::SolidMap::Instance()->AddSolid(this, reflPolycone);
102 }
103 else
104 Geant4GM::SolidMap::Instance()->AddSolid(this, polycone);
105
106 CreateBuffers();
107}
108
109//_____________________________________________________________________________
111 : VGM::ISolid(),
112 VGM::IPolycone(),
113 BaseVGM::VPolycone(),
114 fIsReflected(false),
115 fZValuesRefl(0),
116 fPolycone(0)
117{
119
120 // Get parameters
121 double* z = new double[2];
122 double* rin = new double[2];
123 double* rout = new double[2];
124 z[0] = -cons->GetZHalfLength();
125 z[1] = cons->GetZHalfLength();
126 rin[0] = cons->GetInnerRadiusMinusZ();
127 rin[1] = cons->GetInnerRadiusPlusZ();
128 rout[0] = cons->GetOuterRadiusMinusZ();
129 rout[1] = cons->GetOuterRadiusPlusZ();
130
131 fPolycone = new G4Polycone(cons->GetName(), cons->GetStartPhiAngle(),
132 cons->GetDeltaPhiAngle(), 2, z, rin, rout);
133
134 Geant4GM::SolidMap::Instance()->AddSolid(this, fPolycone);
135}
136
137//_____________________________________________________________________________
139 : VGM::ISolid(),
140 VGM::IPolycone(),
141 BaseVGM::VPolycone(),
142 fIsReflected(false),
143 fZValuesRefl(0),
144 fPolycone(0)
145{
147
148 // Get parameters
149 double* z = new double[2];
150 double* rin = new double[2];
151 double* rout = new double[2];
152 z[0] = -tubs->GetZHalfLength();
153 z[1] = tubs->GetZHalfLength();
154 rin[0] = tubs->GetInnerRadius();
155 rin[1] = tubs->GetInnerRadius();
156 rout[0] = tubs->GetOuterRadius();
157 rout[1] = tubs->GetOuterRadius();
158
159 fPolycone = new G4Polycone(tubs->GetName(), tubs->GetStartPhiAngle(),
160 tubs->GetDeltaPhiAngle(), 2, z, rin, rout);
161
162 Geant4GM::SolidMap::Instance()->AddSolid(this, fPolycone);
163}
164
165//_____________________________________________________________________________
167 : VGM::ISolid(), VGM::IPolycone(), BaseVGM::VPolycone()
168{
170}
171
172//_____________________________________________________________________________
174 : VGM::ISolid(rhs), VGM::IPolycone(rhs), BaseVGM::VPolycone(rhs)
175{
177}
178
179//_____________________________________________________________________________
181{
182 //
183 delete[] fZValuesRefl;
184}
185
186//_____________________________________________________________________________
187void Geant4GM::Polycone::CreateBuffers()
188{
189 if (!fgZBuffer) fgZBuffer = new double[fgkMaxNofZPlanes];
190 if (!fgRinBuffer) fgRinBuffer = new double[fgkMaxNofZPlanes];
191 if (!fgRoutBuffer) fgRoutBuffer = new double[fgkMaxNofZPlanes];
192}
193
194//_____________________________________________________________________________
195std::string Geant4GM::Polycone::Name() const { return fPolycone->GetName(); }
196
197//_____________________________________________________________________________
199{
200 return fPolycone->GetStartPhi() * ClhepVGM::Units::Angle();
201}
202
203//_____________________________________________________________________________
205{
206 double deltaPhi = fPolycone->GetEndPhi() - fPolycone->GetStartPhi();
207
208 return deltaPhi * ClhepVGM::Units::Angle();
209}
210
211//_____________________________________________________________________________
213{
214 return fPolycone->GetOriginalParameters()->Num_z_planes;
215}
216
217//_____________________________________________________________________________
219{
220 int nofZPlanes = NofZPlanes();
221 if (nofZPlanes > fgkMaxNofZPlanes) {
222 nofZPlanes = fgkMaxNofZPlanes;
223 std::cerr << "+++ Warning +++" << std::endl;
224 std::cerr << " Number of Zplanes > size of buffer." << std::endl;
225 std::cerr << " only " << nofZPlanes << " values are returned."
226 << std::endl;
227 }
228
229 for (int i = 0; i < nofZPlanes; i++)
230 if (!fIsReflected) {
231 fgZBuffer[i] = fPolycone->GetOriginalParameters()->Z_values[i];
232 fgZBuffer[i] *= ClhepVGM::Units::Length();
233 }
234 else
235 fgZBuffer[i] = fZValuesRefl[i] * ClhepVGM::Units::Length();
236
237 return fgZBuffer;
238}
239
240//_____________________________________________________________________________
242{
243 int nofZPlanes = NofZPlanes();
244 if (nofZPlanes > fgkMaxNofZPlanes) {
245 nofZPlanes = fgkMaxNofZPlanes;
246 std::cerr << "+++ Warning +++" << std::endl;
247 std::cerr << " Number of Zplanes > size of buffer." << std::endl;
248 std::cerr << " only " << nofZPlanes << " values are returned."
249 << std::endl;
250 }
251
252 for (int i = 0; i < nofZPlanes; i++) {
253 fgRinBuffer[i] = fPolycone->GetOriginalParameters()->Rmin[i];
254 fgRinBuffer[i] *= ClhepVGM::Units::Length();
255 }
256
257 return fgRinBuffer;
258}
259
260//_____________________________________________________________________________
262{
263 int nofZPlanes = NofZPlanes();
264 if (nofZPlanes > fgkMaxNofZPlanes) {
265 nofZPlanes = fgkMaxNofZPlanes;
266 std::cerr << "+++ Warning +++" << std::endl;
267 std::cerr << " Number of Zplanes > size of buffer." << std::endl;
268 std::cerr << " only " << nofZPlanes << " values are returned."
269 << std::endl;
270 }
271
272 for (int i = 0; i < nofZPlanes; i++) {
273 fgRoutBuffer[i] = fPolycone->GetOriginalParameters()->Rmax[i];
274 fgRoutBuffer[i] *= ClhepVGM::Units::Length();
275 }
276
277 return fgRoutBuffer;
278}
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
VGM implementation for Geant4 polycone solid.
Definition Polycone.h:35
virtual ~Polycone()
Definition Polycone.cxx:180
virtual double DeltaPhi() const
Return opening phi angle of the segment in deg.
Definition Polycone.cxx:204
virtual std::string Name() const
Return the name of this solid.
Definition Polycone.cxx:195
virtual double * InnerRadiusValues() const
Return the array of inner radius of the planes in mm.
Definition Polycone.cxx:241
virtual double * ZValues() const
Return the array of z positions of the planes in mm.
Definition Polycone.cxx:218
virtual double * OuterRadiusValues() const
Return the array of outer radius of the planes in mm.
Definition Polycone.cxx:261
virtual double StartPhi() const
Return starting phi angle of the segment in deg.
Definition Polycone.cxx:198
virtual int NofZPlanes() const
Return number of planes perpendicular to the z axis.
Definition Polycone.cxx:212
static SolidMap * Instance()
Definition SolidMap.cxx:28
void AddSolid(VGM::ISolid *, G4VSolid *)
Definition SolidMap.cxx:59
BaseVGM utilities.
Definition utilities.h:23
VGM interfaces.
Definition VMedium.h:28