Belle II Software  release-05-01-25
BelleLathe.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016-2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Alexei Sibidanov *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef BelleLathe_HH
12 #define BelleLathe_HH
13 
14 #include "G4Types.hh"
15 
16 #include "G4CSGSolid.hh"
17 #include "G4Polyhedron.hh"
18 #include <vector>
19 
20 namespace Belle2 {
25  namespace ECL {
26 
27  struct zr_t {
28  double z, r;
29  };
30 
31  struct cachezr_t {
32  double z, r;
33  double dz, dr;
34  double s2, is2, is;
35  double zmin, zmax;
36  double r2min, r2max;
37  double ta;
38  bool isconvex;
39  };
40 
42  struct vector_t {double x, y, z;};
43 
45  struct triangle_t {int i0, i1, i2;};
46 
47  inline double dotxy(const vector_t& u, const vector_t& v)
48  {
49  return u.x * v.x + u.y * v.y;
50  }
51 
52  class BelleLathe : public G4CSGSolid {
53  public: // with description
58  explicit BelleLathe(const G4String& pName);
59 
61  BelleLathe(const G4String& pName, double phi0, double dphi, int n, double* z, double* rin, double* rout);
63  BelleLathe(const G4String& pName, double, double, const std::vector<zr_t>&);
64 
66  virtual ~BelleLathe();
67 
68  // Methods for solid
69 
71  void ComputeDimensions(G4VPVParameterisation* p,
72  const G4int n,
73  const G4VPhysicalVolume* pRep);
74 
76  G4bool CalculateExtent(const EAxis pAxis,
77  const G4VoxelLimits& pVoxelLimit,
78  const G4AffineTransform& pTransform,
79  G4double& pMin, G4double& pMax) const;
80 
81  EInside Inside(const G4ThreeVector& p) const;
82 
83  G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
84 
85  G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
86 
87  G4double DistanceToIn(const G4ThreeVector& p) const;
88 
89  G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
90  const G4bool calcNorm = false,
91  G4bool* validNorm = 0, G4ThreeVector* n = 0) const;
92 
93  G4double DistanceToOut(const G4ThreeVector& p) const;
94 
95  G4GeometryType GetEntityType() const;
96 
97  G4ThreeVector GetPointOnSurface() const;
98 
99  G4double GetCubicVolume() {return fCubicVolume;}
100 
101  G4double GetSurfaceArea() {return fSurfaceArea;}
102 
103  G4VSolid* Clone() const;
104 
106  void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
107 
108  std::ostream& StreamInfo(std::ostream& os) const;
109 
110  // Visualisation functions
111 
112  void DescribeYourselfTo(G4VGraphicsScene& scene) const;
113  G4Polyhedron* CreatePolyhedron() const;
114 
115  public: // without description
116 
122  explicit BelleLathe(__void__&);
123 
125  BelleLathe(const BelleLathe& rhs);
127  BelleLathe& operator=(const BelleLathe& rhs);
128 
129  protected: // with description
130  bool insector(double, double) const;
131  // double sectorside_intersection(double, const vector_t&, const vector_t&) const ;
132  // double sectorside_intersection(double, const G4ThreeVector&, const G4ThreeVector&) const ;
133  // double sectorside(const G4ThreeVector&, const G4ThreeVector&, bool, bool) const;
134  int wn_poly(const zr_t&) const;
135  double mindist(const zr_t&) const;
136  std::vector<double> linecross(const G4ThreeVector&, const G4ThreeVector&) const;
137  void eartrim() const;
138  zr_t normal(const zr_t&, double&) const ;
139  void getvolarea();
140  void Init(const std::vector<zr_t>&, double, double);
141 
142  private:
143  std::vector<zr_t> fcontour;
144  std::vector<cachezr_t> fcache;
145  std::vector<double> fz;
146  std::vector<int> findx, fseg;
147  mutable std::vector<double> farea;
148  mutable std::vector<triangle_t> ftlist;
149 
150  double fphi, fdphi; // starting angle and finishing angle
151  double fs0, fc0, fs1, fc1;
152  double fn0x, fn0y, fn1x, fn1y;
153  double frmin, frmax, fzmin, fzmax;
154  bool fgtpi, ftwopi;
155 
156  G4VSolid* fshape;
157  mutable std::vector<G4ThreeVector> fsurf;
158  };
159 
161  class PolyhedronBelleLathe: public G4Polyhedron {
162  public:
163  PolyhedronBelleLathe(const std::vector<zr_t>&, const std::vector<triangle_t>&, double, double);
164  virtual ~PolyhedronBelleLathe();
165  };
166  }
168 }
169 #endif
170 
Belle2::ECL::PolyhedronBelleLathe::~PolyhedronBelleLathe
virtual ~PolyhedronBelleLathe()
destructor
Definition: BelleLathe.cc:1988
Belle2::ECL::BelleLathe::operator=
BelleLathe & operator=(const BelleLathe &rhs)
assignment operator
Definition: BelleLathe.cc:295
Belle2::ECL::BelleLathe::~BelleLathe
virtual ~BelleLathe()
Destructor.
Definition: BelleLathe.cc:275
Belle2::ECL::PolyhedronBelleLathe::PolyhedronBelleLathe
PolyhedronBelleLathe(const std::vector< zr_t > &, const std::vector< triangle_t > &, double, double)
constructor
Definition: BelleLathe.cc:1932
Belle2::ECL::BelleLathe::BelleLathe
BelleLathe(const G4String &pName)
Constructor for "nominal" BelleLathe whose parameters are to be set by a G4VPVParamaterisation later.
Definition: BelleLathe.cc:258
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECL::BelleLathe::BoundingLimits
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Two vectors define an axis-parallel bounding box for the shape.
Definition: BelleLathe.cc:1837
Belle2::ECL::zr_t
Definition: BelleLathe.h:35
Belle2::ECL::BelleLathe::CalculateExtent
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:500
Belle2::ECL::BelleLathe
Definition: BelleLathe.h:60
Belle2::ECL::vector_t
struct for a three vector
Definition: BelleLathe.h:50
Belle2::ECL::triangle_t
struct for a triangle
Definition: BelleLathe.h:53
Belle2::ECL::BelleLathe::ComputeDimensions
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
compute the dimensions
Definition: BelleLathe.cc:335