Belle II Software  release-06-00-14
BelleLathe.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 
11 #include "G4Types.hh"
12 
13 #include "G4CSGSolid.hh"
14 #include "G4Polyhedron.hh"
15 #include <vector>
16 
17 namespace Belle2 {
22  namespace ECL {
23 
24  struct zr_t {
25  double z, r;
26  };
27 
28  struct cachezr_t {
29  double z, r;
30  double dz, dr;
31  double s2, is2, is;
32  double zmin, zmax;
33  double r2min, r2max;
34  double ta;
35  bool isconvex;
36  };
37 
39  struct vector_t {double x, y, z;};
40 
42  struct triangle_t {int i0, i1, i2;};
43 
44  inline double dotxy(const vector_t& u, const vector_t& v)
45  {
46  return u.x * v.x + u.y * v.y;
47  }
48 
49  class BelleLathe : public G4CSGSolid {
50  public: // with description
55  explicit BelleLathe(const G4String& pName);
56 
58  BelleLathe(const G4String& pName, double phi0, double dphi, int n, double* z, double* rin, double* rout);
60  BelleLathe(const G4String& pName, double, double, const std::vector<zr_t>&);
61 
63  virtual ~BelleLathe();
64 
65  // Methods for solid
66 
68  void ComputeDimensions(G4VPVParameterisation* p,
69  const G4int n,
70  const G4VPhysicalVolume* pRep);
71 
73  G4bool CalculateExtent(const EAxis pAxis,
74  const G4VoxelLimits& pVoxelLimit,
75  const G4AffineTransform& pTransform,
76  G4double& pMin, G4double& pMax) const;
77 
78  EInside Inside(const G4ThreeVector& p) const;
79 
80  G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
81 
82  G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
83 
84  G4double DistanceToIn(const G4ThreeVector& p) const;
85 
86  G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
87  const G4bool calcNorm = false,
88  G4bool* validNorm = 0, G4ThreeVector* n = 0) const;
89 
90  G4double DistanceToOut(const G4ThreeVector& p) const;
91 
92  G4GeometryType GetEntityType() const;
93 
94  G4ThreeVector GetPointOnSurface() const;
95 
96  G4double GetCubicVolume() {return fCubicVolume;}
97 
98  G4double GetSurfaceArea() {return fSurfaceArea;}
99 
100  G4VSolid* Clone() const;
101 
103  void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
104 
105  std::ostream& StreamInfo(std::ostream& os) const;
106 
107  // Visualisation functions
108 
109  void DescribeYourselfTo(G4VGraphicsScene& scene) const;
110  G4Polyhedron* CreatePolyhedron() const;
111 
112  public: // without description
113 
119  explicit BelleLathe(__void__&);
120 
122  BelleLathe(const BelleLathe& rhs);
124  BelleLathe& operator=(const BelleLathe& rhs);
125 
126  protected: // with description
127  bool insector(double, double) const;
128  // double sectorside_intersection(double, const vector_t&, const vector_t&) const ;
129  // double sectorside_intersection(double, const G4ThreeVector&, const G4ThreeVector&) const ;
130  // double sectorside(const G4ThreeVector&, const G4ThreeVector&, bool, bool) const;
131  int wn_poly(const zr_t&) const;
132  double mindist(const zr_t&) const;
133  std::vector<double> linecross(const G4ThreeVector&, const G4ThreeVector&) const;
134  void eartrim() const;
135  zr_t normal(const zr_t&, double&) const ;
136  void getvolarea();
137  void Init(const std::vector<zr_t>&, double, double);
138 
139  private:
140  std::vector<zr_t> fcontour;
141  std::vector<cachezr_t> fcache;
142  std::vector<double> fz;
143  std::vector<int> findx, fseg;
144  mutable std::vector<double> farea;
145  mutable std::vector<triangle_t> ftlist;
146 
147  double fphi, fdphi; // starting angle and finishing angle
148  double fs0, fc0, fs1, fc1;
149  double fn0x, fn0y, fn1x, fn1y;
150  double frmin, frmax, fzmin, fzmax;
151  bool fgtpi, ftwopi;
152 
153  G4VSolid* fshape;
154  mutable std::vector<G4ThreeVector> fsurf;
155  };
156 
158  class PolyhedronBelleLathe: public G4Polyhedron {
159  public:
160  PolyhedronBelleLathe(const std::vector<zr_t>&, const std::vector<triangle_t>&, double, double);
161  virtual ~PolyhedronBelleLathe();
162  };
163  }
165 }
BelleLathe & operator=(const BelleLathe &rhs)
assignment operator
Definition: BelleLathe.cc:301
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Two vectors define an axis-parallel bounding box for the shape.
Definition: BelleLathe.cc:1843
virtual ~BelleLathe()
Destructor.
Definition: BelleLathe.cc:281
BelleLathe(const G4String &pName)
Constructor for "nominal" BelleLathe whose parameters are to be set by a G4VPVParamaterisation later.
Definition: BelleLathe.cc:264
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
calculate the extent of the volume
Definition: BelleLathe.cc:506
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
compute the dimensions
Definition: BelleLathe.cc:341
Belle lathe polyhedron.
Definition: BelleLathe.h:158
virtual ~PolyhedronBelleLathe()
destructor
Definition: BelleLathe.cc:1994
PolyhedronBelleLathe(const std::vector< zr_t > &, const std::vector< triangle_t > &, double, double)
constructor
Definition: BelleLathe.cc:1938
Abstract base class for different kinds of events.
struct for a triangle
Definition: BelleLathe.h:42
struct for a three vector
Definition: BelleLathe.h:39