Belle II Software development
G4TriangularPrism Class Reference

Triangular prism. More...

#include <G4TriangularPrism.h>

Public Member Functions

 G4TriangularPrism (const G4String &name, double r1, double phi1, double r2, double phi2, G4double halfZlen)
 Constructor.
 
 G4TriangularPrism (const G4TriangularPrism &)=delete
 Copy constructor (disabled).
 
G4TriangularPrismoperator= (const G4TriangularPrism &)=delete
 Operator = (disabled).
 
 ~G4TriangularPrism ()
 Destructor.
 
G4VSolid * getSolid ()
 Get solid.
 

Private Attributes

G4Box * m_box
 Box.
 
G4Tubs * m_tube
 Tube.
 
G4IntersectionSolid * m_is
 Intersection.
 

Detailed Description

Triangular prism.

Definition at line 25 of file G4TriangularPrism.h.

Constructor & Destructor Documentation

◆ G4TriangularPrism()

G4TriangularPrism ( const G4String &  name,
double  r1,
double  phi1,
double  r2,
double  phi2,
G4double  halfZlen 
)

Constructor.

Parameters
[in]nameName of the volume.
[in]r1First point radius.
[in]phi1First point angle.
[in]r2Second point radius.
[in]phi2Second point angle.
[in]halfZlenHalf of Z length.

Coordinates of the third point are (0, 0)

Definition at line 21 of file G4TriangularPrism.cc.

25{
26 double rl;
27 double rs;
28 double delta_phi;
29 double tg_alpha;
30 double alpha;
31 double sin_alpha;
32 double cos_alpha;
33 G4Transform3D t;
34 m_is = nullptr;
35 try {
36 m_tube = new G4Tubs("Tube_" + name, 0., std::max(r1, r2), halfZlen,
37 phi1, fabs(phi2 - phi1));
38 } catch (std::bad_alloc& ba) {
39 goto err_mem1;
40 }
41 if (r1 >= r2) {
42 rl = r1;
43 rs = r2;
44 } else {
45 rl = r2;
46 rs = r1;
47 }
48 delta_phi = phi2 - phi1;
49 tg_alpha = (rl / rs - cos(delta_phi)) / sin(delta_phi);
50 alpha = atan(tg_alpha);
51 sin_alpha = tg_alpha / sqrt(1.0 + tg_alpha * tg_alpha);
52 cos_alpha = 1.0 / sqrt(1.0 + tg_alpha * tg_alpha);
53 try {
54 m_box = new G4Box("Box_" + name, rl * sin_alpha,
55 rl * cos_alpha, halfZlen);
56 } catch (std::bad_alloc& ba) {
57 goto err_mem2;
58 }
59 if (r1 >= r2)
60 t = G4RotateZ3D((phi1 + alpha) * CLHEP::rad - 90.0 * CLHEP::deg);
61 else
62 t = G4RotateZ3D((phi2 - alpha) * CLHEP::rad + 90.0 * CLHEP::deg);
63 try {
64 m_is = new G4IntersectionSolid(name, m_tube, m_box, t);
65 } catch (std::bad_alloc& ba) {
66 goto err_mem3;
67 }
68 return;
69err_mem3:
70 delete m_box;
71err_mem2:
72 delete m_tube;
73err_mem1:
74 throw (std::bad_alloc());
75}
G4IntersectionSolid * m_is
Intersection.
double atan(double a)
atan for double
Definition: beamHelpers.h:34
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ ~G4TriangularPrism()

Destructor.

The resulting solid m_is (access by getSolid()) is not deleted here. It is meant to be deleted by Geant.

Definition at line 77 of file G4TriangularPrism.cc.

78{
79}

Member Function Documentation

◆ getSolid()

G4VSolid * getSolid ( )
inline

Get solid.

Returns
Solid corresponding to the prism.

The resulting G4VSolid* is allocated via operator new and must be deleted when is is not necessary. If it is used in Geant geometry, do not delete it.

Definition at line 69 of file G4TriangularPrism.h.

70 {
71 return m_is;
72 }

Member Data Documentation

◆ m_box

G4Box* m_box
private

Box.

Definition at line 79 of file G4TriangularPrism.h.

◆ m_is

G4IntersectionSolid* m_is
private

Intersection.

Definition at line 89 of file G4TriangularPrism.h.

◆ m_tube

G4Tubs* m_tube
private

Tube.

Definition at line 84 of file G4TriangularPrism.h.


The documentation for this class was generated from the following files: