Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ParameterisationTrd.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 G4ParameterisationTrd 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 "G4RotationMatrix.hh"
41#include "G4VPhysicalVolume.hh"
42#include "G4LogicalVolume.hh"
43#include "G4ReflectedSolid.hh"
44#include "G4Trd.hh"
45#include "G4Trap.hh"
46
47//--------------------------------------------------------------------------
50 G4double offset, G4VSolid* msolid,
51 DivisionType divType )
52 : G4VDivisionParameterisation( axis, nDiv, width, offset, divType, msolid ),
53 bDivInTrap(false)
54{
55 G4Trd* msol = (G4Trd*)(msolid);
56 if (msolid->GetEntityType() == "G4ReflectedSolid")
57 {
58 // Get constituent solid
59 G4VSolid* mConstituentSolid
60 = ((G4ReflectedSolid*)msolid)->GetConstituentMovedSolid();
61 msol = (G4Trd*)(mConstituentSolid);
62
63 // Create a new solid with inversed parameters
64 G4Trd* newSolid
65 = new G4Trd(msol->GetName(),
66 msol->GetXHalfLength2(), msol->GetXHalfLength1(),
67 msol->GetYHalfLength2(), msol->GetYHalfLength1(),
68 msol->GetZHalfLength());
69 msol = newSolid;
70 fmotherSolid = newSolid;
71 fReflectedSolid = true;
72 fDeleteSolid = true;
73 }
74}
75
76//------------------------------------------------------------------------
78{
79}
80
81//------------------------------------------------------------------------
84 G4double width, G4double offset,
85 G4VSolid* msolid, DivisionType divType )
86 : G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType )
87{
89 SetType( "DivisionTrdX" );
90
91 G4Trd* msol = (G4Trd*)(fmotherSolid);
92 if( divType == DivWIDTH )
93 {
95 width, offset );
96 }
97 else if( divType == DivNDIV )
98 {
100 nDiv, offset );
101 }
102
103#ifdef G4DIVDEBUG
104 if( verbose >= 1 )
105 {
106 G4cout << " G4ParameterisationTrdX - ## divisions " << fnDiv << " = "
107 << nDiv << G4endl
108 << " Offset " << foffset << " = " << offset << G4endl
109 << " Width " << fwidth << " = " << width << G4endl;
110 }
111#endif
112
113 G4double mpDx1 = msol->GetXHalfLength1();
114 G4double mpDx2 = msol->GetXHalfLength2();
115 if( std::fabs(mpDx1 - mpDx2) > kCarTolerance )
116 {
117 bDivInTrap = true;
118 }
119}
120
121//------------------------------------------------------------------------
123{
124}
125
126//------------------------------------------------------------------------
128{
129 G4Trd* msol = (G4Trd*)(fmotherSolid);
130 return (msol->GetXHalfLength1()+msol->GetXHalfLength2());
131}
132
133//------------------------------------------------------------------------
134void
136ComputeTransformation( const G4int copyNo,
137 G4VPhysicalVolume *physVol ) const
138{
139 G4Trd* msol = (G4Trd*)(fmotherSolid );
140 G4double mdx = ( msol->GetXHalfLength1() + msol->GetXHalfLength2() ) / 2.;
141
142 //----- translation
143 G4ThreeVector origin(0.,0.,0.);
144 G4double posi;
145 if( !bDivInTrap )
146 {
147 posi = -mdx + foffset + (copyNo+0.5)*fwidth;
148 }
149 else
150 {
151 G4double aveHL = (msol->GetXHalfLength1()+msol->GetXHalfLength2())/2.;
152 posi = - aveHL + foffset + (copyNo+0.5)*aveHL/fnDiv*2;
153 }
154 if( faxis == kXAxis )
155 {
156 origin.setX( posi );
157 }
158 else
159 {
160 G4Exception("G4ParameterisationTrdX::ComputeTransformation()",
161 "GeomDiv0002", FatalException,
162 "Only axes along X are allowed, and axis is: "+faxis);
163 }
164
165#ifdef G4DIVDEBUG
166 if( verbose >= 2 )
167 {
168 G4cout << std::setprecision(8)
169 << " G4ParameterisationTrdX::ComputeTransformation() "
170 << copyNo << G4endl
171 << " Position: " << origin << " - Axis: " << faxis << G4endl;
172 }
173#endif
174
175 //----- set translation
176 physVol->SetTranslation( origin );
177}
178
179//--------------------------------------------------------------------------
180void
182ComputeDimensions( G4Trd& trd, const G4int, const G4VPhysicalVolume* ) const
183{
184 G4Trd* msol = (G4Trd*)(fmotherSolid);
185
186 G4double pDy1 = msol->GetYHalfLength1();
187 G4double pDy2 = msol->GetYHalfLength2();
188 G4double pDz = msol->GetZHalfLength();
189 G4double pDx = fwidth/2. - fhgap;
190
191 trd.SetAllParameters ( pDx, pDx, pDy1, pDy2, pDz );
192
193#ifdef G4DIVDEBUG
194 if( verbose >= 2 )
195 {
196 G4cout << " G4ParameterisationTrdX::ComputeDimensions():"
197 << copyNo << G4endl;
198 trd.DumpInfo();
199 }
200#endif
201}
202
205{
206 if( bDivInTrap )
207 {
209 }
210 else
211 {
212 return fmotherSolid;
213 }
214}
215
216
217//--------------------------------------------------------------------------
218void
220 const G4VPhysicalVolume* ) const
221{
222 G4Trd* msol = (G4Trd*)(fmotherSolid);
223 G4double pDy1 = msol->GetYHalfLength1();
224 G4double pDy2 = msol->GetYHalfLength2();
225 G4double pDz = msol->GetZHalfLength();
226 G4double pDx1 = msol->GetXHalfLength1()/fnDiv;
227 G4double pDx2 = msol->GetXHalfLength2()/fnDiv;
228
229 G4double cxy1 = -msol->GetXHalfLength1() + foffset
230 + (copyNo+0.5)*pDx1*2;// centre of the side at y=-pDy1
231 G4double cxy2 = -msol->GetXHalfLength2() + foffset
232 + (copyNo+0.5)*pDx2*2;// centre of the side at y=+pDy1
233 G4double alp = std::atan( (cxy2-cxy1)/pDz );
234
235 trap.SetAllParameters ( pDz,
236 0.,
237 0.,
238 pDy1,
239 pDx1,
240 pDx2,
241 alp,
242 pDy2,
243 pDx1 - fhgap,
244 pDx2 - fhgap * pDx2/pDx1,
245 alp);
246
247#ifdef G4DIVDEBUG
248 if( verbose >= 2 )
249 {
250 G4cout << " G4ParameterisationTrdX::ComputeDimensions():"
251 << copyNo << G4endl;
252 trap.DumpInfo();
253 }
254#endif
255}
256
257//--------------------------------------------------------------------------
259{
261/*
262 G4Trd* msol = (G4Trd*)(fmotherSolid);
263
264 G4double mpDx1 = msol->GetXHalfLength1();
265 G4double mpDx2 = msol->GetXHalfLength2();
266 bDivInTrap = false;
267
268 if( std::fabs(mpDx1 - mpDx2) > kCarTolerance )
269 {
270 std::ostringstream message;
271 message << "Invalid solid specification. NOT supported." << G4endl
272 << "Making a division of a TRD along axis X," << G4endl
273 << "while the X half lengths are not equal," << G4endl
274 << "is not (yet) supported. It will result" << G4endl
275 << "in non-equal division solids.";
276 G4Exception("G4ParameterisationTrdX::CheckParametersValidity()",
277 "GeomDiv0001", FatalException, message);
278 }
279*/
280}
281
282//--------------------------------------------------------------------------
283void G4ParameterisationTrdX::
284ComputeTrapParams()
285{
286}
287
288//--------------------------------------------------------------------------
291 G4double width, G4double offset,
292 G4VSolid* msolid, DivisionType divType)
293 : G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType )
294{
296 SetType( "DivisionTrdY" );
297
298 G4Trd* msol = (G4Trd*)(fmotherSolid);
299 if( divType == DivWIDTH )
300 {
302 width, offset );
303 }
304 else if( divType == DivNDIV )
305 {
307 nDiv, offset );
308 }
309
310#ifdef G4DIVDEBUG
311 if( verbose >= 1 )
312 {
313 G4cout << " G4ParameterisationTrdY no divisions " << fnDiv
314 << " = " << nDiv << G4endl
315 << " Offset " << foffset << " = " << offset << G4endl
316 << " width " << fwidth << " = " << width << G4endl;
317 }
318#endif
319}
320
321//------------------------------------------------------------------------
323{
324}
325
326//------------------------------------------------------------------------
328{
329 G4Trd* msol = (G4Trd*)(fmotherSolid);
330 return 2*msol->GetYHalfLength1();
331}
332
333//--------------------------------------------------------------------------
334void
336ComputeTransformation( const G4int copyNo, G4VPhysicalVolume* physVol ) const
337{
338 G4Trd* msol = (G4Trd*)(fmotherSolid );
339 G4double mdy = msol->GetYHalfLength1();
340
341 //----- translation
342 G4ThreeVector origin(0.,0.,0.);
343 G4double posi = -mdy + foffset + (copyNo+0.5)*fwidth;
344
345 if( faxis == kYAxis )
346 {
347 origin.setY( posi );
348 }
349 else
350 {
351 G4Exception("G4ParameterisationTrdY::ComputeTransformation()",
352 "GeomDiv0002", FatalException,
353 "Only axes along Y are allowed !");
354 }
355
356#ifdef G4DIVDEBUG
357 if( verbose >= 2 )
358 {
359 G4cout << std::setprecision(8)
360 << " G4ParameterisationTrdY::ComputeTransformation " << copyNo
361 << " pos " << origin << " rot mat " << " axis " << faxis << G4endl;
362 }
363#endif
364
365 //----- set translation
366 physVol->SetTranslation( origin );
367}
368
369//--------------------------------------------------------------------------
370void
372ComputeDimensions(G4Trd& trd, const G4int, const G4VPhysicalVolume*) const
373{
374 //---- The division along Y of a Trd will result a Trd, only
375 //--- if Y at -Z and +Z are equal, else use the G4Trap version
376 G4Trd* msol = (G4Trd*)(fmotherSolid);
377
378 G4double pDx1 = msol->GetXHalfLength1();
379 G4double pDx2 = msol->GetXHalfLength2();
380 G4double pDz = msol->GetZHalfLength();
381 G4double pDy = fwidth/2. - fhgap;
382
383 trd.SetAllParameters ( pDx1, pDx2, pDy, pDy, pDz );
384
385#ifdef G4DIVDEBUG
386 if( verbose >= 2 )
387 {
388 G4cout << " G4ParameterisationTrdY::ComputeDimensions():" << G4endl;
389 trd.DumpInfo();
390 }
391#endif
392}
393
394//--------------------------------------------------------------------------
396{
398
399 G4Trd* msol = (G4Trd*)(fmotherSolid);
400
401 G4double mpDy1 = msol->GetYHalfLength1();
402 G4double mpDy2 = msol->GetYHalfLength2();
403
404 if( std::fabs(mpDy1 - mpDy2) > kCarTolerance )
405 {
406 std::ostringstream message;
407 message << "Invalid solid specification. NOT supported." << G4endl
408 << "Making a division of a TRD along axis Y while" << G4endl
409 << "the Y half lengths are not equal is not (yet)" << G4endl
410 << "supported. It will result in non-equal" << G4endl
411 << "division solids.";
412 G4Exception("G4ParameterisationTrdY::CheckParametersValidity()",
413 "GeomDiv0001", FatalException, message);
414 }
415}
416
417//--------------------------------------------------------------------------
420 G4double width, G4double offset,
421 G4VSolid* msolid, DivisionType divType )
422 : G4VParameterisationTrd( axis, nDiv, width, offset, msolid, divType )
423{
425 SetType( "DivTrdZ" );
426
427 G4Trd* msol = (G4Trd*)(fmotherSolid);
428 if( divType == DivWIDTH )
429 {
431 width, offset );
432 }
433 else if( divType == DivNDIV )
434 {
436 nDiv, offset );
437 }
438
439#ifdef G4DIVDEBUG
440 if( verbose >= 1 )
441 {
442 G4cout << " G4ParameterisationTrdZ no divisions " << fnDiv
443 << " = " << nDiv << G4endl
444 << " Offset " << foffset << " = " << offset << G4endl
445 << " Width " << fwidth << " = " << width << G4endl;
446 }
447#endif
448}
449
450//------------------------------------------------------------------------
452{
453}
454
455//------------------------------------------------------------------------
457{
458 G4Trd* msol = (G4Trd*)(fmotherSolid);
459 return 2*msol->GetZHalfLength();
460}
461
462//--------------------------------------------------------------------------
463void
465ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
466{
467 G4Trd* msol = (G4Trd*)(fmotherSolid );
468 G4double mdz = msol->GetZHalfLength();
469
470 //----- translation
471 G4ThreeVector origin(0.,0.,0.);
472 G4double posi = -mdz + OffsetZ() + (copyNo+0.5)*fwidth;
473 if( faxis == kZAxis )
474 {
475 origin.setZ( posi );
476 }
477 else
478 {
479 G4Exception("G4ParameterisationTrdZ::ComputeTransformation()",
480 "GeomDiv0002", FatalException,
481 "Only axes along Z are allowed !");
482 }
483
484#ifdef G4DIVDEBUG
485 if( verbose >= 1 )
486 {
487 G4cout << std::setprecision(8) << " G4ParameterisationTrdZ: "
488 << copyNo << G4endl
489 << " Position: " << origin << " - Offset: " << foffset
490 << " - Width: " << fwidth << " Axis " << faxis << G4endl;
491 }
492#endif
493
494 //----- set translation
495 physVol->SetTranslation( origin );
496}
497
498//--------------------------------------------------------------------------
499void
501ComputeDimensions(G4Trd& trd, const G4int copyNo,
502 const G4VPhysicalVolume*) const
503{
504 //---- The division along Z of a Trd will result a Trd
505 G4Trd* msol = (G4Trd*)(fmotherSolid);
506
507 G4double pDx1 = msol->GetXHalfLength1();
508 G4double DDx = (msol->GetXHalfLength2() - msol->GetXHalfLength1() );
509 G4double pDy1 = msol->GetYHalfLength1();
510 G4double DDy = (msol->GetYHalfLength2() - msol->GetYHalfLength1() );
511 G4double pDz = fwidth/2. - fhgap;
512 G4double zLength = 2*msol->GetZHalfLength();
513
514 trd.SetAllParameters( pDx1+DDx*(OffsetZ()+copyNo*fwidth+fhgap)/zLength,
515 pDx1+DDx*(OffsetZ()+(copyNo+1)*fwidth-fhgap)/zLength,
516 pDy1+DDy*(OffsetZ()+copyNo*fwidth+fhgap)/zLength,
517 pDy1+DDy*(OffsetZ()+(copyNo+1)*fwidth-fhgap)/zLength,
518 pDz );
519
520#ifdef G4DIVDEBUG
521 if( verbose >= 1 )
522 {
523 G4cout << " G4ParameterisationTrdZ::ComputeDimensions()"
524 << " - Mother TRD " << G4endl;
525 msol->DumpInfo();
526 G4cout << " - Parameterised TRD: "
527 << copyNo << G4endl;
528 trd.DumpInfo();
529 }
530#endif
531}
@ 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)
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
void ComputeDimensions(G4Trd &trd, const G4int copyNo, const G4VPhysicalVolume *pv) const
G4ParameterisationTrdX(EAxis axis, G4int nCopies, G4double width, G4double offset, G4VSolid *motherSolid, DivisionType divType)
G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
G4ParameterisationTrdY(EAxis axis, G4int nCopies, G4double width, G4double offset, G4VSolid *motherSolid, DivisionType divType)
void ComputeDimensions(G4Trd &trd, const G4int copyNo, const G4VPhysicalVolume *pv) const
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
void ComputeTransformation(const G4int copyNo, G4VPhysicalVolume *physVol) const
void ComputeDimensions(G4Trd &trd, const G4int copyNo, const G4VPhysicalVolume *pv) const
G4ParameterisationTrdZ(EAxis axis, G4int nCopies, G4double width, G4double offset, G4VSolid *motherSolid, DivisionType divType)
void SetAllParameters(G4double pDz, G4double pTheta, G4double pPhi, G4double pDy1, G4double pDx1, G4double pDx2, G4double pAlp1, G4double pDy2, G4double pDx3, G4double pDx4, G4double pAlp2)
Definition: G4Trap.cc:603
Definition: G4Trd.hh:63
void SetAllParameters(G4double pdx1, G4double pdx2, G4double pdy1, G4double pdy2, G4double pdz)
Definition: G4Trd.cc:169
G4double GetXHalfLength2() const
G4double GetYHalfLength2() const
G4double GetXHalfLength1() const
G4double GetYHalfLength1() const
G4double GetZHalfLength() const
void SetType(const G4String &type)
G4double CalculateWidth(G4double motherDim, G4int nDiv, G4double offset) const
G4int CalculateNDiv(G4double motherDim, G4double width, G4double offset) const
virtual G4VSolid * ComputeSolid(const G4int, G4VPhysicalVolume *)
G4VParameterisationTrd(EAxis axis, G4int nCopies, G4double offset, G4double step, G4VSolid *msolid, DivisionType divType)
void SetTranslation(const G4ThreeVector &v)
G4String GetName() const
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