File: TrdStruct.h

package info (click to toggle)
vecgeom 1.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 23,928 kB
  • sloc: cpp: 88,717; ansic: 6,894; python: 1,035; sh: 582; sql: 538; makefile: 29
file content (124 lines) | stat: -rw-r--r-- 4,552 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// This file is part of VecGeom and is distributed under the
// conditions in the file LICENSE.txt in the top directory.
// For the full list of authors see CONTRIBUTORS.txt and `git log`.

/// Declaration of a struct with data members for the Trd class
/// @file volumes/TrdStruct.h
/// @author Mihaela Gheata

#ifndef VECGEOM_VOLUMES_TRDSTRUCT_H_
#define VECGEOM_VOLUMES_TRDSTRUCT_H_
#include "VecGeom/base/Global.h"

namespace vecgeom {

inline namespace VECGEOM_IMPL_NAMESPACE {

/// Struct encapsulating data members of the unplaced Trd
template <typename T = double>
struct TrdStruct {
  T fDX1; ///< Half-length along x at the surface positioned at -dz
  T fDX2; ///< Half-length along x at the surface positioned at +dz
  T fDY1; ///< Half-length along y at the surface positioned at -dz
  T fDY2; ///< Half-length along y at the surface positioned at +dz
  T fDZ;  ///< Half-length along z axis

  // cached values
  T fX2minusX1;    ///< Difference between half-legths along x at +dz and -dz
  T fY2minusY1;    ///< Difference between half-legths along y at +dz and -dz
  T fHalfX1plusX2; ///< Half-length along x at z = 0
  T fHalfY1plusY2; ///< Half-length along y at z = 0
  T fCalfX;        ///< Absolute value of cosine of inclination angle along x
  T fCalfY;        ///< Absolute value of cosine of inclination angle along y
  T fSecxz;        ///< Reciprocal of fCalfX
  T fSecyz;        ///< Reciprocal of fCalfY
  T fToleranceX;   ///< Corrected tolerance for Inside checks on X
  T fToleranceY;   ///< Corrected tolerance for Inside checks on Y

  T fFx; ///< Tangent of inclination angle along x
  T fFy; ///< Tangent of inclination angle along y

  /// Default constructor, it just allocates memory
  VECCORE_ATT_HOST_DEVICE
  TrdStruct() {}

  /// Constructor
  /// @param x1 Half-length along x at the surface positioned at -dz
  /// @param x2 Half-length along x at the surface positioned at +dz
  /// @param y Half-length along y axis
  /// @param z Half-length along z axis
  VECCORE_ATT_HOST_DEVICE
  TrdStruct(const T x1, const T x2, const T y, const T z)
      : fDX1(x1), fDX2(x2), fDY1(y), fDY2(y), fDZ(z), fX2minusX1(0), fY2minusY1(0), fHalfX1plusX2(0), fHalfY1plusY2(0),
        fCalfX(0), fCalfY(0), fFx(0), fFy(0)
  {
    CalculateCached();
  }

  /// Constructor
  /// @param x1 Half-length along x at the surface positioned at -dz
  /// @param x2 Half-length along x at the surface positioned at +dz
  /// @param y1 Half-length along y at the surface positioned at -dz
  /// @param y2 Half-length along y at the surface positioned at +dz
  /// @param z Half-length along z axis
  VECCORE_ATT_HOST_DEVICE
  TrdStruct(const T x1, const T x2, const T y1, const T y2, const T z)
      : fDX1(x1), fDX2(x2), fDY1(y1), fDY2(y2), fDZ(z), fX2minusX1(0), fY2minusY1(0), fHalfX1plusX2(0),
        fHalfY1plusY2(0), fCalfX(0), fCalfY(0), fFx(0), fFy(0)
  {
    CalculateCached();
  }

  /// Constructor
  /// @param x Half-length along x axis
  /// @param y Half-length along y axis
  /// @param z Half-length along z axis
  VECCORE_ATT_HOST_DEVICE
  TrdStruct(const T x, const T y, const T z)
      : fDX1(x), fDX2(x), fDY1(y), fDY2(y), fDZ(z), fX2minusX1(0), fY2minusY1(0), fHalfX1plusX2(0), fHalfY1plusY2(0),
        fCalfX(0), fCalfY(0), fFx(0), fFy(0)
  {
    CalculateCached();
  }

  /// Set all data members
  /// @param x1 Half-length along x at the surface positioned at -dz
  /// @param x2 Half-length along x at the surface positioned at +dz
  /// @param y1 Half-length along y at the surface positioned at -dz
  /// @param y2 Half-length along y at the surface positioned at +dz
  /// @param z Half-length along z axis
  VECCORE_ATT_HOST_DEVICE
  void SetAllParameters(T x1, T x2, T y1, T y2, T z)
  {
    fDX1 = x1;
    fDX2 = x2;
    fDY1 = y1;
    fDY2 = y2;
    fDZ  = z;
    CalculateCached();
  }

  /// Calculate cached values
  VECCORE_ATT_HOST_DEVICE
  void CalculateCached()
  {
    fX2minusX1    = fDX2 - fDX1;
    fY2minusY1    = fDY2 - fDY1;
    fHalfX1plusX2 = 0.5 * (fDX1 + fDX2);
    fHalfY1plusY2 = 0.5 * (fDY1 + fDY2);

    fFx    = 0.5 * (fDX1 - fDX2) / fDZ;
    fFy    = 0.5 * (fDY1 - fDY2) / fDZ;
    fSecxz = sqrt(1 + fFx * fFx);
    fSecyz = sqrt(1 + fFy * fFy);

    fCalfX      = 1. / Sqrt(1.0 + fFx * fFx);
    fCalfY      = 1. / Sqrt(1.0 + fFy * fFy);
    fToleranceX = kTolerance * Sqrt(fX2minusX1 * fX2minusX1 + 4 * fDZ * fDZ);
    fToleranceY = kTolerance * Sqrt(fX2minusX1 * fX2minusX1 + 4 * fDZ * fDZ);
  }
};
} // namespace VECGEOM_IMPL_NAMESPACE
} // namespace vecgeom

#endif