Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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// G4ParameterisationBox[X/Y/Z] implementation
27//
28// 26.05.03 - P.Arce, Initial version
29// 08.04.04 - I.Hrivnacova, Implemented reflection
30// 21.04.10 - M.Asai, Added gaps
31// --------------------------------------------------------------------
32
34
35#include <iomanip>
36#include "G4ThreeVector.hh"
37#include "G4Transform3D.hh"
38#include "G4RotationMatrix.hh"
39#include "G4VPhysicalVolume.hh"
40#include "G4ReflectedSolid.hh"
41#include "G4Box.hh"
42
43//--------------------------------------------------------------------------
46 G4double offset, G4VSolid* msolid,
47 DivisionType divType )
48 : G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid )
49{
50 G4Box* msol = (G4Box*)(msolid);
51 if (msolid->GetEntityType() == "G4ReflectedSolid")
52 {
53 // Get constituent solid
54 G4VSolid* mConstituentSolid
55 = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid();
56 msol = (G4Box*)(mConstituentSolid);
57 fmotherSolid = msol;
58 fReflectedSolid = true;
59 }
60}
61
62//--------------------------------------------------------------------------
64{
65}
66
67//--------------------------------------------------------------------------
70 G4double offset, G4VSolid* msolid,
71 DivisionType divType )
72 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
73{
75 SetType( "DivisionBoxX" );
76
77 G4Box* mbox = (G4Box*)(fmotherSolid);
78 if( divType == DivWIDTH )
79 {
80 fnDiv = CalculateNDiv( 2*mbox->GetXHalfLength(), width, offset );
81 }
82 else if( divType == DivNDIV )
83 {
84 fwidth = CalculateWidth( 2*mbox->GetXHalfLength(), nDiv, offset );
85 }
86#ifdef G4DIVDEBUG
87 if( verbose >= 1 )
88 {
89 G4cout << " G4ParameterisationBoxX - no divisions "
90 << fnDiv << " = " << nDiv << G4endl
91 << " Offset " << foffset << " = " << offset << G4endl
92 << " Width " << fwidth << " = " << width << G4endl;
93 }
94#endif
95}
96
97//------------------------------------------------------------------------
99{
100}
101
102//------------------------------------------------------------------------
104{
105 G4Box* msol = (G4Box*)(fmotherSolid);
106 return 2*msol->GetXHalfLength();
107}
108
109//------------------------------------------------------------------------
110void
112ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
113{
114 G4Box* msol = (G4Box*)(fmotherSolid );
115 G4double mdx = msol->GetXHalfLength( );
116
117 //----- translation
118 G4ThreeVector origin(0.,0.,0.);
119 G4double posi = -mdx + foffset+(copyNo+0.5)*fwidth;
120
121 if( faxis == kXAxis )
122 {
123 origin.setX( posi );
124 }
125 else
126 {
127 std::ostringstream message;
128 message << "Only axes along X are allowed ! Axis: " << faxis;
129 G4Exception("G4ParameterisationBoxX::ComputeTransformation()",
130 "GeomDiv0002", FatalException, message);
131 }
132#ifdef G4DIVDEBUG
133 if( verbose >= 2 )
134 {
135 G4cout << std::setprecision(8) << " G4ParameterisationBoxX: "
136 << copyNo << G4endl
137 << " Position " << origin << " Axis " << faxis << G4endl;
138 }
139#endif
140 //----- set translation
141 physVol->SetTranslation( origin );
142}
143
144//------------------------------------------------------------------------
145void
147ComputeDimensions( G4Box& box, const G4int,
148 const G4VPhysicalVolume* ) const
149{
150 G4Box* msol = (G4Box*)(fmotherSolid);
151
152 G4double pDx = fwidth/2. - fhgap;
153 G4double pDy = msol->GetYHalfLength();
154 G4double pDz = msol->GetZHalfLength();
155
156 box.SetXHalfLength( pDx );
157 box.SetYHalfLength( pDy );
158 box.SetZHalfLength( pDz );
159
160#ifdef G4DIVDEBUG
161 if( verbose >= 2 )
162 {
163 G4cout << " G4ParameterisationBoxX::ComputeDimensions()" << G4endl
164 << " pDx: " << pDz << G4endl;
165 box.DumpInfo();
166 }
167#endif
168}
169
170//------------------------------------------------------------------------
172G4ParameterisationBoxY( EAxis axis, G4int nDiv, G4double width,
173 G4double offset, G4VSolid* msolid,
174 DivisionType divType)
175 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
176{
178 SetType( "DivisionBoxY" );
179
180 G4Box* mbox = (G4Box*)(fmotherSolid);
181 if( divType == DivWIDTH )
182 {
183 fnDiv = CalculateNDiv( 2*mbox->GetYHalfLength(), width, offset );
184 }
185 else if( divType == DivNDIV )
186 {
187 fwidth = CalculateWidth( 2*mbox->GetYHalfLength(), nDiv, offset );
188 }
189
190#ifdef G4DIVDEBUG
191 if( verbose >= 1 )
192 {
193 G4cout << " G4ParameterisationBoxY - no divisions " << fnDiv << " = "
194 << nDiv << ". Offset " << foffset << " = " << offset
195 << ". Width " << fwidth << " = " << width << G4endl;
196 }
197#endif
198}
199
200//------------------------------------------------------------------------
202{
203}
204
205//------------------------------------------------------------------------
207{
208 G4Box* msol = (G4Box*)(fmotherSolid);
209 return 2*msol->GetYHalfLength();
210}
211
212//------------------------------------------------------------------------
213void
215ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
216{
217 G4Box* msol = (G4Box*)(fmotherSolid);
218 G4double mdy = msol->GetYHalfLength();
219
220 //----- translation
221 G4ThreeVector origin(0.,0.,0.);
222 G4double posi = -mdy + foffset + (copyNo+0.5)*fwidth;
223 if( faxis == kYAxis )
224 {
225 origin.setY( posi );
226 }
227 else
228 {
229 std::ostringstream message;
230 message << "Only axes along Y are allowed ! Axis: " << faxis;
231 G4Exception("G4ParameterisationBoxY::ComputeTransformation()",
232 "GeomDiv0002", FatalException, message);
233 }
234#ifdef G4DIVDEBUG
235 if( verbose >= 2 )
236 {
237 G4cout << std::setprecision(8) << " G4ParameterisationBoxY: "
238 << copyNo << G4endl
239 << " Position " << origin << " Axis " << faxis << G4endl;
240 }
241#endif
242 //----- set translation
243 physVol->SetTranslation( origin );
244}
245
246//------------------------------------------------------------------------
247void
249ComputeDimensions( G4Box& box, const G4int,
250 const G4VPhysicalVolume* ) const
251{
252 G4Box* msol = (G4Box*)(fmotherSolid);
253
254 G4double pDx = msol->GetXHalfLength();
255 G4double pDy = fwidth/2. - fhgap;
256 G4double pDz = msol->GetZHalfLength();
257
258 box.SetXHalfLength( pDx );
259 box.SetYHalfLength( pDy );
260 box.SetZHalfLength( pDz );
261
262#ifdef G4DIVDEBUG
263 if( verbose >= 2 )
264 {
265 G4cout << " G4ParameterisationBoxY::ComputeDimensions()" << G4endl
266 << " pDx: " << pDz << G4endl;
267 box.DumpInfo();
268 }
269#endif
270}
271
272//------------------------------------------------------------------------
274G4ParameterisationBoxZ( EAxis axis, G4int nDiv, G4double width,
275 G4double offset, G4VSolid* msolid,
276 DivisionType divType )
277 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
278{
280 SetType( "DivisionBoxZ" );
281
282 G4Box* mbox = (G4Box*)(fmotherSolid);
283 if( divType == DivWIDTH )
284 {
285 fnDiv = CalculateNDiv( 2*mbox->GetZHalfLength(), width, offset );
286 }
287 else if ( divType == DivNDIV )
288 {
289 fwidth = CalculateWidth( 2*mbox->GetZHalfLength(), nDiv, offset );
290 }
291#ifdef G4DIVDEBUG
292 if( verbose >= 1 )
293 {
294 G4cout << " G4ParameterisationBoxZ - no divisions " << fnDiv << " = "
295 << nDiv << ". Offset " << foffset << " = " << offset
296 << ". Width " << fwidth << " = " << width << G4endl;
297 }
298#endif
299}
300
301//------------------------------------------------------------------------
303{
304}
305
306//------------------------------------------------------------------------
308{
309 G4Box* msol = (G4Box*)(fmotherSolid);
310 return 2*msol->GetZHalfLength();
311}
312
313//------------------------------------------------------------------------
314void
316ComputeTransformation( const G4int copyNo, G4VPhysicalVolume *physVol ) const
317{
318 G4Box* msol = (G4Box*)(fmotherSolid );
319 G4double mdz = msol->GetZHalfLength();
320
321 //----- translation
322 G4ThreeVector origin(0.,0.,0.);
323 G4double posi = -mdz + OffsetZ() + (copyNo+0.5)*fwidth;
324
325 if( faxis == kZAxis )
326 {
327 origin.setZ( posi );
328 }
329 else
330 {
331 std::ostringstream message;
332 message << "Only axes along Z are allowed ! Axis: " << faxis;
333 G4Exception("G4ParameterisationBoxZ::ComputeTransformation()",
334 "GeomDiv0002", FatalException, message);
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
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
void setY(double)
void setZ(double)
void setX(double)
Definition: G4Box.hh:56
G4double GetYHalfLength() const
G4double GetZHalfLength() const
void SetZHalfLength(G4double dz)
Definition: G4Box.cc:172
G4double GetXHalfLength() const
void SetYHalfLength(G4double dy)
Definition: G4Box.cc:149
void SetXHalfLength(G4double dx)
Definition: G4Box.cc:125
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:56
@ kXAxis
Definition: geomdefs.hh:55
@ kZAxis
Definition: geomdefs.hh:57