Belle II Software  release-05-02-19
G4TriangularPrism.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2011 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Kirill Chilikin *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 /* Own header. */
12 #include <klm/eklm/geometry/G4TriangularPrism.h>
13 
14 /* CLHEP headers. */
15 #include <CLHEP/Units/SystemOfUnits.h>
16 
17 /* C++ headers. */
18 #include <cmath>
19 #include <new>
20 
21 using namespace Belle2;
22 
24  double r1, double phi1,
25  double r2, double phi2,
26  G4double halfZlen)
27 {
28  double rl;
29  double rs;
30  double delta_phi;
31  double tg_alpha;
32  double alpha;
33  double sin_alpha;
34  double cos_alpha;
35  G4Transform3D t;
36  m_is = nullptr;
37  try {
38  m_tube = new G4Tubs("Tube_" + name, 0., std::max(r1, r2), halfZlen,
39  phi1, fabs(phi2 - phi1));
40  } catch (std::bad_alloc& ba) {
41  goto err_mem1;
42  }
43  if (r1 >= r2) {
44  rl = r1;
45  rs = r2;
46  } else {
47  rl = r2;
48  rs = r1;
49  }
50  delta_phi = phi2 - phi1;
51  tg_alpha = (rl / rs - cos(delta_phi)) / sin(delta_phi);
52  alpha = atan(tg_alpha);
53  sin_alpha = tg_alpha / sqrt(1.0 + tg_alpha * tg_alpha);
54  cos_alpha = 1.0 / sqrt(1.0 + tg_alpha * tg_alpha);
55  try {
56  m_box = new G4Box("Box_" + name, rl * sin_alpha,
57  rl * cos_alpha, halfZlen);
58  } catch (std::bad_alloc& ba) {
59  goto err_mem2;
60  }
61  if (r1 >= r2)
62  t = G4RotateZ3D((phi1 + alpha) * CLHEP::rad - 90.0 * CLHEP::deg);
63  else
64  t = G4RotateZ3D((phi2 - alpha) * CLHEP::rad + 90.0 * CLHEP::deg);
65  try {
66  m_is = new G4IntersectionSolid(name, m_tube, m_box, t);
67  } catch (std::bad_alloc& ba) {
68  goto err_mem3;
69  }
70  return;
71 err_mem3:
72  delete m_box;
73 err_mem2:
74  delete m_tube;
75 err_mem1:
76  throw (std::bad_alloc());
77 }
78 
80 {
81 }
Belle2::G4TriangularPrism::m_is
G4IntersectionSolid * m_is
Intersection.
Definition: G4TriangularPrism.h:99
Belle2::G4TriangularPrism::m_box
G4Box * m_box
Box.
Definition: G4TriangularPrism.h:89
Belle2::G4TriangularPrism::G4TriangularPrism
G4TriangularPrism(const G4String &name, double r1, double phi1, double r2, double phi2, G4double halfZlen)
Constructor.
Definition: G4TriangularPrism.cc:23
Belle2::G4TriangularPrism::~G4TriangularPrism
~G4TriangularPrism()
Destructor.
Definition: G4TriangularPrism.cc:79
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::G4TriangularPrism::m_tube
G4Tubs * m_tube
Tube.
Definition: G4TriangularPrism.h:94