Belle II Software development
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
17namespace Belle2 {
22 namespace ECL {
23
25 struct zr_t {
26 double z;
27 double r;
28 };
29
31 struct cachezr_t {
32 double z;
33 double r;
34 double dz;
35 double dr;
36 double s2;
37 double is2;
38 double is;
39 double zmin;
40 double zmax;
41 double r2min;
42 double r2max;
43 double ta;
44 bool isconvex;
45 };
46
48 struct vector_t {
49 double x;
50 double y;
51 double z;
52 };
53
55 struct triangle_t {
56 int i0;
57 int i1;
58 int i2;
59 };
60
61 inline double dotxy(const vector_t& u, const vector_t& v)
62 {
63 return u.x * v.x + u.y * v.y;
64 }
65
67 class BelleLathe : public G4CSGSolid {
68 public: // with description
73 explicit BelleLathe(const G4String& pName);
74
76 BelleLathe(const G4String& pName, double phi0, double dphi, int n, double* z, double* rin, double* rout);
78 BelleLathe(const G4String& pName, double, double, const std::vector<zr_t>&);
79
81 virtual ~BelleLathe();
82
83 // Methods for solid
84
86 void ComputeDimensions(G4VPVParameterisation* p,
87 const G4int n,
88 const G4VPhysicalVolume* pRep);
89
91 G4bool CalculateExtent(const EAxis pAxis,
92 const G4VoxelLimits& pVoxelLimit,
93 const G4AffineTransform& pTransform,
94 G4double& pMin, G4double& pMax) const;
95
97 EInside Inside(const G4ThreeVector& p) const;
98
100 G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
101
103 G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
104
106 G4double DistanceToIn(const G4ThreeVector& p) const;
107
109 G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
110 const G4bool calcNorm = false,
111 G4bool* validNorm = 0, G4ThreeVector* n = 0) const;
112
114 G4double DistanceToOut(const G4ThreeVector& p) const;
115
117 G4GeometryType GetEntityType() const;
118
120 G4ThreeVector GetPointOnSurface() const;
121
123 G4double GetCubicVolume() {return fCubicVolume;}
124
126 G4double GetSurfaceArea() {return fSurfaceArea;}
127
129 G4VSolid* Clone() const;
130
132 void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
133
135 std::ostream& StreamInfo(std::ostream& os) const;
136
138 void DescribeYourselfTo(G4VGraphicsScene& scene) const;
140 G4Polyhedron* CreatePolyhedron() const;
141
142 public: // without description
143
149 explicit BelleLathe(__void__&);
150
152 BelleLathe(const BelleLathe& rhs);
154 BelleLathe& operator=(const BelleLathe& rhs);
155
156 protected: // with description
157 bool insector(double, double) const;
158 // double sectorside_intersection(double, const vector_t&, const vector_t&) const ;
159 // double sectorside_intersection(double, const G4ThreeVector&, const G4ThreeVector&) const ;
160 // double sectorside(const G4ThreeVector&, const G4ThreeVector&, bool, bool) const;
161 int wn_poly(const zr_t&) const;
162 double mindist(const zr_t&) const;
164 std::vector<double> linecross(const G4ThreeVector&, const G4ThreeVector&) const;
165 void eartrim() const;
166 zr_t normal(const zr_t&, double&) const ;
167 void getvolarea();
168 void Init(const std::vector<zr_t>&, double, double);
170 private:
171 std::vector<zr_t> fcontour;
172 std::vector<cachezr_t> fcache;
173 std::vector<double> fz;
174 std::vector<int> findx;
175 std::vector<int> fseg;
176 mutable std::vector<double> farea;
177 mutable std::vector<triangle_t> ftlist;
179 double fphi;
180 double fdphi;
181 double fs0;
182 double fc0;
183 double fs1;
184 double fc1;
185 double fn0x;
186 double fn0y;
187 double fn1x;
188 double fn1y;
189 double frmin;
190 double frmax;
191 double fzmin;
192 double fzmax;
193 bool fgtpi;
194 bool ftwopi;
196 G4VSolid* fshape;
197 mutable std::vector<G4ThreeVector> fsurf;
198 };
199
201 class PolyhedronBelleLathe: public G4Polyhedron {
202 public:
203 PolyhedronBelleLathe(const std::vector<zr_t>&, const std::vector<triangle_t>&, double, double);
204 virtual ~PolyhedronBelleLathe();
205 };
206 }
208}
BelleLathe class.
Definition: BelleLathe.h:67
double fzmax
maximal z value
Definition: BelleLathe.h:192
void getvolarea()
get volume area
Definition: BelleLathe.cc:1739
double fphi
starting angle
Definition: BelleLathe.h:179
std::vector< double > fz
vector of z values
Definition: BelleLathe.h:173
G4GeometryType GetEntityType() const
Get entity type.
Definition: BelleLathe.cc:1810
std::vector< int > findx
vector of indices
Definition: BelleLathe.h:174
std::vector< triangle_t > ftlist
vector of triangle structs
Definition: BelleLathe.h:177
void DescribeYourselfTo(G4VGraphicsScene &scene) const
Visualisation function.
Definition: BelleLathe.cc:1849
void Init(const std::vector< zr_t > &, double, double)
initialize
Definition: BelleLathe.cc:101
bool ftwopi
bound within +- 2pi?
Definition: BelleLathe.h:194
std::vector< double > farea
vector of area values
Definition: BelleLathe.h:176
G4Polyhedron * CreatePolyhedron() const
create polyhedron
Definition: BelleLathe.cc:2008
std::vector< int > fseg
vector of segments
Definition: BelleLathe.h:175
G4VSolid * fshape
shape
Definition: BelleLathe.h:196
double fdphi
finishing angle
Definition: BelleLathe.h:180
std::vector< double > linecross(const G4ThreeVector &, const G4ThreeVector &) const
calculate all ray solid's surface intersection return ordered vector
Definition: BelleLathe.cc:428
BelleLathe & operator=(const BelleLathe &rhs)
assignment operator
Definition: BelleLathe.cc:305
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Two vectors define an axis-parallel bounding box for the shape.
Definition: BelleLathe.cc:1855
virtual ~BelleLathe()
Destructor.
Definition: BelleLathe.cc:285
std::vector< zr_t > fcontour
vector of zr structs
Definition: BelleLathe.h:171
bool fgtpi
greater than pi?
Definition: BelleLathe.h:193
G4double GetCubicVolume()
Get cubic volume.
Definition: BelleLathe.h:123
std::vector< cachezr_t > fcache
vector of cached zr structs
Definition: BelleLathe.h:172
double mindist(const zr_t &) const
minimal distance
Definition: BelleLathe.cc:962
double fzmin
minimal z value
Definition: BelleLathe.h:191
zr_t normal(const zr_t &, double &) const
return normal
Definition: BelleLathe.cc:1026
bool insector(double, double) const
True if (x,y) is within the shape rotation.
Definition: BelleLathe.cc:937
G4ThreeVector GetPointOnSurface() const
Get point on surface.
Definition: BelleLathe.cc:1764
double frmax
maximal r value
Definition: BelleLathe.h:190
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:514
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const
Calculate side nearest to p, and return normal.
Definition: BelleLathe.cc:1077
G4double DistanceToIn(const G4ThreeVector &p, const G4ThreeVector &v) const
Calculate distance to shape from outside - return kInfinity if no intersection.
Definition: BelleLathe.cc:1253
double frmin
minimal r value
Definition: BelleLathe.h:189
void eartrim() const
ear trim
Definition: BelleLathe.cc:1702
std::vector< G4ThreeVector > fsurf
vector of surfaces
Definition: BelleLathe.h:197
G4VSolid * Clone() const
Make a clone of the object.
Definition: BelleLathe.cc:1816
std::ostream & StreamInfo(std::ostream &os) const
Stream object contents to an output stream.
Definition: BelleLathe.cc:1822
int wn_poly(const zr_t &) const
wn_poly
Definition: BelleLathe.cc:945
EInside Inside(const G4ThreeVector &p) const
Return whether point inside/outside/on surface, using tolerance.
Definition: BelleLathe.cc:983
G4double GetSurfaceArea()
Get surface area.
Definition: BelleLathe.h:126
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
compute the dimensions
Definition: BelleLathe.cc:345
G4double DistanceToOut(const G4ThreeVector &p, const G4ThreeVector &v, const G4bool calcNorm=false, G4bool *validNorm=0, G4ThreeVector *n=0) const
Calculate distance to surface of shape from inside.
Definition: BelleLathe.cc:1471
Belle lathe polyhedron.
Definition: BelleLathe.h:201
virtual ~PolyhedronBelleLathe()
destructor
Definition: BelleLathe.cc:2006
Abstract base class for different kinds of events.
cached z-r struct
Definition: BelleLathe.h:31
double s2
squared distance
Definition: BelleLathe.h:36
bool isconvex
is shape convex?
Definition: BelleLathe.h:44
double dr
difference in r
Definition: BelleLathe.h:35
double dz
difference in z
Definition: BelleLathe.h:34
double is2
inverted distance squared
Definition: BelleLathe.h:37
double r
r coordinate
Definition: BelleLathe.h:33
double r2min
minimal r value squared
Definition: BelleLathe.h:41
double zmin
minimal z value
Definition: BelleLathe.h:39
double z
z coordinate
Definition: BelleLathe.h:32
double is
distance
Definition: BelleLathe.h:38
double ta
ratio of dr over dz
Definition: BelleLathe.h:43
double zmax
maximal z value
Definition: BelleLathe.h:40
double r2max
maximal r value squared
Definition: BelleLathe.h:42
struct for a triangle
Definition: BelleLathe.h:55
int i2
third side
Definition: BelleLathe.h:58
int i0
first side
Definition: BelleLathe.h:56
int i1
second side
Definition: BelleLathe.h:57
struct for a three vector
Definition: BelleLathe.h:48
double z
z coordinate
Definition: BelleLathe.h:51
double y
y coordinate
Definition: BelleLathe.h:50
double x
x coordinate
Definition: BelleLathe.h:49
simple struct with z and r coordinates
Definition: BelleLathe.h:25
double r
r coordinate
Definition: BelleLathe.h:27
double z
z coordinate
Definition: BelleLathe.h:26