source: trunk/source/geometry/divisions/src/G4ParameterisationBox.cc@ 1165

Last change on this file since 1165 was 1010, checked in by garnier, 17 years ago

update

File size: 11.3 KB
Line 
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: G4ParameterisationBox.cc,v 1.10 2006/06/29 18:18:35 gunter Exp $
28// GEANT4 tag $Name: geant4-09-02-ref-02 $
29//
30// class G4ParameterisationBox Implementation file
31//
32// 26.05.03 - P.Arce, Initial version
33// 08.04.04 - I.Hrivnacova, Implemented reflection
34// --------------------------------------------------------------------
35
36#include "G4ParameterisationBox.hh"
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//--------------------------------------------------------------------------
47G4VParameterisationBox::
48G4VParameterisationBox( EAxis axis, G4int nDiv, G4double width,
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//--------------------------------------------------------------------------
66G4VParameterisationBox::~G4VParameterisationBox()
67{
68}
69
70//--------------------------------------------------------------------------
71G4ParameterisationBoxX::
72G4ParameterisationBoxX( EAxis axis, G4int nDiv, G4double width,
73 G4double offset, G4VSolid* msolid,
74 DivisionType divType )
75 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
76{
77 CheckParametersValidity();
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//------------------------------------------------------------------------
101G4ParameterisationBoxX::~G4ParameterisationBoxX()
102{
103}
104
105//------------------------------------------------------------------------
106G4double G4ParameterisationBoxX::GetMaxParameter() const
107{
108 G4Box* msol = (G4Box*)(fmotherSolid);
109 return 2*msol->GetXHalfLength();
110}
111
112//------------------------------------------------------------------------
113void
114G4ParameterisationBoxX::
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 "IllegalConstruct", 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
148G4ParameterisationBoxX::
149ComputeDimensions( G4Box& box, const G4int,
150 const G4VPhysicalVolume* ) const
151{
152 G4Box* msol = (G4Box*)(fmotherSolid);
153
154 G4double pDx = fwidth/2.;
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//------------------------------------------------------------------------
173G4ParameterisationBoxY::
174G4ParameterisationBoxY( EAxis axis, G4int nDiv, G4double width,
175 G4double offset, G4VSolid* msolid,
176 DivisionType divType)
177 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
178{
179 CheckParametersValidity();
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//------------------------------------------------------------------------
203G4ParameterisationBoxY::~G4ParameterisationBoxY()
204{
205}
206
207//------------------------------------------------------------------------
208G4double G4ParameterisationBoxY::GetMaxParameter() const
209{
210 G4Box* msol = (G4Box*)(fmotherSolid);
211 return 2*msol->GetYHalfLength();
212}
213
214//------------------------------------------------------------------------
215void
216G4ParameterisationBoxY::
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 "IllegalConstruct", 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
249G4ParameterisationBoxY::
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.;
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//------------------------------------------------------------------------
274G4ParameterisationBoxZ::
275G4ParameterisationBoxZ( EAxis axis, G4int nDiv, G4double width,
276 G4double offset, G4VSolid* msolid,
277 DivisionType divType )
278 : G4VParameterisationBox( axis, nDiv, width, offset, msolid, divType )
279{
280 CheckParametersValidity();
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//------------------------------------------------------------------------
303G4ParameterisationBoxZ::~G4ParameterisationBoxZ()
304{
305}
306
307//------------------------------------------------------------------------
308G4double G4ParameterisationBoxZ::GetMaxParameter() const
309{
310 G4Box* msol = (G4Box*)(fmotherSolid);
311 return 2*msol->GetZHalfLength();
312}
313
314//------------------------------------------------------------------------
315void
316G4ParameterisationBoxZ::
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 "IllegalConstruct", 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
350G4ParameterisationBoxZ::
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.;
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
Note: See TracBrowser for help on using the repository browser.