Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4ParameterisationBox.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// class G4ParameterisationBox Implementation file
30//
31// 26.05.03 - P.Arce, Initial version
32// 08.04.04 - I.Hrivnacova, Implemented reflection
33// 21.04.10 - M.Asai, Added gaps
34// --------------------------------------------------------------------
35
37
38#include <iomanip>
39#include "G4ThreeVector.hh"
40#include "G4Transform3D.hh"
41#include "G4RotationMatrix.hh"
42#include "G4VPhysicalVolume.hh"
43#include "G4ReflectedSolid.hh"
44#include "G4Box.hh"
45
46//--------------------------------------------------------------------------
49 G4double offset, G4VSolid* msolid,
50 DivisionType divType )
51 : G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid )
52{
53 G4Box* msol = (G4Box*)(msolid);
54 if (msolid->GetEntityType() == "G4ReflectedSolid")
55 {
56 // Get constituent solid
57 G4VSolid* mConstituentSolid
58 = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid();
59 msol = (G4Box*)(mConstituentSolid);
60 fmotherSolid = msol;
61 fReflectedSolid = true;
62 }
63}
64
65//--------------------------------------------------------------------------
67{
68}
69
70//--------------------------------------------------------------------------
73 G4double offset, G4VSolid* msolid,
74 DivisionType divType )
75 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
76{
78 SetType( "DivisionBoxX" );
79
80 G4Box* mbox = (G4Box*)(fmotherSolid);
81 if( divType == DivWIDTH )
82 {
83 fnDiv = CalculateNDiv( 2*mbox->GetXHalfLength(), width, offset );
84 }
85 else if( divType == DivNDIV )
86 {
87 fwidth = CalculateWidth( 2*mbox->GetXHalfLength(), nDiv, offset );
88 }
89#ifdef G4DIVDEBUG
90 if( verbose >= 1 )
91 {
92 G4cout << " G4ParameterisationBoxX - no divisions "
93 << fnDiv << " = " << nDiv << G4endl
94 << " Offset " << foffset << " = " << offset << G4endl
95 << " Width " << fwidth << " = " << width << G4endl;
96 }
97#endif
98}
99
100//------------------------------------------------------------------------
102{
103}
104
105//------------------------------------------------------------------------
107{
108 G4Box* msol = (G4Box*)(fmotherSolid);
109 return 2*msol->GetXHalfLength();
110}
111
112//------------------------------------------------------------------------
113void
115ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
116{
117 G4Box* msol = (G4Box*)(fmotherSolid );
118 G4double mdx = msol->GetXHalfLength( );
119
120 //----- translation
121 G4ThreeVector origin(0.,0.,0.);
122 G4double posi = -mdx + foffset+(copyNo+0.5)*fwidth;
123
124 if( faxis == kXAxis )
125 {
126 origin.setX( posi );
127 }
128 else
129 {
130 G4Exception("G4ParameterisationBoxX::ComputeTransformation()",
131 "GeomDiv0002", FatalException,
132 "Only axes along X are allowed ! Axis: "+faxis);
133 }
134#ifdef G4DIVDEBUG
135 if( verbose >= 2 )
136 {
137 G4cout << std::setprecision(8) << " G4ParameterisationBoxX: "
138 << copyNo << G4endl
139 << " Position " << origin << " Axis " << faxis << G4endl;
140 }
141#endif
142 //----- set translation
143 physVol->SetTranslation( origin );
144}
145
146//------------------------------------------------------------------------
147void
149ComputeDimensions( G4Box& box, const G4int,
150 const G4VPhysicalVolume* ) const
151{
152 G4Box* msol = (G4Box*)(fmotherSolid);
153
154 G4double pDx = fwidth/2. - fhgap;
155 G4double pDy = msol->GetYHalfLength();
156 G4double pDz = msol->GetZHalfLength();
157
158 box.SetXHalfLength( pDx );
159 box.SetYHalfLength( pDy );
160 box.SetZHalfLength( pDz );
161
162#ifdef G4DIVDEBUG
163 if( verbose >= 2 )
164 {
165 G4cout << " G4ParameterisationBoxX::ComputeDimensions()" << G4endl
166 << " pDx: " << pDz << G4endl;
167 box.DumpInfo();
168 }
169#endif
170}
171
172//------------------------------------------------------------------------
174G4ParameterisationBoxY( EAxis axis, G4int nDiv, G4double width,
175 G4double offset, G4VSolid* msolid,
176 DivisionType divType)
177 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
178{
180 SetType( "DivisionBoxY" );
181
182 G4Box* mbox = (G4Box*)(fmotherSolid);
183 if( divType == DivWIDTH )
184 {
185 fnDiv = CalculateNDiv( 2*mbox->GetYHalfLength(), width, offset );
186 }
187 else if( divType == DivNDIV )
188 {
189 fwidth = CalculateWidth( 2*mbox->GetYHalfLength(), nDiv, offset );
190 }
191
192#ifdef G4DIVDEBUG
193 if( verbose >= 1 )
194 {
195 G4cout << " G4ParameterisationBoxY - no divisions " << fnDiv << " = "
196 << nDiv << ". Offset " << foffset << " = " << offset
197 << ". Width " << fwidth << " = " << width << G4endl;
198 }
199#endif
200}
201
202//------------------------------------------------------------------------
204{
205}
206
207//------------------------------------------------------------------------
209{
210 G4Box* msol = (G4Box*)(fmotherSolid);
211 return 2*msol->GetYHalfLength();
212}
213
214//------------------------------------------------------------------------
215void
217ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
218{
219 G4Box* msol = (G4Box*)(fmotherSolid);
220 G4double mdy = msol->GetYHalfLength();
221
222 //----- translation
223 G4ThreeVector origin(0.,0.,0.);
224 G4double posi = -mdy + foffset + (copyNo+0.5)*fwidth;
225 if( faxis == kYAxis )
226 {
227 origin.setY( posi );
228 }
229 else
230 {
231 G4Exception("G4ParameterisationBoxY::ComputeTransformation()",
232 "GeomDiv0002", FatalException,
233 "Only axes along Y are allowed ! Axis: "+faxis);
234 }
235#ifdef G4DIVDEBUG
236 if( verbose >= 2 )
237 {
238 G4cout << std::setprecision(8) << " G4ParameterisationBoxY: "
239 << copyNo << G4endl
240 << " Position " << origin << " Axis " << faxis << G4endl;
241 }
242#endif
243 //----- set translation
244 physVol->SetTranslation( origin );
245}
246
247//------------------------------------------------------------------------
248void
250ComputeDimensions( G4Box& box, const G4int,
251 const G4VPhysicalVolume* ) const
252{
253 G4Box* msol = (G4Box*)(fmotherSolid);
254
255 G4double pDx = msol->GetXHalfLength();
256 G4double pDy = fwidth/2. - fhgap;
257 G4double pDz = msol->GetZHalfLength();
258
259 box.SetXHalfLength( pDx );
260 box.SetYHalfLength( pDy );
261 box.SetZHalfLength( pDz );
262
263#ifdef G4DIVDEBUG
264 if( verbose >= 2 )
265 {
266 G4cout << " G4ParameterisationBoxY::ComputeDimensions()" << G4endl
267 << " pDx: " << pDz << G4endl;
268 box.DumpInfo();
269 }
270#endif
271}
272
273//------------------------------------------------------------------------
275G4ParameterisationBoxZ( EAxis axis, G4int nDiv, G4double width,
276 G4double offset, G4VSolid* msolid,
277 DivisionType divType )
278 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
279{
281 SetType( "DivisionBoxZ" );
282
283 G4Box* mbox = (G4Box*)(fmotherSolid);
284 if( divType == DivWIDTH )
285 {
286 fnDiv = CalculateNDiv( 2*mbox->GetZHalfLength(), width, offset );
287 }
288 else if ( divType == DivNDIV )
289 {
290 fwidth = CalculateWidth( 2*mbox->GetZHalfLength(), nDiv, offset );
291 }
292#ifdef G4DIVDEBUG
293 if( verbose >= 1 )
294 {
295 G4cout << " G4ParameterisationBoxZ - no divisions " << fnDiv << " = "
296 << nDiv << ". Offset " << foffset << " = " << offset
297 << ". Width " << fwidth << " = " << width << G4endl;
298 }
299#endif
300}
301
302//------------------------------------------------------------------------
304{
305}
306
307//------------------------------------------------------------------------
309{
310 G4Box* msol = (G4Box*)(fmotherSolid);
311 return 2*msol->GetZHalfLength();
312}
313
314//------------------------------------------------------------------------
315void
317ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const
318{
319 G4Box* msol = (G4Box*)(fmotherSolid );
320 G4double mdz = msol->GetZHalfLength();
321
322 //----- translation
323 G4ThreeVector origin(0.,0.,0.);
324 G4double posi = -mdz + OffsetZ() + (copyNo+0.5)*fwidth;
325
326 if( faxis == kZAxis )
327 {
328 origin.setZ( posi );
329 }
330 else
331 {
332 G4Exception("G4ParameterisationBoxZ::ComputeTransformation()",
333 "GeomDiv0002", FatalException,
334 "Only axes along Z are allowed ! Axis: "+faxis);
335 }
336#ifdef G4DIVDEBUG
337 if( verbose >= 2 )
338 {
339 G4cout << std::setprecision(8) << " G4ParameterisationBoxZ: "
340 << copyNo << G4endl
341 << " Position " << origin << " Axis " << faxis << G4endl;
342 }
343#endif
344 //----- set translation
345 physVol->SetTranslation( origin );
346}
347
348//------------------------------------------------------------------------
349void
351ComputeDimensions( G4Box& box, const G4int,
352 const G4VPhysicalVolume* ) const
353{
354 G4Box* msol = (G4Box*)(fmotherSolid);
355
356 G4double pDx = msol->GetXHalfLength();
357 G4double pDy = msol->GetYHalfLength();
358 G4double pDz = fwidth/2. - fhgap;
359
360 box.SetXHalfLength( pDx );
361 box.SetYHalfLength( pDy );
362 box.SetZHalfLength( pDz );
363
364#ifdef G4DIVDEBUG
365 if( verbose >= 2 )
366 {
367 G4cout << " G4ParameterisationBoxZ::ComputeDimensions()" << G4endl
368 << " pDx: " << pDz << G4endl;
369 box.DumpInfo();
370 }
371#endif
372}
373
@ FatalException
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
void setY(double)
void setZ(double)
void setX(double)
Definition: G4Box.hh:55
G4double GetYHalfLength() const
G4double GetZHalfLength() const
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:170
G4double GetXHalfLength() const
void SetYHalfLength(G4double dy)
Definition: G4Box.cc:150
void SetXHalfLength(G4double dx)
Definition: G4Box.cc:130
G4ParameterisationBoxX(EAxis axis, G4int nCopies, G4double offset, G4double step, G4VSolid *msolid, DivisionType divType)
void ComputeDimensions(G4Box &box, const G4int copyNo, const G4VPhysicalVolume *physVol) const
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
G4ParameterisationBoxY(EAxis axis, G4int nCopies, G4double offset, G4double step, G4VSolid *msolid, DivisionType divType)
void ComputeDimensions(G4Box &box, const G4int copyNo, const G4VPhysicalVolume *physVol) const
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
void ComputeDimensions(G4Box &box, const G4int copyNo, const G4VPhysicalVolume *physVol) const
G4ParameterisationBoxZ(EAxis axis, G4int nCopies, G4double offset, G4double step, G4VSolid *msolid, DivisionType divType)
void SetType(const G4String &type)
G4double CalculateWidth(G4double motherDim, G4int nDiv, G4double offset) const
G4int CalculateNDiv(G4double motherDim, G4double width, G4double offset) const
G4VParameterisationBox(EAxis axis, G4int nCopies, G4double offset, G4double step, G4VSolid *msolid, DivisionType divType)
void SetTranslation(const G4ThreeVector &v)
void DumpInfo() const
virtual G4GeometryType GetEntityType() const =0
EAxis
Definition: geomdefs.hh:54
@ kYAxis
Definition: geomdefs.hh:54
@ kXAxis
Definition: geomdefs.hh:54
@ kZAxis
Definition: geomdefs.hh:54
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41